Skip to content

Commit b7934ba

Browse files
committed
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: 6f75723 ("dm: remove the pending IO accounting") Acked-by: Mike Snitzer <snitzer@redhat.com> Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4ba09f6 commit b7934ba

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/md/dm.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,14 @@ static bool md_in_flight(struct mapped_device *md)
650650
{
651651
int cpu;
652652
struct hd_struct *part = &dm_disk(md)->part0;
653+
long sum = 0;
653654

654655
for_each_possible_cpu(cpu) {
655-
if (part_stat_local_read_cpu(part, in_flight[0], cpu) ||
656-
part_stat_local_read_cpu(part, in_flight[1], cpu))
657-
return true;
656+
sum += part_stat_local_read_cpu(part, in_flight[0], cpu);
657+
sum += part_stat_local_read_cpu(part, in_flight[1], cpu);
658658
}
659659

660-
return false;
660+
return sum != 0;
661661
}
662662

663663
static void start_io_acct(struct dm_io *io)
@@ -691,10 +691,8 @@ static void end_io_acct(struct dm_io *io)
691691
true, duration, &io->stats_aux);
692692

693693
/* nudge anyone waiting on suspend queue */
694-
if (unlikely(waitqueue_active(&md->wait))) {
695-
if (!md_in_flight(md))
696-
wake_up(&md->wait);
697-
}
694+
if (unlikely(waitqueue_active(&md->wait)))
695+
wake_up(&md->wait);
698696
}
699697

700698
/*

0 commit comments

Comments
 (0)