summaryrefslogtreecommitdiffstats
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)
downloadop-kernel-dev-cb8e70901d36f32017614f16d2cf7cc089544574.zip
op-kernel-dev-cb8e70901d36f32017614f16d2cf7cc089544574.tar.gz
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 11bfe13..bf4bed6 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,
/*
* create a new subvolume directory/inode (helper for the ioctl).
*/
-int btrfs_create_subvol_root(struct btrfs_root *new_root,
+int btrfs_create_subvol_root(struct btrfs_root *new_root, struct dentry *dentry,
struct btrfs_trans_handle *trans, u64 new_dirid,
struct btrfs_block_group_cache *block_group)
{
struct inode *inode;
+ int error;
u64 index = 0;
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,
inode->i_nlink = 1;
btrfs_i_size_write(inode, 0);
- return btrfs_update_inode(trans, new_root, inode);
+ error = btrfs_update_inode(trans, new_root, inode);
+ if (error)
+ return error;
+
+ d_instantiate(dentry, inode);
+ return 0;
}
/* helper function for file defrag and space balancing. This
OpenPOWER on IntegriCloud