Lines Matching refs:nsock

70 	struct nbd_sock *nsock;  member
290 static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock, in nbd_mark_nsock_dead() argument
293 if (!nsock->dead && notify && !nbd_disconnected(nbd->config)) { in nbd_mark_nsock_dead()
302 if (!nsock->dead) { in nbd_mark_nsock_dead()
303 kernel_sock_shutdown(nsock->sock, SHUT_RDWR); in nbd_mark_nsock_dead()
314 nsock->dead = true; in nbd_mark_nsock_dead()
315 nsock->pending = NULL; in nbd_mark_nsock_dead()
316 nsock->sent = 0; in nbd_mark_nsock_dead()
375 struct nbd_sock *nsock = config->socks[i]; in sock_shutdown() local
376 mutex_lock(&nsock->tx_lock); in sock_shutdown()
377 nbd_mark_nsock_dead(nbd, nsock, 0); in sock_shutdown()
378 mutex_unlock(&nsock->tx_lock); in sock_shutdown()
451 struct nbd_sock *nsock = in nbd_xmit_timeout() local
453 mutex_lock(&nsock->tx_lock); in nbd_xmit_timeout()
460 if (cmd->cookie == nsock->cookie) in nbd_xmit_timeout()
461 nbd_mark_nsock_dead(nbd, nsock, 1); in nbd_xmit_timeout()
462 mutex_unlock(&nsock->tx_lock); in nbd_xmit_timeout()
476 struct nbd_sock *nsock = config->socks[cmd->index]; in nbd_xmit_timeout() local
483 mutex_lock(&nsock->tx_lock); in nbd_xmit_timeout()
484 if (cmd->cookie != nsock->cookie) { in nbd_xmit_timeout()
486 mutex_unlock(&nsock->tx_lock); in nbd_xmit_timeout()
491 mutex_unlock(&nsock->tx_lock); in nbd_xmit_timeout()
577 struct nbd_sock *nsock = config->socks[index]; in nbd_send_cmd() local
587 int sent = nsock->sent, skip = 0; in nbd_send_cmd()
623 cmd->cookie = nsock->cookie; in nbd_send_cmd()
649 nsock->pending = req; in nbd_send_cmd()
650 nsock->sent = sent; in nbd_send_cmd()
691 nsock->pending = req; in nbd_send_cmd()
692 nsock->sent = sent; in nbd_send_cmd()
714 nsock->pending = NULL; in nbd_send_cmd()
715 nsock->sent = 0; in nbd_send_cmd()
852 struct nbd_sock *nsock = args->nsock; in recv_work() local
859 if (nbd_read_reply(nbd, nsock->sock, &reply)) in recv_work()
894 mutex_lock(&nsock->tx_lock); in recv_work()
895 nbd_mark_nsock_dead(nbd, nsock, 1); in recv_work()
896 mutex_unlock(&nsock->tx_lock); in recv_work()
936 struct nbd_sock *nsock = config->socks[index]; in find_fallback() local
937 int fallback = nsock->fallback_index; in find_fallback()
952 if (nsock->fallback_index < 0 || in find_fallback()
953 nsock->fallback_index >= config->num_connections || in find_fallback()
954 config->socks[nsock->fallback_index]->dead) { in find_fallback()
964 nsock->fallback_index = new_index; in find_fallback()
971 new_index = nsock->fallback_index; in find_fallback()
996 struct nbd_sock *nsock; in nbd_handle_cmd() local
1014 nsock = config->socks[index]; in nbd_handle_cmd()
1015 mutex_lock(&nsock->tx_lock); in nbd_handle_cmd()
1016 if (nsock->dead) { in nbd_handle_cmd()
1019 mutex_unlock(&nsock->tx_lock); in nbd_handle_cmd()
1044 if (unlikely(nsock->pending && nsock->pending != req)) { in nbd_handle_cmd()
1063 nbd_mark_nsock_dead(nbd, nsock, 1); in nbd_handle_cmd()
1068 mutex_unlock(&nsock->tx_lock); in nbd_handle_cmd()
1132 struct nbd_sock *nsock; in nbd_add_socket() local
1161 nsock = kzalloc(sizeof(*nsock), GFP_KERNEL); in nbd_add_socket()
1162 if (!nsock) { in nbd_add_socket()
1170 kfree(nsock); in nbd_add_socket()
1177 nsock->fallback_index = -1; in nbd_add_socket()
1178 nsock->dead = false; in nbd_add_socket()
1179 mutex_init(&nsock->tx_lock); in nbd_add_socket()
1180 nsock->sock = sock; in nbd_add_socket()
1181 nsock->pending = NULL; in nbd_add_socket()
1182 nsock->sent = 0; in nbd_add_socket()
1183 nsock->cookie = 0; in nbd_add_socket()
1184 socks[config->num_connections++] = nsock; in nbd_add_socket()
1215 struct nbd_sock *nsock = config->socks[i]; in nbd_reconnect_socket() local
1217 if (!nsock->dead) in nbd_reconnect_socket()
1220 mutex_lock(&nsock->tx_lock); in nbd_reconnect_socket()
1221 if (!nsock->dead) { in nbd_reconnect_socket()
1222 mutex_unlock(&nsock->tx_lock); in nbd_reconnect_socket()
1230 old = nsock->sock; in nbd_reconnect_socket()
1231 nsock->fallback_index = -1; in nbd_reconnect_socket()
1232 nsock->sock = sock; in nbd_reconnect_socket()
1233 nsock->dead = false; in nbd_reconnect_socket()
1237 args->nsock = nsock; in nbd_reconnect_socket()
1238 nsock->cookie++; in nbd_reconnect_socket()
1239 mutex_unlock(&nsock->tx_lock); in nbd_reconnect_socket()
1294 struct nbd_sock *nsock = config->socks[i]; in send_disconnects() local
1297 mutex_lock(&nsock->tx_lock); in send_disconnects()
1302 mutex_unlock(&nsock->tx_lock); in send_disconnects()
1420 args->nsock = config->socks[i]; in nbd_start_device()