Fixed a race between session unregistration and queueing new commands.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2339 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2010-10-02 15:54:39 +00:00
parent dee70735c5
commit d45f587bdc
2 changed files with 8 additions and 15 deletions

View File

@@ -2055,7 +2055,6 @@ static void srpt_completion(struct ib_cq *cq, void *ctx)
{
struct srpt_rdma_ch *ch = ctx;
atomic_inc(&ch->processing_compl);
switch (thread) {
case MODE_IB_COMPLETION_IN_THREAD:
wake_up_interruptible(&ch->wait_queue);
@@ -2067,7 +2066,6 @@ static void srpt_completion(struct ib_cq *cq, void *ctx)
srpt_process_completion(cq, ch, SCST_CONTEXT_TASKLET);
break;
}
atomic_dec(&ch->processing_compl);
}
static int srpt_compl_thread(void *arg)
@@ -2182,20 +2180,9 @@ err_destroy_cq:
static void srpt_destroy_ch_ib(struct srpt_rdma_ch *ch)
{
struct ib_qp_attr qp_attr;
int ret;
if (ch->thread)
kthread_stop(ch->thread);
qp_attr.qp_state = IB_QPS_RESET;
ret = ib_modify_qp(ch->qp, &qp_attr, IB_QP_STATE);
if (ret < 0)
PRINT_ERROR("Resetting queue pair state failed: %d", ret);
while (atomic_read(&ch->processing_compl))
;
ib_destroy_qp(ch->qp);
ib_destroy_cq(ch->cq);
}
@@ -2210,12 +2197,20 @@ static void srpt_unregister_channel(struct srpt_rdma_ch *ch)
__releases(&ch->sport->sdev->spinlock)
{
struct srpt_device *sdev;
struct ib_qp_attr qp_attr;
int ret;
sdev = ch->sport->sdev;
list_del(&ch->list);
atomic_set(&ch->state, RDMA_CHANNEL_DISCONNECTING);
spin_unlock_irq(&sdev->spinlock);
qp_attr.qp_state = IB_QPS_ERR;
ret = ib_modify_qp(ch->qp, &qp_attr, IB_QP_STATE);
if (ret < 0)
PRINT_ERROR("Setting queue pair in error state failed: %d",
ret);
/*
* At this point it is guaranteed that no new commands will be sent to
* the SCST core for channel ch, which is a requirement for
@@ -2524,7 +2519,6 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
ch->sport = &sdev->port[param->port - 1];
ch->cm_id = cm_id;
ch->rq_size = max(SRPT_RQ_SIZE, scst_get_max_lun_commands(NULL, 0));
atomic_set(&ch->processing_compl, 0);
atomic_set(&ch->state, RDMA_CHANNEL_CONNECTING);
INIT_LIST_HEAD(&ch->cmd_wait_list);

View File

@@ -285,7 +285,6 @@ struct srpt_rdma_ch {
struct ib_cm_id *cm_id;
struct ib_qp *qp;
int rq_size;
atomic_t processing_compl;
struct ib_cq *cq;
atomic_t sq_wr_avail;
struct srpt_port *sport;