Skip to content

Commit 31097a1

Browse files
neilbrownbwhacks
authored andcommitted
md: fix possible corruption of array metadata on shutdown.
commit 30b8aa9 upstream. 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. Reported-by: Christoph Nelles <evilazrael@evilazrael.de> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1 parent 4f75fb8 commit 31097a1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/md/md.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8100,7 +8100,8 @@ static int md_notify_reboot(struct notifier_block *this,
81008100

81018101
for_each_mddev(mddev, tmp) {
81028102
if (mddev_trylock(mddev)) {
8103-
__md_stop_writes(mddev);
8103+
if (mddev->pers)
8104+
__md_stop_writes(mddev);
81048105
mddev->safemode = 2;
81058106
mddev_unlock(mddev);
81068107
}

0 commit comments

Comments
 (0)