From: Lai Siyao Date: Sun, 19 Oct 2014 16:19:21 +0000 (-0400) Subject: LU-2272 statahead: ll_intent_drop_lock() called in spinlock X-Git-Tag: 2.6.90~36 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=30165c4024f8a1ee316fb192005d9b2a8b89d0b8;p=fs%2Flustre-release.git LU-2272 statahead: ll_intent_drop_lock() called in spinlock ll_intent_drop_lock() may sleep, which should not be called inside spinlock. Signed-off-by: Lai Siyao Change-Id: Ife50396dc16beaad921751b4bdd7da721dfc15c9 Reviewed-on: http://review.whamcloud.com/9665 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 45bfe84..2874589 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -659,6 +659,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, struct ll_inode_info *lli = ll_i2info(dir); struct ll_statahead_info *sai = lli->lli_sai; struct sa_entry *entry = (struct sa_entry *)minfo->mi_cbdata; + __u64 handle = 0; bool wakeup; ENTRY; @@ -674,6 +675,19 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, CDEBUG(D_READA, "sa_entry %.*s rc %d\n", entry->se_qstr.len, entry->se_qstr.name, rc); + if (rc != 0) { + ll_intent_release(it); + iput(dir); + OBD_FREE_PTR(minfo); + } else { + /* release ibits lock ASAP to avoid deadlock when statahead + * thread enqueues lock on parent in readdir and another + * process enqueues lock on child with parent lock held, eg. + * unlink. */ + handle = it->d.lustre.it_lock_handle; + ll_intent_drop_lock(it); + } + spin_lock(&lli->lli_sa_lock); if (rc != 0) { wakeup = __sa_make_ready(sai, entry, rc); @@ -684,8 +698,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, * when statahead thread tries to enqueue lock on parent * for readpage and other tries to enqueue lock on child * with parent's lock held, for example: unlink. */ - entry->se_handle = it->d.lustre.it_lock_handle; - ll_intent_drop_lock(it); + entry->se_handle = handle; wakeup = !sa_has_callback(sai); list_add_tail(&entry->se_list, &sai->sai_interim_entries); } @@ -694,11 +707,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, wake_up(&sai->sai_thread.t_ctl_waitq); spin_unlock(&lli->lli_sa_lock); - if (rc != 0) { - ll_intent_release(it); - iput(dir); - OBD_FREE_PTR(minfo); - } RETURN(rc); }