Skip to content

Commit f108f0f

Browse files
Bart Van Asschedledford
authored andcommitted
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: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Cc: Alex Estrin <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 8893625 commit f108f0f

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/infiniband/ulp/srpt/ib_srpt.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,8 @@ static void srpt_release_channel_work(struct work_struct *w)
19861986
struct se_session *se_sess;
19871987

19881988
ch = container_of(w, struct srpt_rdma_ch, release_work);
1989-
pr_debug("ch = %p; ch->sess = %p; release_done = %p\n", ch, ch->sess,
1990-
ch->release_done);
1989+
pr_debug("%s: %s-%d; release_done = %p\n", __func__, ch->sess_name,
1990+
ch->qp->qp_num, ch->release_done);
19911991

19921992
sdev = ch->sport->sdev;
19931993
BUG_ON(!sdev);
@@ -2011,11 +2011,10 @@ static void srpt_release_channel_work(struct work_struct *w)
20112011
ch->rsp_size, DMA_TO_DEVICE);
20122012

20132013
spin_lock_irq(&sdev->spinlock);
2014-
list_del(&ch->list);
2015-
spin_unlock_irq(&sdev->spinlock);
2016-
2014+
list_del_init(&ch->list);
20172015
if (ch->release_done)
20182016
complete(ch->release_done);
2017+
spin_unlock_irq(&sdev->spinlock);
20192018

20202019
wake_up(&sdev->ch_releaseQ);
20212020

@@ -3025,24 +3024,26 @@ static void srpt_release_cmd(struct se_cmd *se_cmd)
30253024
static void srpt_close_session(struct se_session *se_sess)
30263025
{
30273026
DECLARE_COMPLETION_ONSTACK(release_done);
3028-
struct srpt_rdma_ch *ch;
3029-
struct srpt_device *sdev;
3030-
unsigned long res;
3031-
3032-
ch = se_sess->fabric_sess_ptr;
3033-
WARN_ON(ch->sess != se_sess);
3027+
struct srpt_rdma_ch *ch = se_sess->fabric_sess_ptr;
3028+
struct srpt_device *sdev = ch->sport->sdev;
3029+
bool wait;
30343030

3035-
pr_debug("ch %p state %d\n", ch, ch->state);
3031+
pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num,
3032+
ch->state);
30363033

3037-
sdev = ch->sport->sdev;
30383034
spin_lock_irq(&sdev->spinlock);
30393035
BUG_ON(ch->release_done);
30403036
ch->release_done = &release_done;
3037+
wait = !list_empty(&ch->list);
30413038
__srpt_close_ch(ch);
30423039
spin_unlock_irq(&sdev->spinlock);
30433040

3044-
res = wait_for_completion_timeout(&release_done, 60 * HZ);
3045-
WARN_ON(res == 0);
3041+
if (!wait)
3042+
return;
3043+
3044+
while (wait_for_completion_timeout(&release_done, 180 * HZ) == 0)
3045+
pr_info("%s(%s-%d state %d): still waiting ...\n", __func__,
3046+
ch->sess_name, ch->qp->qp_num, ch->state);
30463047
}
30473048

30483049
/**

0 commit comments

Comments
 (0)