From: Bruno Faccini Date: Thu, 1 Aug 2013 07:09:05 +0000 (+0200) Subject: LU-1126 ldlm: Fix a race during FLock handling X-Git-Tag: 2.4.93~63 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=22287c7951209525f1f33abefff4f2f069f17c40 LU-1126 ldlm: Fix a race during FLock handling 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 Change-Id: I4f4183098e8e7aaacb2c6b80787d3c7a7ad5688b Reviewed-on: http://review.whamcloud.com/7134 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: John L. Hammond --- diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index 6273b72..d9cc416 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -697,11 +697,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); @@ -711,6 +706,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); + } + /* take lock off the deadlock detection hash list. */ ldlm_flock_blocking_unlink(lock);