Commit b7934ba4 authored by Jens Axboe's avatar Jens Axboe

dm: fix inflight IO check

After switching to percpu inflight counters, the inflight check
is totally buggy. It's perfectly valid for some counters to be
non-zero while having a total inflight IO count of 0, that's how
these kinds of counters work (inc on one CPU, dec on another).
Fix the md_in_flight() check to sum all counters before returning
a false positive, potentially.

While at it, remove the inflight read for IO completion. We don't
need it, just wake anyone that's waiting for the IO count to drop
to zero. The caller needs to re-check that value anyway when woken,
which it does.

Fixes: 6f757231 ("dm: remove the pending IO accounting")
Acked-by: default avatarMike Snitzer <snitzer@redhat.com>
Reported-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4ba09f69
...@@ -650,14 +650,14 @@ static bool md_in_flight(struct mapped_device *md) ...@@ -650,14 +650,14 @@ static bool md_in_flight(struct mapped_device *md)
{ {
int cpu; int cpu;
struct hd_struct *part = &dm_disk(md)->part0; struct hd_struct *part = &dm_disk(md)->part0;
long sum = 0;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (part_stat_local_read_cpu(part, in_flight[0], cpu) || sum += part_stat_local_read_cpu(part, in_flight[0], cpu);
part_stat_local_read_cpu(part, in_flight[1], cpu)) sum += part_stat_local_read_cpu(part, in_flight[1], cpu);
return true;
} }
return false; return sum != 0;
} }
static void start_io_acct(struct dm_io *io) static void start_io_acct(struct dm_io *io)
...@@ -691,10 +691,8 @@ static void end_io_acct(struct dm_io *io) ...@@ -691,10 +691,8 @@ static void end_io_acct(struct dm_io *io)
true, duration, &io->stats_aux); true, duration, &io->stats_aux);
/* nudge anyone waiting on suspend queue */ /* nudge anyone waiting on suspend queue */
if (unlikely(waitqueue_active(&md->wait))) { if (unlikely(waitqueue_active(&md->wait)))
if (!md_in_flight(md)) wake_up(&md->wait);
wake_up(&md->wait);
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment