Commit 9691975d authored by Yan's avatar Yan Committed by Chris Mason

Btrfs: Fix buffer get/release issue in create_snapshot

btrfs_cow_block expects a reference to be held on the buffer being cow'd.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 1a2b2ac7
...@@ -2034,11 +2034,11 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen) ...@@ -2034,11 +2034,11 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen)
key.objectid = objectid; key.objectid = objectid;
key.offset = 1; key.offset = 1;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
extent_buffer_get(root->node);
btrfs_cow_block(trans, root, root->node, NULL, 0, &tmp); btrfs_cow_block(trans, root, root->node, NULL, 0, &tmp);
free_extent_buffer(tmp);
btrfs_set_root_bytenr(&new_root_item, root->node->start); btrfs_set_root_bytenr(&new_root_item, root->node->start);
btrfs_set_root_level(&new_root_item, btrfs_header_level(root->node)); btrfs_set_root_level(&new_root_item, btrfs_header_level(root->node));
ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key, ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
&new_root_item); &new_root_item);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment