[Pkg-zfsonlinux-devel] [SCM] zfs branch, master, updated. debian/0.6.5.8-3-1-g9d894ff

Aron Xu aron at debian.org
Fri Jan 27 15:03:52 UTC 2017


The following commit has been merged in the master branch:
commit 9d894ff17aacc639836e0f52573c408a8f79ff0a
Author: Aron Xu <aron at debian.org>
Date:   Fri Jan 27 22:59:31 2017 +0800

    Linux 4.9 compatibility (Closes: #851513)

diff --git a/.pc/.quilt_patches b/.pc/.quilt_patches
new file mode 100644
index 0000000..6857a8d
--- /dev/null
+++ b/.pc/.quilt_patches
@@ -0,0 +1 @@
+debian/patches
diff --git a/.pc/.quilt_series b/.pc/.quilt_series
new file mode 100644
index 0000000..c206706
--- /dev/null
+++ b/.pc/.quilt_series
@@ -0,0 +1 @@
+series
diff --git a/.pc/.version b/.pc/.version
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/.pc/.version
@@ -0,0 +1 @@
+2
diff --git a/debian/patches/0001-Fix-for-Linux-4.9-compat-iops-rename-wants-flags.patch b/debian/patches/0001-Fix-for-Linux-4.9-compat-iops-rename-wants-flags.patch
new file mode 100644
index 0000000..6d6bd77
--- /dev/null
+++ b/debian/patches/0001-Fix-for-Linux-4.9-compat-iops-rename-wants-flags.patch
@@ -0,0 +1,29 @@
+From 255eba94114b14fe2ce81725b6998f613b5f687d Mon Sep 17 00:00:00 2001
+From: Tim Gardner <tim.gardner at canonical.com>
+Date: Wed, 23 Nov 2016 09:32:09 -0700
+Subject: [PATCH] Fix for Linux 4.9 compat: iops->rename() wants flags
+
+Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
+---
+ module/zfs/zpl_inode.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index 6b2cb67..260ceee 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -662,7 +662,11 @@ const struct inode_operations zpl_inode_operations = {
+ 	.mkdir		= zpl_mkdir,
+ 	.rmdir		= zpl_rmdir,
+ 	.mknod		= zpl_mknod,
++#ifdef HAVE_RENAME_WANTS_FLAGS
++	.rename		= zpl_rename2,
++#else
+ 	.rename		= zpl_rename,
++#endif
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
+ #ifdef HAVE_GENERIC_SETXATTR
+-- 
+2.7.4
+
diff --git a/debian/patches/0001-Linux-4.9-compat-iops-rename-wants-flags.patch b/debian/patches/0001-Linux-4.9-compat-iops-rename-wants-flags.patch
new file mode 100644
index 0000000..15b202b
--- /dev/null
+++ b/debian/patches/0001-Linux-4.9-compat-iops-rename-wants-flags.patch
@@ -0,0 +1,170 @@
+From 8df4984bbbaad779ea5a02b9168c5ac0a915a5b3 Mon Sep 17 00:00:00 2001
+From: Chunwei Chen <david.chen at osnexus.com>
+Date: Wed, 19 Oct 2016 11:19:01 -0700
+Subject: [PATCH 1/4] Linux 4.9 compat: iops->rename() wants flags
+
+In Linux 4.9, torvalds/linux at 2773bf0, iops->rename() and iops->rename2() are
+merged together into iops->rename(), it now wants flags.
+
+Signed-off-by: Chunwei Chen <david.chen at osnexus.com>
+(back ported from commit b8d9e26440ade0edebfa98af8cb9371810c1aeaf)
+Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
+---
+ config/kernel-rename.m4 | 25 +++++++++++++++++++++++++
+ config/kernel.m4        |  1 +
+ module/zfs/zpl_ctldir.c | 23 ++++++++++++++++++++---
+ module/zfs/zpl_inode.c  | 21 +++++++++++++++++++--
+ 4 files changed, 65 insertions(+), 5 deletions(-)
+ create mode 100644 config/kernel-rename.m4
+
+diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4
+new file mode 100644
+index 0000000..9f894fb
+--- /dev/null
++++ b/config/kernel-rename.m4
+@@ -0,0 +1,25 @@
++dnl #
++dnl # 4.9 API change,
++dnl # iops->rename2() merged into iops->rename(), and iops->rename() now wants
++dnl # flags.
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_RENAME_WANTS_FLAGS], [
++	AC_MSG_CHECKING([whether iops->rename() wants flags])
++	ZFS_LINUX_TRY_COMPILE([
++		#include <linux/fs.h>
++		int rename_fn(struct inode *sip, struct dentry *sdp,
++			struct inode *tip, struct dentry *tdp,
++			unsigned int flags) { return 0; }
++
++		static const struct inode_operations
++		    iops __attribute__ ((unused)) = {
++			.rename = rename_fn,
++		};
++	],[
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1, [iops->rename() wants flags])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index 53720ee..77c7935 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -98,6 +98,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
+ 	ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
+ 	ZFS_AC_KERNEL_MAKE_REQUEST_FN
+ 	ZFS_AC_KERNEL_GENERIC_IO_ACCT
++	ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
+ 
+ 	AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
+ 		KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
+diff --git a/module/zfs/zpl_ctldir.c b/module/zfs/zpl_ctldir.c
+index 069834e..d691f67 100644
+--- a/module/zfs/zpl_ctldir.c
++++ b/module/zfs/zpl_ctldir.c
+@@ -301,13 +301,17 @@ zpl_snapdir_readdir(struct file *filp, void *dirent, filldir_t filldir)
+ }
+ #endif /* HAVE_VFS_ITERATE */
+ 
+-int
+-zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
+-    struct inode *tdip, struct dentry *tdentry)
++static int
++zpl_snapdir_rename2(struct inode *sdip, struct dentry *sdentry,
++    struct inode *tdip, struct dentry *tdentry, unsigned int flags)
+ {
+ 	cred_t *cr = CRED();
+ 	int error;
+ 
++	/* We probably don't want to support renameat2(2) in ctldir */
++	if (flags)
++		return (-EINVAL);
++
+ 	crhold(cr);
+ 	error = -zfsctl_snapdir_rename(sdip, dname(sdentry),
+ 	    tdip, dname(tdentry), cr, 0);
+@@ -317,6 +321,15 @@ zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
+ 	return (error);
+ }
+ 
++#ifndef HAVE_RENAME_WANTS_FLAGS
++static int
++zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
++    struct inode *tdip, struct dentry *tdentry)
++{
++	return (zpl_snapdir_rename2(sdip, sdentry, tdip, tdentry, 0));
++}
++#endif
++
+ static int
+ zpl_snapdir_rmdir(struct inode *dip, struct dentry *dentry)
+ {
+@@ -405,7 +418,11 @@ const struct file_operations zpl_fops_snapdir = {
+ const struct inode_operations zpl_ops_snapdir = {
+ 	.lookup		= zpl_snapdir_lookup,
+ 	.getattr	= zpl_snapdir_getattr,
++#ifdef HAVE_RENAME_WANTS_FLAGS
++	.rename		= zpl_snapdir_rename2,
++#else
+ 	.rename		= zpl_snapdir_rename,
++#endif
+ 	.rmdir		= zpl_snapdir_rmdir,
+ 	.mkdir		= zpl_snapdir_mkdir,
+ };
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index cbdab7d..4f67d0e 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -349,13 +349,17 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
+ }
+ 
+ static int
+-zpl_rename(struct inode *sdip, struct dentry *sdentry,
+-    struct inode *tdip, struct dentry *tdentry)
++zpl_rename2(struct inode *sdip, struct dentry *sdentry,
++    struct inode *tdip, struct dentry *tdentry, unsigned int flags)
+ {
+ 	cred_t *cr = CRED();
+ 	int error;
+ 	fstrans_cookie_t cookie;
+ 
++	/* We don't have renameat2(2) support */
++	if (flags)
++		return (-EINVAL);
++
+ 	crhold(cr);
+ 	cookie = spl_fstrans_mark();
+ 	error = -zfs_rename(sdip, dname(sdentry), tdip, dname(tdentry), cr, 0);
+@@ -366,6 +370,15 @@ zpl_rename(struct inode *sdip, struct dentry *sdentry,
+ 	return (error);
+ }
+ 
++#ifndef HAVE_RENAME_WANTS_FLAGS
++static int
++zpl_rename(struct inode *sdip, struct dentry *sdentry,
++    struct inode *tdip, struct dentry *tdentry)
++{
++	return (zpl_rename2(sdip, sdentry, tdip, tdentry, 0));
++}
++#endif
++
+ static int
+ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
+ {
+@@ -682,7 +695,11 @@ const struct inode_operations zpl_dir_inode_operations = {
+ 	.mkdir		= zpl_mkdir,
+ 	.rmdir		= zpl_rmdir,
+ 	.mknod		= zpl_mknod,
++#ifdef HAVE_RENAME_WANTS_FLAGS
++	.rename		= zpl_rename2,
++#else
+ 	.rename		= zpl_rename,
++#endif
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
+ 	.setxattr	= generic_setxattr,
+-- 
+2.7.4
+
diff --git a/debian/patches/0002-Linux-4.9-compat-remove-iops-set-get-remove-xattr.patch b/debian/patches/0002-Linux-4.9-compat-remove-iops-set-get-remove-xattr.patch
new file mode 100644
index 0000000..bbdccae
--- /dev/null
+++ b/debian/patches/0002-Linux-4.9-compat-remove-iops-set-get-remove-xattr.patch
@@ -0,0 +1,120 @@
+From 9f81d81e450f3b59ebdbc845781f3ab9b244bb49 Mon Sep 17 00:00:00 2001
+From: Chunwei Chen <david.chen at osnexus.com>
+Date: Wed, 19 Oct 2016 11:19:17 -0700
+Subject: [PATCH 2/4] Linux 4.9 compat: remove iops->{set,get,remove}xattr
+
+In Linux 4.9, torvalds/linux at fd50eca, iops->{set,get,remove}xattr and
+generic_{set,get,remove}xattr are removed. xattr operations will directly
+go through sb->s_xattr.
+
+Signed-off-by: Chunwei Chen <david.chen at osnexus.com>
+(cherry picked from commit 0fedeedd309eca62d15fffd8bd811e2b12660e21)
+Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
+---
+ config/kernel-xattr-handler.m4 | 25 +++++++++++++++++++++++++
+ config/kernel.m4               |  1 +
+ module/zfs/zpl_inode.c         |  8 ++++++++
+ 3 files changed, 34 insertions(+)
+
+diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4
+index dcffd44..4ac08d8 100644
+--- a/config/kernel-xattr-handler.m4
++++ b/config/kernel-xattr-handler.m4
+@@ -58,6 +58,31 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_NAME], [
+ ])
+ 
+ dnl #
++dnl # 4.9 API change,
++dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are
++dnl # removed. xattr operations will directly go through sb->s_xattr.
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR], [
++	AC_MSG_CHECKING([whether generic_setxattr() exists])
++	ZFS_LINUX_TRY_COMPILE([
++		#include <linux/fs.h>
++		#include <linux/xattr.h>
++
++		static const struct inode_operations
++		    iops __attribute__ ((unused)) = {
++			.setxattr = generic_setxattr
++		};
++	],[
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_GENERIC_SETXATTR, 1,
++		    [generic_setxattr() exists])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
++
++dnl #
+ dnl # Supported xattr handler get() interfaces checked newest to oldest.
+ dnl #
+ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index 77c7935..a7b31b2 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -99,6 +99,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
+ 	ZFS_AC_KERNEL_MAKE_REQUEST_FN
+ 	ZFS_AC_KERNEL_GENERIC_IO_ACCT
+ 	ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
++	ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
+ 
+ 	AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
+ 		KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index 4f67d0e..503c807 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -665,9 +665,11 @@ const struct inode_operations zpl_inode_operations = {
+ 	.rename		= zpl_rename,
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
++#ifdef HAVE_GENERIC_SETXATTR
+ 	.setxattr	= generic_setxattr,
+ 	.getxattr	= generic_getxattr,
+ 	.removexattr	= generic_removexattr,
++#endif
+ 	.listxattr	= zpl_xattr_list,
+ #ifdef HAVE_INODE_TRUNCATE_RANGE
+ 	.truncate_range = zpl_truncate_range,
+@@ -702,9 +704,11 @@ const struct inode_operations zpl_dir_inode_operations = {
+ #endif
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
++#ifdef HAVE_GENERIC_SETXATTR
+ 	.setxattr	= generic_setxattr,
+ 	.getxattr	= generic_getxattr,
+ 	.removexattr	= generic_removexattr,
++#endif
+ 	.listxattr	= zpl_xattr_list,
+ #if defined(CONFIG_FS_POSIX_ACL)
+ #if defined(HAVE_GET_ACL)
+@@ -729,18 +733,22 @@ const struct inode_operations zpl_symlink_inode_operations = {
+ #endif
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
++#ifdef HAVE_GENERIC_SETXATTR
+ 	.setxattr	= generic_setxattr,
+ 	.getxattr	= generic_getxattr,
+ 	.removexattr	= generic_removexattr,
++#endif
+ 	.listxattr	= zpl_xattr_list,
+ };
+ 
+ const struct inode_operations zpl_special_inode_operations = {
+ 	.setattr	= zpl_setattr,
+ 	.getattr	= zpl_getattr,
++#ifdef HAVE_GENERIC_SETXATTR
+ 	.setxattr	= generic_setxattr,
+ 	.getxattr	= generic_getxattr,
+ 	.removexattr	= generic_removexattr,
++#endif
+ 	.listxattr	= zpl_xattr_list,
+ #if defined(CONFIG_FS_POSIX_ACL)
+ #if defined(HAVE_GET_ACL)
+-- 
+2.7.4
+
diff --git a/debian/patches/0003-Linux-4.9-compat-inode_change_ok-renamed-setattr_pre.patch b/debian/patches/0003-Linux-4.9-compat-inode_change_ok-renamed-setattr_pre.patch
new file mode 100644
index 0000000..196e4b6
--- /dev/null
+++ b/debian/patches/0003-Linux-4.9-compat-inode_change_ok-renamed-setattr_pre.patch
@@ -0,0 +1,102 @@
+From 4c73e4d8a11e0046c90f86a67ab58b78df70dd1c Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1 at llnl.gov>
+Date: Tue, 18 Oct 2016 23:49:23 +0000
+Subject: [PATCH 3/4] Linux 4.9 compat: inode_change_ok() renamed
+ setattr_prepare()
+
+In torvalds/linux at 31051c8 the inode_change_ok() function was
+renamed setattr_prepare() and updated to take a dentry ratheri
+than an inode.  Update the code to call the setattr_prepare()
+and add a wrapper function which call inode_change_ok() for
+older kernels.
+
+Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Signed-off-by: Chunwei Chen <david.chen at osnexus.com>
+Requires-spl: refs/pull/581/head
+(cherry picked from commit 3b0ba3ba99b8a3af0fb532bf264629436b1abd84)
+Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
+---
+ config/kernel-setattr-prepare.m4 | 23 +++++++++++++++++++++++
+ config/kernel.m4                 |  1 +
+ include/linux/vfs_compat.h       | 11 +++++++++++
+ module/zfs/zpl_inode.c           |  2 +-
+ 4 files changed, 36 insertions(+), 1 deletion(-)
+ create mode 100644 config/kernel-setattr-prepare.m4
+
+diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4
+new file mode 100644
+index 0000000..32f7deb
+--- /dev/null
++++ b/config/kernel-setattr-prepare.m4
+@@ -0,0 +1,23 @@
++dnl #
++dnl # 4.9 API change
++dnl # The inode_change_ok() function has been renamed setattr_prepare()
++dnl # and updated to take a dentry rather than an inode.
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SETATTR_PREPARE],
++	[AC_MSG_CHECKING([whether setattr_prepare() is available])
++	ZFS_LINUX_TRY_COMPILE_SYMBOL([
++		#include <linux/fs.h>
++	], [
++		struct dentry *dentry = NULL;
++		struct iattr *attr = NULL;
++		int error;
++
++		error = setattr_prepare(dentry, attr);
++	], [setattr_prepare], [fs/attr.c], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_SETATTR_PREPARE, 1,
++		    [setattr_prepare() is available])
++	], [
++		AC_MSG_RESULT(no)
++	])
++])
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index a7b31b2..1b84e1a 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -71,6 +71,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
+ 	ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
+ 	ZFS_AC_KERNEL_COMMIT_METADATA
+ 	ZFS_AC_KERNEL_CLEAR_INODE
++	ZFS_AC_KERNEL_SETATTR_PREPARE
+ 	ZFS_AC_KERNEL_INSERT_INODE_LOCKED
+ 	ZFS_AC_KERNEL_D_MAKE_ROOT
+ 	ZFS_AC_KERNEL_D_OBTAIN_ALIAS
+diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
+index b4881a6..6fc1ec5 100644
+--- a/include/linux/vfs_compat.h
++++ b/include/linux/vfs_compat.h
+@@ -362,4 +362,15 @@ static inline struct inode *file_inode(const struct file *f)
+ #define	zpl_follow_up(path)			follow_up(path)
+ #endif
+ 
++/*
++ * 4.9 API change
++ */
++#ifndef HAVE_SETATTR_PREPARE
++static inline int
++setattr_prepare(struct dentry *dentry, struct iattr *ia)
++{
++	return (inode_change_ok(dentry->d_inode, ia));
++}
++#endif
++
+ #endif /* _ZFS_VFS_H */
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index 503c807..6b2cb67 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -320,7 +320,7 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
+ 	int error;
+ 	fstrans_cookie_t cookie;
+ 
+-	error = inode_change_ok(ip, ia);
++	error = setattr_prepare(dentry, ia);
+ 	if (error)
+ 		return (error);
+ 
+-- 
+2.7.4
+
diff --git a/debian/patches/0004-Kernel-4.9-compat-file_operations-aio_fsync-removal.patch b/debian/patches/0004-Kernel-4.9-compat-file_operations-aio_fsync-removal.patch
new file mode 100644
index 0000000..f3cad5f
--- /dev/null
+++ b/debian/patches/0004-Kernel-4.9-compat-file_operations-aio_fsync-removal.patch
@@ -0,0 +1,122 @@
+From 646d0bc372fb898309e415f13e8f8acdc36c96e2 Mon Sep 17 00:00:00 2001
+From: DeHackEd <DeHackEd at users.noreply.github.com>
+Date: Tue, 15 Nov 2016 12:20:46 -0500
+Subject: [PATCH 4/4] Kernel 4.9 compat: file_operations->aio_fsync removal
+
+Linux kernel commit 723c038475b78 removed this field.
+
+Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Signed-off-by: DHE <git at dehacked.net>
+Closes #5393
+(cherry picked from commit 7ca25051b6470e8471b4ed454d8c66ff21338de3)
+
+Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
+---
+ config/kernel-aio-fsync.m4 | 21 +++++++++++++++++++++
+ config/kernel.m4           |  1 +
+ module/zfs/zpl_file.c      | 11 +++++++++++
+ 3 files changed, 33 insertions(+)
+ create mode 100644 config/kernel-aio-fsync.m4
+
+diff --git a/config/kernel-aio-fsync.m4 b/config/kernel-aio-fsync.m4
+new file mode 100644
+index 0000000..41b7a98
+--- /dev/null
++++ b/config/kernel-aio-fsync.m4
+@@ -0,0 +1,21 @@
++dnl #
++dnl # Linux 4.9-rc5+ ABI, removal of the .aio_fsync field
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_AIO_FSYNC], [
++	AC_MSG_CHECKING([whether fops->aio_fsync() exists])
++	ZFS_LINUX_TRY_COMPILE([
++		#include <linux/fs.h>
++
++		static const struct file_operations
++		    fops __attribute__ ((unused)) = {
++			.aio_fsync = NULL,
++		};
++	],[
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_FILE_AIO_FSYNC, 1, [fops->aio_fsync() exists])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
++
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index 1b84e1a..290d71b 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -61,6 +61,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_AIO_FSYNC
+ 	ZFS_AC_KERNEL_MKDIR_UMODE_T
+ 	ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
+ 	ZFS_AC_KERNEL_CREATE_NAMEIDATA
+diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
+index a629b59..ccb8f81 100644
+--- a/module/zfs/zpl_file.c
++++ b/module/zfs/zpl_file.c
+@@ -131,12 +131,15 @@ zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
+ 	return (error);
+ }
+ 
++#ifdef HAVE_FILE_AIO_FSYNC
+ static int
+ zpl_aio_fsync(struct kiocb *kiocb, int datasync)
+ {
+ 	struct file *filp = kiocb->ki_filp;
+ 	return (zpl_fsync(filp, filp->f_path.dentry, datasync));
+ }
++#endif
++
+ #elif defined(HAVE_FSYNC_WITHOUT_DENTRY)
+ /*
+  * Linux 2.6.35 - 3.0 API,
+@@ -162,11 +165,14 @@ zpl_fsync(struct file *filp, int datasync)
+ 	return (error);
+ }
+ 
++#ifdef HAVE_FILE_AIO_FSYNC
+ static int
+ zpl_aio_fsync(struct kiocb *kiocb, int datasync)
+ {
+ 	return (zpl_fsync(kiocb->ki_filp, datasync));
+ }
++#endif
++
+ #elif defined(HAVE_FSYNC_RANGE)
+ /*
+  * Linux 3.1 - 3.x API,
+@@ -197,11 +203,14 @@ zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
+ 	return (error);
+ }
+ 
++#ifdef HAVE_FILE_AIO_FSYNC
+ static int
+ zpl_aio_fsync(struct kiocb *kiocb, int datasync)
+ {
+ 	return (zpl_fsync(kiocb->ki_filp, kiocb->ki_pos, -1, datasync));
+ }
++#endif
++
+ #else
+ #error "Unsupported fops->fsync() implementation"
+ #endif
+@@ -838,7 +847,9 @@ const struct file_operations zpl_file_operations = {
+ #endif
+ 	.mmap		= zpl_mmap,
+ 	.fsync		= zpl_fsync,
++#ifdef HAVE_FILE_AIO_FSYNC
+ 	.aio_fsync	= zpl_aio_fsync,
++#endif
+ #ifdef HAVE_FILE_FALLOCATE
+ 	.fallocate	= zpl_fallocate,
+ #endif /* HAVE_FILE_FALLOCATE */
+-- 
+2.7.4
+
diff --git a/debian/patches/1002-Fix-dev-zfs-device-is-missing.patch b/debian/patches/1002-Fix-dev-zfs-device-is-missing.patch
new file mode 100644
index 0000000..6de6622
--- /dev/null
+++ b/debian/patches/1002-Fix-dev-zfs-device-is-missing.patch
@@ -0,0 +1,265 @@
+Description: Change /etc/mtab to /proc/self/mounts
+ Fix misleading error message: "The /dev/zfs device is missing and must be created.", if /etc/mtab is missing.
+Author: Eric Desrochers <eric.desrochers at canonical.com>
+Origin: https://github.com/zfsonlinux/zfs/commit/792517389fad5c495a2738b61c2e9c65dedaaa9a
+Bug: https://github.com/zfsonlinux/zfs/issues/4680
+--- a/cmd/mount_zfs/mount_zfs.c
++++ b/cmd/mount_zfs/mount_zfs.c
+@@ -292,11 +292,11 @@
+ 	struct stat st;
+ 	int error, fd;
+ 
+-	error = lstat(MNTTAB, &st);
++	error = lstat("/etc/mtab", &st);
+ 	if (error || S_ISLNK(st.st_mode))
+ 		return (0);
+ 
+-	fd = open(MNTTAB, O_RDWR | O_CREAT, 0644);
++	fd = open("/etc/mtab", O_RDWR | O_CREAT, 0644);
+ 	if (fd < 0)
+ 		return (0);
+ 
+@@ -318,21 +318,21 @@
+ 	mnt.mnt_freq = 0;
+ 	mnt.mnt_passno = 0;
+ 
+-	fp = setmntent(MNTTAB, "a+");
++	fp = setmntent("/etc/mtab", "a+");
+ 	if (!fp) {
+ 		(void) fprintf(stderr, gettext(
+-		    "filesystem '%s' was mounted, but %s "
++		    "filesystem '%s' was mounted, but /etc/mtab "
+ 		    "could not be opened due to error %d\n"),
+-		    dataset, MNTTAB, errno);
++		    dataset, errno);
+ 		return (MOUNT_FILEIO);
+ 	}
+ 
+ 	error = addmntent(fp, &mnt);
+ 	if (error) {
+ 		(void) fprintf(stderr, gettext(
+-		    "filesystem '%s' was mounted, but %s "
++		    "filesystem '%s' was mounted, but /etc/mtab "
+ 		    "could not be updated due to error %d\n"),
+-		    dataset, MNTTAB, errno);
++		    dataset, errno);
+ 		return (MOUNT_FILEIO);
+ 	}
+ 
+--- a/cmd/zfs/zfs_main.c
++++ b/cmd/zfs/zfs_main.c
+@@ -5978,9 +5978,10 @@
+ 		}
+ 
+ 		/*
+-		 * When mount is given no arguments, go through /etc/mtab and
+-		 * display any active ZFS mounts.  We hide any snapshots, since
+-		 * they are controlled automatically.
++		 * When mount is given no arguments, go through
++		 * /proc/self/mounts and display any active ZFS mounts.
++		 * We hide any snapshots, since they are controlled
++		 * automatically.
+ 		 */
+ 
+ 		/* Reopen MNTTAB to prevent reading stale data from open file */
+@@ -6060,8 +6061,8 @@
+ 
+ /*
+  * Convenience routine used by zfs_do_umount() and manual_unmount().  Given an
+- * absolute path, find the entry /etc/mtab, verify that its a ZFS filesystem,
+- * and unmount it appropriately.
++ * absolute path, find the entry /proc/self/mounts, verify that its a
++ * ZFS filesystem, and unmount it appropriately.
+  */
+ static int
+ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
+@@ -6074,7 +6075,7 @@
+ 	ino_t path_inode;
+ 
+ 	/*
+-	 * Search for the path in /etc/mtab.  Rather than looking for the
++	 * Search for the path in /proc/self/mounts.  Rather than looking for the
+ 	 * specific path, which can be fooled by non-standard paths (i.e. ".."
+ 	 * or "//"), we stat() the path and search for the corresponding
+ 	 * (major,minor) device pair.
+@@ -6105,8 +6106,8 @@
+ 			    "currently mounted\n"), cmdname, path);
+ 			return (1);
+ 		}
+-		(void) fprintf(stderr, gettext("warning: %s not in mtab\n"),
+-		    path);
++		(void) fprintf(stderr, gettext("warning: %s not in"
++		    "/proc/self/mounts\n"), path);
+ 		if ((ret = umount2(path, flags)) != 0)
+ 			(void) fprintf(stderr, gettext("%s: %s\n"), path,
+ 			    strerror(errno));
+@@ -6217,9 +6218,9 @@
+ 		/*
+ 		 * We could make use of zfs_for_each() to walk all datasets in
+ 		 * the system, but this would be very inefficient, especially
+-		 * since we would have to linearly search /etc/mtab for each
+-		 * one.  Instead, do one pass through /etc/mtab looking for
+-		 * zfs entries and call zfs_unmount() for each one.
++		 * since we would have to linearly search /proc/self/mounts for
++		 * each one.  Instead, do one pass through /proc/self/mounts
++		 * looking for zfs entries and call zfs_unmount() for each one.
+ 		 *
+ 		 * Things get a little tricky if the administrator has created
+ 		 * mountpoints beneath other ZFS filesystems.  In this case, we
+--- a/cmd/zinject/translate.c
++++ b/cmd/zinject/translate.c
+@@ -120,7 +120,7 @@
+ #else
+ 	if ((fp = fopen(MNTTAB, "r")) == NULL) {
+ #endif
+-		(void) fprintf(stderr, "cannot open /etc/mtab\n");
++		(void) fprintf(stderr, "cannot open %s\n", MNTTAB);
+ 		return (-1);
+ 	}
+ 
+--- a/contrib/initramfs/scripts/zfs
++++ b/contrib/initramfs/scripts/zfs
+@@ -288,9 +288,8 @@
+ 		wait_for_dev
+ 	fi
+ 
+-	# zpool import refuse to import without a valid mtab
+-	[ ! -f /proc/mounts ] && mount proc /proc
+-	[ ! -f /etc/mtab ] && cat /proc/mounts > /etc/mtab
++	# zpool import refuse to import without a valid /proc/self/mounts
++	[ ! -f /proc/self/mounts ] && mount proc /proc
+ 
+ 	# Load the module
+ 	load_module "zfs" || return 1
+@@ -919,7 +918,7 @@
+ 	#
+ 	#   but the MOUNTPOINT prefix is preserved on descendent filesystem
+ 	#   after the pivot into the regular root, which later breaks things
+-	#   like `zfs mount -a` and the /etc/mtab refresh.
++	#   like `zfs mount -a` and the /proc/self/mounts refresh.
+ 	#
+ 	# * Mount additional filesystems required
+ 	#   Such as /usr, /var, /usr/local etc.
+--- a/etc/init.d/zfs-functions.in
++++ b/etc/init.d/zfs-functions.in
+@@ -368,7 +368,7 @@
+ 			# Set the variable.
+ 			eval export MTAB_$mntpnt=\"$fs\"
+ 		fi
+-	done < /proc/mounts
++	done < /proc/self/mounts
+ }
+ 
+ in_mtab()
+--- a/etc/init.d/zfs-mount.in
++++ b/etc/init.d/zfs-mount.in
+@@ -39,7 +39,7 @@
+ 		if [ "$2" = "/" ]; then
+ 			return 0
+ 		fi
+-	done < /etc/mtab
++	done < /proc/self/mounts
+ 
+ 	return 1
+ }
+@@ -178,7 +178,7 @@
+ 
+ 	check_module_loaded "zfs" || exit 0
+ 
+-	# Ensure / exists in /etc/mtab, if not update mtab accordingly.
++	# Ensure / exists in /proc/self/mounts.
+ 	# This should be handled by rc.sysinit but lets be paranoid.
+ 	if ! chkroot
+ 	then
+--- a/lib/libspl/include/sys/mnttab.h
++++ b/lib/libspl/include/sys/mnttab.h
+@@ -38,7 +38,7 @@
+ #undef MNTTAB
+ #endif /* MNTTAB */
+ 
+-#define	MNTTAB		"/etc/mtab"
++#define	MNTTAB		"/proc/self/mounts"
+ #define	MNT_LINE_MAX	4096
+ 
+ #define	MNT_TOOLONG	1	/* entry exceeds MNT_LINE_MAX */
+--- a/lib/libzfs/libzfs_dataset.c
++++ b/lib/libzfs/libzfs_dataset.c
+@@ -1825,9 +1825,9 @@
+  * zfs_prop_get_int() are built using this interface.
+  *
+  * Certain properties can be overridden using 'mount -o'.  In this case, scan
+- * the contents of the /etc/mtab entry, searching for the appropriate options.
+- * If they differ from the on-disk values, report the current values and mark
+- * the source "temporary".
++ * the contents of the /proc/self/mounts entry, searching for the
++ * appropriate options. If they differ from the on-disk values, report the
++ * current values and mark the source "temporary".
+  */
+ static int
+ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
+@@ -1898,8 +1898,9 @@
+ 
+ 	/*
+ 	 * Because looking up the mount options is potentially expensive
+-	 * (iterating over all of /etc/mtab), we defer its calculation until
+-	 * we're looking up a property which requires its presence.
++	 * (iterating over all of /proc/self/mounts), we defer its
++	 * calculation until we're looking up a property which requires
++	 * its presence.
+ 	 */
+ 	if (!zhp->zfs_mntcheck &&
+ 	    (mntopt_on != NULL || prop == ZFS_PROP_MOUNTED)) {
+--- a/lib/libzfs/libzfs_mount.c
++++ b/lib/libzfs/libzfs_mount.c
+@@ -346,8 +346,8 @@
+ 		return (0);
+ 
+ 	/*
+-	 * zfs_prop_get_int() to not used to ensure our mount options
+-	 * are not influenced by the current /etc/mtab contents.
++	 * zfs_prop_get_int() is not used to ensure our mount options
++	 * are not influenced by the current /proc/self/mounts contents.
+ 	 */
+ 	value = getprop_uint64(zhp, prop, &source);
+ 
+@@ -1162,8 +1162,8 @@
+  * Unshare and unmount all datasets within the given pool.  We don't want to
+  * rely on traversing the DSL to discover the filesystems within the pool,
+  * because this may be expensive (if not all of them are mounted), and can fail
+- * arbitrarily (on I/O error, for example).  Instead, we walk /etc/mtab and
+- * gather all the filesystems that are currently mounted.
++ * arbitrarily (on I/O error, for example).  Instead, we walk /proc/self/mounts
++ * and gather all the filesystems that are currently mounted.
+  */
+ int
+ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
+--- a/lib/libzfs/libzfs_util.c
++++ b/lib/libzfs/libzfs_util.c
+@@ -67,9 +67,9 @@
+ 		    "loaded.\nTry running '/sbin/modprobe zfs' as root "
+ 		    "to load them.\n"));
+ 	case ENOENT:
+-		return (dgettext(TEXT_DOMAIN, "The /dev/zfs device is "
+-		    "missing and must be created.\nTry running 'udevadm "
+-		    "trigger' as root to create it.\n"));
++		return (dgettext(TEXT_DOMAIN, "/dev/zfs and /proc/self/mounts "
++		    "are required.\nTry running 'udevadm trigger' and 'mount "
++		    "-t proc proc /proc' as root.\n"));
+ 	case ENOEXEC:
+ 		return (dgettext(TEXT_DOMAIN, "The ZFS modules cannot be "
+ 		    "auto-loaded.\nTry running '/sbin/modprobe zfs' as "
+--- a/scripts/ziltest.sh
++++ b/scripts/ziltest.sh
+@@ -185,7 +185,11 @@
+ #
+ # TX_WRITE (small file with ordering)
+ #
+-cp /etc/mtab $ROOT/small_file
++if is_linux; then
++	cp /proc/self/mounts $ROOT/small_file
++else
++	cp /etc/mtab $ROOT/small_file
++fi
+ cp /etc/profile $ROOT/small_file
+ 
+ #
diff --git a/debian/patches/1014-kernel-lookup-bdev.patch b/debian/patches/1014-kernel-lookup-bdev.patch
new file mode 100644
index 0000000..0f96f82
--- /dev/null
+++ b/debian/patches/1014-kernel-lookup-bdev.patch
@@ -0,0 +1,58 @@
+Index: zfs-linux-0.6.5.8/config/kernel-lookup-bdev.m4
+===================================================================
+--- zfs-linux-0.6.5.8.orig/config/kernel-lookup-bdev.m4
++++ zfs-linux-0.6.5.8/config/kernel-lookup-bdev.m4
+@@ -13,5 +13,16 @@ AC_DEFUN([ZFS_AC_KERNEL_LOOKUP_BDEV],
+ 		AC_DEFINE(HAVE_LOOKUP_BDEV, 1, [lookup_bdev() is available])
+ 	], [
+ 		AC_MSG_RESULT(no)
++		AC_MSG_CHECKING([whether lookup_bdev() is available and wants 2 args])
++		ZFS_LINUX_TRY_COMPILE_SYMBOL([
++			#include <linux/fs.h>
++		], [
++			lookup_bdev(NULL, 0);
++		], [lookup_bdev], [fs/block_dev.c], [
++			AC_MSG_RESULT(yes)
++			AC_DEFINE(HAVE_LOOKUP_BDEV_2ARGS, 1, [lookup_bdev() with 2 args is available])
++		], [
++			AC_MSG_RESULT(no)
++		])
+ 	])
+ ])
+Index: zfs-linux-0.6.5.8/module/zfs/zvol.c
+===================================================================
+--- zfs-linux-0.6.5.8.orig/module/zfs/zvol.c
++++ zfs-linux-0.6.5.8/module/zfs/zvol.c
+@@ -174,7 +174,7 @@ zvol_is_zvol(const char *device)
+ 	struct block_device *bdev;
+ 	unsigned int major;
+ 
+-	bdev = lookup_bdev(device);
++	bdev = zfs_lookup_bdev(device);
+ 	if (IS_ERR(bdev))
+ 		return (B_FALSE);
+ 
+Index: zfs-linux-0.6.5.8/include/linux/blkdev_compat.h
+===================================================================
+--- zfs-linux-0.6.5.8.orig/include/linux/blkdev_compat.h
++++ zfs-linux-0.6.5.8/include/linux/blkdev_compat.h
+@@ -263,9 +263,17 @@ bio_set_flags_failfast(struct block_devi
+  * 2.6.27 API change
+  * The function was exported for use, prior to this it existed by the
+  * symbol was not exported.
++ *
++ * Ubuntu Xenial commit 193fb6a2c94fab8eb8ce70a5da4d21c7d4023bee
++ * ("UBUNTU: SAUCE: block_dev: Support checking inode permissions in lookup_bdev()")
++ * added in a mask parameter which we set as zero.
+  */
+-#ifndef HAVE_LOOKUP_BDEV
+-#define	lookup_bdev(path)		ERR_PTR(-ENOTSUP)
++#ifdef HAVE_LOOKUP_BDEV
++#define zfs_lookup_bdev(path)		lookup_bdev(path)
++#elif defined(HAVE_LOOKUP_BDEV_2ARGS)
++#define zfs_lookup_bdev(path)		lookup_bdev(path, 0)
++#else
++#define	zfs_lookup_bdev(path)		ERR_PTR(-ENOTSUP)
+ #endif
+ 
+ /*
diff --git a/debian/patches/series b/debian/patches/series
index af018e2..ef5fd35 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,5 +5,11 @@
 1002-fix-mips-build.patch
 enable-zed.patch
 1001-cmd-python-exec-path.patch
-1003-linux-4.9-compat.patch
 1004-zed-service-bindir.patch
+1002-Fix-dev-zfs-device-is-missing.patch
+1014-kernel-lookup-bdev.patch                                                   
+0001-Linux-4.9-compat-iops-rename-wants-flags.patch
+0002-Linux-4.9-compat-remove-iops-set-get-remove-xattr.patch
+0003-Linux-4.9-compat-inode_change_ok-renamed-setattr_pre.patch
+0004-Kernel-4.9-compat-file_operations-aio_fsync-removal.patch
+0001-Fix-for-Linux-4.9-compat-iops-rename-wants-flags.patch

-- 
OpenZFS on Linux



More information about the Pkg-zfsonlinux-devel mailing list