[PATCH 2/2] xfs: clean up attr intent recovery error paths

From: Yingjie Gao

Date: Tue Jun 09 2026 - 07:21:24 EST


xfs_attr_recover_work() still uses a backward goto from out_cancel to
out_unlock, and the transaction allocation failure path returns from the
middle of the function.

Restructure the cleanup labels into the same linear fallthrough style
used by the neighboring bmap and exchmaps recovery helpers. Initialize
the local error variable to zero as those helpers do as well, which
makes the shared return path easier to follow.

No functional change intended.

Signed-off-by: Yingjie Gao <gaoyingjie@xxxxxxxxxxxxx>
---
fs/xfs/xfs_attr_item.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index c3d96c7a5bca..f8aa9dd80bb9 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -739,7 +739,7 @@ xfs_attr_recover_work(
struct xfs_trans_res resv;
struct xfs_attri_log_format *attrp;
struct xfs_attri_log_nameval *nv = attrip->attri_nameval;
- int error;
+ int error = 0;
unsigned int total = 0;

/*
@@ -773,10 +773,8 @@ xfs_attr_recover_work(
}
resv = xlog_recover_resv(&resv);
error = xfs_trans_alloc(mp, &resv, total, 0, XFS_TRANS_RESERVE, &tp);
- if (error) {
- xfs_irele(ip);
- return error;
- }
+ if (error)
+ goto out_rele;
args->trans = tp;

xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -791,13 +789,20 @@ xfs_attr_recover_work(
goto out_cancel;

error = xfs_defer_ops_capture_and_commit(tp, capture_list);
-out_unlock:
+ if (error)
+ goto out_unlock;
+
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_irele(ip);
- return error;
+ return 0;
+
out_cancel:
xfs_trans_cancel(tp);
- goto out_unlock;
+out_unlock:
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
+out_rele:
+ xfs_irele(ip);
+ return error;
}

/* Re-log an intent item to push the log tail forward. */
--
2.20.1