aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2008-10-09 13:39:39 -0400
committerChris Mason <chris.mason@oracle.com>2008-10-09 13:39:39 -0400
commitcb8e70901d36f32017614f16d2cf7cc089544574 (patch)
treebc31116dcb5bcdd6f2677a0c83b824e77c1ef097 /fs/btrfs/inode.c
parent833023e46c2a0180ff07d90252c24cb3fdea811d (diff)
Btrfs: Fix subvolume creation locking rules
Creating a subvolume is in many ways like a normal VFS ->mkdir, and we really need to play with the VFS topology locking rules. So instead of just creating the snapshot on disk and then later getting rid of confliting aliases do it correctly from the start. This will become especially important once we allow for subvolumes anywhere in the tree, and not just below a hidden root. Note that snapshots will need the same treatment, but do to the delay in creating them we can't do it currently. Chris promised to fix that issue, so I'll wait on that. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 11bfe131fde6..bf4bed6ca4d6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3420,11 +3420,12 @@ void btrfs_invalidate_dcache_root(struct btrfs_root *root, char *name,
3420/* 3420/*
3421 * create a new subvolume directory/inode (helper for the ioctl). 3421 * create a new subvolume directory/inode (helper for the ioctl).
3422 */ 3422 */
3423int btrfs_create_subvol_root(struct btrfs_root *new_root, 3423int btrfs_create_subvol_root(struct btrfs_root *new_root, struct dentry *dentry,
3424 struct btrfs_trans_handle *trans, u64 new_dirid, 3424 struct btrfs_trans_handle *trans, u64 new_dirid,
3425 struct btrfs_block_group_cache *block_group) 3425 struct btrfs_block_group_cache *block_group)
3426{ 3426{
3427 struct inode *inode; 3427 struct inode *inode;
3428 int error;
3428 u64 index = 0; 3429 u64 index = 0;
3429 3430
3430 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid, 3431 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid,
@@ -3438,7 +3439,12 @@ int btrfs_create_subvol_root(struct btrfs_root *new_root,
3438 inode->i_nlink = 1; 3439 inode->i_nlink = 1;
3439 btrfs_i_size_write(inode, 0); 3440 btrfs_i_size_write(inode, 0);
3440 3441
3441 return btrfs_update_inode(trans, new_root, inode); 3442 error = btrfs_update_inode(trans, new_root, inode);
3443 if (error)
3444 return error;
3445
3446 d_instantiate(dentry, inode);
3447 return 0;
3442} 3448}
3443 3449
3444/* helper function for file defrag and space balancing. This 3450/* helper function for file defrag and space balancing. This