From: Sebastian Riemer <sebastian.riemer@profitbricks.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ben Hutchings <ben@decadent.org.uk>, Neil Brown <neilb@suse.de>,
linux-raid@vger.kernel.org, 696650@bugs.debian.org
Subject: [PATCH v2] md: protect against crash upon fsync on ro array
Date: Mon, 28 Jan 2013 11:32:03 +0100 [thread overview]
Message-ID: <510653A3.9090403@profitbricks.com> (raw)
In-Reply-To: <20130127163942.GA28572@infradead.org>
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
Subject was: Re: fsync() on read-only RAID triggers BUG
On 27.01.2013 17:39, Christoph Hellwig wrote:
> On Sat, Jan 26, 2013 at 07:44:40PM +0000, Ben Hutchings wrote:
>> I applied this on top of 3.2.37 and it certainly fixes the crash.
>> However I wonder whether fsync() should fail or should immediately
>> succeed. I don't know whether the installer expects it to succeed.
>
> It should succeed.
O.K., then I hope Neil applies the attached patch. I've changed the
return value to success.
This is also something for linux-stable and should apply to many kernel
versions without an issue.
[-- Attachment #2: 0001-md-protect-against-crash-upon-fsync-on-ro-array.txt --]
[-- Type: text/plain, Size: 1244 bytes --]
From fe0357344877c9b9cc623fd582a4e0670e448317 Mon Sep 17 00:00:00 2001
From: Sebastian Riemer <sebastian.riemer@profitbricks.com>
Date: Fri, 25 Jan 2013 12:46:59 +0100
Subject: [PATCH v2] md: protect against crash upon fsync on ro array
If an fsync occurrs on a read-only array, we need to send a
completion for the IO and may not increment the active IO count.
Otherwise, we hit a bug trace and can't stop the MD array anymore.
By advice of Christoph Hellwig we silently return success.
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: NeilBrown <neilb@suse.de>
Signed-off-by: Sebastian Riemer <sebastian.riemer@profitbricks.com>
Reported-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/md/md.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3db3d1b..475e0be 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -322,6 +322,11 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
}
finish_wait(&mddev->sb_wait, &__wait);
}
+ if (mddev->ro == 1 && unlikely(rw == WRITE)) {
+ rcu_read_unlock();
+ bio_endio(bio, 0);
+ return;
+ }
atomic_inc(&mddev->active_io);
rcu_read_unlock();
--
1.7.1
next prev parent reply other threads:[~2013-01-28 10:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 18:44 fsync() on read-only RAID triggers BUG Ben Hutchings
2013-01-25 15:09 ` Sebastian Riemer
2013-01-26 19:44 ` Ben Hutchings
2013-01-27 16:39 ` Christoph Hellwig
2013-01-28 10:32 ` Sebastian Riemer [this message]
2013-01-28 12:39 ` [PATCH v3] md: protect against crash upon fsync on ro array Sebastian Riemer
2013-01-29 5:45 ` Ben Hutchings
2013-01-29 11:19 ` [PATCH v4] " Sebastian Riemer
2013-01-29 12:29 ` [PATCH v5] " Paul Menzel
2013-01-31 19:35 ` Sebastian Riemer
2013-02-04 22:30 ` NeilBrown
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=510653A3.9090403@profitbricks.com \
--to=sebastian.riemer@profitbricks.com \
--cc=696650@bugs.debian.org \
--cc=ben@decadent.org.uk \
--cc=hch@infradead.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).