Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Paul Menzel <pm.debian@googlemail.com>
To: Sebastian Riemer <sebastian.riemer@profitbricks.com>
Cc: Ben Hutchings <ben@decadent.org.uk>,
	Christoph Hellwig <hch@infradead.org>, Neil Brown <neilb@suse.de>,
	linux-raid@vger.kernel.org, 696650@bugs.debian.org
Subject: Re: [PATCH v5] md: protect against crash upon fsync on ro array
Date: Tue, 29 Jan 2013 13:29:53 +0100	[thread overview]
Message-ID: <1359462593.2417.1.camel@mattotaupa> (raw)
In-Reply-To: <5107B03A.9030109@profitbricks.com>


[-- Attachment #1.1: Type: text/plain, Size: 170 bytes --]

Am Dienstag, den 29.01.2013, 12:19 +0100 schrieb Sebastian Riemer:

[…]

> Any further objection?

Small typo (occurs) in commit message.


Thanks,

Paul


[-- Attachment #1.2: 0001-md-protect-against-crash-upon-fsync-on-ro-array.txt --]
[-- Type: text/plain, Size: 1504 bytes --]

From adfac4df99edc1a83dced9c732464634d3381a9f 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 v5] md: protect against crash upon fsync on ro array

If an fsync occurs 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 return success upon a flush
request but we return -EROFS for other writes.
We detect flush requests by checking if the bio has zero sectors.

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>
Acked-by: Paul Menzel <paulepanter@users.sourceforge.net>
---
 drivers/md/md.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3db3d1b..1e634a6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -307,6 +307,10 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
 		bio_io_error(bio);
 		return;
 	}
+	if (mddev->ro == 1 && unlikely(rw == WRITE)) {
+		bio_endio(bio, bio_sectors(bio) == 0 ? 0 : -EROFS);
+		return;
+	}
 	smp_rmb(); /* Ensure implications of  'active' are visible */
 	rcu_read_lock();
 	if (mddev->suspended) {
-- 
1.7.1

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-01-29 12:29 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       ` [PATCH v2] md: protect against crash upon fsync on ro array Sebastian Riemer
2013-01-28 12:39         ` [PATCH v3] " Sebastian Riemer
2013-01-29  5:45           ` Ben Hutchings
2013-01-29 11:19             ` [PATCH v4] " Sebastian Riemer
2013-01-29 12:29               ` Paul Menzel [this message]
2013-01-31 19:35                 ` [PATCH v5] " 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=1359462593.2417.1.camel@mattotaupa \
    --to=pm.debian@googlemail.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 \
    --cc=sebastian.riemer@profitbricks.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