From 648f7c94b035675e3d8b601b9d10c3f928a37e72 Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Fri, 3 Aug 2012 11:51:44 +0300 Subject: [PATCH] LU-1722 llite: LTP fcntl14 test fails on a SMP host Release Lustre flock in case of local locking failure Xyratex-bug-id: MRP-447 Reviewed-by: Vitaly Fertman Reviewed-by: Andrew Perepechko Signed-off-by: Andriy Skulysh Change-Id: I27e4627461756442713077344bcefeb3841d594a Reviewed-on: http://review.whamcloud.com/3565 Reviewed-by: Keith Mannthey Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b540065..31a5cd4 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2213,6 +2213,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) ldlm_policy_data_t flock = {{0}}; int flags = 0; int rc; + int rc2 = 0; ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n", @@ -2308,15 +2309,22 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, op_data, &lockh, &flock, 0, NULL /* req */, flags); - ll_finish_md_op_data(op_data); - if ((file_lock->fl_flags & FL_FLOCK) && (rc == 0 || file_lock->fl_type == F_UNLCK)) - flock_lock_file_wait(file, file_lock); + rc2 = flock_lock_file_wait(file, file_lock); if ((file_lock->fl_flags & FL_POSIX) && (rc == 0 || file_lock->fl_type == F_UNLCK) && !(flags & LDLM_FL_TEST_LOCK)) - posix_lock_file_wait(file, file_lock); + rc2 = posix_lock_file_wait(file, file_lock); + + if (rc2 && file_lock->fl_type != F_UNLCK) { + einfo.ei_mode = LCK_NL; + md_enqueue(sbi->ll_md_exp, &einfo, NULL, + op_data, &lockh, &flock, 0, NULL /* req */, flags); + rc = rc2; + } + + ll_finish_md_op_data(op_data); RETURN(rc); } -- 1.8.3.1