]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add full xfs_dqblk verifier
authorEric Sandeen <sandeen@sandeen.net>
Thu, 28 Jun 2018 20:11:55 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:55 +0000 (15:11 -0500)
Source kernel commit: 7224fa482a6daa0558792e03a209e08d34690a26

Add an xfs_dqblk verifier so that it can check the uuid on V5 filesystems;
it calls the existing xfs_dquot_verify verifier to validate the
xfs_disk_dquot_t contained inside it.  This lets us move the uuid
verification out of the crc verifier, which makes little sense.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_dquot_buf.c
libxfs/xfs_quota_defs.h

index 414fbc7bb5568d1f5632186980084d74cf859693..725158f95683c3ce845f2ff04eeca46ef32b5048 100644 (file)
@@ -39,7 +39,12 @@ xfs_calc_dquots_per_chunk(
 
 /*
  * Do some primitive error checking on ondisk dquot data structures.
+ *
+ * The xfs_dqblk structure /contains/ the xfs_disk_dquot structure;
+ * we verify them separately because at some points we have only the
+ * smaller xfs_disk_dquot structure available.
  */
+
 xfs_failaddr_t
 xfs_dquot_verify(
        struct xfs_mount *mp,
@@ -98,6 +103,20 @@ xfs_dquot_verify(
        return NULL;
 }
 
+xfs_failaddr_t
+xfs_dqblk_verify(
+       struct xfs_mount        *mp,
+       struct xfs_dqblk        *dqb,
+       xfs_dqid_t              id,
+       uint                    type)   /* used only during quotacheck */
+{
+       if (xfs_sb_version_hascrc(&mp->m_sb) &&
+           !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
+               return __this_address;
+
+       return xfs_dquot_verify(mp, &dqb->dd_diskdq, id, type);
+}
+
 /*
  * Do some primitive error checking on ondisk dquot data structures.
  */
@@ -154,8 +173,6 @@ xfs_dquot_buf_verify_crc(
                if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
                                 XFS_DQUOT_CRC_OFF))
                        return false;
-               if (!uuid_equal(&d->dd_uuid, &mp->m_sb.sb_meta_uuid))
-                       return false;
        }
        return true;
 }
@@ -165,7 +182,7 @@ xfs_dquot_buf_verify(
        struct xfs_mount        *mp,
        struct xfs_buf          *bp)
 {
-       struct xfs_dqblk        *d = (struct xfs_dqblk *)bp->b_addr;
+       struct xfs_dqblk        *dqb = bp->b_addr;
        xfs_failaddr_t          fa;
        xfs_dqid_t              id = 0;
        int                     ndquots;
@@ -191,12 +208,12 @@ xfs_dquot_buf_verify(
        for (i = 0; i < ndquots; i++) {
                struct xfs_disk_dquot   *ddq;
 
-               ddq = &d[i].dd_diskdq;
+               ddq = &dqb[i].dd_diskdq;
 
                if (i == 0)
                        id = be32_to_cpu(ddq->d_id);
 
-               fa = xfs_dquot_verify(mp, ddq, id + i, 0);
+               fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
                if (fa)
                        return fa;
        }
index 9b5c3e4548185cb013af6d3f5cc3066cab47956c..7e9532ce228e43bf41baeed230900bdb1de8b508 100644 (file)
@@ -155,6 +155,8 @@ typedef uint16_t    xfs_qwarncnt_t;
 
 extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
                struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
+extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
+               struct xfs_dqblk *dqb, xfs_dqid_t id, uint type);
 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
 extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
                xfs_dqid_t id, uint type);