Btrfs: fix wrong size for the reservation of the, snapshot creation
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 6 Sep 2012 10:03:56 +0000 (04:03 -0600)
committerChris Mason <chris.mason@fusionio.com>
Mon, 1 Oct 2012 19:19:12 +0000 (15:19 -0400)
We should insert/update 6 items(root ref, root backref, dir item, dir index,
root item and parent inode) when creating a snapshot, not 5 items, fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
fs/btrfs/extent-tree.c
fs/btrfs/ioctl.c

index 36e03312267ae43771ab01825155060e56fd9fc2..b6b33e463ac3e4ea240dcbb59c351fe89a4bc90c 100644 (file)
@@ -4414,10 +4414,10 @@ int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans,
        struct btrfs_block_rsv *src_rsv = get_block_rsv(trans, root);
        struct btrfs_block_rsv *dst_rsv = &pending->block_rsv;
        /*
-        * two for root back/forward refs, two for directory entries
-        * and one for root of the snapshot.
+        * two for root back/forward refs, two for directory entries,
+        * one for root of the snapshot and one for parent inode.
         */
-       u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5);
+       u64 num_bytes = btrfs_calc_trans_metadata_size(root, 6);
        dst_rsv->space_info = src_rsv->space_info;
        return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes);
 }
index e6934de55a8be92e6af04a547db493bfdce627fc..c56daa368768a2a1ac90efc48c6839d714c6ddac 100644 (file)
@@ -526,7 +526,7 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
                *inherit = NULL;        /* take responsibility to free it */
        }
 
-       trans = btrfs_start_transaction(root->fs_info->extent_root, 5);
+       trans = btrfs_start_transaction(root->fs_info->extent_root, 6);
        if (IS_ERR(trans)) {
                ret = PTR_ERR(trans);
                goto fail;