[PATCH 1/1] UBUNTU: SAUCE: md: fix possible corruption of array metadata on shutdown.

Luis Henriques luis.henriques at canonical.com
Mon Apr 30 16:46:26 UTC 2012

From: NeilBrown <neilb at suse.de>

BugLink: http://bugs.launchpad.net/bugs/992038

commit c744a65c1e2d59acc54333ce8
  md: don't set md arrays to readonly on shutdown.

removed the possibility of a 'BUG' when data is written to an array
that has just been switched to read-only, but also introduced the
possibility that the array metadata could be corrupted.

If, when md_notify_reboot gets the mddev lock, the array is
in a state where it is assembled but hasn't been started (as can
happen if the personality module is not available, or in other unusual
situations), then incorrect metadata will be written out making it
impossible to re-assemble the array.

So only call __md_stop_writes() if the array has actually been

This patch is needed for any stable kernel which has had the above
commit applied.

Cc: stable at vger.kernel.org
Reported-by: Christoph Nelles <evilazrael at evilazrael.de>
Signed-off-by: NeilBrown <neilb at suse.de>
(cherry picked from commit 30b8aa9172dfeaac6d77897c67ee9f9fc574cdbb)

Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 drivers/md/md.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6f37aa4..065ab4f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8100,7 +8100,8 @@ static int md_notify_reboot(struct notifier_block *this,
 	for_each_mddev(mddev, tmp) {
 		if (mddev_trylock(mddev)) {
-			__md_stop_writes(mddev);
+			if (mddev->pers)
+				__md_stop_writes(mddev);
 			mddev->safemode = 2;

More information about the kernel-team mailing list