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>
This commit is contained in:
Cheyenne Wills 2023-11-09 10:38:29 -07:00 committed by Benjamin Kaduk
parent fd527549c2
commit 6edf9d350c
4 changed files with 41 additions and 7 deletions

View File

@ -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;
}

View File

@ -128,6 +128,35 @@ afs_inode_set_ctime(struct inode *inode, time_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

View File

@ -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);
}

View File

@ -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"],