Message ID | 20220309135051.5738-1-gniebler@suse.com (mailing list archive) |
---|---|
Headers | show |
Series | btrfs: Introduce macro to iterate over slots | expand |
On Wed, Mar 09, 2022 at 02:50:37PM +0100, Gabriel Niebler wrote: > There is a common pattern when searching for a key in btrfs: > > * Call btrfs_search_slot to find the slot for the key > * Enter an endless loop: > * If the found slot is larger than the no. of items in the current leaf, > check the next leaf > * If it's still not found in the next leaf, terminate the loop > * Otherwise do something with the found key > * Increment the current slot and continue > > To reduce code duplication, we can replace this code pattern with an iterator > macro, similar to the existing for_each_X macros found elsewhere in the kernel. > This also makes the code easier to understand for newcomers by putting a name > to the encapsulated functionality. > > This patchset survived a complete fstest run. > > Changes from v3: > * Surround arguments with (…) in iterator macro definition (David) > * Fix btrfs_unlink_all_paths after key/found_key confusion broke btrfs/168 > (Josef) > * Various stylistic improvements (David) Added to misc-next with some fixups, thanks.