]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_db: support passing the realtime device to the debugger
authorDarrick J. Wong <djwong@kernel.org>
Tue, 16 Aug 2022 16:39:37 +0000 (09:39 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 22 Nov 2023 23:03:32 +0000 (15:03 -0800)
Create a new -R flag so that sysadmins can pass the realtime device to
the xfs debugger.  Since we can now have superblocks on the rt device,
we need this to be able to inspect/dump/etc.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
db/init.c
db/io.c
db/io.h
db/xfs_admin.sh
man/man8/xfs_db.8

index ba35d6d8c5cd57e565241dbaf42710638cb99e56..0ab896d3bf9af0959fd55db85a30f9292930bdf9 100644 (file)
--- a/db/init.c
+++ b/db/init.c
@@ -33,7 +33,7 @@ static void
 usage(void)
 {
        fprintf(stderr, _(
-               "Usage: %s [-ifFrxV] [-p prog] [-l logdev] [-c cmd]... device\n"
+               "Usage: %s [-ifFrxV] [-p prog] [-l logdev] [-R rtdev] [-c cmd]... device\n"
                ), progname);
        exit(1);
 }
@@ -54,7 +54,7 @@ init(
        textdomain(PACKAGE);
 
        progname = basename(argv[0]);
-       while ((c = getopt(argc, argv, "c:fFip:rxVl:")) != EOF) {
+       while ((c = getopt(argc, argv, "c:fFip:rR:xVl:")) != EOF) {
                switch (c) {
                case 'c':
                        cmdline = xrealloc(cmdline, (ncmdline+1)*sizeof(char*));
@@ -75,6 +75,9 @@ init(
                case 'r':
                        x.isreadonly = LIBXFS_ISREADONLY;
                        break;
+               case 'R':
+                       x.rtname = optarg;
+                       break;
                case 'l':
                        x.logname = optarg;
                        break;
diff --git a/db/io.c b/db/io.c
index 590dd1f82f7bc7f8331e41ba08a5b8eee7e323fd..61befb4343725671aed41dae336453e95a87c29d 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -458,6 +458,7 @@ ring_add(void)
 static void
 write_cur_buf(void)
 {
+       struct xfs_buftarg      *btp = iocur_top->bp->b_target;
        int ret;
 
        ret = -libxfs_bwrite(iocur_top->bp);
@@ -465,7 +466,7 @@ write_cur_buf(void)
                dbprintf(_("write error: %s\n"), strerror(ret));
 
        /* re-read buffer from disk */
-       ret = -libxfs_readbufr(mp->m_ddev_targp, iocur_top->bb, iocur_top->bp,
+       ret = -libxfs_readbufr(btp, iocur_top->bb, iocur_top->bp,
                              iocur_top->blen, 0);
        if (ret != 0)
                dbprintf(_("read error: %s\n"), strerror(ret));
@@ -474,6 +475,7 @@ write_cur_buf(void)
 static void
 write_cur_bbs(void)
 {
+       struct xfs_buftarg      *btp = iocur_top->bp->b_target;
        int ret;
 
        ret = -libxfs_bwrite(iocur_top->bp);
@@ -482,7 +484,7 @@ write_cur_bbs(void)
 
 
        /* re-read buffer from disk */
-       ret = -libxfs_readbufr_map(mp->m_ddev_targp, iocur_top->bp, 0);
+       ret = -libxfs_readbufr_map(btp, iocur_top->bp, 0);
        if (ret != 0)
                dbprintf(_("read error: %s\n"), strerror(ret));
 }
@@ -541,9 +543,9 @@ static void
 __set_cur(
        struct xfs_buftarg      *btargp,
        const typ_t             *type,
-       xfs_daddr_t              blknum,
-       int                      len,
-       int                      ring_flag,
+       xfs_daddr_t             blknum,
+       int                     len,
+       int                     ring_flag,
        bbmap_t                 *bbmap)
 {
        struct xfs_buf          *bp;
@@ -647,6 +649,22 @@ set_log_cur(
        __set_cur(mp->m_logdev_targp, type, blknum, len, ring_flag, bbmap);
 }
 
+int
+set_rt_cur(
+       const typ_t     *type,
+       xfs_daddr_t     blknum,
+       int             len,
+       int             ring_flag,
+       bbmap_t         *bbmap)
+{
+       if (!mp->m_rtdev_targp->bt_bdev) {
+               printf(_("realtime device not loaded, use -R.\n"));
+               return ENODEV;
+       }
+
+       __set_cur(mp->m_rtdev_targp, type, blknum, len, ring_flag, bbmap);
+       return 0;
+}
 
 void
 set_iocur_type(
diff --git a/db/io.h b/db/io.h
index f48b67b47a2b55af2719f039f9651781f34bc14a..bb5065f06c0d8e7cec892f11f745b8915b515e5c 100644 (file)
--- a/db/io.h
+++ b/db/io.h
@@ -51,6 +51,8 @@ extern void   set_cur(const struct typ *type, xfs_daddr_t blknum,
                        int len, int ring_add, bbmap_t *bbmap);
 extern void    set_log_cur(const struct typ *type, xfs_daddr_t blknum,
                        int len, int ring_add, bbmap_t *bbmap);
+extern int     set_rt_cur(const struct typ *type, xfs_daddr_t blknum,
+                       int len, int ring_add, bbmap_t *bbmap);
 extern void     ring_add(void);
 extern void    set_iocur_type(const struct typ *type);
 extern void    xfs_dummy_verify(struct xfs_buf *bp);
index cc650c4255036b51d29320edd59af3dee49c0fdf..52a658ba4a540f2f75fbe26b522f011e284f625f 100755 (executable)
@@ -8,6 +8,7 @@ status=0
 require_offline=""
 require_online=""
 DB_OPTS=""
+DB_DEV_OPTS=""
 REPAIR_OPTS=""
 IO_OPTS=""
 REPAIR_DEV_OPTS=""
@@ -42,6 +43,7 @@ do
                require_offline=1
                ;;
        r)      REPAIR_DEV_OPTS=" -r '$OPTARG'"
+               DB_DEV_OPTS=" -R '$OPTARG'"
                require_offline=1
                ;;
        u)      DB_OPTS=$DB_OPTS" -r -c uuid"
@@ -89,7 +91,7 @@ case $# in
 
                if [ -n "$DB_OPTS" ]
                then
-                       eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1"
+                       eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_DEV_OPTS $DB_OPTS "$1"
                        status=$?
                fi
                if [ -n "$REPAIR_OPTS" ]
index b1712a92f7620a20df23f018d202017c888e7f25..f5e3064d923f56081aba0cc0b5f00a2e13242dfc 100644 (file)
@@ -14,6 +14,9 @@ xfs_db \- debug an XFS filesystem
 .B \-l
 .I logdev
 ] [
+.B \-R
+.I rtdev
+] [
 .B \-p
 .I progname
 ]
@@ -80,6 +83,16 @@ Set the program name to
 for prompts and some error messages, the default value is
 .BR xfs_db .
 .TP
+.B -R
+.I rtdev
+Specifies the device where the realtime data resides.
+This is only relevant for filesystems that have a realtime section.
+See the
+.BR mkfs.xfs "(8) " \-r
+option, and refer to
+.BR xfs (5)
+for a detailed description of the XFS realtime section.
+.TP
 .B -r
 Open
 .I device