Skip to contentSkip to conversation

xfs: remove unneeded return value check for xfs_rmapbt_init_cursor()

PATCH Superseded Joseph Qi 3 participants 4 messages Dec 3, 2020 – Dec 4, 2020 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joseph Qi

author
#0 lore raw

PATCH 1/1 xfs: remove unneeded return value check for xfs_rmapbt_init_cursor()

Since xfs_rmapbt_init_cursor() can always return a valid cursor, the NULL check in caller is unneeded.
This also keeps the behavior consistent with other callers.

---
 fs/xfs/libxfs/xfs_rmap.c | 9 ---------
 fs/xfs/scrub/bmap.c      | 5 -----
 fs/xfs/scrub/common.c    | 2 --
 3 files changed, 16 deletions(-)
fs/xfs/libxfs/xfs_rmap.c +0 -9
index 2668ebe..10e0cf99 100644
@@ -2404,10 +2404,6 @@ struct xfs_rmap_query_range_info {
 			return -EFSCORRUPTED;
 
 		rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno);
-		if (!rcur) {
-			error = -ENOMEM;
-			goto out_cur;
-		}
 	}
 	*pcur = rcur;
 
@@ -2446,11 +2442,6 @@ struct xfs_rmap_query_range_info {
 		error = -EFSCORRUPTED;
 	}
 	return error;
-
-out_cur:
-	xfs_trans_brelse(tp, agbp);
-
-	return error;
 }
 
 /*
fs/xfs/scrub/bmap.c +0 -5
index fed56d2..dd165c0 100644
@@ -563,10 +563,6 @@ struct xchk_bmap_check_rmap_info {
 		return error;
 
 	cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno);
-	if (!cur) {
-		error = -ENOMEM;
-		goto out_agf;
-	}
 
 	sbcri.sc = sc;
 	sbcri.whichfork = whichfork;
@@ -575,7 +571,6 @@ struct xchk_bmap_check_rmap_info {
 		error = 0;
 
 	xfs_btree_del_cursor(cur, error);
-out_agf:
 	xfs_trans_brelse(sc->tp, agf);
 	return error;
 }
fs/xfs/scrub/common.c +0 -2
index 1887605..6757dc7 100644
@@ -502,8 +502,6 @@ struct xchk_rmap_ownedby_info {
 	    xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
 		sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
 				agno);
-		if (!sa->rmap_cur)
-			goto err;
 	}
 
 	/* Set up a refcountbt cursor for cross-referencing. */
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Joseph Qi
Quoted 66 lines · Joseph Qi

Since xfs_rmapbt_init_cursor() can always return a valid cursor, the NULL check in caller is unneeded.
This also keeps the behavior consistent with other callers.

---
 fs/xfs/libxfs/xfs_rmap.c | 9 ---------
 fs/xfs/scrub/bmap.c      | 5 -----
 fs/xfs/scrub/common.c    | 2 --
 3 files changed, 16 deletions(-)
fs/xfs/libxfs/xfs_rmap.c +0 -9
index 2668ebe..10e0cf99 100644
@@ -2404,10 +2404,6 @@ struct xfs_rmap_query_range_info {
 			return -EFSCORRUPTED;
 
 		rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno);
-		if (!rcur) {
-			error = -ENOMEM;
-			goto out_cur;
-		}
 	}
 	*pcur = rcur;
 
@@ -2446,11 +2442,6 @@ struct xfs_rmap_query_range_info {
 		error = -EFSCORRUPTED;
 	}
 	return error;
-
-out_cur:
-	xfs_trans_brelse(tp, agbp);
-
-	return error;
 }
 
 /*
fs/xfs/scrub/bmap.c +0 -5
index fed56d2..dd165c0 100644
@@ -563,10 +563,6 @@ struct xchk_bmap_check_rmap_info {
 		return error;
 
 	cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno);
-	if (!cur) {
-		error = -ENOMEM;
-		goto out_agf;
-	}
 
 	sbcri.sc = sc;
 	sbcri.whichfork = whichfork;
@@ -575,7 +571,6 @@ struct xchk_bmap_check_rmap_info {
 		error = 0;
 
 	xfs_btree_del_cursor(cur, error);
-out_agf:
 	xfs_trans_brelse(sc->tp, agf);
 	return error;
 }
fs/xfs/scrub/common.c +0 -0
index 1887605..6757dc7 100644

fs/xfs/scrub/common.c struct xchk_rmap_ownedby_info { · line 506

Quoted 5 lines
fs/xfs/scrub/common.c +0 -2
@@ -502,8 +502,6 @@ struct xchk_rmap_ownedby_info {
 	    xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
 		sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
 				agno);
-		if (!sa->rmap_cur)
-			goto err;

Would you mind cleaning out the other btree cursor allocation warts under fs/xfs/scrub/ ?

--D

Quoted 6 lines
fs/xfs/scrub/common.c +0 -0
 	}
 
 	/* Set up a refcountbt cursor for cross-referencing. */
Signature · 1 line
1.8.3.1
author
#3 lore raw
Quoted 67 lines · Darrick J. Wong
Quoted 66 lines · Joseph Qi

Since xfs_rmapbt_init_cursor() can always return a valid cursor, the NULL check in caller is unneeded.
This also keeps the behavior consistent with other callers.

---
 fs/xfs/libxfs/xfs_rmap.c | 9 ---------
 fs/xfs/scrub/bmap.c      | 5 -----
 fs/xfs/scrub/common.c    | 2 --
 3 files changed, 16 deletions(-)
fs/xfs/libxfs/xfs_rmap.c +0 -9
index 2668ebe..10e0cf99 100644
@@ -2404,10 +2404,6 @@ struct xfs_rmap_query_range_info {
 			return -EFSCORRUPTED;
 
 		rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno);
-		if (!rcur) {
-			error = -ENOMEM;
-			goto out_cur;
-		}
 	}
 	*pcur = rcur;
 
@@ -2446,11 +2442,6 @@ struct xfs_rmap_query_range_info {
 		error = -EFSCORRUPTED;
 	}
 	return error;
-
-out_cur:
-	xfs_trans_brelse(tp, agbp);
-
-	return error;
 }
 
 /*
fs/xfs/scrub/bmap.c +0 -5
index fed56d2..dd165c0 100644
@@ -563,10 +563,6 @@ struct xchk_bmap_check_rmap_info {
 		return error;
 
 	cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno);
-	if (!cur) {
-		error = -ENOMEM;
-		goto out_agf;
-	}
 
 	sbcri.sc = sc;
 	sbcri.whichfork = whichfork;
@@ -575,7 +571,6 @@ struct xchk_bmap_check_rmap_info {
 		error = 0;
 
 	xfs_btree_del_cursor(cur, error);
-out_agf:
 	xfs_trans_brelse(sc->tp, agf);
 	return error;
 }
fs/xfs/scrub/common.c +0 -0
index 1887605..6757dc7 100644
@@ -502,8 +502,6 @@ struct xchk_rmap_ownedby_info {
Quoted 9 lines

fs/xfs/scrub/common.c struct xchk_rmap_ownedby_info { · line 506

Quoted 5 lines
fs/xfs/scrub/common.c +0 -2
 	    xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
 		sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
 				agno);
-		if (!sa->rmap_cur)
-			goto err;

Would you mind cleaning out the other btree cursor allocation warts under fs/xfs/scrub/ ?

Sure, I'll do this and send v2.

Thanks,
Joseph