From: Li Dongyang Date: Tue, 1 Mar 2016 05:36:49 +0000 (+1100) Subject: LU-6215 llite: handle locks API change in 4.4+ kernels X-Git-Tag: 2.8.51~18 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=dbaa768769a4075ca765dc76a138ef7a39c54eb0 LU-6215 llite: handle locks API change in 4.4+ kernels 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 Change-Id: I1b9c98c2afcad9da3fb377c3e788b12f20261e9e Reviewed-on: http://review.whamcloud.com/18729 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 00b376f..06a56fa 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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 diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 8e6afbd..d1819c6 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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;