btrfs: search for last logged dir index if it's not cached in the inode
authorFilipe Manana <fdmanana@suse.com>
Mon, 22 Aug 2022 10:51:39 +0000 (11:51 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:56 +0000 (12:27 +0200)
commit193df6245704dc6071b75d49f9036ca45b52ace6
tree456cc38ee65016ec9169177fc542cb0cfd1b5b89
parent4c469798eee5c63dea359dbd39dc4efcf96ec0ba
btrfs: search for last logged dir index if it's not cached in the inode

The key offset of the last dir index item that was logged is stored in
the inode's last_dir_index_offset field. However that field is not
persisted in the inode item or elsewhere, so if the inode gets evicted
and reloaded, it gets a value of (u64)-1, so that when we are logging
dir index items we check if they were logged before, to avoid attempts
to insert duplicated keys and fallback to a transaction commit.

Improve on this by searching for the last dir index that was logged when
we start logging a directory if the inode's last_dir_index_offset is not
set (has a value of (u64)-1) and it was logged before. This avoids
checking if each dir index item we find was already logged before, and
simplifies the logging of dir index items (process_dir_items_leaf()).

This will also be needed for an incoming change where we start logging
delayed items directly, without flushing them first.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c