summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Sandoval2015-05-18 11:16:26 +0200
committerChris Mason2015-06-03 13:02:57 +0200
commit773cd04ec1911abb33cf9538b65f55b76cad5d92 (patch)
treeb41feb18b6ba9694cf5d255d8994b6851e46868e
parentBtrfs: wake up extent state waiters on unlock through clear_extent_bits (diff)
downloadkernel-qcow2-linux-773cd04ec1911abb33cf9538b65f55b76cad5d92.tar.gz
kernel-qcow2-linux-773cd04ec1911abb33cf9538b65f55b76cad5d92.tar.xz
kernel-qcow2-linux-773cd04ec1911abb33cf9538b65f55b76cad5d92.zip
Btrfs: lock superblock before remounting for rw subvol
Since commit 0723a0473fb4 ("btrfs: allow mounting btrfs subvolumes with different ro/rw options"), when mounting a subvolume read/write when another subvolume has previously been mounted read-only, we first do a remount. However, this should be done with the superblock locked, as per sync_filesystem(): /* * We need to be protected against the filesystem going from * r/o to r/w or vice versa. */ WARN_ON(!rwsem_is_locked(&sb->s_umount)); This WARN_ON can easily be hit with: mkfs.btrfs -f /dev/vdb mount /dev/vdb /mnt btrfs subvol create /mnt/vol1 btrfs subvol create /mnt/vol2 umount /mnt mount -oro,subvol=/vol1 /dev/vdb /mnt mount -orw,subvol=/vol2 /dev/vdb /mnt2 Fixes: 0723a0473fb4 ("btrfs: allow mounting btrfs subvolumes with different ro/rw options") Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/super.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c761d8e068e8..93f2edf6b603 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1209,7 +1209,9 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
return ERR_CAST(mnt);
}
+ down_write(&mnt->mnt_sb->s_umount);
r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
+ up_write(&mnt->mnt_sb->s_umount);
if (r < 0) {
/* FIXME: release vfsmount mnt ??*/
kfree(newargs);