md: fix possible corruption of array metadata on shutdown.
authorNeilBrown <neilb@suse.de>
Tue, 24 Apr 2012 00:23:16 +0000 (10:23 +1000)
committerLuis Henriques <luis.henriques@canonical.com>
Mon, 30 Apr 2012 18:15:15 +0000 (19:15 +0100)
commit816f4888b38a5e2690cd6e0cb126c9794c4fe9c8
treee787a7fe9ab949847f93ecd9f228d030afdbef6c
parent67777b8bb936ace71a3ca2ebc8eb042098a33158
md: fix possible corruption of array metadata on shutdown.

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
activated.

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

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

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/md/md.c