提交 f108f0f6 编写于 作者: B Bart Van Assche 提交者: Doug Ledford

IB/srpt: Fix srpt_close_session()

Avoid that srpt_close_session() waits if it doesn't have to wait.
Additionally, increase the time during which srpt_close_session()
waits until closing a session has finished. This makes it easier
to detect session shutdown bugs.
Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NSagi Grimberg <sagig@mellanox.com>
Cc: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 88936259
...@@ -1986,8 +1986,8 @@ static void srpt_release_channel_work(struct work_struct *w) ...@@ -1986,8 +1986,8 @@ static void srpt_release_channel_work(struct work_struct *w)
struct se_session *se_sess; struct se_session *se_sess;
ch = container_of(w, struct srpt_rdma_ch, release_work); ch = container_of(w, struct srpt_rdma_ch, release_work);
pr_debug("ch = %p; ch->sess = %p; release_done = %p\n", ch, ch->sess, pr_debug("%s: %s-%d; release_done = %p\n", __func__, ch->sess_name,
ch->release_done); ch->qp->qp_num, ch->release_done);
sdev = ch->sport->sdev; sdev = ch->sport->sdev;
BUG_ON(!sdev); BUG_ON(!sdev);
...@@ -2011,11 +2011,10 @@ static void srpt_release_channel_work(struct work_struct *w) ...@@ -2011,11 +2011,10 @@ static void srpt_release_channel_work(struct work_struct *w)
ch->rsp_size, DMA_TO_DEVICE); ch->rsp_size, DMA_TO_DEVICE);
spin_lock_irq(&sdev->spinlock); spin_lock_irq(&sdev->spinlock);
list_del(&ch->list); list_del_init(&ch->list);
spin_unlock_irq(&sdev->spinlock);
if (ch->release_done) if (ch->release_done)
complete(ch->release_done); complete(ch->release_done);
spin_unlock_irq(&sdev->spinlock);
wake_up(&sdev->ch_releaseQ); wake_up(&sdev->ch_releaseQ);
...@@ -3025,24 +3024,26 @@ static void srpt_release_cmd(struct se_cmd *se_cmd) ...@@ -3025,24 +3024,26 @@ static void srpt_release_cmd(struct se_cmd *se_cmd)
static void srpt_close_session(struct se_session *se_sess) static void srpt_close_session(struct se_session *se_sess)
{ {
DECLARE_COMPLETION_ONSTACK(release_done); DECLARE_COMPLETION_ONSTACK(release_done);
struct srpt_rdma_ch *ch; struct srpt_rdma_ch *ch = se_sess->fabric_sess_ptr;
struct srpt_device *sdev; struct srpt_device *sdev = ch->sport->sdev;
unsigned long res; bool wait;
ch = se_sess->fabric_sess_ptr;
WARN_ON(ch->sess != se_sess);
pr_debug("ch %p state %d\n", ch, ch->state); pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num,
ch->state);
sdev = ch->sport->sdev;
spin_lock_irq(&sdev->spinlock); spin_lock_irq(&sdev->spinlock);
BUG_ON(ch->release_done); BUG_ON(ch->release_done);
ch->release_done = &release_done; ch->release_done = &release_done;
wait = !list_empty(&ch->list);
__srpt_close_ch(ch); __srpt_close_ch(ch);
spin_unlock_irq(&sdev->spinlock); spin_unlock_irq(&sdev->spinlock);
res = wait_for_completion_timeout(&release_done, 60 * HZ); if (!wait)
WARN_ON(res == 0); return;
while (wait_for_completion_timeout(&release_done, 180 * HZ) == 0)
pr_info("%s(%s-%d state %d): still waiting ...\n", __func__,
ch->sess_name, ch->qp->qp_num, ch->state);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册