aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-11-17 20:37:39 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-17 20:37:39 -0500
commit0660b5af3f7ac0fac69de975914e1f4a3a586fb3 (patch)
tree5e911dfad23df29f1815fbbc76d38ffff7fe36d8 /fs/btrfs/ioctl.c
parent3394e1607eaf870ebba37d303fbd590a4c569908 (diff)
Btrfs: Add backrefs and forward refs for subvols and snapshots
Subvols and snapshots can now be referenced from any point in the directory tree. We need to maintain back refs for them so we can find lost subvols. Forward refs are added so that we know all of the subvols and snapshots referenced anywhere in the directory tree of a single subvol. This can be used to do recursive snapshotting (but they aren't yet) and it is also used to detect and prevent directory loops when creating new snapshots. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 773db07b5f72..536ae8837801 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -145,13 +145,23 @@ static noinline int create_subvol(struct btrfs_root *root,
145 BTRFS_FT_DIR, index); 145 BTRFS_FT_DIR, index);
146 if (ret) 146 if (ret)
147 goto fail; 147 goto fail;
148#if 0 148
149 ret = btrfs_insert_inode_ref(trans, root->fs_info->tree_root, 149 /* add the backref first */
150 name, namelen, objectid, 150 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
151 root->fs_info->sb->s_root->d_inode->i_ino, 0); 151 objectid, BTRFS_ROOT_BACKREF_KEY,
152 if (ret) 152 root->root_key.objectid,
153 goto fail; 153 dir->i_ino, index, name, namelen);
154#endif 154
155 BUG_ON(ret);
156
157 /* now add the forward ref */
158 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
159 root->root_key.objectid, BTRFS_ROOT_REF_KEY,
160 objectid,
161 dir->i_ino, index, name, namelen);
162
163 BUG_ON(ret);
164
155 ret = btrfs_commit_transaction(trans, root); 165 ret = btrfs_commit_transaction(trans, root);
156 if (ret) 166 if (ret)
157 goto fail_commit; 167 goto fail_commit;