Whamcloud - gitweb
LU-6215 llite: handle locks API change in 4.4+ kernels 29/18729/3
authorLi Dongyang <dongyang.li@anu.edu.au>
Tue, 1 Mar 2016 05:36:49 +0000 (16:36 +1100)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 23 Mar 2016 06:02:26 +0000 (06:02 +0000)
Since 4.4 linux kernel replaced both posix_lock_file_wait() and
flock_lock_file_wait() by introducing locks_lock_file_wait().
This patch handles the API change.

Linux-commit: 4f6563677ae833baad8003e14353241bc25da4fc

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Change-Id: I1b9c98c2afcad9da3fb377c3e788b12f20261e9e
Reviewed-on: http://review.whamcloud.com/18729
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/llite/file.c

index 00b376f..06a56fa 100644 (file)
@@ -1991,6 +1991,24 @@ cache_head_has_hlist, [
 ]) # LC_HAVE_CACHE_HEAD_HLIST
 
 #
+# LC_HAVE_LOCKS_LOCK_FILE_WAIT
+#
+# 4.4 kernel have moved locks API users to
+# locks_lock_inode_wait()
+#
+AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
+LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
+locks_lock_file_wait, [
+       #include <linux/fs.h>
+],[
+       locks_lock_file_wait(NULL, NULL);
+],[
+       AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
+               [kernel has locks_lock_file_wait])
+])
+]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2155,6 +2173,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 4.3
        LC_HAVE_CACHE_HEAD_HLIST
 
+       # 4.4
+       LC_HAVE_LOCKS_LOCK_FILE_WAIT
+
        #
        AS_IF([test "x$enable_server" != xno], [
                LC_FUNC_DEV_SET_RDONLY
index 8e6afbd..d1819c6 100644 (file)
@@ -2918,6 +2918,11 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
        if (!(flags & LDLM_FL_TEST_LOCK))
                file_lock->fl_type = fl_type;
 
+#ifdef HAVE_LOCKS_LOCK_FILE_WAIT
+       if ((rc == 0 || file_lock->fl_type == F_UNLCK) &&
+           !(flags & LDLM_FL_TEST_LOCK))
+               rc2  = locks_lock_file_wait(file, file_lock);
+#else
         if ((file_lock->fl_flags & FL_FLOCK) &&
             (rc == 0 || file_lock->fl_type == F_UNLCK))
                rc2  = flock_lock_file_wait(file, file_lock);
@@ -2925,6 +2930,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
             (rc == 0 || file_lock->fl_type == F_UNLCK) &&
             !(flags & LDLM_FL_TEST_LOCK))
                rc2  = posix_lock_file_wait(file, file_lock);
+#endif /* HAVE_LOCKS_LOCK_FILE_WAIT */
 
        if (rc2 && file_lock->fl_type != F_UNLCK) {
                einfo.ei_mode = LCK_NL;