Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e74e54f authored by Bruno Faccini's avatar Bruno Faccini Committed by Greg Kroah-Hartman
Browse files

staging: lustre: 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: default avatarBruno 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: default avatarOleg Drokin <oleg.drokin@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 800548b1
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -520,11 +520,6 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
granted:
granted:
	OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10);
	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) {
	if (lock->l_flags & LDLM_FL_FAILED) {
		LDLM_DEBUG(lock, "client-side enqueue waking up: failed");
		LDLM_DEBUG(lock, "client-side enqueue waking up: failed");
		return -EIO;
		return -EIO;
@@ -534,6 +529,16 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)


	lock_res_and_lock(lock);
	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. */
	/* ldlm_lock_enqueue() has already placed lock on the granted list. */
	list_del_init(&lock->l_res_link);
	list_del_init(&lock->l_res_link);