]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: display rt group in verbose bmap output
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:24:39 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:34 +0000 (18:01 -0800)
Display the rt group number in the bmap -v output, just like we do for
regular data files.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
io/bmap.c
libfrog/fsgeom.h

index 6182e1c591da18b30ab7a8143ef2a77c555a626f..b2f6b4905285130d4e04609a62f2331caa8a03d8 100644 (file)
--- a/io/bmap.c
+++ b/io/bmap.c
@@ -257,16 +257,18 @@ bmap_f(
 #define        FLG_BSW         0000010 /* Not on begin of stripe width */
 #define        FLG_ESW         0000001 /* Not on end   of stripe width */
                int     agno;
-               off_t agoff, bbperag;
+               off_t   agoff, bbperag;
                int     foff_w, boff_w, aoff_w, tot_w, agno_w;
                char    rbuf[32], bbuf[32], abuf[32];
                int     sunit, swidth;
 
                foff_w = boff_w = aoff_w = MINRANGE_WIDTH;
                tot_w = MINTOT_WIDTH;
-               if (is_rt)
-                       sunit = swidth = bbperag = 0;
-               else {
+               if (is_rt) {
+                       bbperag = bytes_per_rtgroup(&fsgeo) / BBSIZE;
+                       sunit = 0;
+                       swidth = 0;
+               } else {
                        bbperag = (off_t)fsgeo.agblocks *
                                  (off_t)fsgeo.blocksize / BBSIZE;
                        sunit = (fsgeo.sunit * fsgeo.blocksize) / BBSIZE;
@@ -295,7 +297,7 @@ bmap_f(
                                        (long long)(map[i + 1].bmv_block +
                                                map[i + 1].bmv_length - 1LL));
                                boff_w = max(boff_w, strlen(bbuf));
-                               if (!is_rt) {
+                               if (bbperag > 0) {
                                        agno = map[i + 1].bmv_block / bbperag;
                                        agoff = map[i + 1].bmv_block -
                                                        (agno * bbperag);
@@ -312,13 +314,20 @@ bmap_f(
                                        numlen(map[i+1].bmv_length, 10));
                        }
                }
-               agno_w = is_rt ? 0 : max(MINAG_WIDTH, numlen(fsgeo.agcount, 10));
+               if (is_rt) {
+                       if (fsgeo.rgcount > 0)
+                               agno_w = max(MINAG_WIDTH, numlen(fsgeo.rgcount, 10));
+                       else
+                               agno_w = 0;
+               } else {
+                       agno_w = max(MINAG_WIDTH, numlen(fsgeo.agcount, 10));
+               }
                printf("%4s: %-*s %-*s %*s %-*s %*s%s\n",
                        _("EXT"),
                        foff_w, _("FILE-OFFSET"),
                        boff_w, is_rt ? _("RT-BLOCK-RANGE") : _("BLOCK-RANGE"),
-                       agno_w, is_rt ? "" : _("AG"),
-                       aoff_w, is_rt ? "" : _("AG-OFFSET"),
+                       agno_w, is_rt ? (fsgeo.rgcount ? _("RG") : "") : _("AG"),
+                       aoff_w, is_rt ? (fsgeo.rgcount ? _("RG-OFFSET") : "") : _("AG-OFFSET"),
                        tot_w, _("TOTAL"),
                        flg ? _(" FLAGS") : "");
                for (i = 0; i < egcnt; i++) {
@@ -377,7 +386,7 @@ bmap_f(
                                                map[i + 1].bmv_length - 1LL));
                                printf("%4d: %-*s %-*s", i, foff_w, rbuf,
                                        boff_w, bbuf);
-                               if (!is_rt) {
+                               if (bbperag > 0) {
                                        agno = map[i + 1].bmv_block / bbperag;
                                        agoff = map[i + 1].bmv_block -
                                                        (agno * bbperag);
index c571ddbcfb9b7019935d1e968d36d83116274a8a..b851b9bbf36a58e9b7f34f39d0e9753794c6a343 100644 (file)
@@ -205,4 +205,16 @@ cvt_b_to_agbno(
        return cvt_daddr_to_agbno(xfd, cvt_btobbt(byteno));
 }
 
+/* Return the number of bytes in an rtgroup. */
+static inline uint64_t
+bytes_per_rtgroup(
+       const struct xfs_fsop_geom      *fsgeo)
+{
+       if (!fsgeo->rgcount)
+               return 0;
+
+       return (uint64_t)fsgeo->rgextents * fsgeo->rtextsize *
+               fsgeo->blocksize;
+}
+
 #endif /* __LIBFROG_FSGEOM_H__ */