]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: abort transaction if we fail to find dir item during log replay
authorFilipe Manana <fdmanana@suse.com>
Wed, 3 Sep 2025 16:39:24 +0000 (17:39 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:21 +0000 (08:49 +0200)
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>
fs/btrfs/tree-log.c

index 86c595ef57f474252baf6a445ebf4211182bbdf4..7b91248b38dc946c29bf911fd3494d91b982b5d5 100644 (file)
@@ -1281,7 +1281,9 @@ again:
        /* 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)