Whamcloud - gitweb
LU-1722 llite: LTP fcntl14 test fails on a SMP host
authorAndriy Skulysh <Andriy_Skulysh@xyratex.com>
Fri, 3 Aug 2012 08:51:44 +0000 (11:51 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 21 Jan 2013 18:59:39 +0000 (13:59 -0500)
Release Lustre flock in case of local locking failure

Xyratex-bug-id: MRP-447
Reviewed-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Reviewed-by: Andrew Perepechko <andrew_perepechko@xyratex.com>
Signed-off-by: Andriy Skulysh <Andriy_Skulysh@xyratex.com>
Change-Id: I27e4627461756442713077344bcefeb3841d594a
Reviewed-on: http://review.whamcloud.com/3565
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Tested-by: Hudson
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c

index b540065..31a5cd4 100644 (file)
@@ -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);
 }