* [PATCHSET 3/4] xfs_db: human-inspired bug fixes
@ 2026-06-30 1:02 Darrick J. Wong
2026-06-30 1:04 ` [PATCH 1/2] xfs_db: fix type conversions Darrick J. Wong
2026-06-30 1:04 ` [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields Darrick J. Wong
0 siblings, 2 replies; 5+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:02 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
Hi all,
I stumbled over these two bugs when I was mucking around in xfs_db.
These aren't from Codex!
If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.
With a bit of luck, this should all go splendidly.
Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=db-fixes
---
Commits in this patchset:
* xfs_db: fix type conversions
* xfs_db: dump zoned filesystem superblock fields
---
db/io.c | 9 +++++++--
db/sb.c | 10 ++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] xfs_db: fix type conversions
2026-06-30 1:02 [PATCHSET 3/4] xfs_db: human-inspired bug fixes Darrick J. Wong
@ 2026-06-30 1:04 ` Darrick J. Wong
2026-06-30 5:21 ` Christoph Hellwig
2026-06-30 1:04 ` [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields Darrick J. Wong
1 sibling, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:04 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
While debugging rtrefcount problems, I noticed the following brokenness
in the debugger:
# xfs_db /dev/sdf -c 'path -m /rtgroups/0.refcount' -c 'type text' -c print -c stack
000: 24 84 4b 15 74 55 00 00 c0 5d 40 15 74 55 00 00 ..K.tU......tU..
010: 48 9c 4b 15 74 55 00 00 00 00 00 00 00 00 00 00 H.K.tU..........
020: 50 f3 41 15 74 55 00 00 01 00 00 00 01 00 00 00 P.A.tU..........
030: 00 00 00 00 00 00 00 00 61 9c 4b 15 74 55 00 00 ........a.K.tU..
040: 4f 9c 4b 15 74 55 00 00 00 00 00 00 00 00 00 00 O.K.tU..........
050: 43 9e 4b 15 74 55 00 00 00 00 00 00 00 00 00 00 C.K.tU..........
060: c0 fc 41 15 74 55 00 00 00 00 00 00 00 00 00 00 ..A.tU..........
070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
080: f1 9d 4b 15 74 55 00 00 90 f7 41 15 74 55 00 00 ..K.tU....A.tU..
090: c4 9e 4b 15 74 55 00 00 00 00 00 00 00 00 00 00 ..K.tU..........
0a0: 80 0f 42 15 74 55 00 00 00 00 00 00 ff ff ff ff ..B.tU..........
0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0c0: d5 9e 4b 15 74 55 00 00 00 0c 42 15 74 55 00 00 ..K.tU....B.tU..
0d0: d0 06 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ................
0e0: 90 87 fe 23 74 55 00 00 01 00 00 00 ad 7f 00 00 ....tU..........
0f0: 00 00 00 00 00 00 00 00 80 83 fe 23 74 55 00 00 ............tU..
100: c0 7f fe 23 74 55 00 00 00 00 00 00 00 00 00 00 ....tU..........
110: 00 00 00 00 00 00 22 9d 41 00 00 00 00 00 00 00 ........A.......
120: 2f 75 73 72 2f 73 68 61 72 65 2f 6c 6f 63 61 6c .usr.share.local
130: 65 2f 65 6e 2e 55 54 46 2d 38 2e 75 74 66 38 2f e.en.UTF.8.utf8.
140: 4c 43 5f 4d 45 53 53 41 47 45 53 2f 78 66 73 70 LC.MESSAGES.xfsp
150: 72 6f 67 73 2e 6d 6f 00 51 00 00 00 00 00 00 00 rogs.mo.Q.......
160: 20 95 fe 23 74 55 00 00 01 00 00 00 ad 7f 00 00 ....tU..........
170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
180: 80 83 fe 23 74 55 00 00 e0 94 fe 23 74 55 00 00 ....tU......tU..
190: c0 7f fe 23 74 55 00 00 00 00 00 00 00 00 00 00 ....tU..........
1a0: 00 00 00 00 00 00 22 9d 41 00 00 00 00 00 00 00 ........A.......
1b0: e9 3f 42 57 05 00 00 00 5a 01 d3 41 44 71 76 92 ..BW....Z..ADqv.
1c0: 65 2f 65 6e 5f 55 53 2e 55 54 46 2d 38 2f 4c 43 e.en.US.UTF.8.LC
1d0: 5f 4d 45 53 53 41 47 45 53 2f 78 66 73 70 72 6f .MESSAGES.xfspro
1e0: 67 73 2e 6d 6f 00 00 28 21 00 00 00 00 00 00 00 gs.mo...........
1f0: 09 48 bc 74 71 55 00 00 5a 01 d3 41 44 71 76 92 .H.tqU..Z..ADqv.
1:
byte offset 2642479104, length 512
buffer block 5161088 (fsbno 1064976), 1 bb
inode 8519812, dir inode -1, type text
The rtrefcount btree inode is not *so* corrupt that it's full of random
i18n garbage; valgrind confirms that we're walking off the end of
iocur_top->buf. Looking at what set_iocur_type does, I think it should
be (re)reading the existing buffer while preserving the existing
boff/len fields. Instead, it resets the buffer size to 1 fssector, but,
oddly, preserving boff (and not len). This is why we go off the end of
the buffer.
After fixing, I get:
# xfs_db /dev/sdf -c 'path -m /rtgroups/0.refcount' -c 'type text' -c print -c stack
000: 49 4e 80 00 03 05 00 08 00 00 00 00 00 00 00 00 IN..............
010: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
020: 35 ed d7 36 1e e0 aa 20 35 ed d7 36 1e e0 aa 20 5..6....5..6....
030: 35 ed d7 36 1e e0 ae 08 00 00 00 00 00 00 00 00 5..6............
Truncated for brevity; this is much better.
Cc: <linux-xfs@vger.kernel.org> # v5.18.0
Fixes: 0d376f6cf1799b ("xfs_db: take BB cluster offset into account when using 'type' cmd")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
db/io.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/db/io.c b/db/io.c
index 3841c0dcb86ead..fc9a25d4102482 100644
--- a/db/io.c
+++ b/db/io.c
@@ -682,8 +682,9 @@ set_iocur_type(
const typ_t *type)
{
/* type's size in basic blocks */
- int bb_count = BTOBB(mp->m_sb.sb_sectsize);
+ int bb_count = iocur_top->blen;
int boff = iocur_top->boff;
+ int len = iocur_top->len;
/*
* Inodes are special; verifier checks all inodes in the chunk, the
@@ -704,11 +705,15 @@ set_iocur_type(
}
/* adjust buffer size for types with fields & hence fsize() */
- if (type->fields)
+ if (type->fields) {
bb_count = BTOBB(byteize(fsize(type->fields,
iocur_top->data, 0, 0)));
+ len = BBTOB(bb_count);
+ }
+
set_cur(type, iocur_top->bb, bb_count, DB_RING_IGN, NULL);
set_cur_boff(boff);
+ iocur_top->len = len;
}
static void
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields
2026-06-30 1:02 [PATCHSET 3/4] xfs_db: human-inspired bug fixes Darrick J. Wong
2026-06-30 1:04 ` [PATCH 1/2] xfs_db: fix type conversions Darrick J. Wong
@ 2026-06-30 1:04 ` Darrick J. Wong
2026-06-30 5:21 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2026-06-30 1:04 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
Display the rtstart and rtreserved superblock fields if the filesystem
has zoned storage support.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
db/sb.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/db/sb.c b/db/sb.c
index 52ac48d45d5ae6..666207145a86cb 100644
--- a/db/sb.c
+++ b/db/sb.c
@@ -63,6 +63,14 @@ metadirfld_count(
return xfs_has_metadir(mp) ? 1 : 0;
}
+static int
+zonedfld_count(
+ void *obj,
+ int startoff)
+{
+ return xfs_has_zoned(mp) ? 1 : 0;
+}
+
#define OFF(f) bitize(offsetof(struct xfs_dsb, sb_ ## f))
#define SZC(f) szcount(struct xfs_dsb, sb_ ## f)
const field_t sb_flds[] = {
@@ -136,6 +144,8 @@ const field_t sb_flds[] = {
FLD_COUNT, TYP_NONE },
{ "pad", FLDT_UINT8X, OI(OFF(pad)), metadirfld_count,
FLD_COUNT, TYP_NONE },
+ { "rtstart", FLDT_DRFSBNO, OI(OFF(rtstart)), zonedfld_count, FLD_COUNT, TYP_NONE },
+ { "rtreserved", FLDT_UINT64D, OI(OFF(rtreserved)), zonedfld_count, FLD_COUNT, TYP_NONE },
{ NULL }
};
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] xfs_db: fix type conversions
2026-06-30 1:04 ` [PATCH 1/2] xfs_db: fix type conversions Darrick J. Wong
@ 2026-06-30 5:21 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2026-06-30 5:21 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields
2026-06-30 1:04 ` [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields Darrick J. Wong
@ 2026-06-30 5:21 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2026-06-30 5:21 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On Mon, Jun 29, 2026 at 06:04:44PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Display the rtstart and rtreserved superblock fields if the filesystem
> has zoned storage support.
Ah, yes:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-30 5:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 1:02 [PATCHSET 3/4] xfs_db: human-inspired bug fixes Darrick J. Wong
2026-06-30 1:04 ` [PATCH 1/2] xfs_db: fix type conversions Darrick J. Wong
2026-06-30 5:21 ` Christoph Hellwig
2026-06-30 1:04 ` [PATCH 2/2] xfs_db: dump zoned filesystem superblock fields Darrick J. Wong
2026-06-30 5:21 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox