]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: don't call xfs_sb_quota_from_disk twice
authorEric Sandeen <sandeen@redhat.com>
Wed, 29 Jun 2016 01:13:09 +0000 (11:13 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 29 Jun 2016 01:13:09 +0000 (11:13 +1000)
kernel commit 5ef828c4
xfs: avoid false quotacheck after unclean shutdown

made xfs_sb_from_disk() also call xfs_sb_quota_from_disk
by default.

However, when this was merged to libxfs, existing separate
calls to libxfs_sb_quota_from_disk remained, and calling it
twice in a row on a V4 superblock leads to issues, because:

        if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
...
                sbp->sb_pquotino = sbp->sb_gquotino;
                sbp->sb_gquotino = NULLFSINO;

and after the second call, we have set both pquotino and gquotino
to NULLFSINO.

Fix this by making it safe to call twice, and also remove the extra
calls to libxfs_sb_quota_from_disk.

This is only spotted when running xfstests with "-m crc=0" because
the sb_from_disk change came about after V5 became default, and
the above behavior only exists on a V4 superblock.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/xfs_sb.c
repair/sb.c
repair/scan.c

index 45db6ae8e15a5afb4948d0de3fb31893057e39a7..44f3e3eab991b58fc8252cda7c53c61ac9b5b00d 100644 (file)
@@ -316,13 +316,16 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)
                                        XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
        sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
 
-       if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
+       if (sbp->sb_qflags & XFS_PQUOTA_ACCT &&
+           sbp->sb_gquotino != NULLFSINO)  {
                /*
                 * In older version of superblock, on-disk superblock only
                 * has sb_gquotino, and in-core superblock has both sb_gquotino
                 * and sb_pquotino. But, only one of them is supported at any
                 * point of time. So, if PQUOTA is set in disk superblock,
-                * copy over sb_gquotino to sb_pquotino.
+                * copy over sb_gquotino to sb_pquotino.  The NULLFSINO test
+                * above is to make sure we don't do this twice and wipe them
+                * both out!
                 */
                sbp->sb_pquotino = sbp->sb_gquotino;
                sbp->sb_gquotino = NULLFSINO;
index 8d4843cb745ea5b921e8b324a227b55e95b6ba1a..a8170badcdd7bf5654fe9a2c10156122f315a022 100644 (file)
@@ -155,7 +155,6 @@ __find_secondary_sb(
                for (i = 0; !done && i < bsize; i += BBSIZE)  {
                        c_bufsb = (char *)sb + i;
                        libxfs_sb_from_disk(&bufsb, (xfs_dsb_t *)c_bufsb);
-                       libxfs_sb_quota_from_disk(&bufsb);
 
                        if (verify_sb(c_bufsb, &bufsb, 0) != XR_OK)
                                continue;
@@ -568,7 +567,6 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)
                do_error("%s\n", strerror(error));
        }
        libxfs_sb_from_disk(sbp, buf);
-       libxfs_sb_quota_from_disk(sbp);
 
        rval = verify_sb((char *)buf, sbp, agno == 0);
        free(buf);
index 964ff0604c43a327d936849451db60f23c66395a..366ce16722e017d1fff159721ad665c8e3a932a6 100644 (file)
@@ -1622,7 +1622,6 @@ scan_ag(
                goto out_free_sb;
        }
        libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbbuf));
-       libxfs_sb_quota_from_disk(sb);
 
        agfbuf = libxfs_readbuf(mp->m_dev,
                        XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),