Skip to content

Commit

Permalink
Linux 6.6: Use the inode_set_ctime_current() to set ctime to curtime
Browse files Browse the repository at this point in the history
This change wraps the inode_set_ctime_current(), or, for older kernels,
the 'ip->i_ctime = current_time(ip)' construct, under a new
zpl_inode_set_ctime_current(ip) macro. On newer kernels, it will use the
new API function to set the ctime to "current time".

Signed-off-by: Coleman Kane <ckane@colemankane.org>
  • Loading branch information
ckane committed Sep 13, 2023
1 parent cd5395f commit 32f14d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
18 changes: 18 additions & 0 deletions config/kernel-inode-times.m4
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
memset(&ip, 0, sizeof(ip));
inode_set_ctime_to_ts(&ip, ts);
])
ZFS_LINUX_TEST_SRC([inode_set_ctime_current], [
#include <linux/fs.h>
],[
struct inode ip;
memset(&ip, 0, sizeof(ip));
inode_set_ctime_current(&ip);
])
])

AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
Expand Down Expand Up @@ -90,4 +99,13 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
],[
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING([whether inode_set_ctime_current() exists])
ZFS_LINUX_TEST_RESULT([inode_set_ctime_current], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_SET_CTIME_CURRENT, 1,
[inode_set_ctime_current() exists in linux/fs.h])
],[
AC_MSG_RESULT(no)
])
])
5 changes: 5 additions & 0 deletions include/os/linux/zfs/sys/zpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,10 @@ 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_SET_CTIME_CURRENT
#define zpl_inode_set_ctime_current(ip) inode_set_ctime_current(ip)
#else
#define zpl_inode_set_ctime_current(ip) (ip->i_ctime = current_time(ip))
#endif

#endif /* _SYS_ZPL_H */
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
return (-EMLINK);

crhold(cr);
zpl_inode_set_ctime_to_ts(ip, current_time(ip));
zpl_inode_set_ctime_current(ip);
/* Must have an existing ref, so igrab() cannot return NULL */
VERIFY3P(igrab(ip), !=, NULL);

Expand Down
7 changes: 3 additions & 4 deletions module/os/linux/zfs/zpl_xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ zpl_xattr_set_dir(struct inode *ip, const char *name, const void *value,
error = -zfs_write_simple(xzp, value, size, pos, NULL);
out:
if (error == 0) {
zpl_inode_set_ctime_to_ts(ip, current_time(ip));
zpl_inode_set_ctime_current(ip);
zfs_mark_inode_dirty(ip);
}

Expand Down Expand Up @@ -1011,8 +1011,7 @@ zpl_set_acl_impl(struct inode *ip, struct posix_acl *acl, int type)
*/
if (ip->i_mode != mode) {
ip->i_mode = ITOZ(ip)->z_mode = mode;
zpl_inode_set_ctime_to_ts(ip,
current_time(ip));
zpl_inode_set_ctime_current(ip);
zfs_mark_inode_dirty(ip);
}

Expand Down Expand Up @@ -1171,7 +1170,7 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
return (PTR_ERR(acl));
if (!acl) {
ITOZ(ip)->z_mode = (ip->i_mode &= ~current_umask());
zpl_inode_set_ctime_to_ts(ip, current_time(ip));
zpl_inode_set_ctime_current(ip);
zfs_mark_inode_dirty(ip);
return (0);
}
Expand Down

0 comments on commit 32f14d5

Please sign in to comment.