btrfs: abort transaction if we fail to find dir item during log replay

At __add_inode_ref() if we get an error when trying to lookup a dir item
we don't abort the transaction and propagate the error up the call chain,
so that somewhere else up in the call chain the transaction is aborted.
This however makes it hard to know that the failure comes from looking up
a dir item, so add a transaction abort in case we fail there, so that we
immediately pinpoint where the problem comes from during log replay.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2025-09-03 17:39:24 +01:00 committed by David Sterba
parent e41c5e611a
commit 0b7453b7a1

View File

@ -1281,7 +1281,9 @@ static inline int __add_inode_ref(struct walk_control *wc,
/* look for a conflicting name */
di = btrfs_lookup_dir_item(trans, root, wc->subvol_path, btrfs_ino(dir), name, 0);
if (IS_ERR(di)) {
return PTR_ERR(di);
ret = PTR_ERR(di);
btrfs_abort_transaction(trans, ret);
return ret;
} else if (di) {
ret = drop_one_dir_item(wc, dir, di);
if (ret)