btrfs: send: keep the current inode's path cached
authorFilipe Manana <fdmanana@suse.com>
Thu, 13 Feb 2025 17:08:44 +0000 (17:08 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:46 +0000 (20:35 +0100)
commitfc746acb7aa9aeaa2cb5dcba449323319ba5c8eb
tree56395fa3c60739b057e36722b09ba4861a541b00
parentd7d56ccf100adb140c5655c624fedf7545d569e0
btrfs: send: keep the current inode's path cached

Whenever we need to send a command for the current inode, like sending
writes, xattr updates, truncates, utimes, etc, we compute the inode's
path each time, which implies doing some memory allocations and traversing
the inode hierarchy to extract the name of the inode and each ancestor
directory, and that implies doing lookups in the subvolume tree amongst
other operations.

Most of the time, by far, the current inode's path doesn't change while
we are processing it (like if we need to issue 100 write commands, the
path remains the same and it's pointless to compute it 100 times).

To avoid this keep the current inode's path cached in the send context
and invalidate it or update it whenever it's needed (after unlinks or
renames).

A performance test, and its results, is mentioned in the next patch in
the series (subject: "btrfs: send: avoid path allocation for the current
inode when issuing commands").

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