From: Jinshan Xiong Date: Wed, 4 Jun 2014 00:34:21 +0000 (-0700) Subject: LU-4861 osc: a deadlock problem in osc completion ast X-Git-Tag: 2.6.0-RC1~67 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6fdcac2361d75713c5b08fa06069935a78266ac3 LU-4861 osc: a deadlock problem in osc completion ast In osc_ldlm_completion_ast(), it tries to hold mutex of cl_lock and update the lock even it's known that the lock is not granted, this can introduce a deadlock case if the process is matching a dlm lock with the calling stack: osc_lock_enqueue() -> osc_enqueue_base() -> ldlm_lock_match() -> osc_ldlm_completion_ast() -> cl_lock_mutex_get() The enqueuing lock and the lock for completion_ast() are different lock. This is a deadlock case because we're holding a lock's mutex and then request the other. It's not necessary to acquire the lock in completion_ast() if it's known that the lock has not been granted. Signed-off-by: Jinshan Xiong Change-Id: Ia8c0a4cb1e48c9f7fd921052174ce4d8d07713b1 Reviewed-on: http://review.whamcloud.com/10581 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index 3f828e0..fa076cf0 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -793,8 +793,11 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, int result; int dlmrc; - /* first, do dlm part of the work */ - dlmrc = ldlm_completion_ast_async(dlmlock, flags, data); + /* first, do dlm part of the work */ + dlmrc = ldlm_completion_ast_async(dlmlock, flags, data); + if (flags == LDLM_FL_WAIT_NOREPROC) + return dlmrc; + /* then, notify cl_lock */ env = cl_env_nested_get(&nest); if (!IS_ERR(env)) {