]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: fix clearing of quota CHKD flags
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 30 Jul 2020 00:15:27 +0000 (20:15 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 30 Jul 2020 00:15:27 +0000 (20:15 -0400)
XFS_ALL_QUOTA_CHKD, being a OR of [UGP]QUOTA_CHKD, is a bitset of the
possible *incore* quota checked flags.  This means that it cannot be
used in a comparison with the *ondisk* quota checked flags because V4
filesystems set OQUOTA_CHKD, not the [GU]QUOTA_CHKD flags (which are V5
flags).

If you have a V4 filesystem with user quotas disabled but either group
or project quotas enabled, xfs_repair will /not/ claim that the quota
info will be regenerated on the next mount like it does in any other
situation.  This is because the ondisk qflags field has OQUOTA_CHKD set
but repair fails to notice.

Worse, if you have a V4 filesystem with user and group quotas enabled
and mild corruption, repair will claim that the quota info will be
regenerated.  If you then mount the fs with only group quotas enabled,
quotacheck will not run to correct the data because repair failed to
clear OQUOTA_CHKD properly.

These are fairly benign and unlikely scenarios, but when we add
quotacheck capabilities to xfs_repair, it will complain about the
incorrect quota counts, which causes regressions in xfs/278.

Fixes: 342aef1ec0ec ("xfsprogs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/xfs_repair.c

index 3bfc83115ecd2ee9d7f33fa4c0d1e0a1c76ad868..1a51abd1d6cb185903de33b6c375a614600ad2d2 100644 (file)
@@ -1100,10 +1100,13 @@ _("Warning:  project quota information would be cleared.\n"
 
        dsb = sbp->b_addr;
 
-       if (be16_to_cpu(dsb->sb_qflags) & XFS_ALL_QUOTA_CHKD) {
+       if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD) {
                do_warn(_("Note - quota info will be regenerated on next "
                        "quota mount.\n"));
-               dsb->sb_qflags &= cpu_to_be16(~XFS_ALL_QUOTA_CHKD);
+               dsb->sb_qflags &= cpu_to_be16(~(XFS_UQUOTA_CHKD |
+                                               XFS_GQUOTA_CHKD |
+                                               XFS_PQUOTA_CHKD |
+                                               XFS_OQUOTA_CHKD));
        }
 
        if (copied_sunit) {