Blame SOURCES/xfsprogs-5.9.0-xfs-drop-the-type-parameter-from-xfs_dquot_verify.patch

5d5cbe
From bce109af5ea0b0d6547d8cd0500560f32532e6bd Mon Sep 17 00:00:00 2001
5d5cbe
From: "Darrick J. Wong" <darrick.wong@oracle.com>
5d5cbe
Date: Fri, 4 Sep 2020 16:05:20 -0400
5d5cbe
Subject: [PATCH] xfs: drop the type parameter from xfs_dquot_verify
5d5cbe
5d5cbe
Source kernel commit: f9751c4ad3d17fa93773c187732f10c8a49940e3
5d5cbe
5d5cbe
xfs_qm_reset_dqcounts (aka quotacheck) is the only xfs_dqblk_verify
5d5cbe
caller that actually knows the specific quota type that it's looking
5d5cbe
for.  Since everything else just pass in type==0 (including the buffer
5d5cbe
verifier), drop the parameter and open-code the check like
5d5cbe
xfs_dquot_from_disk already does.
5d5cbe
5d5cbe
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5d5cbe
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5d5cbe
Reviewed-by: Christoph Hellwig <hch@lst.de>
5d5cbe
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5d5cbe
---
5d5cbe
5d5cbe
diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c
5d5cbe
index 5e31938..a3e8ba1 100644
5d5cbe
--- a/libxfs/xfs_dquot_buf.c
5d5cbe
+++ b/libxfs/xfs_dquot_buf.c
5d5cbe
@@ -37,8 +37,7 @@ xfs_failaddr_t
5d5cbe
 xfs_dquot_verify(
5d5cbe
 	struct xfs_mount *mp,
5d5cbe
 	xfs_disk_dquot_t *ddq,
5d5cbe
-	xfs_dqid_t	 id,
5d5cbe
-	uint		 type)	  /* used only during quotacheck */
5d5cbe
+	xfs_dqid_t	 id)	  /* used only during quotacheck */
5d5cbe
 {
5d5cbe
 	/*
5d5cbe
 	 * We can encounter an uninitialized dquot buffer for 2 reasons:
5d5cbe
@@ -60,8 +59,6 @@ xfs_dquot_verify(
5d5cbe
 	if (ddq->d_version != XFS_DQUOT_VERSION)
5d5cbe
 		return __this_address;
5d5cbe
 
5d5cbe
-	if (type && ddq->d_flags != type)
5d5cbe
-		return __this_address;
5d5cbe
 	if (ddq->d_flags != XFS_DQ_USER &&
5d5cbe
 	    ddq->d_flags != XFS_DQ_PROJ &&
5d5cbe
 	    ddq->d_flags != XFS_DQ_GROUP)
5d5cbe
@@ -95,14 +92,13 @@ xfs_failaddr_t
5d5cbe
 xfs_dqblk_verify(
5d5cbe
 	struct xfs_mount	*mp,
5d5cbe
 	struct xfs_dqblk	*dqb,
5d5cbe
-	xfs_dqid_t	 	id,
5d5cbe
-	uint		 	type)	/* used only during quotacheck */
5d5cbe
+	xfs_dqid_t		id)	/* used only during quotacheck */
5d5cbe
 {
5d5cbe
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
5d5cbe
 	    !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
5d5cbe
 		return __this_address;
5d5cbe
 
5d5cbe
-	return xfs_dquot_verify(mp, &dqb->dd_diskdq, id, type);
5d5cbe
+	return xfs_dquot_verify(mp, &dqb->dd_diskdq, id);
5d5cbe
 }
5d5cbe
 
5d5cbe
 /*
5d5cbe
@@ -207,7 +203,7 @@ xfs_dquot_buf_verify(
5d5cbe
 		if (i == 0)
5d5cbe
 			id = be32_to_cpu(ddq->d_id);
5d5cbe
 
5d5cbe
-		fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
5d5cbe
+		fa = xfs_dqblk_verify(mp, &dqb[i], id + i);
5d5cbe
 		if (fa) {
5d5cbe
 			if (!readahead)
5d5cbe
 				xfs_buf_verifier_error(bp, -EFSCORRUPTED,
5d5cbe
diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h
5d5cbe
index d3f2977..afe1ea0 100644
5d5cbe
--- a/libxfs/xfs_quota_defs.h
5d5cbe
+++ b/libxfs/xfs_quota_defs.h
5d5cbe
@@ -140,9 +140,9 @@ typedef uint16_t	xfs_qwarncnt_t;
5d5cbe
 #define XFS_QMOPT_RESBLK_MASK	(XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
5d5cbe
 
5d5cbe
 extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
5d5cbe
-		struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
5d5cbe
+		struct xfs_disk_dquot *ddq, xfs_dqid_t id);
5d5cbe
 extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
5d5cbe
-		struct xfs_dqblk *dqb, xfs_dqid_t id, uint type);
5d5cbe
+		struct xfs_dqblk *dqb, xfs_dqid_t id);
5d5cbe
 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
5d5cbe
 extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
5d5cbe
 		xfs_dqid_t id, uint type);
5d5cbe
diff --git a/repair/dinode.c b/repair/dinode.c
5d5cbe
index 04c2dd5..77f78f1 100644
5d5cbe
--- a/repair/dinode.c
5d5cbe
+++ b/repair/dinode.c
5d5cbe
@@ -1233,8 +1233,10 @@ _("cannot read inode %" PRIu64 ", file block %" PRIu64 ", disk block %" PRIu64 "
5d5cbe
 					goto bad;
5d5cbe
 				}
5d5cbe
 			}
5d5cbe
-			if (libxfs_dquot_verify(mp, &dqb->dd_diskdq, dqid,
5d5cbe
-						quota_type) != NULL) {
5d5cbe
+			if (libxfs_dquot_verify(mp, &dqb->dd_diskdq, dqid)
5d5cbe
+						!= NULL ||
5d5cbe
+			    (dqb->dd_diskdq.d_flags & XFS_DQ_ALLTYPES)
5d5cbe
+						!= quota_type) {
5d5cbe
 				do_warn(_("%s: Corrupt quota for id %u. "),
5d5cbe
 						quota_string, dqid);
5d5cbe
 				bad_dqb = 1;