aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2013-08-15 11:11:20 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:15:55 -0400
commitdd5f9615fc5c5e8d3751aab3a17b92768fb1ce70 (patch)
tree9b7ad64c2761200e7713ee55e5d667e1b57d0e6b /fs/btrfs/transaction.c
parentf7a81ea4cc6bdb51d8267d2f3ff485f0b4070074 (diff)
Btrfs: maintain subvolume items in the UUID tree
When a new subvolume or snapshot is created, a new UUID item is added to the UUID tree. Such items are removed when the subvolume is deleted. The ioctl to set the received subvolume UUID is also touched and will now also add this received UUID into the UUID tree together with the ID of the subvolume. The latter is also done when read-only snapshots are created which inherit all the send/receive information from the parent subvolume. User mode programs use the BTRFS_IOC_TREE_SEARCH ioctl to search and read in the UUID tree. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 579efcc1de16..72ab0dd31937 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1311,8 +1311,26 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1311 dentry->d_name.len * 2); 1311 dentry->d_name.len * 2);
1312 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; 1312 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
1313 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode); 1313 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
1314 if (ret) 1314 if (ret) {
1315 btrfs_abort_transaction(trans, root, ret);
1316 goto fail;
1317 }
1318 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, new_uuid.b,
1319 BTRFS_UUID_KEY_SUBVOL, objectid);
1320 if (ret) {
1315 btrfs_abort_transaction(trans, root, ret); 1321 btrfs_abort_transaction(trans, root, ret);
1322 goto fail;
1323 }
1324 if (!btrfs_is_empty_uuid(new_root_item->received_uuid)) {
1325 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root,
1326 new_root_item->received_uuid,
1327 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
1328 objectid);
1329 if (ret && ret != -EEXIST) {
1330 btrfs_abort_transaction(trans, root, ret);
1331 goto fail;
1332 }
1333 }
1316fail: 1334fail:
1317 pending->error = ret; 1335 pending->error = ret;
1318dir_item_existed: 1336dir_item_existed: