summarylogtreecommitdiffstats
path: root/0010-Linux-6.7-convert-to-inode-a-mtime-accessor-funcs.patch
blob: f410dd938ee13d2763fb2a06537959feb9009a53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 99d55938f14c517c1c81e5d91fed38ac2ad8a4b9 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Thu, 9 Nov 2023 10:38:29 -0700
Subject: [PATCH 10/10] Linux 6.7: convert to inode a/mtime accessor funcs

The Linux 6.7 commit "fs: new accessor methods for atime and mtime"
(077c212f03) is a follow up to the Linux 6.6 commit "fs: add ctime
accessors infrastructure" (9b6304c1d5)

With the above 6.7 commit, the inode's i_atime and i_mtime are renamed
to __i_atime and __i_mtime and accessing these members should use the
new accessor functions.

This commit is similar to the OpenAFS commit "Linux 6.6: convert to
ctime accessor functions" (072c7934cd1)

Add autoconf tests to detect when we need to use the new accessors and
introduce new wrapper functions to get and set an inode's atime and
mtime.

Note, unlike the (072c7934cd1) commit, we need to add support for
reading an inode's atime and mtime, so this commit has the getters for
the atime and mtime members.

Reviewed-on: https://gerrit.openafs.org/15597
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 8962767a7e27f8db9dc9001999edf573be706d66)

Change-Id: If5f58df74f37749b7dfdc52172a8e9573d849ecd
Reviewed-on: https://gerrit.openafs.org/15600
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 6edf9d350c6ffd9d5e51fb8106701c1bc2f6a4d9)
---
 src/afs/LINUX/osi_file.c     |  5 ++---
 src/afs/LINUX/osi_machdep.h  | 29 +++++++++++++++++++++++++++++
 src/afs/LINUX/osi_vnodeops.c |  6 ++----
 src/cf/linux-kernel-func.m4  |  8 ++++++++
 4 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c
index b8bdce7e7..6dbfc155f 100644
--- a/src/afs/LINUX/osi_file.c
+++ b/src/afs/LINUX/osi_file.c
@@ -175,9 +175,8 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 {
     AFS_STATCNT(osi_Stat);
     astat->size = i_size_read(OSIFILE_INODE(afile));
-    astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
-    astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
-
+    astat->mtime = afs_inode_get_mtime_sec(OSIFILE_INODE(afile));
+    astat->atime = afs_inode_get_atime_sec(OSIFILE_INODE(afile));
     return 0;
 }
 
diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h
index f9ceb359e..f08ae8223 100644
--- a/src/afs/LINUX/osi_machdep.h
+++ b/src/afs/LINUX/osi_machdep.h
@@ -128,6 +128,35 @@ afs_inode_set_ctime(struct inode *inode, time64_t sec, long nsec)
     inode->i_ctime.tv_nsec = nsec;
 }
 #endif
+#if defined(HAVE_LINUX_INODE_ATIME_MTIME_ACCESSORS)
+# define afs_inode_set_atime(inode, sec, nsec) inode_set_atime((inode), (sec), (nsec))
+# define afs_inode_get_atime_sec(inode) inode_get_atime_sec((inode))
+# define afs_inode_set_mtime(inode, sec, nsec) inode_set_mtime((inode), (sec), (nsec))
+# define afs_inode_get_mtime_sec(inode) inode_get_mtime_sec((inode))
+#else
+static inline void
+afs_inode_set_atime(struct inode *inode, time_t sec, long nsec)
+{
+    inode->i_atime.tv_sec = sec;
+    inode->i_atime.tv_nsec = nsec;
+}
+static inline time_t
+afs_inode_get_atime_sec(struct inode *inode)
+{
+    return inode->i_atime.tv_sec;
+}
+static inline void
+afs_inode_set_mtime(struct inode *inode, time_t sec, long nsec)
+{
+    inode->i_mtime.tv_sec = sec;
+    inode->i_mtime.tv_nsec = nsec;
+}
+static inline time_t
+afs_inode_get_mtime_sec(struct inode *inode)
+{
+    return inode->i_mtime.tv_sec;
+}
+#endif /* HAVE_LINUX_INODE_ATIME_MTIME_ACCESSORS */
 
 #undef gop_lookupname
 #define gop_lookupname osi_lookupname
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index 86dd7b473..7e85aa552 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -1136,14 +1136,12 @@ vattr2inode(struct inode *ip, struct vattr *vp)
     ip->i_uid = afs_make_kuid(vp->va_uid);
     ip->i_gid = afs_make_kgid(vp->va_gid);
     i_size_write(ip, vp->va_size);
-    ip->i_atime.tv_sec = vp->va_atime.tv_sec;
-    ip->i_atime.tv_nsec = 0;
-    ip->i_mtime.tv_sec = vp->va_mtime.tv_sec;
+    afs_inode_set_atime(ip, vp->va_atime.tv_sec, 0);
     /* Set the mtime nanoseconds to the sysname generation number.
      * This convinces NFS clients that all directories have changed
      * any time the sysname list changes.
      */
-    ip->i_mtime.tv_nsec = afs_sysnamegen;
+    afs_inode_set_mtime(ip, vp->va_mtime.tv_sec, afs_sysnamegen);
     afs_inode_set_ctime(ip, vp->va_ctime.tv_sec, 0);
 }
 
diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4
index dc26b6056..7f3000fc1 100644
--- a/src/cf/linux-kernel-func.m4
+++ b/src/cf/linux-kernel-func.m4
@@ -244,6 +244,14 @@ AC_CHECK_LINUX_FUNC([inode_set_ctime],
 		    [#include <linux/fs.h>],
 		    [inode_set_ctime(NULL, 0, 0);])
 
+dnl Linux 6.7 requires the use of a getter/setter for accessing a inode's
+dnl atime and mtime members.  Test for the setters.  Assummes that the
+dnl getters are present if the setters are.
+AC_CHECK_LINUX_FUNC([inode_atime_mtime_accessors],
+		    [#include <linux/fs.h>],
+		    [inode_set_atime(NULL, 0, 0);
+		     inode_set_mtime(NULL, 0, 0);])
+
 dnl Consequences - things which get set as a result of the
 dnl                above tests
 AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
-- 
2.43.0