mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
Get rid of ICL lock; use upper-layer (initiator or target) lock instead.
This avoids extra locking in icl_pdu_queue(); the upper layer needs to call it while holding its own lock anyway, to avoid sending PDUs out of order. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
1c6e90b0f8
commit
6ed8f5d236
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264022
@ -1215,7 +1215,7 @@ cfiscsi_session_new(struct cfiscsi_softc *softc)
|
||||
cv_init(&cs->cs_login_cv, "cfiscsi_login");
|
||||
#endif
|
||||
|
||||
cs->cs_conn = icl_conn_new();
|
||||
cs->cs_conn = icl_conn_new(&cs->cs_lock);
|
||||
cs->cs_conn->ic_receive = cfiscsi_receive_callback;
|
||||
cs->cs_conn->ic_error = cfiscsi_error_callback;
|
||||
cs->cs_conn->ic_prv0 = cs;
|
||||
|
@ -88,9 +88,10 @@ static volatile u_int icl_ncons;
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ICL_CONN_LOCK(X) mtx_lock(&X->ic_lock)
|
||||
#define ICL_CONN_UNLOCK(X) mtx_unlock(&X->ic_lock)
|
||||
#define ICL_CONN_LOCK_ASSERT(X) mtx_assert(&X->ic_lock, MA_OWNED)
|
||||
#define ICL_CONN_LOCK(X) mtx_lock(X->ic_lock)
|
||||
#define ICL_CONN_UNLOCK(X) mtx_unlock(X->ic_lock)
|
||||
#define ICL_CONN_LOCK_ASSERT(X) mtx_assert(X->ic_lock, MA_OWNED)
|
||||
#define ICL_CONN_LOCK_ASSERT_NOT(X) mtx_assert(X->ic_lock, MA_NOTOWNED)
|
||||
|
||||
static void
|
||||
icl_conn_fail(struct icl_conn *ic)
|
||||
@ -896,7 +897,7 @@ icl_send_thread(void *arg)
|
||||
break;
|
||||
}
|
||||
icl_conn_send_pdus(ic);
|
||||
cv_wait(&ic->ic_send_cv, &ic->ic_lock);
|
||||
cv_wait(&ic->ic_send_cv, ic->ic_lock);
|
||||
}
|
||||
|
||||
ic->ic_send_running = false;
|
||||
@ -961,20 +962,19 @@ icl_pdu_queue(struct icl_pdu *ip)
|
||||
|
||||
ic = ip->ip_conn;
|
||||
|
||||
ICL_CONN_LOCK(ic);
|
||||
ICL_CONN_LOCK_ASSERT(ic);
|
||||
|
||||
if (ic->ic_disconnecting || ic->ic_socket == NULL) {
|
||||
ICL_DEBUG("icl_pdu_queue on closed connection");
|
||||
ICL_CONN_UNLOCK(ic);
|
||||
icl_pdu_free(ip);
|
||||
return;
|
||||
}
|
||||
TAILQ_INSERT_TAIL(&ic->ic_to_send, ip, ip_next);
|
||||
ICL_CONN_UNLOCK(ic);
|
||||
cv_signal(&ic->ic_send_cv);
|
||||
}
|
||||
|
||||
struct icl_conn *
|
||||
icl_conn_new(void)
|
||||
icl_conn_new(struct mtx *lock)
|
||||
{
|
||||
struct icl_conn *ic;
|
||||
|
||||
@ -983,7 +983,7 @@ icl_conn_new(void)
|
||||
ic = uma_zalloc(icl_conn_zone, M_WAITOK | M_ZERO);
|
||||
|
||||
TAILQ_INIT(&ic->ic_to_send);
|
||||
mtx_init(&ic->ic_lock, "icl_lock", NULL, MTX_DEF);
|
||||
ic->ic_lock = lock;
|
||||
cv_init(&ic->ic_send_cv, "icl_tx");
|
||||
cv_init(&ic->ic_receive_cv, "icl_rx");
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -998,7 +998,6 @@ void
|
||||
icl_conn_free(struct icl_conn *ic)
|
||||
{
|
||||
|
||||
mtx_destroy(&ic->ic_lock);
|
||||
cv_destroy(&ic->ic_send_cv);
|
||||
cv_destroy(&ic->ic_receive_cv);
|
||||
uma_zfree(icl_conn_zone, ic);
|
||||
@ -1102,6 +1101,8 @@ icl_conn_handoff(struct icl_conn *ic, int fd)
|
||||
cap_rights_t rights;
|
||||
int error;
|
||||
|
||||
ICL_CONN_LOCK_ASSERT_NOT(ic);
|
||||
|
||||
/*
|
||||
* Steal the socket from userland.
|
||||
*/
|
||||
@ -1141,6 +1142,7 @@ icl_conn_handoff(struct icl_conn *ic, int fd)
|
||||
void
|
||||
icl_conn_shutdown(struct icl_conn *ic)
|
||||
{
|
||||
ICL_CONN_LOCK_ASSERT_NOT(ic);
|
||||
|
||||
ICL_CONN_LOCK(ic);
|
||||
if (ic->ic_socket == NULL) {
|
||||
@ -1157,6 +1159,8 @@ icl_conn_close(struct icl_conn *ic)
|
||||
{
|
||||
struct icl_pdu *pdu;
|
||||
|
||||
ICL_CONN_LOCK_ASSERT_NOT(ic);
|
||||
|
||||
ICL_CONN_LOCK(ic);
|
||||
if (ic->ic_socket == NULL) {
|
||||
ICL_CONN_UNLOCK(ic);
|
||||
@ -1214,6 +1218,7 @@ icl_conn_close(struct icl_conn *ic)
|
||||
bool
|
||||
icl_conn_connected(struct icl_conn *ic)
|
||||
{
|
||||
ICL_CONN_LOCK_ASSERT_NOT(ic);
|
||||
|
||||
ICL_CONN_LOCK(ic);
|
||||
if (ic->ic_socket == NULL) {
|
||||
@ -1234,6 +1239,8 @@ icl_conn_handoff_sock(struct icl_conn *ic, struct socket *so)
|
||||
{
|
||||
int error;
|
||||
|
||||
ICL_CONN_LOCK_ASSERT_NOT(ic);
|
||||
|
||||
if (so->so_type != SOCK_STREAM)
|
||||
return (EINVAL);
|
||||
|
||||
|
@ -74,7 +74,7 @@ void icl_pdu_free(struct icl_pdu *ip);
|
||||
#define ICL_MAX_DATA_SEGMENT_LENGTH (128 * 1024)
|
||||
|
||||
struct icl_conn {
|
||||
struct mtx ic_lock;
|
||||
struct mtx *ic_lock;
|
||||
struct socket *ic_socket;
|
||||
#ifdef DIAGNOSTIC
|
||||
volatile u_int ic_outstanding_pdus;
|
||||
@ -102,7 +102,7 @@ struct icl_conn {
|
||||
void *ic_prv0;
|
||||
};
|
||||
|
||||
struct icl_conn *icl_conn_new(void);
|
||||
struct icl_conn *icl_conn_new(struct mtx *lock);
|
||||
void icl_conn_free(struct icl_conn *ic);
|
||||
int icl_conn_handoff(struct icl_conn *ic, int fd);
|
||||
void icl_conn_shutdown(struct icl_conn *ic);
|
||||
|
@ -1641,7 +1641,7 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa)
|
||||
return (EBUSY);
|
||||
}
|
||||
|
||||
is->is_conn = icl_conn_new();
|
||||
is->is_conn = icl_conn_new(&is->is_lock);
|
||||
is->is_conn->ic_receive = iscsi_receive_callback;
|
||||
is->is_conn->ic_error = iscsi_error_callback;
|
||||
is->is_conn->ic_prv0 = is;
|
||||
|
Loading…
Reference in New Issue
Block a user