md: protect against crash upon fsync on ro array (Closes: #696650)

svn path=/dists/sid/linux/; revision=19777
This commit is contained in:
Ben Hutchings 2013-01-27 00:41:05 +00:00
parent 82605cce77
commit 08517ae9bd
3 changed files with 37 additions and 0 deletions

1
debian/changelog vendored
View File

@ -99,6 +99,7 @@ linux (3.2.37-1) UNRELEASED; urgency=low
- rewrite punch hole to use ext4_ext_remove_space()
- fix hole punch failure when depth is greater than 0
- fix kernel BUG on large-scale rm -rf commands
* md: protect against crash upon fsync on ro array (Closes: #696650)
[ Aurelien Jarno ]
* [armhf/vexpress] Add kernel udebs.

View File

@ -0,0 +1,35 @@
From: Sebastian Riemer <sebastian.riemer@profitbricks.com>
Date: Fri, 25 Jan 2013 12:46:59 +0100
Subject: [PATCH] md: protect against crash upon fsync on ro array
Bug-Debian: http://bugs.debian.org/696650
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.
As return value -EROFS makes most sense.
Signed-off-by: Sebastian Riemer <sebastian.riemer@profitbricks.com>
---
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, -EROFS);
+ return;
+ }
atomic_inc(&mddev->active_io);
rcu_read_unlock();
--
1.7.1

View File

@ -471,3 +471,4 @@ bugfix/all/bridge-Pull-ip-header-into-skb-data-before-looking-i.patch
bugfix/all/ext4-rewrite-punch-hole-to-use-ext4_ext_remove_space.patch
bugfix/all/ext4-fix-hole-punch-failure-when-depth-is-greater-th.patch
bugfix/all/ext4-fix-kernel-BUG-on-large-scale-rm-rf-commands.patch
bugfix/all/md-protect-against-crash-upon-fsync-on-ro-array.patch