From 560f79d15c063fe8a1b4aa5794aff32452a6003e Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 1 Nov 2022 11:23:12 -0700 Subject: xfs: create a function to duplicate an active perag reference There a few object constructor functions throughout XFS where a caller provides an active perag reference and the constructor wants to give the new object its own active reference. Replace the open-coded logic with a common function to do this instead of open-coding atomic_inc logic. This new function adds a few safeguards -- it checks that there's at least one active reference to the perag structure passed in, and it records the refcount bump in the ftrace information. This makes it much easier to debug refcounting problems. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_iunlink_item.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'fs/xfs/xfs_iunlink_item.c') diff --git a/fs/xfs/xfs_iunlink_item.c b/fs/xfs/xfs_iunlink_item.c index 43005ce8bd48..5024a59f0c75 100644 --- a/fs/xfs/xfs_iunlink_item.c +++ b/fs/xfs/xfs_iunlink_item.c @@ -168,9 +168,7 @@ xfs_iunlink_log_inode( iup->ip = ip; iup->next_agino = next_agino; iup->old_agino = ip->i_next_unlinked; - - atomic_inc(&pag->pag_ref); - iup->pag = pag; + iup->pag = xfs_perag_bump(pag); xfs_trans_add_item(tp, &iup->item); tp->t_flags |= XFS_TRANS_DIRTY; -- cgit v1.2.3