[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.17 / 0023-md-fix-possible-corruption-of-array-metadata-on-shut.patch
1 From fd272b3336e1e535826cc345e10353eb104363e8 Mon Sep 17 00:00:00 2001
2 From: NeilBrown <neilb@suse.de>
3 Date: Tue, 24 Apr 2012 10:23:16 +1000
4 Subject: [PATCH 023/165] md: fix possible corruption of array metadata on
5 shutdown.
7 commit 30b8aa9172dfeaac6d77897c67ee9f9fc574cdbb upstream.
9 commit c744a65c1e2d59acc54333ce8
10 md: don't set md arrays to readonly on shutdown.
12 removed the possibility of a 'BUG' when data is written to an array
13 that has just been switched to read-only, but also introduced the
14 possibility that the array metadata could be corrupted.
16 If, when md_notify_reboot gets the mddev lock, the array is
17 in a state where it is assembled but hasn't been started (as can
18 happen if the personality module is not available, or in other unusual
19 situations), then incorrect metadata will be written out making it
20 impossible to re-assemble the array.
22 So only call __md_stop_writes() if the array has actually been
23 activated.
25 This patch is needed for any stable kernel which has had the above
26 commit applied.
28 Reported-by: Christoph Nelles <evilazrael@evilazrael.de>
29 Signed-off-by: NeilBrown <neilb@suse.de>
30 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
31 ---
32 drivers/md/md.c | 3 ++-
33 1 files changed, 2 insertions(+), 1 deletions(-)
35 diff --git a/drivers/md/md.c b/drivers/md/md.c
36 index 6f37aa4..065ab4f 100644
37 --- a/drivers/md/md.c
38 +++ b/drivers/md/md.c
39 @@ -8100,7 +8100,8 @@ static int md_notify_reboot(struct notifier_block *this,
41 for_each_mddev(mddev, tmp) {
42 if (mddev_trylock(mddev)) {
43 - __md_stop_writes(mddev);
44 + if (mddev->pers)
45 + __md_stop_writes(mddev);
46 mddev->safemode = 2;
47 mddev_unlock(mddev);
48 }
49 --
50 1.7.7.6