• Gabriel Niebler's avatar
    btrfs: introduce btrfs_for_each_slot iterator macro · 62142be3
    Gabriel Niebler authored
    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.
    Signed-off-by: default avatarMarcos Paulo de Souza <mpdesouza@suse.com>
    Signed-off-by: default avatarGabriel Niebler <gniebler@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    62142be3
ctree.h 134 KB