]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_{copy,db,logprint,repair}: pass xfs_mount pointers instead of xfs_sb pointers
authorDarrick J. Wong <djwong@kernel.org>
Mon, 31 Jan 2022 20:25:41 +0000 (15:25 -0500)
committerEric Sandeen <sandeen@redhat.com>
Mon, 31 Jan 2022 20:25:41 +0000 (15:25 -0500)
Where possible, convert these four programs to pass a pointer to a
struct xfs_mount instead of the struct xfs_sb inside the mount.  This
will make it easier to convert some of the code to the new
xfs_has_FEATURE predicates later on.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
copy/xfs_copy.c
db/sb.c
libxfs/init.c
logprint/logprint.c
repair/versions.c
repair/versions.h
repair/xfs_repair.c

index f5eff96976d77c735aee8402b84bac7bd603e962..94faa6db716ccc62bf7a9dfa4f834ed950429385 100644 (file)
@@ -515,9 +515,9 @@ write_wbuf(void)
 
 static void
 sb_update_uuid(
-       xfs_sb_t        *sb,            /* Original fs superblock */
-       ag_header_t     *ag_hdr,        /* AG hdr to update for this copy */
-       thread_args     *tcarg)         /* Args for this thread, with UUID */
+       struct xfs_mount        *mp,
+       ag_header_t             *ag_hdr, /* AG hdr to update for this copy */
+       thread_args             *tcarg)  /* Args for this thread, with UUID */
 {
        /*
         * If this filesystem has CRCs, the original UUID is stamped into
@@ -526,24 +526,25 @@ sb_update_uuid(
         * we must copy the original sb_uuid to the sb_meta_uuid slot and set
         * the incompat flag for the feature on this copy.
         */
-       if (xfs_sb_version_hascrc(sb) && !xfs_sb_version_hasmetauuid(sb) &&
-           !uuid_equal(&tcarg->uuid, &sb->sb_uuid)) {
+       if (xfs_sb_version_hascrc(&mp->m_sb) &&
+           !xfs_sb_version_hasmetauuid(&mp->m_sb) &&
+           !uuid_equal(&tcarg->uuid, &mp->m_sb.sb_uuid)) {
                uint32_t feat;
 
                feat = be32_to_cpu(ag_hdr->xfs_sb->sb_features_incompat);
                feat |= XFS_SB_FEAT_INCOMPAT_META_UUID;
                ag_hdr->xfs_sb->sb_features_incompat = cpu_to_be32(feat);
                platform_uuid_copy(&ag_hdr->xfs_sb->sb_meta_uuid,
-                                  &sb->sb_uuid);
+                                  &mp->m_sb.sb_uuid);
        }
 
        /* Copy the (possibly new) fs-identifier UUID into sb_uuid */
        platform_uuid_copy(&ag_hdr->xfs_sb->sb_uuid, &tcarg->uuid);
 
        /* We may have changed the UUID, so update the superblock CRC */
-       if (xfs_sb_version_hascrc(sb))
-               xfs_update_cksum((char *)ag_hdr->xfs_sb, sb->sb_sectsize,
-                                                        XFS_SB_CRC_OFF);
+       if (xfs_sb_version_hascrc(&mp->m_sb))
+               xfs_update_cksum((char *)ag_hdr->xfs_sb, mp->m_sb.sb_sectsize,
+                               XFS_SB_CRC_OFF);
 }
 
 int
@@ -1224,7 +1225,7 @@ main(int argc, char **argv)
                        /* do each thread in turn, each has its own UUID */
 
                        for (j = 0, tcarg = targ; j < num_targets; j++)  {
-                               sb_update_uuid(sb, &ag_hdr, tcarg);
+                               sb_update_uuid(mp, &ag_hdr, tcarg);
                                do_write(tcarg, NULL);
                                tcarg++;
                        }
diff --git a/db/sb.c b/db/sb.c
index cec7dce94bd4147d91625924d5a0e4636deac68e..b4c14276100e799c99eac0b8082b4d3c33c4cd11 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -633,76 +633,76 @@ do_version(xfs_agnumber_t agno, uint16_t version, uint32_t features)
 
 static char *
 version_string(
-       xfs_sb_t        *sbp)
+       struct xfs_mount        *mp)
 {
-       static char     s[1024];
+       static char             s[1024];
 
-       if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_1)
+       if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_1)
                strcpy(s, "V1");
-       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_2)
+       else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_2)
                strcpy(s, "V2");
-       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_3)
+       else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_3)
                strcpy(s, "V3");
-       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
+       else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_4)
                strcpy(s, "V4");
-       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
+       else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
                strcpy(s, "V5");
 
        /*
         * We assume the state of these features now, so macros don't exist for
         * them any more.
         */
-       if (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)
+       if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)
                strcat(s, ",NLINK");
-       if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
+       if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
                strcat(s, ",SHARED");
-       if (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)
+       if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT)
                strcat(s, ",DIRV2");
 
-       if (xfs_sb_version_hasattr(sbp))
+       if (xfs_sb_version_hasattr(&mp->m_sb))
                strcat(s, ",ATTR");
-       if (xfs_sb_version_hasquota(sbp))
+       if (xfs_sb_version_hasquota(&mp->m_sb))
                strcat(s, ",QUOTA");
-       if (xfs_sb_version_hasalign(sbp))
+       if (xfs_sb_version_hasalign(&mp->m_sb))
                strcat(s, ",ALIGN");
-       if (xfs_sb_version_hasdalign(sbp))
+       if (xfs_sb_version_hasdalign(&mp->m_sb))
                strcat(s, ",DALIGN");
-       if (xfs_sb_version_haslogv2(sbp))
+       if (xfs_sb_version_haslogv2(&mp->m_sb))
                strcat(s, ",LOGV2");
        /* This feature is required now as well */
-       if (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)
+       if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)
                strcat(s, ",EXTFLG");
-       if (xfs_sb_version_hassector(sbp))
+       if (xfs_sb_version_hassector(&mp->m_sb))
                strcat(s, ",SECTOR");
-       if (xfs_sb_version_hasasciici(sbp))
+       if (xfs_sb_version_hasasciici(&mp->m_sb))
                strcat(s, ",ASCII_CI");
-       if (xfs_sb_version_hasmorebits(sbp))
+       if (xfs_sb_version_hasmorebits(&mp->m_sb))
                strcat(s, ",MOREBITS");
-       if (xfs_sb_version_hasattr2(sbp))
+       if (xfs_sb_version_hasattr2(&mp->m_sb))
                strcat(s, ",ATTR2");
-       if (xfs_sb_version_haslazysbcount(sbp))
+       if (xfs_sb_version_haslazysbcount(&mp->m_sb))
                strcat(s, ",LAZYSBCOUNT");
-       if (xfs_sb_version_hasprojid32bit(sbp))
+       if (xfs_sb_version_hasprojid32bit(&mp->m_sb))
                strcat(s, ",PROJID32BIT");
-       if (xfs_sb_version_hascrc(sbp))
+       if (xfs_sb_version_hascrc(&mp->m_sb))
                strcat(s, ",CRC");
-       if (xfs_sb_version_hasftype(sbp))
+       if (xfs_sb_version_hasftype(&mp->m_sb))
                strcat(s, ",FTYPE");
-       if (xfs_sb_version_hasfinobt(sbp))
+       if (xfs_sb_version_hasfinobt(&mp->m_sb))
                strcat(s, ",FINOBT");
-       if (xfs_sb_version_hassparseinodes(sbp))
+       if (xfs_sb_version_hassparseinodes(&mp->m_sb))
                strcat(s, ",SPARSE_INODES");
-       if (xfs_sb_version_hasmetauuid(sbp))
+       if (xfs_sb_version_hasmetauuid(&mp->m_sb))
                strcat(s, ",META_UUID");
-       if (xfs_sb_version_hasrmapbt(sbp))
+       if (xfs_sb_version_hasrmapbt(&mp->m_sb))
                strcat(s, ",RMAPBT");
-       if (xfs_sb_version_hasreflink(sbp))
+       if (xfs_sb_version_hasreflink(&mp->m_sb))
                strcat(s, ",REFLINK");
-       if (xfs_sb_version_hasinobtcounts(sbp))
+       if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
                strcat(s, ",INOBTCNT");
-       if (xfs_sb_version_hasbigtime(sbp))
+       if (xfs_sb_version_hasbigtime(&mp->m_sb))
                strcat(s, ",BIGTIME");
-       if (xfs_sb_version_needsrepair(sbp))
+       if (xfs_sb_version_needsrepair(&mp->m_sb))
                strcat(s, ",NEEDSREPAIR");
        return s;
 }
@@ -834,7 +834,7 @@ version_f(
        }
 
        dbprintf(_("versionnum [0x%x+0x%x] = %s\n"), mp->m_sb.sb_versionnum,
-                       mp->m_sb.sb_features2, version_string(&mp->m_sb));
+                       mp->m_sb.sb_features2, version_string(mp));
 
        if (argc == 3) {        /* now reset... */
                mp->m_sb.sb_versionnum = version;
index 75ff4d49f5adf0486c09d41dbddc8e36c7443d59..9d8f20280dafbde37c658da0cf0b94f1dc71c428 100644 (file)
@@ -429,22 +429,20 @@ rtmount_init(
        int             flags)
 {
        struct xfs_buf  *bp;    /* buffer for last block of subvolume */
-       struct xfs_sb   *sbp;   /* filesystem superblock copy in mount */
        xfs_daddr_t     d;      /* address of last block of subvolume */
        int             error;
 
-       sbp = &mp->m_sb;
-       if (sbp->sb_rblocks == 0)
+       if (mp->m_sb.sb_rblocks == 0)
                return 0;
 
-       if (xfs_sb_version_hasreflink(sbp)) {
+       if (xfs_sb_version_hasreflink(&mp->m_sb)) {
                fprintf(stderr,
        _("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
                                progname);
                return -1;
        }
 
-       if (xfs_sb_version_hasrmapbt(sbp)) {
+       if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
                fprintf(stderr,
        _("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
                                progname);
@@ -456,11 +454,11 @@ rtmount_init(
                        progname);
                return -1;
        }
-       mp->m_rsumlevels = sbp->sb_rextslog + 1;
+       mp->m_rsumlevels = mp->m_sb.sb_rextslog + 1;
        mp->m_rsumsize =
                (uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels *
-               sbp->sb_rbmblocks;
-       mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize);
+               mp->m_sb.sb_rbmblocks;
+       mp->m_rsumsize = roundup(mp->m_rsumsize, mp->m_sb.sb_blocksize);
        mp->m_rbmip = mp->m_rsumip = NULL;
 
        /*
index e882c5d44397bfa5071f27be90ad77b8fae7f792..18adf1022edaa3da098149c15dbb15b9619a9ecf 100644 (file)
@@ -85,7 +85,7 @@ logstat(xfs_mount_t *mp)
                x.logBBsize = XFS_FSB_TO_BB(mp, sb->sb_logblocks);
                x.logBBstart = XFS_FSB_TO_DADDR(mp, sb->sb_logstart);
                x.lbsize = BBSIZE;
-               if (xfs_sb_version_hassector(sb))
+               if (xfs_sb_version_hassector(&mp->m_sb))
                        x.lbsize <<= (sb->sb_logsectlog - BBSHIFT);
 
                if (!x.logname && sb->sb_logstart == 0) {
index 4c44b4e79c9514d0a00760a0ce43df24c73fcfee..7f268f6117cd23e67eed07c1c601c94749e8b23d 100644 (file)
@@ -30,21 +30,18 @@ int fs_has_extflgbit;
 xfs_extlen_t   fs_ino_alignment;
 
 void
-update_sb_version(xfs_mount_t *mp)
+update_sb_version(
+       struct xfs_mount        *mp)
 {
-       xfs_sb_t        *sb;
+       if (fs_attributes && !xfs_sb_version_hasattr(&mp->m_sb))
+               xfs_sb_version_addattr(&mp->m_sb);
 
-       sb = &mp->m_sb;
-
-       if (fs_attributes && !xfs_sb_version_hasattr(sb))
-               xfs_sb_version_addattr(sb);
-
-       if (fs_attributes2 && !xfs_sb_version_hasattr2(sb))
-               xfs_sb_version_addattr2(sb);
+       if (fs_attributes2 && !xfs_sb_version_hasattr2(&mp->m_sb))
+               xfs_sb_version_addattr2(&mp->m_sb);
 
        /* V2 inode conversion is now always going to happen */
-       if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT))
-               sb->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
+       if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT))
+               mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
 
        /*
         * fix up the superblock version number and feature bits,
@@ -52,22 +49,22 @@ update_sb_version(xfs_mount_t *mp)
         * have quotas.
         */
        if (fs_quotas)  {
-               if (!xfs_sb_version_hasquota(sb))
-                       xfs_sb_version_addquota(sb);
+               if (!xfs_sb_version_hasquota(&mp->m_sb))
+                       xfs_sb_version_addquota(&mp->m_sb);
 
                /*
                 * protect against stray bits in the quota flag field
                 */
-               if (sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL) {
+               if (mp->m_sb.sb_qflags & ~XFS_MOUNT_QUOTA_ALL) {
                        /*
                         * update the incore superblock, if we're in
                         * no_modify mode, it'll never get flushed out
                         * so this is ok.
                         */
                        do_warn(_("bogus quota flags 0x%x set in superblock"),
-                               sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL);
+                               mp->m_sb.sb_qflags & ~XFS_MOUNT_QUOTA_ALL);
 
-                       sb->sb_qflags &= XFS_MOUNT_QUOTA_ALL;
+                       mp->m_sb.sb_qflags &= XFS_MOUNT_QUOTA_ALL;
 
                        if (!no_modify)
                                do_warn(_(", bogus flags will be cleared\n"));
@@ -75,16 +72,16 @@ update_sb_version(xfs_mount_t *mp)
                                do_warn(_(", bogus flags would be cleared\n"));
                }
        } else  {
-               sb->sb_qflags = 0;
+               mp->m_sb.sb_qflags = 0;
 
-               if (xfs_sb_version_hasquota(sb))  {
+               if (xfs_sb_version_hasquota(&mp->m_sb))  {
                        lost_quotas = 1;
-                       sb->sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT;
+                       mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT;
                }
        }
 
-       if (!fs_aligned_inodes && xfs_sb_version_hasalign(sb))
-               sb->sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT;
+       if (!fs_aligned_inodes && xfs_sb_version_hasalign(&mp->m_sb))
+               mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT;
 }
 
 /*
@@ -93,7 +90,8 @@ update_sb_version(xfs_mount_t *mp)
  * global variables.
  */
 int
-parse_sb_version(xfs_sb_t *sb)
+parse_sb_version(
+       struct xfs_mount        *mp)
 {
        fs_attributes = 0;
        fs_attributes2 = 0;
@@ -107,7 +105,7 @@ parse_sb_version(xfs_sb_t *sb)
        have_gquotino = 0;
        have_pquotino = 0;
 
-       if (sb->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) {
+       if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_SHAREDBIT) {
                do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
                return 1;
        }
@@ -116,38 +114,38 @@ parse_sb_version(xfs_sb_t *sb)
         * ok, check to make sure that the sb isn't newer
         * than we are
         */
-       if (!xfs_sb_good_version(sb))  {
+       if (!xfs_sb_good_version(&mp->m_sb))  {
                do_warn(_("WARNING:  unknown superblock version %d\n"),
-                       XFS_SB_VERSION_NUM(sb));
+                       XFS_SB_VERSION_NUM(&mp->m_sb));
                do_warn(
 _("This filesystem contains features not understood by this program.\n"));
                return(1);
        }
 
-       if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_4)
+       if (XFS_SB_VERSION_NUM(&mp->m_sb) >= XFS_SB_VERSION_4)
                fs_sb_feature_bits = 1;
 
        /* Look for V5 feature flags we don't know about */
-       if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_5 &&
-           (xfs_sb_has_compat_feature(sb, XFS_SB_FEAT_COMPAT_UNKNOWN) ||
-            xfs_sb_has_ro_compat_feature(sb, XFS_SB_FEAT_RO_COMPAT_UNKNOWN) ||
-            xfs_sb_has_incompat_feature(sb, XFS_SB_FEAT_INCOMPAT_UNKNOWN))) {
+       if (XFS_SB_VERSION_NUM(&mp->m_sb) >= XFS_SB_VERSION_5 &&
+           (xfs_sb_has_compat_feature(&mp->m_sb, XFS_SB_FEAT_COMPAT_UNKNOWN) ||
+            xfs_sb_has_ro_compat_feature(&mp->m_sb, XFS_SB_FEAT_RO_COMPAT_UNKNOWN) ||
+            xfs_sb_has_incompat_feature(&mp->m_sb, XFS_SB_FEAT_INCOMPAT_UNKNOWN))) {
                do_warn(
 _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n"
   "Using a more recent xfs_repair is recommended.\n"),
-                       sb->sb_features_compat & XFS_SB_FEAT_COMPAT_UNKNOWN,
-                       sb->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN,
-                       sb->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_UNKNOWN);
+                       mp->m_sb.sb_features_compat & XFS_SB_FEAT_COMPAT_UNKNOWN,
+                       mp->m_sb.sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN,
+                       mp->m_sb.sb_features_incompat & XFS_SB_FEAT_INCOMPAT_UNKNOWN);
                return 1;
        }
 
-       if (xfs_sb_version_hasattr(sb))
+       if (xfs_sb_version_hasattr(&mp->m_sb))
                fs_attributes = 1;
 
-       if (xfs_sb_version_hasattr2(sb))
+       if (xfs_sb_version_hasattr2(&mp->m_sb))
                fs_attributes2 = 1;
 
-       if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) {
+       if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) {
                if (!no_modify) {
                        do_warn(
 _("WARNING: you have a V1 inode filesystem. It will be converted to a\n"
@@ -161,28 +159,28 @@ _("WARNING: you have a V1 inode filesystem. It would be converted to a\n"
                }
        }
 
-       if (xfs_sb_version_hasquota(sb))  {
+       if (xfs_sb_version_hasquota(&mp->m_sb))  {
                fs_quotas = 1;
 
-               if (sb->sb_uquotino != 0 && sb->sb_uquotino != NULLFSINO)
+               if (mp->m_sb.sb_uquotino != 0 && mp->m_sb.sb_uquotino != NULLFSINO)
                        have_uquotino = 1;
 
-               if (sb->sb_gquotino != 0 && sb->sb_gquotino != NULLFSINO)
+               if (mp->m_sb.sb_gquotino != 0 && mp->m_sb.sb_gquotino != NULLFSINO)
                        have_gquotino = 1;
 
-               if (sb->sb_pquotino != 0 && sb->sb_pquotino != NULLFSINO)
+               if (mp->m_sb.sb_pquotino != 0 && mp->m_sb.sb_pquotino != NULLFSINO)
                        have_pquotino = 1;
        }
 
-       if (xfs_sb_version_hasalign(sb))  {
+       if (xfs_sb_version_hasalign(&mp->m_sb))  {
                fs_aligned_inodes = 1;
-               fs_ino_alignment = sb->sb_inoalignmt;
+               fs_ino_alignment = mp->m_sb.sb_inoalignmt;
        }
 
        /*
         * calculate maximum file offset for this geometry
         */
-       fs_max_file_offset = 0x7fffffffffffffffLL >> sb->sb_blocklog;
+       fs_max_file_offset = 0x7fffffffffffffffLL >> mp->m_sb.sb_blocklog;
 
        return(0);
 }
index e1e2521ccb525ebabfcfea379609b641b73454d5..c40a86816d16de6ccb45fd4635898d7dbf31381b 100644 (file)
@@ -34,11 +34,11 @@ extern xfs_extlen_t fs_ino_alignment;
  * modify superblock to reflect current state of global fs
  * feature vars above
  */
-void                   update_sb_version(xfs_mount_t *mp);
+void update_sb_version(struct xfs_mount *mp);
 
 /*
  * parse current sb to set above feature vars
  */
-int                    parse_sb_version(xfs_sb_t *sb);
+int parse_sb_version(struct xfs_mount *mp);
 
 #endif /* _XR_VERSIONS_H */
index 38406eea408065c87344ee0dce9b34369100b5d3..7a142ceb2c6aba4ee09fe70995ff6071936fb2bc 100644 (file)
@@ -1155,7 +1155,7 @@ main(int argc, char **argv)
        /* initialize random globals now that we know the fs geometry */
        inodes_per_block = mp->m_sb.sb_inopblock;
 
-       if (parse_sb_version(&mp->m_sb))  {
+       if (parse_sb_version(mp))  {
                do_warn(
        _("Found unsupported filesystem features.  Exiting now.\n"));
                return(1);