mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Linux 6.7 compat: use inode atime/mtime accessors
6.6 made i_ctime inaccessible; 6.7 has done the same for i_atime and
i_mtime. This extends the method used for ctime in b37f29341
to atime
and mtime as well.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://github.com/sponsors/robn
Closes #15681
This commit is contained in:
parent
00f40961e0
commit
db4fc559cc
@ -52,6 +52,48 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
inode_set_ctime_to_ts(&ip, ts);
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 6.7 API change
|
||||
dnl # i_atime/i_mtime no longer directly accessible, must use
|
||||
dnl # inode_get_mtime(ip), inode_set_mtime*(ip) to
|
||||
dnl # read/write.
|
||||
dnl #
|
||||
ZFS_LINUX_TEST_SRC([inode_get_atime], [
|
||||
#include <linux/fs.h>
|
||||
],[
|
||||
struct inode ip;
|
||||
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
inode_get_atime(&ip);
|
||||
])
|
||||
ZFS_LINUX_TEST_SRC([inode_get_mtime], [
|
||||
#include <linux/fs.h>
|
||||
],[
|
||||
struct inode ip;
|
||||
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
inode_get_mtime(&ip);
|
||||
])
|
||||
|
||||
ZFS_LINUX_TEST_SRC([inode_set_atime_to_ts], [
|
||||
#include <linux/fs.h>
|
||||
],[
|
||||
struct inode ip;
|
||||
struct timespec64 ts = {0};
|
||||
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
inode_set_atime_to_ts(&ip, ts);
|
||||
])
|
||||
ZFS_LINUX_TEST_SRC([inode_set_mtime_to_ts], [
|
||||
#include <linux/fs.h>
|
||||
],[
|
||||
struct inode ip;
|
||||
struct timespec64 ts = {0};
|
||||
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
inode_set_mtime_to_ts(&ip, ts);
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
|
||||
@ -90,4 +132,40 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether inode_get_atime() exists])
|
||||
ZFS_LINUX_TEST_RESULT([inode_get_atime], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_INODE_GET_ATIME, 1,
|
||||
[inode_get_atime() exists in linux/fs.h])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether inode_set_atime_to_ts() exists])
|
||||
ZFS_LINUX_TEST_RESULT([inode_set_atime_to_ts], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_INODE_SET_ATIME_TO_TS, 1,
|
||||
[inode_set_atime_to_ts() exists in linux/fs.h])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether inode_get_mtime() exists])
|
||||
ZFS_LINUX_TEST_RESULT([inode_get_mtime], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_INODE_GET_MTIME, 1,
|
||||
[inode_get_mtime() exists in linux/fs.h])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether inode_set_mtime_to_ts() exists])
|
||||
ZFS_LINUX_TEST_RESULT([inode_set_mtime_to_ts], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_INODE_SET_MTIME_TO_TS, 1,
|
||||
[inode_set_mtime_to_ts() exists in linux/fs.h])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
|
@ -273,5 +273,25 @@ extern long zpl_ioctl_fideduperange(struct file *filp, void *arg);
|
||||
#else
|
||||
#define zpl_inode_set_ctime_to_ts(ip, ts) (ip->i_ctime = ts)
|
||||
#endif
|
||||
#ifdef HAVE_INODE_GET_ATIME
|
||||
#define zpl_inode_get_atime(ip) inode_get_atime(ip)
|
||||
#else
|
||||
#define zpl_inode_get_atime(ip) (ip->i_atime)
|
||||
#endif
|
||||
#ifdef HAVE_INODE_SET_ATIME_TO_TS
|
||||
#define zpl_inode_set_atime_to_ts(ip, ts) inode_set_atime_to_ts(ip, ts)
|
||||
#else
|
||||
#define zpl_inode_set_atime_to_ts(ip, ts) (ip->i_atime = ts)
|
||||
#endif
|
||||
#ifdef HAVE_INODE_GET_MTIME
|
||||
#define zpl_inode_get_mtime(ip) inode_get_mtime(ip)
|
||||
#else
|
||||
#define zpl_inode_get_mtime(ip) (ip->i_mtime)
|
||||
#endif
|
||||
#ifdef HAVE_INODE_SET_MTIME_TO_TS
|
||||
#define zpl_inode_set_mtime_to_ts(ip, ts) inode_set_mtime_to_ts(ip, ts)
|
||||
#else
|
||||
#define zpl_inode_set_mtime_to_ts(ip, ts) (ip->i_mtime = ts)
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_ZPL_H */
|
||||
|
@ -520,8 +520,8 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
|
||||
ip->i_uid = SUID_TO_KUID(0);
|
||||
ip->i_gid = SGID_TO_KGID(0);
|
||||
ip->i_blkbits = SPA_MINBLOCKSHIFT;
|
||||
ip->i_atime = now;
|
||||
ip->i_mtime = now;
|
||||
zpl_inode_set_atime_to_ts(ip, now);
|
||||
zpl_inode_set_mtime_to_ts(ip, now);
|
||||
zpl_inode_set_ctime_to_ts(ip, now);
|
||||
ip->i_fop = fops;
|
||||
ip->i_op = ops;
|
||||
|
@ -2438,15 +2438,17 @@ top:
|
||||
|
||||
if ((mask & ATTR_ATIME) || zp->z_atime_dirty) {
|
||||
zp->z_atime_dirty = B_FALSE;
|
||||
ZFS_TIME_ENCODE(&ip->i_atime, atime);
|
||||
inode_timespec_t tmp_atime;
|
||||
ZFS_TIME_ENCODE(&tmp_atime, atime);
|
||||
zpl_inode_set_atime_to_ts(ZTOI(zp), tmp_atime);
|
||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL,
|
||||
&atime, sizeof (atime));
|
||||
}
|
||||
|
||||
if (mask & (ATTR_MTIME | ATTR_SIZE)) {
|
||||
ZFS_TIME_ENCODE(&vap->va_mtime, mtime);
|
||||
ZTOI(zp)->i_mtime = zpl_inode_timestamp_truncate(
|
||||
vap->va_mtime, ZTOI(zp));
|
||||
zpl_inode_set_mtime_to_ts(ZTOI(zp),
|
||||
zpl_inode_timestamp_truncate(vap->va_mtime, ZTOI(zp)));
|
||||
|
||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL,
|
||||
mtime, sizeof (mtime));
|
||||
@ -3660,7 +3662,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
|
||||
caddr_t va;
|
||||
int err = 0;
|
||||
uint64_t mtime[2], ctime[2];
|
||||
inode_timespec_t tmp_ctime;
|
||||
inode_timespec_t tmp_ts;
|
||||
sa_bulk_attr_t bulk[3];
|
||||
int cnt = 0;
|
||||
struct address_space *mapping;
|
||||
@ -3824,9 +3826,10 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
|
||||
&zp->z_pflags, 8);
|
||||
|
||||
/* Preserve the mtime and ctime provided by the inode */
|
||||
ZFS_TIME_ENCODE(&ip->i_mtime, mtime);
|
||||
tmp_ctime = zpl_inode_get_ctime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ctime, ctime);
|
||||
tmp_ts = zpl_inode_get_mtime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ts, mtime);
|
||||
tmp_ts = zpl_inode_get_ctime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ts, ctime);
|
||||
zp->z_atime_dirty = B_FALSE;
|
||||
zp->z_seq++;
|
||||
|
||||
@ -3880,7 +3883,7 @@ zfs_dirty_inode(struct inode *ip, int flags)
|
||||
zfsvfs_t *zfsvfs = ITOZSB(ip);
|
||||
dmu_tx_t *tx;
|
||||
uint64_t mode, atime[2], mtime[2], ctime[2];
|
||||
inode_timespec_t tmp_ctime;
|
||||
inode_timespec_t tmp_ts;
|
||||
sa_bulk_attr_t bulk[4];
|
||||
int error = 0;
|
||||
int cnt = 0;
|
||||
@ -3925,10 +3928,12 @@ zfs_dirty_inode(struct inode *ip, int flags)
|
||||
SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16);
|
||||
|
||||
/* Preserve the mode, mtime and ctime provided by the inode */
|
||||
ZFS_TIME_ENCODE(&ip->i_atime, atime);
|
||||
ZFS_TIME_ENCODE(&ip->i_mtime, mtime);
|
||||
tmp_ctime = zpl_inode_get_ctime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ctime, ctime);
|
||||
tmp_ts = zpl_inode_get_atime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ts, atime);
|
||||
tmp_ts = zpl_inode_get_mtime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ts, mtime);
|
||||
tmp_ts = zpl_inode_get_ctime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_ts, ctime);
|
||||
mode = ip->i_mode;
|
||||
|
||||
zp->z_mode = mode;
|
||||
@ -3971,7 +3976,9 @@ zfs_inactive(struct inode *ip)
|
||||
if (error) {
|
||||
dmu_tx_abort(tx);
|
||||
} else {
|
||||
ZFS_TIME_ENCODE(&ip->i_atime, atime);
|
||||
inode_timespec_t tmp_atime;
|
||||
tmp_atime = zpl_inode_get_atime(ip);
|
||||
ZFS_TIME_ENCODE(&tmp_atime, atime);
|
||||
mutex_enter(&zp->z_lock);
|
||||
(void) sa_update(zp->z_sa_hdl, SA_ZPL_ATIME(zfsvfs),
|
||||
(void *)&atime, sizeof (atime), tx);
|
||||
|
@ -542,7 +542,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
|
||||
uint64_t links;
|
||||
uint64_t z_uid, z_gid;
|
||||
uint64_t atime[2], mtime[2], ctime[2], btime[2];
|
||||
inode_timespec_t tmp_ctime;
|
||||
inode_timespec_t tmp_ts;
|
||||
uint64_t projid = ZFS_DEFAULT_PROJID;
|
||||
sa_bulk_attr_t bulk[12];
|
||||
int count = 0;
|
||||
@ -614,10 +614,12 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
|
||||
if (zp->z_pflags & ZFS_XATTR)
|
||||
zp->z_xattr_parent = parent;
|
||||
|
||||
ZFS_TIME_DECODE(&ip->i_atime, atime);
|
||||
ZFS_TIME_DECODE(&ip->i_mtime, mtime);
|
||||
ZFS_TIME_DECODE(&tmp_ctime, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ip, tmp_ctime);
|
||||
ZFS_TIME_DECODE(&tmp_ts, atime);
|
||||
zpl_inode_set_atime_to_ts(ip, tmp_ts);
|
||||
ZFS_TIME_DECODE(&tmp_ts, mtime);
|
||||
zpl_inode_set_mtime_to_ts(ip, tmp_ts);
|
||||
ZFS_TIME_DECODE(&tmp_ts, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ip, tmp_ts);
|
||||
ZFS_TIME_DECODE(&zp->z_btime, btime);
|
||||
|
||||
ip->i_ino = zp->z_id;
|
||||
@ -1197,7 +1199,7 @@ zfs_rezget(znode_t *zp)
|
||||
uint64_t gen;
|
||||
uint64_t z_uid, z_gid;
|
||||
uint64_t atime[2], mtime[2], ctime[2], btime[2];
|
||||
inode_timespec_t tmp_ctime;
|
||||
inode_timespec_t tmp_ts;
|
||||
uint64_t projid = ZFS_DEFAULT_PROJID;
|
||||
znode_hold_t *zh;
|
||||
|
||||
@ -1290,10 +1292,12 @@ zfs_rezget(znode_t *zp)
|
||||
zfs_uid_write(ZTOI(zp), z_uid);
|
||||
zfs_gid_write(ZTOI(zp), z_gid);
|
||||
|
||||
ZFS_TIME_DECODE(&ZTOI(zp)->i_atime, atime);
|
||||
ZFS_TIME_DECODE(&ZTOI(zp)->i_mtime, mtime);
|
||||
ZFS_TIME_DECODE(&tmp_ctime, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ZTOI(zp), tmp_ctime);
|
||||
ZFS_TIME_DECODE(&tmp_ts, atime);
|
||||
zpl_inode_set_atime_to_ts(ZTOI(zp), tmp_ts);
|
||||
ZFS_TIME_DECODE(&tmp_ts, mtime);
|
||||
zpl_inode_set_mtime_to_ts(ZTOI(zp), tmp_ts);
|
||||
ZFS_TIME_DECODE(&tmp_ts, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ZTOI(zp), tmp_ts);
|
||||
ZFS_TIME_DECODE(&zp->z_btime, btime);
|
||||
|
||||
if ((uint32_t)gen != ZTOI(zp)->i_generation) {
|
||||
@ -1401,22 +1405,24 @@ zfs_zinactive(znode_t *zp)
|
||||
boolean_t
|
||||
zfs_relatime_need_update(const struct inode *ip)
|
||||
{
|
||||
inode_timespec_t now, tmp_ctime;
|
||||
inode_timespec_t now, tmp_atime, tmp_ts;
|
||||
|
||||
gethrestime(&now);
|
||||
tmp_atime = zpl_inode_get_atime(ip);
|
||||
/*
|
||||
* In relatime mode, only update the atime if the previous atime
|
||||
* is earlier than either the ctime or mtime or if at least a day
|
||||
* has passed since the last update of atime.
|
||||
*/
|
||||
if (zfs_compare_timespec(&ip->i_mtime, &ip->i_atime) >= 0)
|
||||
tmp_ts = zpl_inode_get_mtime(ip);
|
||||
if (zfs_compare_timespec(&tmp_ts, &tmp_atime) >= 0)
|
||||
return (B_TRUE);
|
||||
|
||||
tmp_ctime = zpl_inode_get_ctime(ip);
|
||||
if (zfs_compare_timespec(&tmp_ctime, &ip->i_atime) >= 0)
|
||||
tmp_ts = zpl_inode_get_ctime(ip);
|
||||
if (zfs_compare_timespec(&tmp_ts, &tmp_atime) >= 0)
|
||||
return (B_TRUE);
|
||||
|
||||
if ((hrtime_t)now.tv_sec - (hrtime_t)ip->i_atime.tv_sec >= 24*60*60)
|
||||
if ((hrtime_t)now.tv_sec - (hrtime_t)tmp_atime.tv_sec >= 24*60*60)
|
||||
return (B_TRUE);
|
||||
|
||||
return (B_FALSE);
|
||||
@ -1439,7 +1445,7 @@ void
|
||||
zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
|
||||
uint64_t ctime[2])
|
||||
{
|
||||
inode_timespec_t now, tmp_ctime;
|
||||
inode_timespec_t now, tmp_ts;
|
||||
|
||||
gethrestime(&now);
|
||||
|
||||
@ -1447,7 +1453,8 @@ zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
|
||||
|
||||
if (flag & ATTR_MTIME) {
|
||||
ZFS_TIME_ENCODE(&now, mtime);
|
||||
ZFS_TIME_DECODE(&(ZTOI(zp)->i_mtime), mtime);
|
||||
ZFS_TIME_DECODE(&tmp_ts, mtime);
|
||||
zpl_inode_set_mtime_to_ts(ZTOI(zp), tmp_ts);
|
||||
if (ZTOZSB(zp)->z_use_fuids) {
|
||||
zp->z_pflags |= (ZFS_ARCHIVE |
|
||||
ZFS_AV_MODIFIED);
|
||||
@ -1456,8 +1463,8 @@ zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
|
||||
|
||||
if (flag & ATTR_CTIME) {
|
||||
ZFS_TIME_ENCODE(&now, ctime);
|
||||
ZFS_TIME_DECODE(&tmp_ctime, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ZTOI(zp), tmp_ctime);
|
||||
ZFS_TIME_DECODE(&tmp_ts, ctime);
|
||||
zpl_inode_set_ctime_to_ts(ZTOI(zp), tmp_ts);
|
||||
if (ZTOZSB(zp)->z_use_fuids)
|
||||
zp->z_pflags |= ZFS_ARCHIVE;
|
||||
}
|
||||
|
@ -526,7 +526,8 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
|
||||
vap->va_ctime = ia->ia_ctime;
|
||||
|
||||
if (vap->va_mask & ATTR_ATIME)
|
||||
ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
|
||||
zpl_inode_set_atime_to_ts(ip,
|
||||
zpl_inode_timestamp_truncate(ia->ia_atime, ip));
|
||||
|
||||
cookie = spl_fstrans_mark();
|
||||
#ifdef HAVE_USERNS_IOPS_SETATTR
|
||||
|
Loading…
Reference in New Issue
Block a user