Blame SOURCES/xfsprogs-5.1.0-libxfs-create-current_time-helper-and-sync-xfs_trans.patch

f49185
From b192e77cc38473964c718bd035502b702c6a6e34 Mon Sep 17 00:00:00 2001
f49185
From: Eric Sandeen <sandeen@redhat.com>
f49185
Date: Tue, 21 May 2019 11:03:43 -0500
f49185
Subject: [PATCH] libxfs: create current_time helper and sync
f49185
 xfs_trans_ichgtime
f49185
f49185
Make xfs_trans_ichgtime() almost match kernelspace by creating a
f49185
new current_time() helper to match the kernel utility.
f49185
f49185
This reduces still more cosmetic change.  We may want to sync the
f49185
creation flag over to the kernel even though it's not used today.
f49185
f49185
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
f49185
Reviewed-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/include/xfs_inode.h b/include/xfs_inode.h
f49185
index 52d79f3..76f9ac7 100644
f49185
--- a/include/xfs_inode.h
f49185
+++ b/include/xfs_inode.h
f49185
@@ -16,6 +16,16 @@ struct xfs_mount;
f49185
 struct xfs_inode_log_item;
f49185
 struct xfs_dir_ops;
f49185
 
f49185
+/*
f49185
+ * These are not actually used, they are only for userspace build
f49185
+ * compatibility in code that looks at i_state
f49185
+ */
f49185
+#define I_DIRTY_TIME		0
f49185
+#define I_DIRTY_TIME_EXPIRED	0
f49185
+
f49185
+#define IS_I_VERSION(inode)			(0)
f49185
+#define inode_maybe_inc_iversion(inode,flags)	(0)
f49185
+
f49185
 /*
f49185
  * Inode interface. This fakes up a "VFS inode" to make the xfs_inode appear
f49185
  * similar to the kernel which now is used tohold certain parts of the on-disk
f49185
@@ -25,6 +35,7 @@ struct inode {
f49185
 	mode_t		i_mode;
f49185
 	uint32_t	i_nlink;
f49185
 	xfs_dev_t	i_rdev;		/* This actually holds xfs_dev_t */
f49185
+	unsigned long	i_state;	/* Not actually used in userspace */
f49185
 	uint32_t	i_generation;
f49185
 	uint64_t	i_version;
f49185
 	struct timespec	i_atime;
f49185
@@ -150,6 +161,9 @@ extern void	libxfs_trans_ichgtime(struct xfs_trans *,
f49185
 				struct xfs_inode *, int);
f49185
 extern int	libxfs_iflush_int (struct xfs_inode *, struct xfs_buf *);
f49185
 
f49185
+#define timespec64 timespec
f49185
+extern struct timespec64 current_time(struct inode *inode);
f49185
+
f49185
 /* Inode Cache Interfaces */
f49185
 extern bool	libxfs_inode_verify_forks(struct xfs_inode *ip);
f49185
 extern int	libxfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
f49185
diff --git a/libxfs/util.c b/libxfs/util.c
f49185
index 9fe9a36..951f7cf 100644
f49185
--- a/libxfs/util.c
f49185
+++ b/libxfs/util.c
f49185
@@ -136,11 +136,21 @@ xfs_log_calc_unit_res(
f49185
 	return unit_bytes;
f49185
 }
f49185
 
f49185
+struct timespec64
f49185
+current_time(struct inode *inode)
f49185
+{
f49185
+	struct timespec64	tv;
f49185
+	struct timeval		stv;
f49185
+
f49185
+	gettimeofday(&stv, (struct timezone *)0);
f49185
+	tv.tv_sec = stv.tv_sec;
f49185
+	tv.tv_nsec = stv.tv_usec * 1000;
f49185
+
f49185
+	return tv;
f49185
+}
f49185
+
f49185
 /*
f49185
  * Change the requested timestamp in the given inode.
f49185
- *
f49185
- * This was once shared with the kernel, but has diverged to the point
f49185
- * where it's no longer worth the hassle of maintaining common code.
f49185
  */
f49185
 void
f49185
 libxfs_trans_ichgtime(
f49185
@@ -148,12 +158,14 @@ libxfs_trans_ichgtime(
f49185
 	struct xfs_inode	*ip,
f49185
 	int			flags)
f49185
 {
f49185
-	struct timespec tv;
f49185
-	struct timeval	stv;
f49185
+	struct inode		*inode = VFS_I(ip);
f49185
+	struct timespec64	tv;
f49185
+
f49185
+	ASSERT(tp);
f49185
+	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
f49185
+
f49185
+	tv = current_time(inode);
f49185
 
f49185
-	gettimeofday(&stv, (struct timezone *)0);
f49185
-	tv.tv_sec = stv.tv_sec;
f49185
-	tv.tv_nsec = stv.tv_usec * 1000;
f49185
 	if (flags & XFS_ICHGTIME_MOD)
f49185
 		VFS_I(ip)->i_mtime = tv;
f49185
 	if (flags & XFS_ICHGTIME_CHG)