Close race between cfiscsi_offline() and new connection arrival.
Incoming connection should be either rejected or accepted and terminated.
This commit is contained in:
parent
40dd22f4fb
commit
9a3e44f9c5
@ -1060,6 +1060,8 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
|
|||||||
union ctl_io *io;
|
union ctl_io *io;
|
||||||
int error, last;
|
int error, last;
|
||||||
|
|
||||||
|
if (cs->cs_target == NULL)
|
||||||
|
return; /* No target yet, so nothing to do. */
|
||||||
io = ctl_alloc_io(cs->cs_target->ct_port.ctl_pool_ref);
|
io = ctl_alloc_io(cs->cs_target->ct_port.ctl_pool_ref);
|
||||||
if (io == NULL) {
|
if (io == NULL) {
|
||||||
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
|
CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
|
||||||
@ -1239,11 +1241,7 @@ cfiscsi_session_new(struct cfiscsi_softc *softc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mtx_lock(&softc->lock);
|
mtx_lock(&softc->lock);
|
||||||
cs->cs_id = softc->last_session_id + 1;
|
cs->cs_id = ++softc->last_session_id;
|
||||||
softc->last_session_id++;
|
|
||||||
mtx_unlock(&softc->lock);
|
|
||||||
|
|
||||||
mtx_lock(&softc->lock);
|
|
||||||
TAILQ_INSERT_TAIL(&softc->sessions, cs, cs_next);
|
TAILQ_INSERT_TAIL(&softc->sessions, cs, cs_next);
|
||||||
mtx_unlock(&softc->lock);
|
mtx_unlock(&softc->lock);
|
||||||
|
|
||||||
@ -1421,14 +1419,6 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct->ct_online == 0) {
|
|
||||||
ci->status = CTL_ISCSI_ERROR;
|
|
||||||
snprintf(ci->error_str, sizeof(ci->error_str),
|
|
||||||
"%s: port offline", __func__);
|
|
||||||
cfiscsi_target_release(ct);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ICL_KERNEL_PROXY
|
#ifdef ICL_KERNEL_PROXY
|
||||||
if (cihp->socket > 0 && cihp->connection_id > 0) {
|
if (cihp->socket > 0 && cihp->connection_id > 0) {
|
||||||
snprintf(ci->error_str, sizeof(ci->error_str),
|
snprintf(ci->error_str, sizeof(ci->error_str),
|
||||||
@ -1440,7 +1430,7 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
|
|||||||
if (cihp->socket == 0) {
|
if (cihp->socket == 0) {
|
||||||
mtx_lock(&cfiscsi_softc.lock);
|
mtx_lock(&cfiscsi_softc.lock);
|
||||||
TAILQ_FOREACH(cs, &cfiscsi_softc.sessions, cs_next) {
|
TAILQ_FOREACH(cs, &cfiscsi_softc.sessions, cs_next) {
|
||||||
if (cs->cs_id == cihp->socket)
|
if (cs->cs_id == cihp->connection_id)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cs == NULL) {
|
if (cs == NULL) {
|
||||||
@ -1465,7 +1455,6 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
|
|||||||
#ifdef ICL_KERNEL_PROXY
|
#ifdef ICL_KERNEL_PROXY
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cs->cs_target = ct;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First PDU of Full Feature phase has the same CmdSN as the last
|
* First PDU of Full Feature phase has the same CmdSN as the last
|
||||||
@ -1497,6 +1486,19 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
|
|||||||
cihp->initiator_isid[2], cihp->initiator_isid[3],
|
cihp->initiator_isid[2], cihp->initiator_isid[3],
|
||||||
cihp->initiator_isid[4], cihp->initiator_isid[5]);
|
cihp->initiator_isid[4], cihp->initiator_isid[5]);
|
||||||
|
|
||||||
|
mtx_lock(&softc->lock);
|
||||||
|
if (ct->ct_online == 0) {
|
||||||
|
mtx_unlock(&softc->lock);
|
||||||
|
cfiscsi_session_terminate(cs);
|
||||||
|
cfiscsi_target_release(ct);
|
||||||
|
ci->status = CTL_ISCSI_ERROR;
|
||||||
|
snprintf(ci->error_str, sizeof(ci->error_str),
|
||||||
|
"%s: port offline", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cs->cs_target = ct;
|
||||||
|
mtx_unlock(&softc->lock);
|
||||||
|
|
||||||
refcount_acquire(&cs->cs_outstanding_ctl_pdus);
|
refcount_acquire(&cs->cs_outstanding_ctl_pdus);
|
||||||
restart:
|
restart:
|
||||||
if (!cs->cs_terminating) {
|
if (!cs->cs_terminating) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user