|
|
f49185 |
From 344f38a9e5d0f938dae337c8c769853e6368d480 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: report bigtime format timestamps
|
|
|
f49185 |
|
|
|
f49185 |
Report the large format timestamps in a human-readable manner if it is
|
|
|
f49185 |
possible to do so without loss of information.
|
|
|
f49185 |
|
|
|
f49185 |
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
f49185 |
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
f49185 |
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
|
|
f49185 |
---
|
|
|
f49185 |
|
|
|
f49185 |
diff --git a/db/fprint.c b/db/fprint.c
|
|
|
f49185 |
index 72ed55f..65accfd 100644
|
|
|
f49185 |
--- a/db/fprint.c
|
|
|
f49185 |
+++ b/db/fprint.c
|
|
|
f49185 |
@@ -112,6 +112,35 @@ fp_sarray(
|
|
|
f49185 |
return 1;
|
|
|
f49185 |
}
|
|
|
f49185 |
|
|
|
f49185 |
+static void
|
|
|
f49185 |
+fp_time64(
|
|
|
f49185 |
+ time64_t sec)
|
|
|
f49185 |
+{
|
|
|
f49185 |
+ time_t tt = sec;
|
|
|
f49185 |
+ time64_t tt_sec = tt;
|
|
|
f49185 |
+ char *c;
|
|
|
f49185 |
+
|
|
|
f49185 |
+ /*
|
|
|
f49185 |
+ * Stupid time_t shenanigans -- POSIX.1-2017 only requires that this
|
|
|
f49185 |
+ * type represent a time in seconds. Since we have no idea if our
|
|
|
f49185 |
+ * time64_t filesystem timestamps can actually be represented by the C
|
|
|
f49185 |
+ * library, we resort to converting the input value from time64_t to
|
|
|
f49185 |
+ * time_t and back to time64_t to check for information loss. If so,
|
|
|
f49185 |
+ * we print the raw value; otherwise we print a human-readable value.
|
|
|
f49185 |
+ */
|
|
|
f49185 |
+ if (tt_sec != sec)
|
|
|
f49185 |
+ goto raw;
|
|
|
f49185 |
+
|
|
|
f49185 |
+ c = ctime(&tt;;
|
|
|
f49185 |
+ if (!c)
|
|
|
f49185 |
+ goto raw;
|
|
|
f49185 |
+
|
|
|
f49185 |
+ dbprintf("%24.24s", c);
|
|
|
f49185 |
+ return;
|
|
|
f49185 |
+raw:
|
|
|
f49185 |
+ dbprintf("%lld", sec);
|
|
|
f49185 |
+}
|
|
|
f49185 |
+
|
|
|
f49185 |
int
|
|
|
f49185 |
fp_time(
|
|
|
f49185 |
void *obj,
|
|
|
f49185 |
@@ -138,7 +167,7 @@ fp_time(
|
|
|
f49185 |
ts = obj + byteize(bitpos);
|
|
|
f49185 |
tv = libxfs_inode_from_disk_ts(obj, *ts);
|
|
|
f49185 |
|
|
|
f49185 |
- dbprintf("%24.24s", tv.tv_sec);
|
|
|
f49185 |
+ fp_time64(tv.tv_sec);
|
|
|
f49185 |
|
|
|
f49185 |
if (i < count - 1)
|
|
|
f49185 |
dbprintf(" ");
|
|
|
f49185 |
@@ -191,7 +220,8 @@ fp_qtimer(
|
|
|
f49185 |
int base,
|
|
|
f49185 |
int array)
|
|
|
f49185 |
{
|
|
|
f49185 |
- uint32_t sec;
|
|
|
f49185 |
+ struct xfs_disk_dquot *ddq = obj;
|
|
|
f49185 |
+ time64_t sec;
|
|
|
f49185 |
__be32 *t;
|
|
|
f49185 |
int bitpos;
|
|
|
f49185 |
int i;
|
|
|
f49185 |
@@ -204,9 +234,16 @@ fp_qtimer(
|
|
|
f49185 |
dbprintf("%d:", i + base);
|
|
|
f49185 |
|
|
|
f49185 |
t = obj + byteize(bitpos);
|
|
|
f49185 |
- sec = be32_to_cpu(*t);
|
|
|
f49185 |
+ sec = libxfs_dquot_from_disk_ts(ddq, *t);
|
|
|
f49185 |
|
|
|
f49185 |
- dbprintf("%u", sec);
|
|
|
f49185 |
+ /*
|
|
|
f49185 |
+ * Display the raw value if it's the default grace expiration
|
|
|
f49185 |
+ * period (root dquot) or if the quota has not expired.
|
|
|
f49185 |
+ */
|
|
|
f49185 |
+ if (ddq->d_id == 0 || sec == 0)
|
|
|
f49185 |
+ dbprintf("%lld", sec);
|
|
|
f49185 |
+ else
|
|
|
f49185 |
+ fp_time64(sec);
|
|
|
f49185 |
|
|
|
f49185 |
if (i < count - 1)
|
|
|
f49185 |
dbprintf(" ");
|
|
|
f49185 |
diff --git a/db/inode.c b/db/inode.c
|
|
|
f49185 |
index bbfee74..37c7dc0 100644
|
|
|
f49185 |
--- a/db/inode.c
|
|
|
f49185 |
+++ b/db/inode.c
|
|
|
f49185 |
@@ -172,10 +172,12 @@ const field_t inode_v3_flds[] = {
|
|
|
f49185 |
{ "cowextsz", FLDT_UINT1,
|
|
|
f49185 |
OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_COWEXTSIZE_BIT-1), C1,
|
|
|
f49185 |
0, TYP_NONE },
|
|
|
f49185 |
+ { "bigtime", FLDT_UINT1,
|
|
|
f49185 |
+ OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_BIGTIME_BIT - 1), C1,
|
|
|
f49185 |
+ 0, TYP_NONE },
|
|
|
f49185 |
{ NULL }
|
|
|
f49185 |
};
|
|
|
f49185 |
|
|
|
f49185 |
-
|
|
|
f49185 |
const field_t timestamp_flds[] = {
|
|
|
f49185 |
{ "sec", FLDT_TIME, OI(0), C1, 0, TYP_NONE },
|
|
|
f49185 |
{ "nsec", FLDT_NSEC, OI(0), C1, 0, TYP_NONE },
|
|
|
f49185 |
diff --git a/db/sb.c b/db/sb.c
|
|
|
f49185 |
index d63fc71..109fdc3 100644
|
|
|
f49185 |
--- a/db/sb.c
|
|
|
f49185 |
+++ b/db/sb.c
|
|
|
f49185 |
@@ -689,6 +689,8 @@ version_string(
|
|
|
f49185 |
strcat(s, ",REFLINK");
|
|
|
f49185 |
if (xfs_sb_version_hasinobtcounts(sbp))
|
|
|
f49185 |
strcat(s, ",INOBTCNT");
|
|
|
f49185 |
+ if (xfs_sb_version_hasbigtime(sbp))
|
|
|
f49185 |
+ strcat(s, ",BIGTIME");
|
|
|
f49185 |
return s;
|
|
|
f49185 |
}
|
|
|
f49185 |
|