diff mbox series

[01/11] xfs_io: display rtgroup number in verbose fsrefs output

Message ID 173568777884.2709794.12247373333506534863.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [01/11] xfs_io: display rtgroup number in verbose fsrefs output | expand

Commit Message

Darrick J. Wong Dec. 31, 2024, 11:45 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Display the rtgroup number in the verbose fsrefcounts output.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 io/fsrefcounts.c |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/io/fsrefcounts.c b/io/fsrefcounts.c
index ad1f26dfde3ec3..9127f536da382e 100644
--- a/io/fsrefcounts.c
+++ b/io/fsrefcounts.c
@@ -13,6 +13,7 @@ 
 
 static cmdinfo_t	fsrefcounts_cmd;
 static dev_t		xfs_data_dev;
+static dev_t		xfs_rt_dev;
 
 static void
 fsrefcounts_help(void)
@@ -119,7 +120,7 @@  dump_refcounts_verbose(
 	unsigned long long		i;
 	struct xfs_getfsrefs		*p;
 	int				agno;
-	off_t				agoff, bperag;
+	off_t				agoff, bperag, bperrtg;
 	int				boff_w, aoff_w, tot_w, agno_w, own_w;
 	int				nr_w, dev_w;
 	char				bbuf[40], abuf[40], obuf[40];
@@ -132,6 +133,7 @@  dump_refcounts_verbose(
 	nr_w = 4;
 	tot_w = MINTOT_WIDTH;
 	bperag = (off_t)fsgeo->agblocks * (off_t)fsgeo->blocksize;
+	bperrtg = bytes_per_rtgroup(fsgeo);
 	sunit = (fsgeo->sunit * fsgeo->blocksize);
 	swidth = (fsgeo->swidth * fsgeo->blocksize);
 
@@ -173,6 +175,13 @@  dump_refcounts_verbose(
 				"(%lld..%lld)",
 				(long long)BTOBBT(agoff),
 				(long long)BTOBBT(agoff + p->fcr_length - 1));
+		} else if (p->fcr_device == xfs_rt_dev && fsgeo->rgcount > 0) {
+			agno = p->fcr_physical / bperrtg;
+			agoff = p->fcr_physical - (agno * bperrtg);
+			snprintf(abuf, sizeof(abuf),
+				"(%lld..%lld)",
+				(long long)BTOBBT(agoff),
+				(long long)BTOBBT(agoff + p->fcr_length - 1));
 		} else
 			abuf[0] = 0;
 		aoff_w = max(aoff_w, strlen(abuf));
@@ -231,6 +240,16 @@  dump_refcounts_verbose(
 			snprintf(gbuf, sizeof(gbuf),
 				"%lld",
 				(long long)agno);
+		} else if (p->fcr_device == xfs_rt_dev && fsgeo->rgcount > 0) {
+			agno = p->fcr_physical / bperrtg;
+			agoff = p->fcr_physical - (agno * bperrtg);
+			snprintf(abuf, sizeof(abuf),
+				"(%lld..%lld)",
+				(long long)BTOBBT(agoff),
+				(long long)BTOBBT(agoff + p->fcr_length - 1));
+			snprintf(gbuf, sizeof(gbuf),
+				"%lld",
+				(long long)agno);
 		} else {
 			abuf[0] = 0;
 			gbuf[0] = 0;
@@ -420,6 +439,7 @@  fsrefcounts_f(
 	}
 	fs = fs_table_lookup(file->name, FS_MOUNT_POINT);
 	xfs_data_dev = fs ? fs->fs_datadev : 0;
+	xfs_rt_dev = fs ? fs->fs_rtdev : 0;
 
 	head->fch_count = map_size;
 	do {