Skip to content

Commit 905af72

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: simplify usage of the rcur local variable in xfs_rmap_finish_one
Only update rcur when we know the final *pcur value. Signed-off-by: Christoph Hellwig <[email protected]> [djwong: don't leave the caller with a dangling ref] Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 8363b43 commit 905af72

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ xfs_rmap_finish_one(
25702570
{
25712571
struct xfs_owner_info oinfo;
25722572
struct xfs_mount *mp = tp->t_mountp;
2573-
struct xfs_btree_cur *rcur;
2573+
struct xfs_btree_cur *rcur = *pcur;
25742574
struct xfs_buf *agbp = NULL;
25752575
xfs_agblock_t bno;
25762576
bool unwritten;
@@ -2585,7 +2585,6 @@ xfs_rmap_finish_one(
25852585
* If we haven't gotten a cursor or the cursor AG doesn't match
25862586
* the startblock, get one now.
25872587
*/
2588-
rcur = *pcur;
25892588
if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) {
25902589
xfs_btree_del_cursor(rcur, 0);
25912590
rcur = NULL;
@@ -2607,9 +2606,8 @@ xfs_rmap_finish_one(
26072606
return -EFSCORRUPTED;
26082607
}
26092608

2610-
rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
2609+
*pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
26112610
}
2612-
*pcur = rcur;
26132611

26142612
xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
26152613
ri->ri_bmap.br_startoff);

0 commit comments

Comments
 (0)