Blame SOURCES/xfsprogs-5.10.0-xfs_db-refactor-quota-timer-printing.patch

f49185
From a9a32fcb9176c82aed6d85f209e7279b76c8b55f Mon Sep 17 00:00:00 2001
f49185
From: "Darrick J. Wong" <darrick.wong@oracle.com>
f49185
Date: Fri, 20 Nov 2020 17:03:28 -0500
f49185
Subject: [PATCH] xfs_db: refactor quota timer printing
f49185
f49185
Introduce type-specific printing functions to xfs_db to print a quota
f49185
timer instead of printing a raw int32 value.  This is needed to stay
f49185
ahead of changes that we're going to make to the quota timer format in
f49185
the following patches.
f49185
f49185
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
f49185
Reviewed-by: Christoph Hellwig <hch@lst.de>
f49185
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
f49185
---
f49185
f49185
diff --git a/db/dquot.c b/db/dquot.c
f49185
index dd9e83f..5c82456 100644
f49185
--- a/db/dquot.c
f49185
+++ b/db/dquot.c
f49185
@@ -60,8 +60,8 @@ const field_t	disk_dquot_flds[] = {
f49185
 	  TYP_NONE },
f49185
 	{ "bcount", FLDT_QCNT, OI(DOFF(bcount)), C1, 0, TYP_NONE },
f49185
 	{ "icount", FLDT_QCNT, OI(DOFF(icount)), C1, 0, TYP_NONE },
f49185
-	{ "itimer", FLDT_INT32D, OI(DOFF(itimer)), C1, 0, TYP_NONE },
f49185
-	{ "btimer", FLDT_INT32D, OI(DOFF(btimer)), C1, 0, TYP_NONE },
f49185
+	{ "itimer", FLDT_QTIMER, OI(DOFF(itimer)), C1, 0, TYP_NONE },
f49185
+	{ "btimer", FLDT_QTIMER, OI(DOFF(btimer)), C1, 0, TYP_NONE },
f49185
 	{ "iwarns", FLDT_QWARNCNT, OI(DOFF(iwarns)), C1, 0, TYP_NONE },
f49185
 	{ "bwarns", FLDT_QWARNCNT, OI(DOFF(bwarns)), C1, 0, TYP_NONE },
f49185
 	{ "pad0", FLDT_UINT32X, OI(DOFF(pad0)), C1, FLD_SKIPALL, TYP_NONE },
f49185
@@ -70,7 +70,7 @@ const field_t	disk_dquot_flds[] = {
f49185
 	{ "rtb_softlimit", FLDT_QCNT, OI(DOFF(rtb_softlimit)), C1, 0,
f49185
 	  TYP_NONE },
f49185
 	{ "rtbcount", FLDT_QCNT, OI(DOFF(rtbcount)), C1, 0, TYP_NONE },
f49185
-	{ "rtbtimer", FLDT_INT32D, OI(DOFF(rtbtimer)), C1, 0, TYP_NONE },
f49185
+	{ "rtbtimer", FLDT_QTIMER, OI(DOFF(rtbtimer)), C1, 0, TYP_NONE },
f49185
 	{ "rtbwarns", FLDT_QWARNCNT, OI(DOFF(rtbwarns)), C1, 0, TYP_NONE },
f49185
 	{ "pad", FLDT_UINT16X, OI(DOFF(pad)), C1, FLD_SKIPALL, TYP_NONE },
f49185
 	{ NULL }
f49185
diff --git a/db/field.c b/db/field.c
f49185
index a187a72..770acda 100644
f49185
--- a/db/field.c
f49185
+++ b/db/field.c
f49185
@@ -351,6 +351,8 @@ const ftattr_t	ftattrtab[] = {
f49185
 	  FTARG_SIGNED, NULL, NULL },
f49185
 	{ FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds,
f49185
 	  SI(bitsz(xfs_timestamp_t)), 0, NULL, timestamp_flds },
f49185
+	{ FLDT_QTIMER, "qtimer", fp_qtimer, NULL, SI(bitsz(uint32_t)), 0,
f49185
+	  NULL, NULL },
f49185
 	{ FLDT_UINT1, "uint1", fp_num, "%u", SI(1), 0, NULL, NULL },
f49185
 	{ FLDT_UINT16D, "uint16d", fp_num, "%u", SI(bitsz(uint16_t)), 0, NULL,
f49185
 	  NULL },
f49185
diff --git a/db/field.h b/db/field.h
f49185
index 1506537..387c189 100644
f49185
--- a/db/field.h
f49185
+++ b/db/field.h
f49185
@@ -170,6 +170,7 @@ typedef enum fldt	{
f49185
 
f49185
 	FLDT_TIME,
f49185
 	FLDT_TIMESTAMP,
f49185
+	FLDT_QTIMER,
f49185
 	FLDT_UINT1,
f49185
 	FLDT_UINT16D,
f49185
 	FLDT_UINT16O,
f49185
diff --git a/db/fprint.c b/db/fprint.c
f49185
index 6e72bf0..72ed55f 100644
f49185
--- a/db/fprint.c
f49185
+++ b/db/fprint.c
f49185
@@ -180,6 +180,40 @@ fp_nsec(
f49185
 	return 1;
f49185
 }
f49185
 
f49185
+int
f49185
+fp_qtimer(
f49185
+	void			*obj,
f49185
+	int			bit,
f49185
+	int			count,
f49185
+	char			*fmtstr,
f49185
+	int			size,
f49185
+	int			arg,
f49185
+	int			base,
f49185
+	int			array)
f49185
+{
f49185
+	uint32_t		sec;
f49185
+	__be32			*t;
f49185
+	int			bitpos;
f49185
+	int			i;
f49185
+
f49185
+	ASSERT(bitoffs(bit) == 0);
f49185
+	for (i = 0, bitpos = bit;
f49185
+	     i < count && !seenint();
f49185
+	     i++, bitpos += size) {
f49185
+		if (array)
f49185
+			dbprintf("%d:", i + base);
f49185
+
f49185
+		t = obj + byteize(bitpos);
f49185
+		sec = be32_to_cpu(*t);
f49185
+
f49185
+		dbprintf("%u", sec);
f49185
+
f49185
+		if (i < count - 1)
f49185
+			dbprintf(" ");
f49185
+	}
f49185
+	return 1;
f49185
+}
f49185
+
f49185
 /*ARGSUSED*/
f49185
 int
f49185
 fp_uuid(
f49185
diff --git a/db/fprint.h b/db/fprint.h
f49185
index bfeed15..a1ea935 100644
f49185
--- a/db/fprint.h
f49185
+++ b/db/fprint.h
f49185
@@ -17,6 +17,8 @@ extern int	fp_time(void *obj, int bit, int count, char *fmtstr, int size,
f49185
 			int arg, int base, int array);
f49185
 extern int	fp_nsec(void *obj, int bit, int count, char *fmtstr, int size,
f49185
 			int arg, int base, int array);
f49185
+extern int	fp_qtimer(void *obj, int bit, int count, char *fmtstr, int size,
f49185
+			int arg, int base, int array);
f49185
 extern int	fp_uuid(void *obj, int bit, int count, char *fmtstr, int size,
f49185
 			int arg, int base, int array);
f49185
 extern int	fp_crc(void *obj, int bit, int count, char *fmtstr, int size,