Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374757

[PATCH 03/17] staging: lustre: ldlm: Fix a race during FLock handling

From James Simmons <jsimmons@infradead.org>
Newsgroups linux.kernel
Subject [PATCH 03/17] staging: lustre: ldlm: Fix a race during FLock handling
Date 2016-04-10 15:20 +0200
Message-ID <rmnrt-5Be-23@gated-at.bofh.it> (permalink)
References <rmnrr-5Be-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Bruno Faccini <bruno.faccini@intel.com>

Protect against race where lock could have been just destroyed
due to overlap, in ldlm_process_flock_lock().
Easy reproducer is BULL's NFS Locktests in pthread mode.
(http://nfsv4.bullopensource.org/tools/tests/locktest.php)

Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1126
Reviewed-on: http://review.whamcloud.com/7134
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 3f97e1c..5102d78 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -520,11 +520,6 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
 granted:
 	OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10);
 
-	if (lock->l_flags & LDLM_FL_DESTROYED) {
-		LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed");
-		return 0;
-	}
-
 	if (lock->l_flags & LDLM_FL_FAILED) {
 		LDLM_DEBUG(lock, "client-side enqueue waking up: failed");
 		return -EIO;
@@ -534,6 +529,16 @@ granted:
 
 	lock_res_and_lock(lock);
 
+	/*
+	 * Protect against race where lock could have been just destroyed
+	 * due to overlap in ldlm_process_flock_lock().
+	 */
+	if (lock->l_flags & LDLM_FL_DESTROYED) {
+		unlock_res_and_lock(lock);
+		LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed");
+		return 0;
+	}
+
 	/* ldlm_lock_enqueue() has already placed lock on the granted list. */
 	list_del_init(&lock->l_res_link);
 
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/17] staging : lustre : rest of missing patches from 2.5.0 release James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 11/17] staging: lustre: osc: osc_extent_wait() shouldn't be interruptible James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 15/17] staging: lustre: lov: Don't wait for active target with OBD_STATFS_NODELAY James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 03/17] staging: lustre: ldlm: Fix a race during FLock handling James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 10/17] staging: lustre: llite: Truncate to restore file James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 02/17] staging: lustre: clio: incorrect assertions in 'enable-invariants' James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 17/17] staging: lustre: hsm: don't use real suppgid James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 09/17] staging: lustre: ptlrpc: return a meaningful status from ptlrpcd_init() James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 06/17] staging: lustre: llite: speedup in unlink/rmdir James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 08/17] staging: lustre: obd: MDT mount fails on MDS w/o MGS on it James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 04/17] staging: lustre: ldlm: refine LU-2665 patch for POSIX compliance James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 14/17] staging: lustre: lov: return minimal FIEMAP for released files James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200
  [PATCH 12/17] staging: lustre: lprocfs: implement log2 using bitops James Simmons <jsimmons@infradead.org> - 2016-04-10 15:20 +0200

csiph-web