aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2624b53ea783..54dfd45cc591 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -82,22 +82,25 @@ static noinline int create_subvol(struct btrfs_root *root,
82 if (ret) 82 if (ret)
83 goto fail; 83 goto fail;
84 84
85 leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0, 85 leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
86 objectid, trans->transid, 0, 0, 0); 86 0, objectid, NULL, 0, 0, 0);
87 if (IS_ERR(leaf)) { 87 if (IS_ERR(leaf)) {
88 ret = PTR_ERR(leaf); 88 ret = PTR_ERR(leaf);
89 goto fail; 89 goto fail;
90 } 90 }
91 91
92 btrfs_set_header_nritems(leaf, 0); 92 memset_extent_buffer(leaf, 0, 0, sizeof(struct btrfs_header));
93 btrfs_set_header_level(leaf, 0);
94 btrfs_set_header_bytenr(leaf, leaf->start); 93 btrfs_set_header_bytenr(leaf, leaf->start);
95 btrfs_set_header_generation(leaf, trans->transid); 94 btrfs_set_header_generation(leaf, trans->transid);
95 btrfs_set_header_backref_rev(leaf, BTRFS_MIXED_BACKREF_REV);
96 btrfs_set_header_owner(leaf, objectid); 96 btrfs_set_header_owner(leaf, objectid);
97 97
98 write_extent_buffer(leaf, root->fs_info->fsid, 98 write_extent_buffer(leaf, root->fs_info->fsid,
99 (unsigned long)btrfs_header_fsid(leaf), 99 (unsigned long)btrfs_header_fsid(leaf),
100 BTRFS_FSID_SIZE); 100 BTRFS_FSID_SIZE);
101 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid,
102 (unsigned long)btrfs_header_chunk_tree_uuid(leaf),
103 BTRFS_UUID_SIZE);
101 btrfs_mark_buffer_dirty(leaf); 104 btrfs_mark_buffer_dirty(leaf);
102 105
103 inode_item = &root_item.inode; 106 inode_item = &root_item.inode;
@@ -125,7 +128,7 @@ static noinline int create_subvol(struct btrfs_root *root,
125 btrfs_set_root_dirid(&root_item, new_dirid); 128 btrfs_set_root_dirid(&root_item, new_dirid);
126 129
127 key.objectid = objectid; 130 key.objectid = objectid;
128 key.offset = 1; 131 key.offset = 0;
129 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); 132 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
130 ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key, 133 ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
131 &root_item); 134 &root_item);
@@ -911,10 +914,10 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
911 if (disko) { 914 if (disko) {
912 inode_add_bytes(inode, datal); 915 inode_add_bytes(inode, datal);
913 ret = btrfs_inc_extent_ref(trans, root, 916 ret = btrfs_inc_extent_ref(trans, root,
914 disko, diskl, leaf->start, 917 disko, diskl, 0,
915 root->root_key.objectid, 918 root->root_key.objectid,
916 trans->transid, 919 inode->i_ino,
917 inode->i_ino); 920 new_key.offset - datao);
918 BUG_ON(ret); 921 BUG_ON(ret);
919 } 922 }
920 } else if (type == BTRFS_FILE_EXTENT_INLINE) { 923 } else if (type == BTRFS_FILE_EXTENT_INLINE) {