Skip to content

Commit

Permalink
Btrfs: Fix a crash when mounting a subvolume
Browse files Browse the repository at this point in the history
We should drop dentry before deactivating the superblock, otherwise
we can hit this bug:

BUG: Dentry f349a690{i=100,n=/} still in use (1) [unmount of btrfs loop1]
...

Steps to reproduce the bug:

  # mount /dev/loop1 /mnt
  # mkdir save
  # btrfs subvolume snapshot /mnt save/snap1
  # umount /mnt
  # mount -o subvol=save/snap1 /dev/loop1 /mnt
  (crash)

Reported-by: Michael Niederle <[email protected]>
Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Li Zefan authored and chrismason-xx committed Dec 10, 2010
1 parent 75eaa0e commit f106e82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,9 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
mutex_unlock(&root->d_inode->i_mutex);

if (IS_ERR(new_root)) {
dput(root);
deactivate_locked_super(s);
error = PTR_ERR(new_root);
dput(root);
goto error_free_subvol_name;
}
if (!new_root->d_inode) {
Expand Down

0 comments on commit f106e82

Please sign in to comment.