diff mbox series

[08/26] xfs_logprint: refactor timestamp printing

Message ID 160375529676.881414.3983778876306819986.stgit@magnolia
State Rejected
Headers show
Series xfsprogs: widen timestamps to deal with y2038 | expand

Commit Message

Darrick J. Wong Oct. 26, 2020, 11:34 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Introduce type-specific printing functions to xfs_logprint to print an
xfs_timestamp instead of open-coding the timestamp decoding.  This is
needed to stay ahead of changes that we're going to make to
xfs_timestamp_t in the following patches.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 logprint/log_misc.c      |   18 ++++++++++++++++--
 logprint/log_print_all.c |    3 +--
 logprint/logprint.h      |    2 ++
 3 files changed, 19 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Oct. 29, 2020, 9:48 a.m. UTC | #1
On Mon, Oct 26, 2020 at 04:34:56PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Introduce type-specific printing functions to xfs_logprint to print an
> xfs_timestamp instead of open-coding the timestamp decoding.  This is
> needed to stay ahead of changes that we're going to make to
> xfs_timestamp_t in the following patches.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Eric Sandeen Nov. 23, 2020, 8:14 p.m. UTC | #2
On 10/26/20 6:34 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Introduce type-specific printing functions to xfs_logprint to print an
> xfs_timestamp instead of open-coding the timestamp decoding.  This is
> needed to stay ahead of changes that we're going to make to
> xfs_timestamp_t in the following patches.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  logprint/log_misc.c      |   18 ++++++++++++++++--
>  logprint/log_print_all.c |    3 +--
>  logprint/logprint.h      |    2 ++
>  3 files changed, 19 insertions(+), 4 deletions(-)
> 

Just for the record, I decided to not take this one; the helper function
with the somewhat vague "compact" arg at the callers doesnt' really seem
worth it, I just open-coded this at the 2 callsites when I did the merge.

Thanks,
-Eric
Darrick J. Wong Nov. 24, 2020, 12:25 a.m. UTC | #3
On Mon, Nov 23, 2020 at 02:14:27PM -0600, Eric Sandeen wrote:
> On 10/26/20 6:34 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Introduce type-specific printing functions to xfs_logprint to print an
> > xfs_timestamp instead of open-coding the timestamp decoding.  This is
> > needed to stay ahead of changes that we're going to make to
> > xfs_timestamp_t in the following patches.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  logprint/log_misc.c      |   18 ++++++++++++++++--
> >  logprint/log_print_all.c |    3 +--
> >  logprint/logprint.h      |    2 ++
> >  3 files changed, 19 insertions(+), 4 deletions(-)
> > 
> 
> Just for the record, I decided to not take this one; the helper function
> with the somewhat vague "compact" arg at the callers doesnt' really seem
> worth it, I just open-coded this at the 2 callsites when I did the merge.

<nod> it was kind of questionable from the start :)

--D

> Thanks,
> -Eric
diff mbox series

Patch

diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index af927cbfa792..a747cbd360af 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -435,6 +435,21 @@  xlog_print_trans_qoff(char **ptr, uint len)
     }
 }	/* xlog_print_trans_qoff */
 
+void
+xlog_print_dinode_ts(
+	struct xfs_log_dinode	*ldip,
+	bool			compact)
+{
+	const char		*fmt;
+
+	if (compact)
+		fmt = _("atime 0x%x mtime 0x%x ctime 0x%x\n");
+	else
+		fmt = _("		atime:%d  mtime:%d  ctime:%d\n");
+
+	printf(fmt, ldip->di_atime.t_sec, ldip->di_mtime.t_sec,
+			ldip->di_ctime.t_sec);
+}
 
 static void
 xlog_print_trans_inode_core(
@@ -446,8 +461,7 @@  xlog_print_trans_inode_core(
 	   (int)ip->di_format);
     printf(_("nlink %hd uid %d gid %d\n"),
 	   ip->di_nlink, ip->di_uid, ip->di_gid);
-    printf(_("atime 0x%x mtime 0x%x ctime 0x%x\n"),
-	   ip->di_atime.t_sec, ip->di_mtime.t_sec, ip->di_ctime.t_sec);
+    xlog_print_dinode_ts(ip, true);
     printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%x\n"),
 	   (unsigned long long)ip->di_size, (unsigned long long)ip->di_nblocks,
 	   ip->di_extsize, ip->di_nextents);
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index 1924a0af70b6..fae531d3e030 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -249,8 +249,7 @@  xlog_recover_print_inode_core(
 	printf(_("		uid:%d  gid:%d  nlink:%d projid:0x%04x%04x\n"),
 	       di->di_uid, di->di_gid, di->di_nlink,
 	       di->di_projid_hi, di->di_projid_lo);
-	printf(_("		atime:%d  mtime:%d  ctime:%d\n"),
-	       di->di_atime.t_sec, di->di_mtime.t_sec, di->di_ctime.t_sec);
+	xlog_print_dinode_ts(di, false);
 	printf(_("		flushiter:%d\n"), di->di_flushiter);
 	printf(_("		size:0x%llx  nblks:0x%llx  exsize:%d  "
 	     "nextents:%d  anextents:%d\n"), (unsigned long long)
diff --git a/logprint/logprint.h b/logprint/logprint.h
index ee85bfe5f21f..6639e1cf5862 100644
--- a/logprint/logprint.h
+++ b/logprint/logprint.h
@@ -29,6 +29,8 @@  extern void print_xlog_record_line(void);
 extern void print_xlog_op_line(void);
 extern void print_stars(void);
 
+void xlog_print_dinode_ts(struct xfs_log_dinode *ldip, bool compact);
+
 extern struct xfs_inode_log_format *
 	xfs_inode_item_format_convert(char *, uint, struct xfs_inode_log_format *);