]> git.pld-linux.org Git - packages/spl.git/commitdiff
- fix building with linux 4.7 auto/th/spl-0.6.5.7-2
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 1 Aug 2016 20:06:21 +0000 (22:06 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Mon, 1 Aug 2016 20:06:21 +0000 (22:06 +0200)
- rel 2

linux-4.7.patch [new file with mode: 0644]
spl.spec

diff --git a/linux-4.7.patch b/linux-4.7.patch
new file mode 100644 (file)
index 0000000..7f0e647
--- /dev/null
@@ -0,0 +1,109 @@
+From fdbc1ba99d1f4d3958189079eee9b6c957e0264b Mon Sep 17 00:00:00 2001
+From: Chunwei Chen <david.chen@osnexus.com>
+Date: Wed, 18 May 2016 11:28:46 -0700
+Subject: [PATCH] Linux 4.7 compat: inode_lock() and friends
+
+Linux 4.7 changes i_mutex to i_rwsem, and we should used inode_lock and
+inode_lock_shared to do exclusive and shared lock respectively.
+
+We use spl_inode_lock{,_shared}() to hide the difference. Note that on older
+kernel you'll always take an exclusive lock.
+
+We also add all other inode_lock friends. And nested users now should
+explicitly call spl_inode_lock_nested with correct subclass.
+
+Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Issue zfsonlinux/zfs#4665
+Closes #549
+---
+ config/spl-build.m4         | 25 +++++++++++++++++++++++++
+ include/linux/file_compat.h | 19 ++++++++++++++++++-
+ module/spl/spl-vnode.c      |  3 ++-
+ 3 files changed, 45 insertions(+), 2 deletions(-)
+
+diff --git a/config/spl-build.m4 b/config/spl-build.m4
+index 55453c8..7205069 100644
+--- a/config/spl-build.m4
++++ b/config/spl-build.m4
+@@ -45,6 +45,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+       SPL_AC_USLEEP_RANGE
+       SPL_AC_KMEM_CACHE_ALLOCFLAGS
+       SPL_AC_WAIT_ON_BIT
++      SPL_AC_INODE_LOCK
+ ])
+ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
+@@ -1476,3 +1477,27 @@ AC_DEFUN([SPL_AC_MUTEX_OWNER], [
+       ])
+       EXTRA_KCFLAGS="$tmp_flags"
+ ])
++
++dnl #
++dnl # 4.7 API change
++dnl # i_mutex is changed to i_rwsem. Instead of directly using
++dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
++dnl # We test inode_lock_shared because inode_lock is introduced earlier.
++dnl #
++AC_DEFUN([SPL_AC_INODE_LOCK], [
++      AC_MSG_CHECKING([whether inode_lock_shared() exists])
++      tmp_flags="$EXTRA_KCFLAGS"
++      EXTRA_KCFLAGS="-Werror"
++      SPL_LINUX_TRY_COMPILE([
++              #include <linux/fs.h>
++      ],[
++              struct inode *inode = NULL;
++              inode_lock_shared(inode);
++      ],[
++              AC_MSG_RESULT(yes)
++              AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
++      ],[
++              AC_MSG_RESULT(no)
++      ])
++      EXTRA_KCFLAGS="$tmp_flags"
++])
+diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h
+index c58bb81..9165145 100644
+--- a/include/linux/file_compat.h
++++ b/include/linux/file_compat.h
+@@ -76,8 +76,25 @@ spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len)
+ #define       spl_filp_fsync(fp, sync)        vfs_fsync(fp, (fp)->f_dentry, sync)
+ #endif /* HAVE_2ARGS_VFS_FSYNC */
+-#define       spl_inode_lock(ip)              mutex_lock(&(ip)->i_mutex)
++#ifdef HAVE_INODE_LOCK_SHARED
++#define       spl_inode_lock(ip)              inode_lock(ip)
++#define       spl_inode_unlock(ip)            inode_unlock(ip)
++#define       spl_inode_lock_shared(ip)       inode_lock_shared(ip)
++#define       spl_inode_unlock_shared(ip)     inode_unlock_shared(ip)
++#define       spl_inode_trylock(ip)           inode_trylock(ip)
++#define       spl_inode_trylock_shared(ip)    inode_trylock_shared(ip)
++#define       spl_inode_is_locked(ip)         inode_is_locked(ip)
++#define       spl_inode_lock_nested(ip, s)    inode_lock_nested(ip, s)
++#else
++#define       spl_inode_lock(ip)              mutex_lock(&(ip)->i_mutex)
+ #define       spl_inode_unlock(ip)            mutex_unlock(&(ip)->i_mutex)
++#define       spl_inode_lock_shared(ip)       mutex_lock(&(ip)->i_mutex)
++#define       spl_inode_unlock_shared(ip)     mutex_unlock(&(ip)->i_mutex)
++#define       spl_inode_trylock(ip)           mutex_trylock(&(ip)->i_mutex)
++#define       spl_inode_trylock_shared(ip)    mutex_trylock(&(ip)->i_mutex)
++#define       spl_inode_is_locked(ip)         mutex_is_locked(&(ip)->i_mutex)
++#define       spl_inode_lock_nested(ip, s)    mutex_lock_nested(&(ip)->i_mutex, s)
++#endif
+ #endif /* SPL_FILE_COMPAT_H */
+diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
+index a914e04..addc611 100644
+--- a/module/spl/spl-vnode.c
++++ b/module/spl/spl-vnode.c
+@@ -352,7 +352,8 @@ spl_kern_path_locked(const char *name, struct path *path)
+       if (rc)
+               return (ERR_PTR(rc));
+-      spl_inode_lock(parent.dentry->d_inode);
++      /* use I_MUTEX_PARENT because vfs_unlink needs it */
++      spl_inode_lock_nested(parent.dentry->d_inode, I_MUTEX_PARENT);
+       dentry = lookup_one_len(basename, parent.dentry, len);
+       if (IS_ERR(dentry)) {
index b7059b73fe6345ebd7e71f9a62f9b24210f50e15..5a25a8dd16aacef7e29f3e47caeb5052eca777f6 100644 (file)
--- a/spl.spec
+++ b/spl.spec
@@ -21,7 +21,7 @@ exit 1
 %define                _duplicate_files_terminate_build        0
 
 %define                pname   spl
-%define                rel     1
+%define                rel     2
 Summary:       Solaris Porting Layer
 Summary(pl.UTF-8):     Solaris Porting Layer - warstwa do portowania kodu z Solarisa
 Name:          %{pname}%{?_pld_builder:%{?with_kernel:-kernel}}%{_alt_kernel}
@@ -31,6 +31,7 @@ License:      GPL v2+
 Group:         Applications/System
 Source0:       http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/%{pname}-%{version}.tar.gz
 # Source0-md5: 4e6866cea182d25f2ecab1fb7201316a
+Patch0:                linux-4.7.patch
 URL:           http://zfsonlinux.org/
 BuildRequires: rpmbuild(macros) >= 1.701
 %{?with_kernel:%{expand:%buildrequires_kernel kernel%%{_alt_kernel}-module-build >= 3:2.6.20.2}}
@@ -122,6 +123,8 @@ p=`pwd`\
 
 %prep
 %setup -q -n %{pname}-%{version}
+%patch0 -p1
+
 
 %build
 %{__aclocal} -I config
This page took 0.098248 seconds and 4 git commands to generate.