]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: support version 5 superblock in versionnum command
authorDave Chinner <dchinner@redhat.com>
Fri, 7 Jun 2013 00:25:52 +0000 (10:25 +1000)
committerBen Myers <bpm@sgi.com>
Tue, 6 Aug 2013 20:23:05 +0000 (15:23 -0500)
While there, add visibility of the new superblock fields in the "sb"
command.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
db/sb.c

diff --git a/db/sb.c b/db/sb.c
index 54ca7dd8b07c357084f6375c8befc44b7488a33d..d178f58ff33ff24395eb5351e7b9b1eb45464d5e 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -108,7 +108,19 @@ const field_t      sb_flds[] = {
        { "logsectsize", FLDT_UINT16D, OI(OFF(logsectsize)), C1, 0, TYP_NONE },
        { "logsunit", FLDT_UINT32D, OI(OFF(logsunit)), C1, 0, TYP_NONE },
        { "features2", FLDT_UINT32X, OI(OFF(features2)), C1, 0, TYP_NONE },
-       { "bad_features2", FLDT_UINT32X, OI(OFF(bad_features2)), C1, 0, TYP_NONE },
+       { "bad_features2", FLDT_UINT32X, OI(OFF(bad_features2)),
+               C1, 0, TYP_NONE },
+       { "features_compat", FLDT_UINT32X, OI(OFF(features_compat)),
+               C1, 0, TYP_NONE },
+       { "features_ro_compat", FLDT_UINT32X, OI(OFF(features_ro_compat)),
+               C1, 0, TYP_NONE },
+       { "features_incompat", FLDT_UINT32X, OI(OFF(features_incompat)),
+               C1, 0, TYP_NONE },
+       { "features_log_incompat", FLDT_UINT32X, OI(OFF(features_log_incompat)),
+               C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
+       { "pquotino", FLDT_INO, OI(OFF(pquotino)), C1, 0, TYP_INODE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
        { NULL }
 };
 
@@ -597,6 +609,8 @@ version_string(
                strcpy(s, "V3");
        else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
                strcpy(s, "V4");
+       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
+               strcpy(s, "V5");
 
        if (xfs_sb_version_hasattr(sbp))
                strcat(s, ",ATTR");
@@ -628,9 +642,17 @@ version_string(
                strcat(s, ",LAZYSBCOUNT");
        if (xfs_sb_version_hasprojid32bit(sbp))
                strcat(s, ",PROJID32BIT");
+       if (xfs_sb_version_hascrc(sbp))
+               strcat(s, ",CRC");
        return s;
 }
 
+/*
+ * XXX: this only supports reading and writing to version 4 superblock fields.
+ * V5 superblocks always define certain V4 feature bits - they are blocked from
+ * being changed if a V5 sb is detected, but otherwise v5 superblock features
+ * are not handled here.
+ */
 static int
 version_f(
        int             argc,
@@ -662,12 +684,16 @@ version_f(
                                break;
                        case XFS_SB_VERSION_4:
                                if (xfs_sb_version_hasextflgbit(&mp->m_sb))
-                                       dbprintf(_("unwritten extents flag"
-                                                " is already enabled\n"));
+                                       dbprintf(
+               _("unwritten extents flag is already enabled\n"));
                                else
                                        version = mp->m_sb.sb_versionnum |
                                                  XFS_SB_VERSION_EXTFLGBIT;
                                break;
+                       case XFS_SB_VERSION_5:
+                               dbprintf(
+               _("unwritten extents always enabled for v5 superblocks.\n"));
+                               break;
                        }
                } else if (!strcasecmp(argv[1], "log2")) {
                        switch (XFS_SB_VERSION_NUM(&mp->m_sb)) {
@@ -682,14 +708,24 @@ version_f(
                                break;
                        case XFS_SB_VERSION_4:
                                if (xfs_sb_version_haslogv2(&mp->m_sb))
-                                       dbprintf(_("version 2 log format"
-                                                " is already in use\n"));
+                                       dbprintf(
+               _("version 2 log format is already in use\n"));
                                else
                                        version = mp->m_sb.sb_versionnum |
                                                  XFS_SB_VERSION_LOGV2BIT;
                                break;
+                       case XFS_SB_VERSION_5:
+                               dbprintf(
+               _("Version 2 logs always enabled for v5 superblocks.\n"));
+                               break;
                        }
+               } else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) {
+                       dbprintf(
+               _("%s: Cannot change %s on v5 superblocks.\n"),
+                               progname, argv[1]);
+                       return 0;
                } else if (!strcasecmp(argv[1], "attr1")) {
+
                        if (xfs_sb_version_hasattr2(&mp->m_sb)) {
                                if (!(mp->m_sb.sb_features2 &=
                                                ~XFS_SB_VERSION2_ATTR2BIT))