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