Skip to content

Commit

Permalink
btrfs: preparation to fixing mount/umount race
Browse files Browse the repository at this point in the history
We need fs_info and root to live until the moment when the victim
superblock leaves the list, so we need to postpone free_fs_info()
until after ->put_super().  The call is buried in close_ctree(),
though, so we need to lift it into the callers (including
btrfs_put_super()) first.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 9, 2012
1 parent 48fa57a commit 98c7089
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
up_read(&fs_info->cleanup_work_sem);
if (err) {
close_ctree(tree_root);
free_fs_info(fs_info);
return ERR_PTR(err);
}
}
Expand Down Expand Up @@ -3059,8 +3060,6 @@ int close_ctree(struct btrfs_root *root)
bdi_destroy(&fs_info->bdi);
cleanup_srcu_struct(&fs_info->subvol_srcu);

free_fs_info(fs_info);

return 0;
}

Expand Down
6 changes: 5 additions & 1 deletion fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static void btrfs_put_super(struct super_block *sb)
int ret;

ret = close_ctree(root);
free_fs_info(root->fs_info);
sb->s_fs_info = NULL;

(void)ret; /* FIXME: need to fix VFS to return error? */
Expand Down Expand Up @@ -589,6 +590,7 @@ static int btrfs_fill_super(struct super_block *sb,
struct inode *inode;
struct dentry *root_dentry;
struct btrfs_root *tree_root;
struct btrfs_fs_info *fs_info;
struct btrfs_key key;
int err;

Expand All @@ -609,12 +611,13 @@ static int btrfs_fill_super(struct super_block *sb,
printk("btrfs: open_ctree failed\n");
return PTR_ERR(tree_root);
}
fs_info = tree_root->fs_info;
sb->s_fs_info = tree_root;

key.objectid = BTRFS_FIRST_FREE_OBJECTID;
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root, NULL);
inode = btrfs_iget(sb, &key, fs_info->fs_root, NULL);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto fail_close;
Expand All @@ -635,6 +638,7 @@ static int btrfs_fill_super(struct super_block *sb,

fail_close:
close_ctree(tree_root);
free_fs_info(fs_info);
return err;
}

Expand Down

0 comments on commit 98c7089

Please sign in to comment.