Skip to content

Commit

Permalink
md: fix possible corruption of array metadata on shutdown.
Browse files Browse the repository at this point in the history
commit c744a65
  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: [email protected]
Reported-by: Christoph Nelles <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
  • Loading branch information
neilbrown committed Apr 24, 2012
1 parent ed20958 commit 30b8aa9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -8140,7 +8140,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;
mddev_unlock(mddev);
}
Expand Down

0 comments on commit 30b8aa9

Please sign in to comment.