[btrfs-devel]A bug related to btrfs_search_slot and
btrfs_extend_item
Chris Mason
chris.mason at oracle.com
Tue Oct 23 06:19:09 PDT 2007
On Tue, 23 Oct 2007 17:58:25 +0800
"Yan Zheng" <yanzheng at 21cn.com> wrote:
> Hello,
>
> When we want to extent the size of some item in the tree, the typical
> function call sequence is:
> ...
> btrfs_search_slot((trans, root, key, path, size_to_extent, 1);
> ...
> btrfs_extend_item(trans, root, path, size_to_extent);
>
> There is a flaw in codes like this, to guarantee a leaf has enough
> free space, 'btrfs_search_slot' may call 'split_leaf' which split the
> leaf or insert a empty leaf. When 'split_leaf' insert a empty leaf,
> the lowest level of the btrfs_path points to the empty leaf. After
> 'btrfs_search_slot' return, 'btrfs_extend_item' is called, it will be
> in trouble to extent a non-exist item.
Yes, I've fixed a few mistakes in this area, but I think you're right,
I need to add a parameter to search_slot that indicates insert vs
extend.
Thanks for this test case!
-chris
More information about the Btrfs-devel
mailing list