Commit 4b06e5b9 authored by Jun'ichi Nomura's avatar Jun'ichi Nomura Committed by Al Viro
Browse files

freeze_bdev: don't deactivate successfully frozen MS_RDONLY sb

Thanks Thomas and Christoph for testing and review.
I removed 'smp_wmb()' before up_write from the previous patch,
since up_write() should have necessary ordering constraints.
(I.e. the change of s_frozen is visible to others after up_write)
I'm quite sure the change is harmless but if you are uncomfortable
with Tested-by/Reviewed-by on the modified patch, please remove them.

If MS_RDONLY, freeze_bdev should just up_write(s_umount) instead of
Also, keep sb->s_frozen consistent so that remount can check the frozen state.

Otherwise a crash reported here can happen:

This patch should be applied for 2.6.32 stable series, too.
Reviewed-by: default avatarChristoph Hellwig <>
Tested-by: default avatarThomas Backlund <>
Signed-off-by: default avatarJun'ichi Nomura <>
Signed-off-by: default avatarAl Viro <>
parent 8dd5ca53
...@@ -246,7 +246,8 @@ struct super_block *freeze_bdev(struct block_device *bdev) ...@@ -246,7 +246,8 @@ struct super_block *freeze_bdev(struct block_device *bdev)
if (!sb) if (!sb)
goto out; goto out;
if (sb->s_flags & MS_RDONLY) { if (sb->s_flags & MS_RDONLY) {
deactivate_locked_super(sb); sb->s_frozen = SB_FREEZE_TRANS;
mutex_unlock(&bdev->bd_fsfreeze_mutex); mutex_unlock(&bdev->bd_fsfreeze_mutex);
return sb; return sb;
} }
...@@ -307,7 +308,7 @@ int thaw_bdev(struct block_device *bdev, struct super_block *sb) ...@@ -307,7 +308,7 @@ int thaw_bdev(struct block_device *bdev, struct super_block *sb)
BUG_ON(sb->s_bdev != bdev); BUG_ON(sb->s_bdev != bdev);
down_write(&sb->s_umount); down_write(&sb->s_umount);
if (sb->s_flags & MS_RDONLY) if (sb->s_flags & MS_RDONLY)
goto out_deactivate; goto out_unfrozen;
if (sb->s_op->unfreeze_fs) { if (sb->s_op->unfreeze_fs) {
error = sb->s_op->unfreeze_fs(sb); error = sb->s_op->unfreeze_fs(sb);
...@@ -321,11 +322,11 @@ int thaw_bdev(struct block_device *bdev, struct super_block *sb) ...@@ -321,11 +322,11 @@ int thaw_bdev(struct block_device *bdev, struct super_block *sb)
} }
} }
sb->s_frozen = SB_UNFROZEN; sb->s_frozen = SB_UNFROZEN;
smp_wmb(); smp_wmb();
wake_up(&sb->s_wait_unfrozen); wake_up(&sb->s_wait_unfrozen);
if (sb) if (sb)
deactivate_locked_super(sb); deactivate_locked_super(sb);
out_unlock: out_unlock:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment