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;
if (it_disposition(it, DISP_LOOKUP_NEG))
CDEBUG(D_READA, "sa_entry %.*s rc %d\n",
entry->se_qstr.len, entry->se_qstr.name, rc);
+ if (rc) {
+ ll_intent_release(it);
+ iput(dir);
+ kfree(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->it_lock_handle;
+ ll_intent_drop_lock(it);
+ }
+
spin_lock(&lli->lli_sa_lock);
if (rc) {
wakeup = __sa_make_ready(sai, entry, rc);
* for readpage and other tries to enqueue lock on child
* with parent's lock held, for example: unlink.
*/
- entry->se_handle = it->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);
}
wake_up(&sai->sai_thread.t_ctl_waitq);
spin_unlock(&lli->lli_sa_lock);
- if (rc) {
- ll_intent_release(it);
- iput(dir);
- kfree(minfo);
- }
return rc;
}