Blame SOURCES/xfsprogs-5.8.0-xfs_quota-state-command-should-report-ugp-grace-time.patch

4bf432
From d8a9454608ff97e98fb7de0da28f8d40804d2296 Mon Sep 17 00:00:00 2001
4bf432
From: Bill O'Donnell <billodo@redhat.com>
4bf432
Date: Mon, 24 Aug 2020 13:23:43 -0400
4bf432
Subject: [PATCH] xfs_quota: state command should report ugp grace times
4bf432
4bf432
Since grace periods are now supported for three quota types (ugp),
4bf432
modify xfs_quota state command to report times for all three.
4bf432
Add a helper function for stat reporting.
4bf432
4bf432
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
4bf432
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
4bf432
Reviewed-by: Christoph Hellwig <hch@lst.de>
4bf432
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4bf432
---
4bf432
 quota/state.c | 96 +++++++++++++++++++++++++++++++++++----------------
4bf432
 1 file changed, 67 insertions(+), 29 deletions(-)
4bf432
4bf432
diff --git a/quota/state.c b/quota/state.c
4bf432
index 1627181d..19d34ed0 100644
4bf432
--- a/quota/state.c
4bf432
+++ b/quota/state.c
4bf432
@@ -191,49 +191,87 @@ state_stat_to_statv(
4bf432
 }
4bf432
 
4bf432
 static void
4bf432
-state_quotafile_mount(
4bf432
+state_quotafile_stat(
4bf432
 	FILE			*fp,
4bf432
 	uint			type,
4bf432
-	struct fs_path		*mount,
4bf432
+	struct fs_path          *mount,
4bf432
+	struct fs_quota_statv	*sv,
4bf432
+	struct fs_quota_stat	*s,
4bf432
 	uint			flags)
4bf432
 {
4bf432
-	struct fs_quota_stat	s;
4bf432
-	struct fs_quota_statv	sv;
4bf432
+	bool			accounting, enforcing;
4bf432
+	struct fs_qfilestatv	*qsv;
4bf432
 	char			*dev = mount->fs_name;
4bf432
 
4bf432
-	sv.qs_version = FS_QSTATV_VERSION1;
4bf432
-
4bf432
-	if (xfsquotactl(XFS_GETQSTATV, dev, type, 0, (void *)&sv) < 0) {
4bf432
-		if (xfsquotactl(XFS_GETQSTAT, dev, type, 0, (void *)&s) < 0) {
4bf432
+	if (xfsquotactl(XFS_GETQSTATV, dev, type, 0, (void *)sv) < 0) {
4bf432
+		if (xfsquotactl(XFS_GETQSTAT, dev, type, 0, (void *)s) < 0) {
4bf432
 			if (flags & VERBOSE_FLAG)
4bf432
 				fprintf(fp,
4bf432
 					_("%s quota are not enabled on %s\n"),
4bf432
 					type_to_string(type), dev);
4bf432
 			return;
4bf432
 		}
4bf432
-		state_stat_to_statv(&s, &sv;;
4bf432
+		state_stat_to_statv(s, sv);
4bf432
+	}
4bf432
+
4bf432
+	switch(type) {
4bf432
+	case XFS_USER_QUOTA:
4bf432
+		qsv = &sv->qs_uquota;
4bf432
+		accounting = sv->qs_flags & XFS_QUOTA_UDQ_ACCT;
4bf432
+		enforcing = sv->qs_flags & XFS_QUOTA_UDQ_ENFD;
4bf432
+		break;
4bf432
+	case XFS_GROUP_QUOTA:
4bf432
+		qsv = &sv->qs_gquota;
4bf432
+		accounting = sv->qs_flags & XFS_QUOTA_GDQ_ACCT;
4bf432
+		enforcing = sv->qs_flags & XFS_QUOTA_GDQ_ENFD;
4bf432
+		break;
4bf432
+	case XFS_PROJ_QUOTA:
4bf432
+		qsv = &sv->qs_pquota;
4bf432
+		accounting = sv->qs_flags & XFS_QUOTA_PDQ_ACCT;
4bf432
+		enforcing = sv->qs_flags & XFS_QUOTA_PDQ_ENFD;
4bf432
+		break;
4bf432
+	default:
4bf432
+		return;
4bf432
 	}
4bf432
 
4bf432
-	if (type & XFS_USER_QUOTA)
4bf432
-		state_qfilestat(fp, mount, XFS_USER_QUOTA, &sv.qs_uquota,
4bf432
-				sv.qs_flags & XFS_QUOTA_UDQ_ACCT,
4bf432
-				sv.qs_flags & XFS_QUOTA_UDQ_ENFD);
4bf432
-	if (type & XFS_GROUP_QUOTA)
4bf432
-		state_qfilestat(fp, mount, XFS_GROUP_QUOTA, &sv.qs_gquota,
4bf432
-				sv.qs_flags & XFS_QUOTA_GDQ_ACCT,
4bf432
-				sv.qs_flags & XFS_QUOTA_GDQ_ENFD);
4bf432
-	if (type & XFS_PROJ_QUOTA)
4bf432
-		state_qfilestat(fp, mount, XFS_PROJ_QUOTA, &sv.qs_pquota,
4bf432
-				sv.qs_flags & XFS_QUOTA_PDQ_ACCT,
4bf432
-				sv.qs_flags & XFS_QUOTA_PDQ_ENFD);
4bf432
-
4bf432
-	state_timelimit(fp, XFS_BLOCK_QUOTA, sv.qs_btimelimit);
4bf432
-	state_warnlimit(fp, XFS_BLOCK_QUOTA, sv.qs_bwarnlimit);
4bf432
-
4bf432
-	state_timelimit(fp, XFS_INODE_QUOTA, sv.qs_itimelimit);
4bf432
-	state_warnlimit(fp, XFS_INODE_QUOTA, sv.qs_iwarnlimit);
4bf432
-
4bf432
-	state_timelimit(fp, XFS_RTBLOCK_QUOTA, sv.qs_rtbtimelimit);
4bf432
+
4bf432
+	state_qfilestat(fp, mount, type, qsv, accounting, enforcing);
4bf432
+
4bf432
+	state_timelimit(fp, XFS_BLOCK_QUOTA, sv->qs_btimelimit);
4bf432
+	state_warnlimit(fp, XFS_BLOCK_QUOTA, sv->qs_bwarnlimit);
4bf432
+
4bf432
+	state_timelimit(fp, XFS_INODE_QUOTA, sv->qs_itimelimit);
4bf432
+	state_warnlimit(fp, XFS_INODE_QUOTA, sv->qs_iwarnlimit);
4bf432
+
4bf432
+	state_timelimit(fp, XFS_RTBLOCK_QUOTA, sv->qs_rtbtimelimit);
4bf432
+}
4bf432
+
4bf432
+static void
4bf432
+state_quotafile_mount(
4bf432
+	FILE			*fp,
4bf432
+	uint			type,
4bf432
+	struct fs_path		*mount,
4bf432
+	uint			flags)
4bf432
+{
4bf432
+	struct fs_quota_stat	s;
4bf432
+	struct fs_quota_statv	sv;
4bf432
+
4bf432
+	sv.qs_version = FS_QSTATV_VERSION1;
4bf432
+
4bf432
+	if (type & XFS_USER_QUOTA) {
4bf432
+		state_quotafile_stat(fp, XFS_USER_QUOTA, mount,
4bf432
+				     &sv, &s, flags);
4bf432
+	}
4bf432
+
4bf432
+	if (type & XFS_GROUP_QUOTA) {
4bf432
+		state_quotafile_stat(fp, XFS_GROUP_QUOTA, mount,
4bf432
+				     &sv, &s, flags);
4bf432
+	}
4bf432
+
4bf432
+	if (type & XFS_PROJ_QUOTA) {
4bf432
+		state_quotafile_stat(fp, XFS_PROJ_QUOTA, mount,
4bf432
+				     &sv, &s, flags);
4bf432
+	}
4bf432
 }
4bf432
 
4bf432
 static void
4bf432
-- 
4bf432
2.31.1
4bf432