diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4 index 412e13b47df5..9cc098bf3dcc 100644 --- a/config/kernel-inode-times.m4 +++ b/config/kernel-inode-times.m4 @@ -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 + ],[ + struct inode ip; + + memset(&ip, 0, sizeof(ip)); + inode_set_ctime_current(&ip); + ]) ]) AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [ @@ -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) + ]) ]) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index f4f1dcf95d4c..187afc6a104a 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -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 */ diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index ef50f8687779..398fdd67cd21 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -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); diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 4e4f5210f85d..95747e7d5bae 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -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); } @@ -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); } @@ -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); }