]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: access realtime file blocks
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Oct 2024 00:03:32 +0000 (17:03 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:05 +0000 (15:45 -0700)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/block.c
db/block.h
db/faddr.c

index 6ad9f038c6da6713269db6af091a71521e6fe382..87118a4751ef940a422070da050085b3b1809ff2 100644 (file)
@@ -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], xfs_rtb_to_daddr(mp, dfsbno),
+                               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;
 }
index 7c4e8cb2acb051cff792a00ef7fc75937e3a3764..55843a6b521393884a47c47eab2ef08360232850 100644 (file)
@@ -3,8 +3,28 @@
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
  */
+#ifndef __XFS_DB_BLOCK_H
+#define __XFS_DB_BLOCK_H
 
 struct field;
 
 extern void    block_init(void);
 extern void    print_block(const struct field *fields, int argc, char **argv);
+
+static inline xfs_daddr_t
+xfs_rtb_to_daddr(
+       struct xfs_mount        *mp,
+       xfs_rtblock_t           rtb)
+{
+       return rtb << mp->m_blkbb_log;
+}
+
+static inline xfs_rtblock_t
+xfs_daddr_to_rtb(
+       struct xfs_mount        *mp,
+       xfs_daddr_t             daddr)
+{
+       return daddr >> mp->m_blkbb_log;
+}
+
+#endif /* __XFS_DB_BLOCK_H */
index ec4aae68bb5a8172cc69f9f9186d3f50b454a49f..e2f9587da0a67c9ae0abcc332e74608a26bb934b 100644 (file)
@@ -15,6 +15,7 @@
 #include "bmap.h"
 #include "output.h"
 #include "init.h"
+#include "block.h"
 
 void
 fa_agblock(
@@ -323,7 +324,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], xfs_rtb_to_daddr(mp, bno), blkbb,
+                       DB_RING_ADD, NULL);
 }
 
 /*ARGSUSED*/