Yan Zheng
2007-Dec-04 05:22 UTC
[Btrfs-devel][PATCH]Fix buffer get/release issue in create_snapshot
Hello, '__btrfs_cow_block' expects the caller holds a reference to the buffer and it drops caller's reference. If the caller doesn't hold a reference, root->commit_root's reference may lose. Regards YZ diff -r 66ea50b1a761 inode.c --- a/inode.c Tue Nov 20 13:44:45 2007 -0500 +++ b/inode.c Tue Dec 04 18:32:38 2007 +0800 @@ -2035,7 +2035,9 @@ static int create_snapshot(struct btrfs_ key.offset = 1; btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); + extent_buffer_get(root->node); 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_level(&new_root_item, btrfs_header_level(root->node));
Yan Zheng
2007-Dec-04 05:39 UTC
[Btrfs-devel][PATCH]Fix buffer get/release issue in create_snapshot
Sorry, there is a typo in previous patch. --- diff -r 66ea50b1a761 inode.c --- a/inode.c Tue Nov 20 13:44:45 2007 -0500 +++ b/inode.c Tue Dec 04 21:38:06 2007 +0800 @@ -2035,7 +2035,9 @@ static int create_snapshot(struct btrfs_ key.offset = 1; btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); + extent_buffer_get(root->node); 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_level(&new_root_item, btrfs_header_level(root->node));
Chris Mason
2007-Dec-04 10:27 UTC
[Btrfs-devel][PATCH]Fix buffer get/release issue in create_snapshot
On Tue, 4 Dec 2007 21:22:44 +0800 "Yan Zheng" <yanzheng@21cn.com> wrote:> Hello, > > '__btrfs_cow_block' expects the caller holds a reference to the buffer > and it drops caller's reference. If the caller doesn't hold a > reference, root->commit_root's reference may lose.Thanks, I've got the updated patch. -chris