From af26c4d4ab545767456d8c21ed48e9e01ce6a3e7 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 13 Oct 2012 18:44:15 -0700 Subject: [PATCH 1/5] Linux 3.6 compat, sops->write_super() removed The .write_super callback was removed the the super_operations structure by Linux commit f0cd2dbb6cf387c11f87265462e370bb5469299e. All file systems are now expected to self manage writing any dirty state assoicated with their super block. ZFS never made use of this callback so it can simply be removed from the super_operations structure. Signed-off-by: Yuxuan Shui Signed-off-by: Brian Behlendorf Issue #873 --- module/zfs/zpl_super.c | 1 - 1 file changed, 1 deletion(-) diff --git a/module/zfs/zpl_super.c b/module/zfs/zpl_super.c index 29d7f7dfbb..fd4f691e19 100644 --- a/module/zfs/zpl_super.c +++ b/module/zfs/zpl_super.c @@ -316,7 +316,6 @@ const struct super_operations zpl_super_operations = { .delete_inode = zpl_inode_delete, #endif /* HAVE_EVICT_INODE */ .put_super = zpl_put_super, - .write_super = NULL, .sync_fs = zpl_sync_fs, .statfs = zpl_statfs, .remount_fs = zpl_remount_fs, From 3c203610756f98f275c7c9f731d67a38b1111509 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 12 Oct 2012 21:40:53 +0800 Subject: [PATCH 2/5] Linux 3.6 compat, sget() As of Linux commit 9249e17fe094d853d1ef7475dd559a2cc7e23d42 the mount flags are now passed to sget() so they can be used when initializing a new superblock. ZFS never uses sget() in this fashion so we can simply pass a zero and add a zpl_sget() compatibility wrapper. Signed-off-by: Yuxuan Shui Signed-off-by: Brian Behlendorf Issue #873 --- config/kernel-sget-args.m4 | 23 +++++++++++++++++++++++ config/kernel.m4 | 1 + include/linux/vfs_compat.h | 10 ++++++++++ module/zfs/zfs_ctldir.c | 4 ++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 config/kernel-sget-args.m4 diff --git a/config/kernel-sget-args.m4 b/config/kernel-sget-args.m4 new file mode 100644 index 0000000000..9d1745925f --- /dev/null +++ b/config/kernel-sget-args.m4 @@ -0,0 +1,23 @@ +dnl # +dnl # 3.6 API change, +dnl # 'sget' now takes the mount flags as an argument. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_5ARG_SGET], + [AC_MSG_CHECKING([whether sget() wants 5 args]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct file_system_type *type = NULL; + int (*test)(struct super_block *,void *) = NULL; + int (*set)(struct super_block *,void *) = NULL; + int flags = 0; + void *data = NULL; + (void) sget(type, test, set, flags, data); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_5ARG_SGET, 1, [sget() wants 5 args]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + diff --git a/config/kernel.m4 b/config/kernel.m4 index 89b0a9806b..3a144a3371 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -68,6 +68,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER ZFS_AC_KERNEL_SET_NLINK ZFS_AC_KERNEL_ELEVATOR_CHANGE + ZFS_AC_KERNEL_5ARG_SGET AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h index 9343f99a5a..7181625dfd 100644 --- a/include/linux/vfs_compat.h +++ b/include/linux/vfs_compat.h @@ -131,4 +131,14 @@ typedef int zpl_umode_t; #define clear_inode(ip) end_writeback(ip) #endif /* HAVE_EVICT_INODE && !HAVE_CLEAR_INODE */ +/* + * 3.6 API change, + * The sget() helper function now takes the mount flags as an argument. + */ +#ifdef HAVE_5ARG_SGET +#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, fl, mtd) +#else +#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, mtd) +#endif /* HAVE_5ARG_SGET */ + #endif /* _ZFS_VFS_H */ diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index c49d7172a2..55d1696543 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -920,8 +920,8 @@ zfsctl_lookup_objset(struct super_block *sb, uint64_t objsetid, zfs_sb_t **zsbp) * race cannot occur to an expired mount point because * we hold the zsb->z_ctldir_lock to prevent the race. */ - sbp = sget(&zpl_fs_type, zfsctl_test_super, - zfsctl_set_super, &id); + sbp = zpl_sget(&zpl_fs_type, zfsctl_test_super, + zfsctl_set_super, 0, &id); if (IS_ERR(sbp)) { error = -PTR_ERR(sbp); } else { From 8f195a908ffaa8faf8f4c8a0e701e44ae3859e33 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 12 Oct 2012 22:41:06 +0800 Subject: [PATCH 3/5] Linux 3.6 compat, iops->lookup() As of Linux commit 00cd8dd3bf95f2cc8435b4cac01d9995635c6d0b the struct nameidata is no longer passed to iops->lookup. Instead only the inamedata->flags are passed. ZFS like almost all Linux fileystems never made use of this so only the prototype needs to be wrapped for compatibility. Signed-off-by: Yuxuan Shui Signed-off-by: Brian Behlendorf Issue #873 --- config/kernel-lookup-nameidata.m4 | 21 +++++++++++++++++++++ config/kernel.m4 | 1 + module/zfs/zpl_ctldir.c | 15 +++++++++++++++ module/zfs/zpl_inode.c | 4 ++++ 4 files changed, 41 insertions(+) create mode 100644 config/kernel-lookup-nameidata.m4 diff --git a/config/kernel-lookup-nameidata.m4 b/config/kernel-lookup-nameidata.m4 new file mode 100644 index 0000000000..5e30be4335 --- /dev/null +++ b/config/kernel-lookup-nameidata.m4 @@ -0,0 +1,21 @@ +dnl # +dnl # 3.6 API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_LOOKUP_NAMEIDATA], [ + AC_MSG_CHECKING([whether iops->lookup() takes struct nameidata]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + struct dentry * (*inode_lookup) (struct inode *,struct dentry *, + struct nameidata *) = NULL; + struct inode_operations iops __attribute__ ((unused)) = { + .lookup = inode_lookup, + }; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LOOKUP_NAMEIDATA, 1, + [iops->lookup() operation takes nameidata]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 3a144a3371..8d8cd6b48e 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -49,6 +49,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_NR_CACHED_OBJECTS ZFS_AC_KERNEL_FREE_CACHED_OBJECTS ZFS_AC_KERNEL_FALLOCATE + ZFS_AC_KERNEL_LOOKUP_NAMEIDATA ZFS_AC_KERNEL_TRUNCATE_RANGE ZFS_AC_KERNEL_CREATE_UMODE_T ZFS_AC_KERNEL_AUTOMOUNT diff --git a/module/zfs/zpl_ctldir.c b/module/zfs/zpl_ctldir.c index c680e54431..7dfaf6ebcc 100644 --- a/module/zfs/zpl_ctldir.c +++ b/module/zfs/zpl_ctldir.c @@ -143,7 +143,11 @@ zpl_root_getattr(struct vfsmount *mnt, struct dentry *dentry, } static struct dentry * +#ifdef HAVE_LOOKUP_NAMEIDATA zpl_root_lookup(struct inode *dip, struct dentry *dentry, struct nameidata *nd) +#else +zpl_root_lookup(struct inode *dip, struct dentry *dentry, unsigned int flags) +#endif { cred_t *cr = CRED(); struct inode *ip; @@ -180,8 +184,14 @@ const struct inode_operations zpl_ops_root = { }; static struct dentry * +#ifdef HAVE_LOOKUP_NAMEIDATA zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry, struct nameidata *nd) +#else +zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry, + unsigned int flags) +#endif + { cred_t *cr = CRED(); struct inode *ip; @@ -410,8 +420,13 @@ const struct dentry_operations zpl_dops_snapdirs = { #endif /* HAVE_AUTOMOUNT */ static struct dentry * +#ifdef HAVE_LOOKUP_NAMEIDATA zpl_shares_lookup(struct inode *dip, struct dentry *dentry, struct nameidata *nd) +#else +zpl_shares_lookup(struct inode *dip, struct dentry *dentry, + unsigned int flags) +#endif { cred_t *cr = CRED(); struct inode *ip = NULL; diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c index 0dab82cc09..5b31c126cd 100644 --- a/module/zfs/zpl_inode.c +++ b/module/zfs/zpl_inode.c @@ -31,7 +31,11 @@ static struct dentry * +#ifdef HAVE_LOOKUP_NAMEIDATA zpl_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) +#else +zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) +#endif { cred_t *cr = CRED(); struct inode *ip; From 558ef6d0805457654938dbe56c9a19b0121a712d Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 12 Oct 2012 23:20:58 +0800 Subject: [PATCH 4/5] Linux 3.6 compat, iops->create() As of Linux commit ebfc3b49a7ac25920cb5be5445f602e51d2ea559 the struct nameidata is no longer passed to iops->create. Instead only the result of (inamedata->flags & LOOKUP_EXCL) is passed. ZFS like almost all Linux fileystems never made use of this so only the prototype needs to be wrapped for compatibility. Signed-off-by: Yuxuan Shui Signed-off-by: Brian Behlendorf Issue #873 --- config/kernel-create-nameidata.m4 | 26 ++++++++++++++++++++++++++ config/kernel.m4 | 1 + module/zfs/zpl_inode.c | 5 +++++ 3 files changed, 32 insertions(+) create mode 100644 config/kernel-create-nameidata.m4 diff --git a/config/kernel-create-nameidata.m4 b/config/kernel-create-nameidata.m4 new file mode 100644 index 0000000000..100f077612 --- /dev/null +++ b/config/kernel-create-nameidata.m4 @@ -0,0 +1,26 @@ +dnl # +dnl # 3.6 API change +dnl # +AC_DEFUN([ZFS_AC_KERNEL_CREATE_NAMEIDATA], [ + AC_MSG_CHECKING([whether iops->create() takes struct nameidata]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + #ifdef HAVE_MKDIR_UMODE_T + int (*inode_create) (struct inode *,struct dentry *, + umode_t, struct nameidata *) = NULL; + #else + int (*inode_create) (struct inode *,struct dentry *, + int, struct nameidata *) = NULL; + #endif + struct inode_operations iops __attribute__ ((unused)) = { + .create = inode_create, + }; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CREATE_NAMEIDATA, 1, + [iops->create() operation takes nameidata]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 8d8cd6b48e..dd01fb28b4 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -50,6 +50,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_FREE_CACHED_OBJECTS ZFS_AC_KERNEL_FALLOCATE ZFS_AC_KERNEL_LOOKUP_NAMEIDATA + ZFS_AC_KERNEL_CREATE_NAMEIDATA ZFS_AC_KERNEL_TRUNCATE_RANGE ZFS_AC_KERNEL_CREATE_UMODE_T ZFS_AC_KERNEL_AUTOMOUNT diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c index 5b31c126cd..bb389f8375 100644 --- a/module/zfs/zpl_inode.c +++ b/module/zfs/zpl_inode.c @@ -75,8 +75,13 @@ zpl_vap_init(vattr_t *vap, struct inode *dir, struct dentry *dentry, } static int +#ifdef HAVE_CREATE_NAMEIDATA zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode, struct nameidata *nd) +#else +zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode, + bool flag) +#endif { cred_t *cr = CRED(); struct inode *ip; From 95f5c63b47d8f8294b38843f9ba710e97b749b63 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Thu, 16 Aug 2012 19:31:54 -0400 Subject: [PATCH 5/5] Linux 3.6 compat, iops->mkdir() Use .mkdir instead of .create in 3.3 compatibility check. Linux 3.6 modifies inode_operations->create's function prototype. This causes an autotools Linux 3.3. compatibility check for a function prototype change in create, mkdir and mknode to fail. Since mkdir and mknode are unchanged, we modify the check to examine it instead. Signed-off-by: Richard Yao Signed-off-by: Brian Behlendorf Issue #873 --- ...{kernel-create-umode-t.m4 => kernel-mkdir-umode-t.m4} | 9 ++++----- config/kernel.m4 | 2 +- include/linux/vfs_compat.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) rename config/{kernel-create-umode-t.m4 => kernel-mkdir-umode-t.m4} (77%) diff --git a/config/kernel-create-umode-t.m4 b/config/kernel-mkdir-umode-t.m4 similarity index 77% rename from config/kernel-create-umode-t.m4 rename to config/kernel-mkdir-umode-t.m4 index f88113f405..dd5d94ba97 100644 --- a/config/kernel-create-umode-t.m4 +++ b/config/kernel-mkdir-umode-t.m4 @@ -6,19 +6,18 @@ dnl # would also change all three prototypes. However, if it turns out that dnl # some distribution doesn't backport the whole thing this could be dnl # broken apart in to three seperate checks. dnl # -AC_DEFUN([ZFS_AC_KERNEL_CREATE_UMODE_T], [ +AC_DEFUN([ZFS_AC_KERNEL_MKDIR_UMODE_T], [ AC_MSG_CHECKING([whether iops->create()/mkdir()/mknod() take umode_t]) ZFS_LINUX_TRY_COMPILE([ #include ],[ - int (*create) (struct inode *, struct dentry *, umode_t, - struct nameidata *) = NULL; + int (*mkdir) (struct inode *,struct dentry *,umode_t) = NULL; struct inode_operations iops __attribute__ ((unused)) = { - .create = create, + .mkdir = mkdir, }; ],[ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CREATE_UMODE_T, 1, + AC_DEFINE(HAVE_MKDIR_UMODE_T, 1, [iops->create()/mkdir()/mknod() take umode_t]) ],[ AC_MSG_RESULT(no) diff --git a/config/kernel.m4 b/config/kernel.m4 index dd01fb28b4..13238d8ac2 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -49,10 +49,10 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_NR_CACHED_OBJECTS ZFS_AC_KERNEL_FREE_CACHED_OBJECTS ZFS_AC_KERNEL_FALLOCATE + ZFS_AC_KERNEL_MKDIR_UMODE_T ZFS_AC_KERNEL_LOOKUP_NAMEIDATA ZFS_AC_KERNEL_CREATE_NAMEIDATA ZFS_AC_KERNEL_TRUNCATE_RANGE - ZFS_AC_KERNEL_CREATE_UMODE_T ZFS_AC_KERNEL_AUTOMOUNT ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE ZFS_AC_KERNEL_COMMIT_METADATA diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h index 7181625dfd..c4e1771ae5 100644 --- a/include/linux/vfs_compat.h +++ b/include/linux/vfs_compat.h @@ -115,7 +115,7 @@ set_nlink(struct inode *inode, unsigned int nlink) * umode_t type rather than an int. To cleanly handle both definitions * the zpl_umode_t type is introduced and set accordingly. */ -#ifdef HAVE_CREATE_UMODE_T +#ifdef HAVE_MKDIR_UMODE_T typedef umode_t zpl_umode_t; #else typedef int zpl_umode_t;