xfs: avoid false quotacheck after unclean shutdown
authorEric Sandeen <sandeen@sandeen.net>
Mon, 4 Aug 2014 01:35:44 +0000 (11:35 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 4 Aug 2014 01:35:44 +0000 (11:35 +1000)
The commit

83e782e xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD

added a new function xfs_sb_quota_from_disk() which swaps
on-disk XFS_OQUOTA_* flags for in-core XFS_GQUOTA_* and XFS_PQUOTA_*
flags after the superblock is read.

However, if log recovery is required, the superblock is read again,
and the modified in-core flags are re-read from disk, so we have
XFS_OQUOTA_* flags in memory again.  This causes the
XFS_QM_NEED_QUOTACHECK() test to be true, because the XFS_OQUOTA_CHKD
is still set, and not XFS_GQUOTA_CHKD or XFS_PQUOTA_CHKD.

Change xfs_sb_from_disk to call xfs_sb_quota_from disk and always
convert the disk flags to in-memory flags.

Add a lower-level function which can be called with "false" to
not convert the flags, so that the sb verifier can verify
exactly what was on disk, per Brian Foster's suggestion.

Reported-by: Cyril B. <cbay@excellency.fr>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
fs/xfs/libxfs/xfs_sb.c
fs/xfs/xfs_mount.c

index f5ca0286a0afc3ebaf7451d7bd0f135af18ef4c5..8db9e923a53e4a92d4a3f6798e971b2f6613ee3a 100644 (file)
@@ -386,10 +386,11 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)
        }
 }
 
-void
-xfs_sb_from_disk(
+static void
+__xfs_sb_from_disk(
        struct xfs_sb   *to,
-       xfs_dsb_t       *from)
+       xfs_dsb_t       *from,
+       bool            convert_xquota)
 {
        to->sb_magicnum = be32_to_cpu(from->sb_magicnum);
        to->sb_blocksize = be32_to_cpu(from->sb_blocksize);
@@ -445,6 +446,17 @@ xfs_sb_from_disk(
        to->sb_pad = 0;
        to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
        to->sb_lsn = be64_to_cpu(from->sb_lsn);
+       /* Convert on-disk flags to in-memory flags? */
+       if (convert_xquota)
+               xfs_sb_quota_from_disk(to);
+}
+
+void
+xfs_sb_from_disk(
+       struct xfs_sb   *to,
+       xfs_dsb_t       *from)
+{
+       __xfs_sb_from_disk(to, from, true);
 }
 
 static inline void
@@ -560,7 +572,11 @@ xfs_sb_verify(
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_sb   sb;
 
-       xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp));
+       /*
+        * Use call variant which doesn't convert quota flags from disk 
+        * format, because xfs_mount_validate_sb checks the on-disk flags.
+        */
+       __xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp), false);
 
        /*
         * Only check the in progress field for the primary superblock as
index d5c44a6bdb5b50c4393b6648acc7533beaf25b36..5612aa8b46ad6f2877355935950e313440147154 100644 (file)
@@ -324,7 +324,6 @@ reread:
         * Initialize the mount structure from the superblock.
         */
        xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
-       xfs_sb_quota_from_disk(sbp);
 
        /*
         * If we haven't validated the superblock, do so now before we try