diff mbox series

[60/61] xfs_db: convert the agresv command to use for_each_perag

Message ID 163174752232.350433.14940185128838830345.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfs: sync libxfs with 5.14 | expand

Commit Message

Darrick J. Wong Sept. 15, 2021, 11:12 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Convert the AG iteration loop for this debugger command to use
for_each_perag, since it's the only place in userspace that obvious
wants it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/info.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Christoph Hellwig Sept. 16, 2021, 7:20 a.m. UTC | #1
On Wed, Sep 15, 2021 at 04:12:02PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Convert the AG iteration loop for this debugger command to use
> for_each_perag, since it's the only place in userspace that obvious
> wants it.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/db/info.c b/db/info.c
index 2ecaea64..fdee76ba 100644
--- a/db/info.c
+++ b/db/info.c
@@ -62,11 +62,11 @@  agresv_help(void)
 
 static void
 print_agresv_info(
-	xfs_agnumber_t	agno)
+	struct xfs_perag *pag)
 {
 	struct xfs_buf	*bp;
 	struct xfs_agf	*agf;
-	struct xfs_perag *pag = libxfs_perag_get(mp, agno);
+	xfs_agnumber_t	agno = pag->pag_agno;
 	xfs_extlen_t	ask = 0;
 	xfs_extlen_t	used = 0;
 	xfs_extlen_t	free = 0;
@@ -97,7 +97,6 @@  print_agresv_info(
 	if (ask - used > free)
 		printf(" <not enough space>");
 	printf("\n");
-	libxfs_perag_put(pag);
 }
 
 static int
@@ -105,6 +104,7 @@  agresv_f(
 	int			argc,
 	char			**argv)
 {
+	struct xfs_perag	*pag;
 	xfs_agnumber_t		agno;
 	int			i;
 
@@ -127,13 +127,15 @@  agresv_f(
 				continue;
 			}
 
-			print_agresv_info(a);
+			pag = libxfs_perag_get(mp, a);
+			print_agresv_info(pag);
+			libxfs_perag_put(pag);
 		}
 		return 0;
 	}
 
-	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++)
-		print_agresv_info(agno);
+	for_each_perag(mp, agno, pag)
+		print_agresv_info(pag);
 
 	return 0;
 }