Whamcloud - gitweb
LU-2272 statahead: ll_intent_drop_lock() called in spinlock 74/10674/2
authorLai Siyao <lai.siyao@intel.com>
Wed, 11 Jun 2014 04:35:08 +0000 (12:35 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 11 Jun 2014 19:39:34 +0000 (19:39 +0000)
ll_intent_drop_lock() may sleep, which should not be called inside
spinlock.

This is back-ported from the following patch:
Lustre-change: http://review.whamcloud.com/9665

Test-Parameters: alwaysuploadlogs envdefinitions=SLOW=yes \
mdtcount=1 testlist=lustre-rsync-test,lustre-rsync-test

Signed-off-by: Lai Siyao <lai.siyao@intel.com>
Change-Id: Id658c0bd3b9dc0a918995c66842b0c3fabe8a7ae
Signed-off-by: Jian Yu <jian.yu@intel.com>
Reviewed-on: http://review.whamcloud.com/10674
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/statahead.c

index 26fb4e7..1c116c1 100644 (file)
@@ -712,12 +712,22 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
         struct ll_inode_info     *lli = ll_i2info(dir);
         struct ll_statahead_info *sai = NULL;
         struct ll_sa_entry       *entry;
+       __u64 handle              = 0;
         int                       wakeup;
         ENTRY;
 
         if (it_disposition(it, DISP_LOOKUP_NEG))
                 rc = -ENOENT;
 
+       if (rc == 0) {
+               /* 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);
        /* stale entry */
        if (unlikely(lli->lli_sai == NULL ||
@@ -749,8 +759,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_received_empty(sai);
                        cfs_list_add_tail(&entry->se_list,
                                          &sai->sai_entries_received);