aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-12-20 08:53:44 -0800
committerDarrick J. Wong <djwong@kernel.org>2023-12-21 18:29:14 -0800
commit1665923a8302088744a69403ff60a1709f5d24ed (patch)
treedbdf22857f28f609ce8d4b66ea76672e2c004ffe
parent6ecc6712238c3ea5b574caf4a165ff20f5450e8b (diff)
downloadxfsprogs-dev-1665923a8302088744a69403ff60a1709f5d24ed.tar.gz
xfs_db: report the device associated with each io cursor
When db is reporting on an io cursor, have it print out the device that the cursor is pointing to. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--db/block.c14
-rw-r--r--db/io.c35
-rw-r--r--db/io.h3
3 files changed, 48 insertions, 4 deletions
diff --git a/db/block.c b/db/block.c
index 788337d370..d730c77967 100644
--- a/db/block.c
+++ b/db/block.c
@@ -126,7 +126,15 @@ daddr_f(
char *p;
if (argc == 1) {
- dbprintf(_("current daddr is %lld\n"), iocur_top->off >> BBSHIFT);
+ xfs_daddr_t daddr = iocur_top->off >> BBSHIFT;
+
+ if (iocur_is_ddev(iocur_top))
+ dbprintf(_("datadev daddr is %lld\n"), daddr);
+ else if (iocur_is_extlogdev(iocur_top))
+ dbprintf(_("logdev daddr is %lld\n"), daddr);
+ else
+ dbprintf(_("current daddr is %lld\n"), daddr);
+
return 0;
}
d = (int64_t)strtoull(argv[1], &p, 0);
@@ -220,6 +228,10 @@ fsblock_f(
char *p;
if (argc == 1) {
+ if (!iocur_is_ddev(iocur_top)) {
+ dbprintf(_("cursor does not point to data device\n"));
+ return 0;
+ }
dbprintf(_("current fsblock is %lld\n"),
XFS_DADDR_TO_FSB(mp, iocur_top->off >> BBSHIFT));
return 0;
diff --git a/db/io.c b/db/io.c
index 5ccfe3b536..590dd1f82f 100644
--- a/db/io.c
+++ b/db/io.c
@@ -137,18 +137,47 @@ pop_help(void)
));
}
+bool
+iocur_is_ddev(const struct iocur *ioc)
+{
+ if (!ioc->bp)
+ return false;
+
+ return ioc->bp->b_target == ioc->bp->b_mount->m_ddev_targp;
+}
+
+bool
+iocur_is_extlogdev(const struct iocur *ioc)
+{
+ struct xfs_buf *bp = ioc->bp;
+
+ if (!bp)
+ return false;
+ if (bp->b_mount->m_logdev_targp == bp->b_mount->m_ddev_targp)
+ return false;
+
+ return bp->b_target == bp->b_mount->m_logdev_targp;
+}
+
void
print_iocur(
char *tag,
iocur_t *ioc)
{
+ const char *block_unit = "fsbno?";
int i;
+ if (iocur_is_ddev(ioc))
+ block_unit = "fsbno";
+ else if (iocur_is_extlogdev(ioc))
+ block_unit = "logbno";
+
dbprintf("%s\n", tag);
dbprintf(_("\tbyte offset %lld, length %d\n"), ioc->off, ioc->len);
- dbprintf(_("\tbuffer block %lld (fsbno %lld), %d bb%s\n"), ioc->bb,
- (xfs_fsblock_t)XFS_DADDR_TO_FSB(mp, ioc->bb), ioc->blen,
- ioc->blen == 1 ? "" : "s");
+ dbprintf(_("\tbuffer block %lld (%s %lld), %d bb%s\n"), ioc->bb,
+ block_unit,
+ (xfs_fsblock_t)XFS_DADDR_TO_FSB(mp, ioc->bb),
+ ioc->blen, ioc->blen == 1 ? "" : "s");
if (ioc->bbmap) {
dbprintf(_("\tblock map"));
for (i = 0; i < ioc->bbmap->nmaps; i++)
diff --git a/db/io.h b/db/io.h
index bd86c31f67..f48b67b47a 100644
--- a/db/io.h
+++ b/db/io.h
@@ -56,6 +56,9 @@ extern void set_iocur_type(const struct typ *type);
extern void xfs_dummy_verify(struct xfs_buf *bp);
extern void xfs_verify_recalc_crc(struct xfs_buf *bp);
+bool iocur_is_ddev(const struct iocur *ioc);
+bool iocur_is_extlogdev(const struct iocur *ioc);
+
/*
* returns -1 for unchecked, 0 for bad and 1 for good
*/