]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_repair: try not to trash qflags on metadir filesystems
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Aug 2024 16:43:35 +0000 (09:43 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 9 Oct 2024 23:29:16 +0000 (16:29 -0700)
Try to preserve the accounting and enforcement quota flags when
repairing filesystems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
repair/agheader.c
repair/phase4.c
repair/sb.c

index 5735bb720d94ec773816e8ef1824ae7e3892b2f7..a9780f8f9aeee0f3ba99c788f148196611fc9e05 100644 (file)
@@ -642,7 +642,8 @@ verify_set_agheader(xfs_mount_t *mp, struct xfs_buf *sbuf, xfs_sb_t *sb,
                        sb->sb_fdblocks = 0;
                        sb->sb_frextents = 0;
 
-                       sb->sb_qflags = 0;
+                       if (!xfs_has_metadir(mp))
+                               sb->sb_qflags = 0;
                }
 
                rval |= XR_AG_SB;
index a4183c557a1891ac34b671174743b19033e424e8..728d9ed84cdc7ada3fb47bcf0ac5a5a2a5579ba7 100644 (file)
@@ -71,6 +71,26 @@ quotino_check(
 static void
 quota_sb_check(xfs_mount_t *mp)
 {
+       if (xfs_has_metadir(mp)) {
+               /*
+                * Metadir filesystems try to preserve the quota accounting
+                * and enforcement flags so that users don't have to remember
+                * to supply quota mount options.  Phase 1 discovered the
+                * QUOTABIT flag (fs_quotas) and phase 2 discovered the quota
+                * inodes from the metadir for us.
+                *
+                * If QUOTABIT wasn't set but we found quota inodes, signal
+                * phase 5 to add the feature bit for us.  We do not ever
+                * downgrade the filesystem.
+                */
+               if (!fs_quotas &&
+                   (has_quota_inode(XFS_DQTYPE_USER) ||
+                    has_quota_inode(XFS_DQTYPE_GROUP) ||
+                    has_quota_inode(XFS_DQTYPE_PROJ)))
+                       fs_quotas = 1;
+               return;
+       }
+
        /*
         * if the sb says we have quotas and we lost both,
         * signal a superblock downgrade.  that will cause
index 05fd886f37ba6a9cf3fe5b33aa5b48353c0eca02..384916a317f2d461b7b344755801956d8ae32dfa 100644 (file)
@@ -233,6 +233,9 @@ find_secondary_sb(xfs_sb_t *rsb)
         if (!retval)
                 retval = __find_secondary_sb(rsb, XFS_AG_MIN_BYTES, BSIZE);
 
+       if (retval && xfs_sb_version_hasmetadir(rsb))
+               do_warn(_("quota accounting and enforcement flags lost\n"));
+
        return retval;
 }