From: Filipe Manana Date: Wed, 3 Sep 2025 16:39:24 +0000 (+0100) Subject: btrfs: abort transaction if we fail to find dir item during log replay X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0b7453b7a1c1f8aa1570da2d0cc81bf7691eb5f1;p=users%2Fhch%2Fmisc.git 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 Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 86c595ef57f4..7b91248b38dc 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -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)