diff options
author | Darrick J. Wong <djwong@kernel.org> | 2024-07-02 11:23:11 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2024-07-02 11:37:07 -0700 |
commit | e51987a12cb57ca3702bff5df8a615037b2c8f8a (patch) | |
tree | d6c7bd346efe0ee5ffd07bf065224c93820ad797 /fs | |
parent | bac3f784925299b5e69a857e7e03e59c88aa14be (diff) |
xfs: simplify usage of the rcur local variable in xfs_refcount_finish_one
Only update rcur when we know the final *pcur value.
Inspired-by: Christoph Hellwig <hch@lst.de>
[djwong: don't leave the caller with a dangling ref]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_refcount.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 10a16635d93f..4137a8d1ac13 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1341,7 +1341,7 @@ xfs_refcount_finish_one( struct xfs_btree_cur **pcur) { struct xfs_mount *mp = tp->t_mountp; - struct xfs_btree_cur *rcur; + struct xfs_btree_cur *rcur = *pcur; struct xfs_buf *agbp = NULL; int error = 0; xfs_agblock_t bno; @@ -1359,7 +1359,6 @@ xfs_refcount_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - rcur = *pcur; if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { nr_ops = rcur->bc_refc.nr_ops; shape_changes = rcur->bc_refc.shape_changes; @@ -1373,11 +1372,11 @@ xfs_refcount_finish_one( if (error) return error; - rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, ri->ri_pag); + *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, + ri->ri_pag); rcur->bc_refc.nr_ops = nr_ops; rcur->bc_refc.shape_changes = shape_changes; } - *pcur = rcur; switch (ri->ri_type) { case XFS_REFCOUNT_INCREASE: |