btrfs-progs: use path->search_for_extension

This flag is used by the kernel btrfs_search_slot to make sure that leaf
splitting decision doesn't subtract the size of an item.  This is for
inline extent items and csum items where we know we're going to find the
item we want, and we're only going to want to extend it.  Currently this
flag doesn't do anything, but when we sync ctree.c we'll stop making the
right decision WRT the leaf space, so add the flag usage in the places
we need it so we can sync ctree.c easily.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2023-08-23 10:32:48 -04:00 committed by David Sterba
parent 2d8058ae09
commit f858c8b191
2 changed files with 8 additions and 2 deletions

View file

@ -881,10 +881,12 @@ static int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
key.offset = num_bytes;
want = extent_ref_type(parent, owner);
if (insert)
if (insert) {
extra_size = btrfs_extent_inline_ref_size(want);
else
path->search_for_extension = 1;
} else {
extra_size = -1;
}
if (owner < BTRFS_FIRST_FREE_OBJECTID && skinny_metadata) {
key.type = BTRFS_METADATA_ITEM_KEY;
@ -1022,6 +1024,8 @@ again:
}
*ref_ret = (struct btrfs_extent_inline_ref *)ptr;
out:
if (insert)
path->search_for_extension = 0;
return err;
}

View file

@ -257,8 +257,10 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, u64 logical,
* enough yet to put our csum in. Grow it
*/
btrfs_release_path(path);
path->search_for_extension = 1;
ret = btrfs_search_slot(trans, root, &file_key, path,
csum_size, 1);
path->search_for_extension = 0;
if (ret < 0)
goto fail;
if (ret == 0) {