Make cfiscsi_offline() synchronous, waiting for connections termination

before return.  This should make ctld restart more clean and predictable.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2014-11-21 18:05:02 +00:00
parent 6de78f9f24
commit 6f58afed59
2 changed files with 11 additions and 0 deletions

View File

@ -1274,6 +1274,7 @@ cfiscsi_session_delete(struct cfiscsi_session *cs)
mtx_lock(&softc->lock);
TAILQ_REMOVE(&softc->sessions, cs, cs_next);
cv_signal(&softc->sessions_cv);
mtx_unlock(&softc->lock);
free(cs, M_CFISCSI);
@ -1290,6 +1291,7 @@ cfiscsi_init(void)
bzero(softc, sizeof(*softc));
mtx_init(&softc->lock, "cfiscsi", NULL, MTX_DEF);
cv_init(&softc->sessions_cv, "cfiscsi_sessions");
#ifdef ICL_KERNEL_PROXY
cv_init(&softc->accept_cv, "cfiscsi_accept");
#endif
@ -1374,6 +1376,14 @@ cfiscsi_offline(void *arg)
if (cs->cs_target == ct)
cfiscsi_session_terminate(cs);
}
do {
TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
if (cs->cs_target == ct)
break;
}
if (cs != NULL)
cv_wait(&softc->sessions_cv, &softc->lock);
} while (cs != NULL && ct->ct_online == 0);
mtx_unlock(&softc->lock);
if (online > 0)
return;

View File

@ -115,6 +115,7 @@ struct cfiscsi_softc {
unsigned int last_session_id;
TAILQ_HEAD(, cfiscsi_target) targets;
TAILQ_HEAD(, cfiscsi_session) sessions;
struct cv sessions_cv;
#ifdef ICL_KERNEL_PROXY
struct icl_listen *listener;
struct cv accept_cv;