diff mbox series

[4/8] xfs_db: access realtime file blocks

Message ID 172983773789.3041229.10050634092165024838.stgit@frogsfrogsfrogs (mailing list archive)
State Deferred, archived
Headers show
Series [1/8] xfs_db: support passing the realtime device to the debugger | expand

Commit Message

Darrick J. Wong Oct. 25, 2024, 6:35 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Now that we have the ability to point the io cursor at the realtime
device, let's make it so that the "dblock" command can walk the contents
of realtime files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/block.c |   17 +++++++++++++++--
 db/faddr.c |    4 +++-
 2 files changed, 18 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Oct. 28, 2024, 8:37 a.m. UTC | #1
> +	if (is_rtfile(iocur_top->data))
> +		set_rt_cur(&typtab[type], (int64_t)dfsbno << mp->m_blkbb_log,

Shouldn't this be xfs_rtb_to_daddr?

> diff --git a/db/faddr.c b/db/faddr.c
> index ec4aae68bb5a81..fd65b86b5e915d 100644
> --- a/db/faddr.c
> +++ b/db/faddr.c
> @@ -323,7 +323,9 @@ fa_drtbno(
>  		dbprintf(_("null block number, cannot set new addr\n"));
>  		return;
>  	}
> -	/* need set_cur to understand rt subvolume */
> +
> +	set_rt_cur(&typtab[next], (int64_t)XFS_FSB_TO_BB(mp, bno), blkbb,
> +			DB_RING_ADD, NULL);

Same here?
Darrick J. Wong Oct. 28, 2024, 5:50 p.m. UTC | #2
On Mon, Oct 28, 2024 at 01:37:12AM -0700, Christoph Hellwig wrote:
> > +	if (is_rtfile(iocur_top->data))
> > +		set_rt_cur(&typtab[type], (int64_t)dfsbno << mp->m_blkbb_log,
> 
> Shouldn't this be xfs_rtb_to_daddr?

This series is for xfsprogs 6.12; the helpers adding rtb <-> daddr
conversions won't get added until the rtgroups cleanups that are headed
towards 6.13.

I could try to fling a patch for 6.12 to add these trivial helpers, hope
that I can persuade Carlos to persuade Linus to add that for 6.12-rc6,
then wait until next week to port the new helper patch to xfsprogs and
*then* resend this series.  Then I'd rebase all the 6.13 stuff, initiate
another round of review, and maybe we can push metadir into 6.13
for-next after rc6.

Good grief that sounds incredibly bureaucratic for a left and right
shift helper.

I'm going to add rtb_to_daddr and daddr_to_rtb to db/block.h for now and
update them to the xfs_ versions in the metadir patchset.

> > diff --git a/db/faddr.c b/db/faddr.c
> > index ec4aae68bb5a81..fd65b86b5e915d 100644
> > --- a/db/faddr.c
> > +++ b/db/faddr.c
> > @@ -323,7 +323,9 @@ fa_drtbno(
> >  		dbprintf(_("null block number, cannot set new addr\n"));
> >  		return;
> >  	}
> > -	/* need set_cur to understand rt subvolume */
> > +
> > +	set_rt_cur(&typtab[next], (int64_t)XFS_FSB_TO_BB(mp, bno), blkbb,
> > +			DB_RING_ADD, NULL);
> 
> Same here?

Yep.

--D
diff mbox series

Patch

diff --git a/db/block.c b/db/block.c
index 6ad9f038c6da67..ff34557a612a2f 100644
--- a/db/block.c
+++ b/db/block.c
@@ -196,6 +196,13 @@  dblock_help(void)
 ));
 }
 
+static inline bool
+is_rtfile(
+	struct xfs_dinode	*dip)
+{
+	return dip->di_flags & cpu_to_be16(XFS_DIFLAG_REALTIME);
+}
+
 static int
 dblock_f(
 	int		argc,
@@ -235,8 +242,14 @@  dblock_f(
 	ASSERT(typtab[type].typnm == type);
 	if (nex > 1)
 		make_bbmap(&bbmap, nex, bmp);
-	set_cur(&typtab[type], (int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
-		nb * blkbb, DB_RING_ADD, nex > 1 ? &bbmap : NULL);
+	if (is_rtfile(iocur_top->data))
+		set_rt_cur(&typtab[type], (int64_t)dfsbno << mp->m_blkbb_log,
+				nb * blkbb, DB_RING_ADD,
+				nex > 1 ? &bbmap : NULL);
+	else
+		set_cur(&typtab[type], (int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
+				nb * blkbb, DB_RING_ADD,
+				nex > 1 ? &bbmap : NULL);
 	free(bmp);
 	return 0;
 }
diff --git a/db/faddr.c b/db/faddr.c
index ec4aae68bb5a81..fd65b86b5e915d 100644
--- a/db/faddr.c
+++ b/db/faddr.c
@@ -323,7 +323,9 @@  fa_drtbno(
 		dbprintf(_("null block number, cannot set new addr\n"));
 		return;
 	}
-	/* need set_cur to understand rt subvolume */
+
+	set_rt_cur(&typtab[next], (int64_t)XFS_FSB_TO_BB(mp, bno), blkbb,
+			DB_RING_ADD, NULL);
 }
 
 /*ARGSUSED*/