Skip to content

Commit 059421e

Browse files
NeilBrownshligit
authored andcommitted
md: allow metadata updates while suspending an array - fix
Commit 35bfc52 ("md: allow metadata update while suspending.") added support for allowing md_check_recovery() to still perform metadata updates while the array is entering the 'suspended' state. This is needed to allow the processes of entering the state to complete. Unfortunately, the patch doesn't really work. The test for "mddev->suspended" at the start of md_check_recovery() means that the function doesn't try to do anything at all while entering suspend. This patch moves the code of updating the metadata while suspending to *before* the test on mddev->suspended. Reported-by: Jeff Mahoney <[email protected]> Fixes: 35bfc52 ("md: allow metadata update while suspending.") Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent d595567 commit 059421e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/md/md.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8794,6 +8794,18 @@ static void md_start_sync(struct work_struct *ws)
87948794
*/
87958795
void md_check_recovery(struct mddev *mddev)
87968796
{
8797+
if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags) && mddev->sb_flags) {
8798+
/* Write superblock - thread that called mddev_suspend()
8799+
* holds reconfig_mutex for us.
8800+
*/
8801+
set_bit(MD_UPDATING_SB, &mddev->flags);
8802+
smp_mb__after_atomic();
8803+
if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags))
8804+
md_update_sb(mddev, 0);
8805+
clear_bit_unlock(MD_UPDATING_SB, &mddev->flags);
8806+
wake_up(&mddev->sb_wait);
8807+
}
8808+
87978809
if (mddev->suspended)
87988810
return;
87998811

@@ -8953,16 +8965,6 @@ void md_check_recovery(struct mddev *mddev)
89538965
unlock:
89548966
wake_up(&mddev->sb_wait);
89558967
mddev_unlock(mddev);
8956-
} else if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags) && mddev->sb_flags) {
8957-
/* Write superblock - thread that called mddev_suspend()
8958-
* holds reconfig_mutex for us.
8959-
*/
8960-
set_bit(MD_UPDATING_SB, &mddev->flags);
8961-
smp_mb__after_atomic();
8962-
if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags))
8963-
md_update_sb(mddev, 0);
8964-
clear_bit_unlock(MD_UPDATING_SB, &mddev->flags);
8965-
wake_up(&mddev->sb_wait);
89668968
}
89678969
}
89688970
EXPORT_SYMBOL(md_check_recovery);

0 commit comments

Comments
 (0)