• Filipe Manana's avatar
    btrfs: unify lookup return value when dir entry is missing · 8dcbc261
    Filipe Manana authored
    btrfs_lookup_dir_index_item() and btrfs_lookup_dir_item() lookup for dir
    entries and both are used during log replay or when updating a log tree
    during an unlink.
    
    However when the dir item does not exists, btrfs_lookup_dir_item() returns
    NULL while btrfs_lookup_dir_index_item() returns PTR_ERR(-ENOENT), and if
    the dir item exists but there is no matching entry for a given name or
    index, both return NULL. This makes the call sites during log replay to
    be more verbose than necessary and it makes it easy to miss this slight
    difference. Since we don't need to distinguish between those two cases,
    make btrfs_lookup_dir_index_item() always return NULL when there is no
    matching directory entry - either because there isn't any dir entry or
    because there is one but it does not match the given name and index.
    
    Also rename the argument 'objectid' of btrfs_lookup_dir_index_item() to
    'index' since it is supposed to match an index number, and the name
    'objectid' is not very good because it can easily be confused with an
    inode number (like the inode number a dir entry points to).
    
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    8dcbc261
tree-log.c 179 KB