xfs: create traced helper to get extra perag references
authorDarrick J. Wong <djwong@kernel.org>
Wed, 12 Apr 2023 01:59:55 +0000 (18:59 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 12 Apr 2023 01:59:55 +0000 (18:59 -0700)
commit9b2e5a234c89f097ec36f922763dfa1465dc06f8
tree70dd0e29d57d54b4bcafdd8516f70281d325ed75
parent00e7b3bac1dc8961bd5aa9d39e79131c6bd81181
xfs: create traced helper to get extra perag references

There are a few places in the XFS codebase where a caller has either an
active or a passive reference to a perag structure and wants to give
a passive reference to some other piece of code.  Btree cursor creation
and inode walks are good examples of this.  Replace the open-coded logic
with a helper to do this.

The new function adds a few safeguards -- it checks that there's at
least one reference to the perag structure passed in, and it records the
refcount bump in the ftrace information.  This makes it much easier to
debug perag refcounting problems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h
fs/xfs/libxfs/xfs_alloc_btree.c
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_refcount_btree.c
fs/xfs/libxfs/xfs_rmap_btree.c
fs/xfs/xfs_iunlink_item.c
fs/xfs/xfs_iwalk.c
fs/xfs/xfs_trace.h