Skip to content

Commit e51987a

Browse files
author
Darrick J. Wong
committed
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 <[email protected]> [djwong: don't leave the caller with a dangling ref] Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent bac3f78 commit e51987a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/xfs/libxfs/xfs_refcount.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ xfs_refcount_finish_one(
13411341
struct xfs_btree_cur **pcur)
13421342
{
13431343
struct xfs_mount *mp = tp->t_mountp;
1344-
struct xfs_btree_cur *rcur;
1344+
struct xfs_btree_cur *rcur = *pcur;
13451345
struct xfs_buf *agbp = NULL;
13461346
int error = 0;
13471347
xfs_agblock_t bno;
@@ -1359,7 +1359,6 @@ xfs_refcount_finish_one(
13591359
* If we haven't gotten a cursor or the cursor AG doesn't match
13601360
* the startblock, get one now.
13611361
*/
1362-
rcur = *pcur;
13631362
if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) {
13641363
nr_ops = rcur->bc_refc.nr_ops;
13651364
shape_changes = rcur->bc_refc.shape_changes;
@@ -1373,11 +1372,11 @@ xfs_refcount_finish_one(
13731372
if (error)
13741373
return error;
13751374

1376-
rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, ri->ri_pag);
1375+
*pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp,
1376+
ri->ri_pag);
13771377
rcur->bc_refc.nr_ops = nr_ops;
13781378
rcur->bc_refc.shape_changes = shape_changes;
13791379
}
1380-
*pcur = rcur;
13811380

13821381
switch (ri->ri_type) {
13831382
case XFS_REFCOUNT_INCREASE:

0 commit comments

Comments
 (0)