]> www.infradead.org Git - users/willy/xarray.git/commit
btrfs: introduce btrfs_search_backwards function
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Thu, 29 Jul 2021 08:22:16 +0000 (05:22 -0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Aug 2021 11:19:09 +0000 (13:19 +0200)
commit0ff40a910f5649dfacc4fb5daa7e73692196342d
treed72db74b8b671afb17c773282fa22dc1b0dd0e06
parentea3dc7d2d1f524eb2a34b6501be38c82be5c7ff1
btrfs: introduce btrfs_search_backwards function

It's a common practice to start a search using offset (u64)-1, which is
the u64 maximum value, meaning that we want the search_slot function to
be set in the last item with the same objectid and type.

Once we are in this position, it's a matter to start a search backwards
by calling btrfs_previous_item, which will check if we'll need to go to
a previous leaf and other necessary checks, only to be sure that we are
in last offset of the same object and type.

The new btrfs_search_backwards function does the all these steps when
necessary, and can be used to avoid code duplication.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/ioctl.c
fs/btrfs/super.c
fs/btrfs/volumes.c