From: Jens Axboe <axboe@kernel.dk>
To: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
device-mapper development <dm-devel@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH] dm: fix inflight IO check
Date: Mon, 10 Dec 2018 15:45:53 -0700 [thread overview]
Message-ID: <4fec4b01-35f9-8008-22ec-2ac8af58b854@kernel.dk> (raw)
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: 6f75723190d8 ("dm: remove the pending IO accounting")
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 70568f8b6c53..79ad4b3d215c 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -650,14 +650,14 @@ static bool md_in_flight(struct mapped_device *md)
{
int cpu;
struct hd_struct *part = &dm_disk(md)->part0;
+ long sum = 0;
for_each_possible_cpu(cpu) {
- if (part_stat_local_read_cpu(part, in_flight[0], cpu) ||
- part_stat_local_read_cpu(part, in_flight[1], cpu))
- return true;
+ sum += part_stat_local_read_cpu(part, in_flight[0], cpu);
+ sum += part_stat_local_read_cpu(part, in_flight[1], cpu);
}
- return false;
+ return sum != 0;
}
static void start_io_acct(struct dm_io *io)
@@ -691,10 +691,8 @@ static void end_io_acct(struct dm_io *io)
true, duration, &io->stats_aux);
/* nudge anyone waiting on suspend queue */
- if (unlikely(waitqueue_active(&md->wait))) {
- if (!md_in_flight(md))
- wake_up(&md->wait);
- }
+ if (unlikely(waitqueue_active(&md->wait)))
+ wake_up(&md->wait);
}
/*
--
Jens Axboe
next reply other threads:[~2018-12-10 22:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 22:45 Jens Axboe [this message]
2018-12-11 0:32 ` dm: fix inflight IO check Mike Snitzer
2018-12-12 2:34 ` xfstests generic/347 was never correct [was: Re: dm: fix inflight IO check] Mike Snitzer
2018-12-12 2:58 ` Eric Sandeen
2018-12-12 15:18 ` Mike Snitzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4fec4b01-35f9-8008-22ec-2ac8af58b854@kernel.dk \
--to=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=snitzer@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox