From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH] xfs_db: don't hardcode 'type data' size at 512b
Date: Mon, 22 Jan 2024 20:10:44 -0800 [thread overview]
Message-ID: <20240123041044.GD6226@frogsfrogsfrogs> (raw)
From: Darrick J. Wong <djwong@kernel.org>
On a disk with 4096-byte LBAs, the xfs_db 'type data' subcommand doesn't
work:
# xfs_io -c 'sb' -c 'type data' /dev/sda
xfs_db: read failed: Invalid argument
no current object
The cause of this is the hardcoded initialization of bb_count when we're
setting type data -- it should be the filesystem sector size, not just 1.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
db/block.c | 7 ++++---
db/io.c | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/db/block.c b/db/block.c
index f234fcb4edcb..c847a91dd22f 100644
--- a/db/block.c
+++ b/db/block.c
@@ -149,6 +149,7 @@ daddr_f(
int64_t d;
char *p;
int c;
+ int bb_count = BTOBB(mp->m_sb.sb_sectsize);
xfs_rfsblock_t max_daddrs = mp->m_sb.sb_dblocks;
enum daddr_target tgt = DT_DATA;
@@ -202,13 +203,13 @@ daddr_f(
ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
switch (tgt) {
case DT_DATA:
- set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+ set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
break;
case DT_RT:
- set_rt_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+ set_rt_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
break;
case DT_LOG:
- set_log_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+ set_log_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
break;
}
return 0;
diff --git a/db/io.c b/db/io.c
index 580d34015868..3841c0dcb86e 100644
--- a/db/io.c
+++ b/db/io.c
@@ -681,7 +681,8 @@ void
set_iocur_type(
const typ_t *type)
{
- int bb_count = 1; /* type's size in basic blocks */
+ /* type's size in basic blocks */
+ int bb_count = BTOBB(mp->m_sb.sb_sectsize);
int boff = iocur_top->boff;
/*
next reply other threads:[~2024-01-23 4:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <XHUtgxly_CH13p8M7H9gfXcYh0jkPKFUt3PdJWiUb0Zd-14mjvJntXzbO99fH1XtOezv0aqG4XSdnTZ06vmgzw==@protonmail.internalid>
2024-01-23 4:10 ` Darrick J. Wong [this message]
2024-01-23 4:15 ` [PATCH] xfs_db: don't hardcode 'type data' size at 512b Christoph Hellwig
2024-01-23 10:38 ` Carlos Maiolino
2024-02-22 22:04 ` [PATCH v2] " Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123041044.GD6226@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox