From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
NeilBrown <neilb@suse.de>
Subject: [04/11] md/raid10: fix deadlock with unaligned read during resync
Date: Wed, 11 Aug 2010 16:45:43 -0700 [thread overview]
Message-ID: <20100811234625.266596539@clark.site> (raw)
In-Reply-To: <20100811234809.GA676@kroah.com>
2.6.27-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <neilb@suse.de>
commit 51e9ac77035a3dfcb6fc0a88a0d80b6f99b5edb1 upstream.
If the 'bio_split' path in raid10-read is used while
resync/recovery is happening it is possible to deadlock.
Fix this be elevating ->nr_waiting for the duration of both
parts of the split request.
This fixes a bug that has been present since 2.6.22
but has only started manifesting recently for unknown reasons.
It is suitable for and -stable since then.
Reported-by: Justin Bronder <jsbronder@gentoo.org>
Tested-by: Justin Bronder <jsbronder@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/md/raid10.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -818,11 +818,29 @@ static int make_request(struct request_q
*/
bp = bio_split(bio, bio_split_pool,
chunk_sects - (bio->bi_sector & (chunk_sects - 1)) );
+
+ /* Each of these 'make_request' calls will call 'wait_barrier'.
+ * If the first succeeds but the second blocks due to the resync
+ * thread raising the barrier, we will deadlock because the
+ * IO to the underlying device will be queued in generic_make_request
+ * and will never complete, so will never reduce nr_pending.
+ * So increment nr_waiting here so no new raise_barriers will
+ * succeed, and so the second wait_barrier cannot block.
+ */
+ spin_lock_irq(&conf->resync_lock);
+ conf->nr_waiting++;
+ spin_unlock_irq(&conf->resync_lock);
+
if (make_request(q, &bp->bio1))
generic_make_request(&bp->bio1);
if (make_request(q, &bp->bio2))
generic_make_request(&bp->bio2);
+ spin_lock_irq(&conf->resync_lock);
+ conf->nr_waiting--;
+ wake_up(&conf->wait_barrier);
+ spin_unlock_irq(&conf->resync_lock);
+
bio_pair_release(bp);
return 0;
bad_map:
next prev parent reply other threads:[~2010-08-11 23:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 23:48 [00/11] 2.6.27.51-stable review Greg KH
2010-08-11 23:45 ` [01/11] nvram: Fix write beyond end condition; prove to gcc copy is safe Greg KH
2010-08-11 23:45 ` [02/11] splice: fix misuse of SPLICE_F_NONBLOCK Greg KH
2010-08-11 23:45 ` [03/11] PCI: disable MSI on VIA K8M800 Greg KH
2010-08-11 23:45 ` Greg KH [this message]
2010-08-11 23:45 ` [05/11] eCryptfs: Handle ioctl calls with unlocked and compat functions Greg KH
2010-08-11 23:45 ` [06/11] fs/ecryptfs/file.c: introduce missing free Greg KH
2010-08-11 23:45 ` [07/11] signalfd: fill in ssi_int for posix timers and message queues Greg KH
2010-08-11 23:45 ` [08/11] jfs: dont allow os2 xattr namespace overlap with others Greg KH
2010-08-11 23:45 ` [09/11] xen: drop xen_sched_clock in favour of using plain wallclock time Greg KH
2010-08-11 23:45 ` [10/11] bdi: register sysfs bdi device only once per queue Greg KH
2010-08-11 23:45 ` [11/11] mm/backing-dev.c: remove recently-added WARN_ON() Greg KH
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=20100811234625.266596539@clark.site \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=stable-review@kernel.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®