]> granicus.if.org Git - zfs/commitdiff
Linux 4.12 compat: CURRENT_TIME removed
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 10 May 2017 16:30:48 +0000 (09:30 -0700)
committerGitHub <noreply@github.com>
Wed, 10 May 2017 16:30:48 +0000 (09:30 -0700)
Linux 4.9 added current_time() as the preferred interface to get
the filesystem time.  CURRENT_TIME was retired in Linux 4.12.

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6114

config/kernel-current-time.m4 [new file with mode: 0644]
config/kernel.m4
include/linux/vfs_compat.h
module/zfs/zfs_ctldir.c
module/zfs/zpl_ctldir.c
module/zfs/zpl_inode.c
module/zfs/zpl_xattr.c

diff --git a/config/kernel-current-time.m4 b/config/kernel-current-time.m4
new file mode 100644 (file)
index 0000000..2ede9ff
--- /dev/null
@@ -0,0 +1,19 @@
+dnl #
+dnl # 4.9, current_time() added
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_CURRENT_TIME],
+       [AC_MSG_CHECKING([whether current_time() exists])
+       ZFS_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/fs.h>
+       ], [
+               struct inode ip;
+               struct timespec now __attribute__ ((unused));
+
+               now = current_time(&ip);
+       ], [current_time], [fs/inode.c], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_CURRENT_TIME, 1, [current_time() exists])
+       ], [
+               AC_MSG_RESULT(no)
+       ])
+])
index 57dad7b3aa88837f1318347b23f0fffc8987ad7c..c96c8b17fd626538c756a6bc3952a07b4619bbef 100644 (file)
@@ -118,6 +118,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
        ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
        ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
+       ZFS_AC_KERNEL_CURRENT_TIME
 
        AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
                KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
index 4e61b1d0901795f219ce223e53d80d4518465eb0..0085aa850394804382b0a9b9ea7e0dcdb9018be0 100644 (file)
@@ -565,5 +565,16 @@ func(const struct path *path, struct kstat *stat, u32 request_mask,        \
 #error
 #endif
 
+/*
+ * 4.9 API change
+ * Preferred interface to get the current FS time.
+ */
+#if !defined(HAVE_CURRENT_TIME)
+static inline struct timespec
+current_time(struct inode *ip)
+{
+       return (timespec_trunc(current_kernel_time(), ip->i_sb->s_time_gran));
+}
+#endif
 
 #endif /* _ZFS_VFS_H */
index eea1bb2e80317f163db82381c7eab5fae5940f4b..0c90532c1039de8a4093015f1531fa9915ef2e85 100644 (file)
@@ -451,7 +451,7 @@ static struct inode *
 zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
     const struct file_operations *fops, const struct inode_operations *ops)
 {
-       struct timespec now = current_fs_time(zfsvfs->z_sb);
+       struct timespec now;
        struct inode *ip;
        znode_t *zp;
 
@@ -459,6 +459,7 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
        if (ip == NULL)
                return (NULL);
 
+       now = current_time(ip);
        zp = ITOZ(ip);
        ASSERT3P(zp->z_dirlocks, ==, NULL);
        ASSERT3P(zp->z_acl_cached, ==, NULL);
index bd8af3928835ac4f07f310e617049d22a6a0f4cd..1c5fb34e656a02da665d87b2da566910f0f94fbb 100644 (file)
@@ -103,8 +103,10 @@ static int
 zpl_root_getattr_impl(const struct path *path, struct kstat *stat,
     u32 request_mask, unsigned int query_flags)
 {
-       generic_fillattr(path->dentry->d_inode, stat);
-       stat->atime = CURRENT_TIME;
+       struct inode *ip = path->dentry->d_inode;
+
+       generic_fillattr(ip, stat);
+       stat->atime = current_time(ip);
 
        return (0);
 }
@@ -377,14 +379,15 @@ static int
 zpl_snapdir_getattr_impl(const struct path *path, struct kstat *stat,
     u32 request_mask, unsigned int query_flags)
 {
-       zfsvfs_t *zfsvfs = ITOZSB(path->dentry->d_inode);
+       struct inode *ip = path->dentry->d_inode;
+       zfsvfs_t *zfsvfs = ITOZSB(ip);
 
        ZFS_ENTER(zfsvfs);
-       generic_fillattr(path->dentry->d_inode, stat);
+       generic_fillattr(ip, stat);
 
        stat->nlink = stat->size = 2;
        stat->ctime = stat->mtime = dmu_objset_snap_cmtime(zfsvfs->z_os);
-       stat->atime = CURRENT_TIME;
+       stat->atime = current_time(ip);
        ZFS_EXIT(zfsvfs);
 
        return (0);
@@ -522,7 +525,7 @@ zpl_shares_getattr_impl(const struct path *path, struct kstat *stat,
        if (zfsvfs->z_shares_dir == 0) {
                generic_fillattr(path->dentry->d_inode, stat);
                stat->nlink = stat->size = 2;
-               stat->atime = CURRENT_TIME;
+               stat->atime = current_time(ip);
                ZFS_EXIT(zfsvfs);
                return (0);
        }
index 8351ab5a0c62b2fff32c830181f677137b9de442..3b5643d09177944ed80f877605e6ca0f91bf55bb 100644 (file)
@@ -596,7 +596,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
                return (-EMLINK);
 
        crhold(cr);
-       ip->i_ctime = CURRENT_TIME_SEC;
+       ip->i_ctime = current_time(ip);
        igrab(ip); /* Use ihold() if available */
 
        cookie = spl_fstrans_mark();
index 5edabedd3c2ea4a540b3bdd92b3145b91e7048c2..d3bb4bbf8c49dea572c222608341356ec4f228ff 100644 (file)
@@ -938,7 +938,6 @@ xattr_handler_t zpl_xattr_security_handler = {
 int
 zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
 {
-       struct super_block *sb = ITOZSB(ip)->z_sb;
        char *name, *value = NULL;
        int error = 0;
        size_t size = 0;
@@ -964,7 +963,7 @@ zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
                                 */
                                if (ip->i_mode != mode) {
                                        ip->i_mode = mode;
-                                       ip->i_ctime = current_fs_time(sb);
+                                       ip->i_ctime = current_time(ip);
                                        zfs_mark_inode_dirty(ip);
                                }
 
@@ -1130,7 +1129,7 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
 
                if (!acl) {
                        ip->i_mode &= ~current_umask();
-                       ip->i_ctime = current_fs_time(ITOZSB(ip)->z_sb);
+                       ip->i_ctime = current_time(ip);
                        zfs_mark_inode_dirty(ip);
                        return (0);
                }