aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2009-09-21 15:56:00 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-21 15:56:00 -0400
commit4df27c4d5cc1dda54ed7d0a8389347f2df359cf9 (patch)
tree2008f348d28c6c19e31924ae4fb414ca929a01f1 /fs/btrfs/transaction.c
parent13a8a7c8c47e542b3cdb45bec3f431f96af79361 (diff)
Btrfs: change how subvolumes are organized
btrfs allows subvolumes and snapshots anywhere in the directory tree. If we snapshot a subvolume that contains a link to other subvolume called subvolA, subvolA can be accessed through both the original subvolume and the snapshot. This is similar to creating hard link to directory, and has the very similar problems. The aim of this patch is enforcing there is only one access point to each subvolume. Only the first directory entry (the one added when the subvolume/snapshot was created) is treated as valid access point. The first directory entry is distinguished by checking root forward reference. If the corresponding root forward reference is missing, we know the entry is not the first one. This patch also adds snapshot/subvolume rename support, the code allows rename subvolume link across subvolumes. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 94f816cb6e35..915077725fea 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -779,24 +779,14 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info,
779 ret = btrfs_update_inode(trans, parent_root, parent_inode); 779 ret = btrfs_update_inode(trans, parent_root, parent_inode);
780 BUG_ON(ret); 780 BUG_ON(ret);
781 781
782 /* add the backref first */
783 ret = btrfs_add_root_ref(trans, parent_root->fs_info->tree_root, 782 ret = btrfs_add_root_ref(trans, parent_root->fs_info->tree_root,
784 pending->root_key.objectid, 783 pending->root_key.objectid,
785 BTRFS_ROOT_BACKREF_KEY,
786 parent_root->root_key.objectid, 784 parent_root->root_key.objectid,
787 parent_inode->i_ino, index, pending->name, 785 parent_inode->i_ino, index, pending->name,
788 namelen); 786 namelen);
789 787
790 BUG_ON(ret); 788 BUG_ON(ret);
791 789
792 /* now add the forward ref */
793 ret = btrfs_add_root_ref(trans, parent_root->fs_info->tree_root,
794 parent_root->root_key.objectid,
795 BTRFS_ROOT_REF_KEY,
796 pending->root_key.objectid,
797 parent_inode->i_ino, index, pending->name,
798 namelen);
799
800 inode = btrfs_lookup_dentry(parent_inode, pending->dentry); 790 inode = btrfs_lookup_dentry(parent_inode, pending->dentry);
801 d_instantiate(pending->dentry, inode); 791 d_instantiate(pending->dentry, inode);
802fail: 792fail: