]> granicus.if.org Git - zfs/commitdiff
Linux 4.16 compat: inode_set_iversion()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 8 Feb 2018 22:27:59 +0000 (14:27 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 9 Feb 2018 05:25:19 +0000 (21:25 -0800)
A new interface was added to manipulate the version field of an
inode.  Add a inode_set_iversion() wrapper for older kernels and
use the new interface when available.

The i_version field was dropped from the trace point due to the
switch to an atomic64_t i_version type.

Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7148

config/kernel-inode-set-iversion.m4 [new file with mode: 0644]
config/kernel.m4
include/linux/vfs_compat.h
include/sys/trace_acl.h
module/zfs/zpl_super.c

diff --git a/config/kernel-inode-set-iversion.m4 b/config/kernel-inode-set-iversion.m4
new file mode 100644 (file)
index 0000000..9a7d789
--- /dev/null
@@ -0,0 +1,19 @@
+dnl #
+dnl # 4.16 API change
+dnl # inode_set_iversion introduced to set i_version
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_INODE_SET_IVERSION], [
+       AC_MSG_CHECKING([whether inode_set_iversion() exists])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/iversion.h>
+       ],[
+               struct inode inode;
+               inode_set_iversion(&inode, 1);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_INODE_SET_IVERSION, 1,
+                   [inode_set_iversion() exists])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
index f8d81cdc0fb5b3fbdc6d4f56a790fd7287f969a0..805ec60a148345e6667c69e9e5f494cce7351832 100644 (file)
@@ -65,6 +65,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
        ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR
        ZFS_AC_KERNEL_INODE_SET_FLAGS
+       ZFS_AC_KERNEL_INODE_SET_IVERSION
        ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
        ZFS_AC_KERNEL_SHOW_OPTIONS
        ZFS_AC_KERNEL_FILE_INODE
index 6111f0afca1d86332900654b78f836267abb17f3..f51ff887d6aebe7e1916e26f2f63302f04176074 100644 (file)
@@ -578,4 +578,18 @@ current_time(struct inode *ip)
 }
 #endif
 
+/*
+ * 4.16 API change
+ * Added iversion interface for managing inode version field.
+ */
+#ifdef HAVE_INODE_SET_IVERSION
+#include <linux/iversion.h>
+#else
+static inline void
+inode_set_iversion(struct inode *ip, u64 val)
+{
+       ip->i_version = val;
+}
+#endif
+
 #endif /* _ZFS_VFS_H */
index 1057e560ba6c582041a8f1d2c283a3bac4fba8b9..610bbe29c25c19842631dd4720f6be8223d3685f 100644 (file)
@@ -68,7 +68,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
            __field(uint32_t,           i_gid)
            __field(unsigned long,      i_ino)
            __field(unsigned int,       i_nlink)
-           __field(u64,                i_version)
            __field(loff_t,             i_size)
            __field(unsigned int,       i_blkbits)
            __field(unsigned short,     i_bytes)
@@ -103,7 +102,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
            __entry->i_gid              = KGID_TO_SGID(ZTOI(zn)->i_gid);
            __entry->i_ino              = zn->z_inode.i_ino;
            __entry->i_nlink            = zn->z_inode.i_nlink;
-           __entry->i_version          = zn->z_inode.i_version;
            __entry->i_size             = zn->z_inode.i_size;
            __entry->i_blkbits          = zn->z_inode.i_blkbits;
            __entry->i_bytes            = zn->z_inode.i_bytes;
@@ -121,7 +119,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
            "mapcnt %llu size %llu pflags %llu "
            "sync_cnt %u mode 0x%x is_sa %d "
            "is_mapped %d is_ctldir %d is_stale %d inode { "
-           "uid %u gid %u ino %lu nlink %u version %llu size %lli "
+           "uid %u gid %u ino %lu nlink %u size %lli "
            "blkbits %u bytes %u mode 0x%x generation %x } } "
            "ace { type %u flags %u access_mask %u } mask_matched %u",
            __entry->z_id, __entry->z_unlinked, __entry->z_atime_dirty,
@@ -131,7 +129,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
            __entry->z_is_sa, __entry->z_is_mapped,
            __entry->z_is_ctldir, __entry->z_is_stale, __entry->i_uid,
            __entry->i_gid, __entry->i_ino, __entry->i_nlink,
-           __entry->i_version, __entry->i_size, __entry->i_blkbits,
+           __entry->i_size, __entry->i_blkbits,
            __entry->i_bytes, __entry->i_mode, __entry->i_generation,
            __entry->z_type, __entry->z_flags, __entry->z_access_mask,
            __entry->mask_matched)
index b6ef60277664b76b086ad5ba7836a9163ace5ece..25e75a897355710dfce2ff0facea2509fb8c4f36 100644 (file)
@@ -36,7 +36,7 @@ zpl_inode_alloc(struct super_block *sb)
        struct inode *ip;
 
        VERIFY3S(zfs_inode_alloc(sb, &ip), ==, 0);
-       ip->i_version = 1;
+       inode_set_iversion(ip, 1);
 
        return (ip);
 }