]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: update secondary superblocks after changing features
authorDarrick J. Wong <djwong@kernel.org>
Fri, 25 Feb 2022 22:42:16 +0000 (17:42 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 25 Feb 2022 22:42:16 +0000 (17:42 -0500)
When we add features to an existing filesystem, make sure we update the
secondary superblocks to reflect the new geometry so that if we lose the
primary super in the future, repair will recover correctly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
repair/globals.c
repair/globals.h
repair/phase2.c
repair/xfs_repair.c

index a086fca23586192c2a91d6bb80f0aca1d57ddc4d..0862d4b09f7d375b638442e9041c3522ed6aa9af 100644 (file)
 #define xfs_trans_roll                 libxfs_trans_roll
 #define xfs_trim_extent                        libxfs_trim_extent
 
+#define xfs_update_secondary_sbs       libxfs_update_secondary_sbs
+
 #define xfs_validate_stripe_geometry   libxfs_validate_stripe_geometry
 #define xfs_verify_agbno               libxfs_verify_agbno
 #define xfs_verify_agino               libxfs_verify_agino
index 506a4e728c707f45c27da361d0efd172fbc2a04f..f8d4f1e4016d187d659b3c93e125f0ea8cf3bcc9 100644 (file)
@@ -48,6 +48,7 @@ char  *rt_name;               /* Name of realtime device */
 int    rt_spec;                /* Realtime dev specified as option */
 int    convert_lazy_count;     /* Convert lazy-count mode on/off */
 int    lazy_count;             /* What to set if to if converting */
+bool   features_changed;       /* did we change superblock feature bits? */
 bool   add_inobtcount;         /* add inode btree counts to AGI */
 bool   add_bigtime;            /* add support for timestamps up to 2486 */
 
index 929b82be387a3f99c50da18c5d8a77b51d99d684..0f98bd2b58ce99d8b6bb3808eacd817a2d2bf665 100644 (file)
@@ -89,6 +89,7 @@ extern char   *rt_name;               /* Name of realtime device */
 extern int     rt_spec;                /* Realtime dev specified as option */
 extern int     convert_lazy_count;     /* Convert lazy-count mode on/off */
 extern int     lazy_count;             /* What to set if to if converting */
+extern bool    features_changed;       /* did we change superblock feature bits? */
 extern bool    add_inobtcount;         /* add inode btree counts to AGI */
 extern bool    add_bigtime;            /* add support for timestamps up to 2486 */
 
index cfba649aeb5bc508c82590e17bfba28ad30be5f1..138327016520787dce5ee737ba1515faa0d00829 100644 (file)
@@ -218,6 +218,7 @@ upgrade_filesystem(
                                error);
 
        libxfs_buf_relse(bp);
+       features_changed = true;
 }
 
 /*
index 4769c130bef7f6a9344a4b6f3765993608fc3e19..de8617bae97c112eb342127c93119222f8dd01f5 100644 (file)
@@ -1297,6 +1297,21 @@ _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\
        libxfs_buf_mark_dirty(sbp);
        libxfs_buf_relse(sbp);
 
+       /*
+        * If we upgraded V5 filesystem features, we need to update the
+        * secondary superblocks to include the new feature bits.  Don't set
+        * NEEDSREPAIR on the secondaries.
+        */
+       if (features_changed) {
+               mp->m_sb.sb_features_incompat &=
+                               ~XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+               error = -libxfs_update_secondary_sbs(mp);
+               if (error)
+                       do_error(_("upgrading features of secondary supers"));
+               mp->m_sb.sb_features_incompat |=
+                               XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+       }
+
        /*
         * Done. Flush all cached buffers and inodes first to ensure all
         * verifiers are run (where we discover the max metadata LSN), reformat