Lines Matching full:server
59 /* Drop the connection to not overload the server */
62 static int ip_connect(struct TCP_Server_Info *server);
63 static int generic_ip_connect(struct TCP_Server_Info *server);
71 * This should be called with server->srv_mutex held.
73 static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) in reconn_set_ipaddr_from_hostname() argument
80 if (!server->hostname) in reconn_set_ipaddr_from_hostname()
83 /* if server hostname isn't populated, there's nothing to do here */ in reconn_set_ipaddr_from_hostname()
84 if (server->hostname[0] == '\0') in reconn_set_ipaddr_from_hostname()
87 len = strlen(server->hostname) + 3; in reconn_set_ipaddr_from_hostname()
94 scnprintf(unc, len, "\\\\%s", server->hostname); in reconn_set_ipaddr_from_hostname()
96 spin_lock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
97 ss = server->dstaddr; in reconn_set_ipaddr_from_hostname()
98 spin_unlock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
104 cifs_dbg(FYI, "%s: failed to resolve server part of %s to IP: %d\n", in reconn_set_ipaddr_from_hostname()
105 __func__, server->hostname, rc); in reconn_set_ipaddr_from_hostname()
107 spin_lock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
108 memcpy(&server->dstaddr, &ss, sizeof(server->dstaddr)); in reconn_set_ipaddr_from_hostname()
109 spin_unlock(&server->srv_lock); in reconn_set_ipaddr_from_hostname()
123 struct TCP_Server_Info *server = tcon->ses->server; in smb2_query_server_interfaces() local
126 * query server network interfaces, in case they change in smb2_query_server_interfaces()
128 if (!server->ops->query_server_interfaces) in smb2_query_server_interfaces()
132 rc = server->ops->query_server_interfaces(xid, tcon, false); in smb2_query_server_interfaces()
139 cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", in smb2_query_server_interfaces()
148 * Update the tcpStatus for the server.
153 * @server: the tcp ses for which reconnect is needed
157 cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, in cifs_signal_cifsd_for_reconnect() argument
164 /* If server is a channel, select the primary channel */ in cifs_signal_cifsd_for_reconnect()
165 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_signal_cifsd_for_reconnect()
169 spin_lock(&server->srv_lock); in cifs_signal_cifsd_for_reconnect()
170 if (server->tcpStatus != CifsExiting) in cifs_signal_cifsd_for_reconnect()
171 server->tcpStatus = CifsNeedReconnect; in cifs_signal_cifsd_for_reconnect()
172 spin_unlock(&server->srv_lock); in cifs_signal_cifsd_for_reconnect()
182 if (!ses->chans[i].server) in cifs_signal_cifsd_for_reconnect()
185 spin_lock(&ses->chans[i].server->srv_lock); in cifs_signal_cifsd_for_reconnect()
186 if (ses->chans[i].server->tcpStatus != CifsExiting) in cifs_signal_cifsd_for_reconnect()
187 ses->chans[i].server->tcpStatus = CifsNeedReconnect; in cifs_signal_cifsd_for_reconnect()
188 spin_unlock(&ses->chans[i].server->srv_lock); in cifs_signal_cifsd_for_reconnect()
201 * @server: the tcp ses for which reconnect is needed
202 * @server needs to be previously set to CifsNeedReconnect.
206 cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, in cifs_mark_tcp_ses_conns_for_reconnect() argument
219 /* If server is a channel, select the primary channel */ in cifs_mark_tcp_ses_conns_for_reconnect()
220 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_mark_tcp_ses_conns_for_reconnect()
223 * if the server has been marked for termination, there is a in cifs_mark_tcp_ses_conns_for_reconnect()
230 if (server->terminate) { in cifs_mark_tcp_ses_conns_for_reconnect()
232 server = pserver; in cifs_mark_tcp_ses_conns_for_reconnect()
245 if (cifs_ses_get_chan_index(ses, server) == in cifs_mark_tcp_ses_conns_for_reconnect()
251 if (!cifs_chan_is_iface_active(ses, server)) { in cifs_mark_tcp_ses_conns_for_reconnect()
253 cifs_chan_update_iface(ses, server); in cifs_mark_tcp_ses_conns_for_reconnect()
257 if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) { in cifs_mark_tcp_ses_conns_for_reconnect()
265 cifs_chan_set_need_reconnect(ses, server); in cifs_mark_tcp_ses_conns_for_reconnect()
300 cifs_abort_connection(struct TCP_Server_Info *server) in cifs_abort_connection() argument
305 server->maxBuf = 0; in cifs_abort_connection()
306 server->max_read = 0; in cifs_abort_connection()
310 cifs_server_lock(server); in cifs_abort_connection()
311 if (server->ssocket) { in cifs_abort_connection()
312 cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n", server->ssocket->state, in cifs_abort_connection()
313 server->ssocket->flags); in cifs_abort_connection()
314 kernel_sock_shutdown(server->ssocket, SHUT_WR); in cifs_abort_connection()
315 cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n", server->ssocket->state, in cifs_abort_connection()
316 server->ssocket->flags); in cifs_abort_connection()
317 sock_release(server->ssocket); in cifs_abort_connection()
318 server->ssocket = NULL; in cifs_abort_connection()
320 server->sequence_number = 0; in cifs_abort_connection()
321 server->session_estab = false; in cifs_abort_connection()
322 kfree_sensitive(server->session_key.response); in cifs_abort_connection()
323 server->session_key.response = NULL; in cifs_abort_connection()
324 server->session_key.len = 0; in cifs_abort_connection()
325 server->lstrp = jiffies; in cifs_abort_connection()
330 spin_lock(&server->mid_lock); in cifs_abort_connection()
331 list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) { in cifs_abort_connection()
338 spin_unlock(&server->mid_lock); in cifs_abort_connection()
339 cifs_server_unlock(server); in cifs_abort_connection()
348 if (cifs_rdma_enabled(server)) { in cifs_abort_connection()
349 cifs_server_lock(server); in cifs_abort_connection()
350 smbd_destroy(server); in cifs_abort_connection()
351 cifs_server_unlock(server); in cifs_abort_connection()
355 static bool cifs_tcp_ses_needs_reconnect(struct TCP_Server_Info *server, int num_targets) in cifs_tcp_ses_needs_reconnect() argument
357 spin_lock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
358 server->nr_targets = num_targets; in cifs_tcp_ses_needs_reconnect()
359 if (server->tcpStatus == CifsExiting) { in cifs_tcp_ses_needs_reconnect()
361 spin_unlock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
362 wake_up(&server->response_q); in cifs_tcp_ses_needs_reconnect()
367 trace_smb3_reconnect(server->CurrentMid, server->conn_id, in cifs_tcp_ses_needs_reconnect()
368 server->hostname); in cifs_tcp_ses_needs_reconnect()
369 server->tcpStatus = CifsNeedReconnect; in cifs_tcp_ses_needs_reconnect()
371 spin_unlock(&server->srv_lock); in cifs_tcp_ses_needs_reconnect()
388 static int __cifs_reconnect(struct TCP_Server_Info *server, in __cifs_reconnect() argument
393 if (!cifs_tcp_ses_needs_reconnect(server, 1)) in __cifs_reconnect()
396 cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session); in __cifs_reconnect()
398 cifs_abort_connection(server); in __cifs_reconnect()
402 cifs_server_lock(server); in __cifs_reconnect()
404 if (!cifs_swn_set_server_dstaddr(server)) { in __cifs_reconnect()
406 rc = reconn_set_ipaddr_from_hostname(server); in __cifs_reconnect()
410 if (cifs_rdma_enabled(server)) in __cifs_reconnect()
411 rc = smbd_reconnect(server); in __cifs_reconnect()
413 rc = generic_ip_connect(server); in __cifs_reconnect()
415 cifs_server_unlock(server); in __cifs_reconnect()
420 set_credits(server, 1); in __cifs_reconnect()
421 spin_lock(&server->srv_lock); in __cifs_reconnect()
422 if (server->tcpStatus != CifsExiting) in __cifs_reconnect()
423 server->tcpStatus = CifsNeedNegotiate; in __cifs_reconnect()
424 spin_unlock(&server->srv_lock); in __cifs_reconnect()
425 cifs_swn_reset_server_dstaddr(server); in __cifs_reconnect()
426 cifs_server_unlock(server); in __cifs_reconnect()
427 mod_delayed_work(cifsiod_wq, &server->reconnect, 0); in __cifs_reconnect()
429 } while (server->tcpStatus == CifsNeedReconnect); in __cifs_reconnect()
431 spin_lock(&server->srv_lock); in __cifs_reconnect()
432 if (server->tcpStatus == CifsNeedNegotiate) in __cifs_reconnect()
433 mod_delayed_work(cifsiod_wq, &server->echo, 0); in __cifs_reconnect()
434 spin_unlock(&server->srv_lock); in __cifs_reconnect()
436 wake_up(&server->response_q); in __cifs_reconnect()
441 static int __reconnect_target_unlocked(struct TCP_Server_Info *server, const char *target) in __reconnect_target_unlocked() argument
446 if (!cifs_swn_set_server_dstaddr(server)) { in __reconnect_target_unlocked()
447 if (server->hostname != target) { in __reconnect_target_unlocked()
450 spin_lock(&server->srv_lock); in __reconnect_target_unlocked()
451 kfree(server->hostname); in __reconnect_target_unlocked()
452 server->hostname = hostname; in __reconnect_target_unlocked()
453 spin_unlock(&server->srv_lock); in __reconnect_target_unlocked()
457 cifs_dbg(FYI, "%s: default to last target server: %s\n", __func__, in __reconnect_target_unlocked()
458 server->hostname); in __reconnect_target_unlocked()
462 rc = reconn_set_ipaddr_from_hostname(server); in __reconnect_target_unlocked()
466 if (cifs_rdma_enabled(server)) in __reconnect_target_unlocked()
467 rc = smbd_reconnect(server); in __reconnect_target_unlocked()
469 rc = generic_ip_connect(server); in __reconnect_target_unlocked()
474 static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_cache_tgt_list *tl, in reconnect_target_unlocked() argument
482 /* If dfs target list is empty, then reconnect to last server */ in reconnect_target_unlocked()
485 return __reconnect_target_unlocked(server, server->hostname); in reconnect_target_unlocked()
489 rc = __reconnect_target_unlocked(server, dfs_cache_get_tgt_name(tit)); in reconnect_target_unlocked()
498 static int reconnect_dfs_server(struct TCP_Server_Info *server) in reconnect_dfs_server() argument
510 * targets (server->nr_targets). It's also possible that the cached referral was cleared in reconnect_dfs_server()
511 * through /proc/fs/cifs/dfscache or the target list is empty due to server settings after in reconnect_dfs_server()
514 mutex_lock(&server->refpath_lock); in reconnect_dfs_server()
515 if (!dfs_cache_noreq_find(server->leaf_fullpath + 1, NULL, &tl)) in reconnect_dfs_server()
517 mutex_unlock(&server->refpath_lock); in reconnect_dfs_server()
521 if (!cifs_tcp_ses_needs_reconnect(server, num_targets)) in reconnect_dfs_server()
526 * different server or share during failover. It could be improved by adding some logic to in reconnect_dfs_server()
527 * only do that in case it connects to a different server or share, though. in reconnect_dfs_server()
529 cifs_mark_tcp_ses_conns_for_reconnect(server, true); in reconnect_dfs_server()
531 cifs_abort_connection(server); in reconnect_dfs_server()
535 cifs_server_lock(server); in reconnect_dfs_server()
537 rc = reconnect_target_unlocked(server, &tl, &target_hint); in reconnect_dfs_server()
540 cifs_server_unlock(server); in reconnect_dfs_server()
548 * through the reconnected target server. in reconnect_dfs_server()
551 set_credits(server, 1); in reconnect_dfs_server()
552 spin_lock(&server->srv_lock); in reconnect_dfs_server()
553 if (server->tcpStatus != CifsExiting) in reconnect_dfs_server()
554 server->tcpStatus = CifsNeedNegotiate; in reconnect_dfs_server()
555 spin_unlock(&server->srv_lock); in reconnect_dfs_server()
556 cifs_swn_reset_server_dstaddr(server); in reconnect_dfs_server()
557 cifs_server_unlock(server); in reconnect_dfs_server()
558 mod_delayed_work(cifsiod_wq, &server->reconnect, 0); in reconnect_dfs_server()
559 } while (server->tcpStatus == CifsNeedReconnect); in reconnect_dfs_server()
561 mutex_lock(&server->refpath_lock); in reconnect_dfs_server()
562 dfs_cache_noreq_update_tgthint(server->leaf_fullpath + 1, target_hint); in reconnect_dfs_server()
563 mutex_unlock(&server->refpath_lock); in reconnect_dfs_server()
567 spin_lock(&server->srv_lock); in reconnect_dfs_server()
568 if (server->tcpStatus == CifsNeedNegotiate) in reconnect_dfs_server()
569 mod_delayed_work(cifsiod_wq, &server->echo, 0); in reconnect_dfs_server()
570 spin_unlock(&server->srv_lock); in reconnect_dfs_server()
572 wake_up(&server->response_q); in reconnect_dfs_server()
576 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) in cifs_reconnect() argument
578 mutex_lock(&server->refpath_lock); in cifs_reconnect()
579 if (!server->leaf_fullpath) { in cifs_reconnect()
580 mutex_unlock(&server->refpath_lock); in cifs_reconnect()
581 return __cifs_reconnect(server, mark_smb_session); in cifs_reconnect()
583 mutex_unlock(&server->refpath_lock); in cifs_reconnect()
585 return reconnect_dfs_server(server); in cifs_reconnect()
588 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) in cifs_reconnect() argument
590 return __cifs_reconnect(server, mark_smb_session); in cifs_reconnect()
598 struct TCP_Server_Info *server = container_of(work, in cifs_echo_request() local
606 if (server->tcpStatus == CifsNeedReconnect || in cifs_echo_request()
607 server->tcpStatus == CifsExiting || in cifs_echo_request()
608 server->tcpStatus == CifsNew || in cifs_echo_request()
609 (server->ops->can_echo && !server->ops->can_echo(server)) || in cifs_echo_request()
610 time_before(jiffies, server->lstrp + server->echo_interval - HZ)) in cifs_echo_request()
613 rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS; in cifs_echo_request()
620 queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval); in cifs_echo_request()
624 allocate_buffers(struct TCP_Server_Info *server) in allocate_buffers() argument
626 if (!server->bigbuf) { in allocate_buffers()
627 server->bigbuf = (char *)cifs_buf_get(); in allocate_buffers()
628 if (!server->bigbuf) { in allocate_buffers()
634 } else if (server->large_buf) { in allocate_buffers()
636 memset(server->bigbuf, 0, HEADER_SIZE(server)); in allocate_buffers()
639 if (!server->smallbuf) { in allocate_buffers()
640 server->smallbuf = (char *)cifs_small_buf_get(); in allocate_buffers()
641 if (!server->smallbuf) { in allocate_buffers()
650 memset(server->smallbuf, 0, HEADER_SIZE(server)); in allocate_buffers()
657 server_unresponsive(struct TCP_Server_Info *server) in server_unresponsive() argument
661 * and the server abruptly shut down (e.g. socket wasn't closed, packet in server_unresponsive()
665 spin_lock(&server->srv_lock); in server_unresponsive()
666 if (server->tcpStatus == CifsInNegotiate && in server_unresponsive()
667 time_after(jiffies, server->lstrp + 20 * HZ)) { in server_unresponsive()
668 spin_unlock(&server->srv_lock); in server_unresponsive()
669 cifs_reconnect(server, false); in server_unresponsive()
683 if ((server->tcpStatus == CifsGood || in server_unresponsive()
684 server->tcpStatus == CifsNeedNegotiate) && in server_unresponsive()
685 (!server->ops->can_echo || server->ops->can_echo(server)) && in server_unresponsive()
686 time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { in server_unresponsive()
687 spin_unlock(&server->srv_lock); in server_unresponsive()
689 (3 * server->echo_interval) / HZ); in server_unresponsive()
690 cifs_reconnect(server, false); in server_unresponsive()
693 spin_unlock(&server->srv_lock); in server_unresponsive()
699 zero_credits(struct TCP_Server_Info *server) in zero_credits() argument
703 spin_lock(&server->req_lock); in zero_credits()
704 val = server->credits + server->echo_credits + server->oplock_credits; in zero_credits()
705 if (server->in_flight == 0 && val == 0) { in zero_credits()
706 spin_unlock(&server->req_lock); in zero_credits()
709 spin_unlock(&server->req_lock); in zero_credits()
714 cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg) in cifs_readv_from_socket() argument
723 if (zero_credits(server)) { in cifs_readv_from_socket()
724 cifs_reconnect(server, false); in cifs_readv_from_socket()
728 if (server_unresponsive(server)) in cifs_readv_from_socket()
730 if (cifs_rdma_enabled(server) && server->smbd_conn) in cifs_readv_from_socket()
731 length = smbd_recv(server->smbd_conn, smb_msg); in cifs_readv_from_socket()
733 length = sock_recvmsg(server->ssocket, smb_msg, 0); in cifs_readv_from_socket()
735 spin_lock(&server->srv_lock); in cifs_readv_from_socket()
736 if (server->tcpStatus == CifsExiting) { in cifs_readv_from_socket()
737 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
741 if (server->tcpStatus == CifsNeedReconnect) { in cifs_readv_from_socket()
742 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
743 cifs_reconnect(server, false); in cifs_readv_from_socket()
746 spin_unlock(&server->srv_lock); in cifs_readv_from_socket()
754 * CifsNeedReconnect if server hung. in cifs_readv_from_socket()
763 cifs_reconnect(server, false); in cifs_readv_from_socket()
771 cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, in cifs_read_from_socket() argument
779 return cifs_readv_from_socket(server, &smb_msg); in cifs_read_from_socket()
783 cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) in cifs_discard_from_socket() argument
794 return cifs_readv_from_socket(server, &smb_msg); in cifs_discard_from_socket()
798 cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct iov_iter *iter, in cifs_read_iter_from_socket() argument
804 return cifs_readv_from_socket(server, &smb_msg); in cifs_read_iter_from_socket()
808 is_smb_response(struct TCP_Server_Info *server, unsigned char type) in is_smb_response() argument
831 /* give server a second to clean up */ in is_smb_response()
839 cifs_set_port((struct sockaddr *)&server->dstaddr, CIFS_PORT); in is_smb_response()
840 cifs_reconnect(server, true); in is_smb_response()
844 cifs_reconnect(server, true); in is_smb_response()
856 spin_lock(&mid->server->mid_lock); in dequeue_mid()
866 spin_unlock(&mid->server->mid_lock); in dequeue_mid()
871 spin_unlock(&mid->server->mid_lock); in dequeue_mid()
876 smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) in smb2_get_credits_from_hdr() argument
883 if (is_smb1(server)) in smb2_get_credits_from_hdr()
890 handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, in handle_mid() argument
893 if (server->ops->check_trans2 && in handle_mid()
894 server->ops->check_trans2(mid, server, buf, malformed)) in handle_mid()
896 mid->credits_received = smb2_get_credits_from_hdr(buf, server); in handle_mid()
898 mid->large_buf = server->large_buf; in handle_mid()
902 if (server->large_buf) in handle_mid()
903 server->bigbuf = NULL; in handle_mid()
905 server->smallbuf = NULL; in handle_mid()
911 cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required) in cifs_enable_signing() argument
913 bool srv_sign_required = server->sec_mode & server->vals->signing_required; in cifs_enable_signing()
914 bool srv_sign_enabled = server->sec_mode & server->vals->signing_enabled; in cifs_enable_signing()
932 /* If server requires signing, does client allow it? */ in cifs_enable_signing()
935 cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n"); in cifs_enable_signing()
938 server->sign = true; in cifs_enable_signing()
941 /* If client requires signing, does server allow it? */ in cifs_enable_signing()
944 cifs_dbg(VFS, "Server does not support signing!\n"); in cifs_enable_signing()
947 server->sign = true; in cifs_enable_signing()
950 if (cifs_rdma_enabled(server) && server->sign) in cifs_enable_signing()
957 clean_demultiplex_info(struct TCP_Server_Info *server) in clean_demultiplex_info() argument
962 spin_lock(&server->srv_lock); in clean_demultiplex_info()
963 list_del_init(&server->tcp_ses_list); in clean_demultiplex_info()
964 spin_unlock(&server->srv_lock); in clean_demultiplex_info()
966 cancel_delayed_work_sync(&server->echo); in clean_demultiplex_info()
968 spin_lock(&server->srv_lock); in clean_demultiplex_info()
969 server->tcpStatus = CifsExiting; in clean_demultiplex_info()
970 spin_unlock(&server->srv_lock); in clean_demultiplex_info()
971 wake_up_all(&server->response_q); in clean_demultiplex_info()
974 spin_lock(&server->req_lock); in clean_demultiplex_info()
975 if (server->credits <= 0) in clean_demultiplex_info()
976 server->credits = 1; in clean_demultiplex_info()
977 spin_unlock(&server->req_lock); in clean_demultiplex_info()
982 * same server - they now will see the session is in exit state and get in clean_demultiplex_info()
985 wake_up_all(&server->request_q); in clean_demultiplex_info()
988 if (cifs_rdma_enabled(server)) in clean_demultiplex_info()
989 smbd_destroy(server); in clean_demultiplex_info()
990 if (server->ssocket) { in clean_demultiplex_info()
991 sock_release(server->ssocket); in clean_demultiplex_info()
992 server->ssocket = NULL; in clean_demultiplex_info()
995 if (!list_empty(&server->pending_mid_q)) { in clean_demultiplex_info()
1000 spin_lock(&server->mid_lock); in clean_demultiplex_info()
1001 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { in clean_demultiplex_info()
1009 spin_unlock(&server->mid_lock); in clean_demultiplex_info()
1023 if (!list_empty(&server->pending_mid_q)) { in clean_demultiplex_info()
1040 kfree(server->leaf_fullpath); in clean_demultiplex_info()
1041 kfree(server); in clean_demultiplex_info()
1049 standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) in standard_receive3() argument
1052 char *buf = server->smallbuf; in standard_receive3()
1053 unsigned int pdu_length = server->pdu_size; in standard_receive3()
1056 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - in standard_receive3()
1057 HEADER_PREAMBLE_SIZE(server)) { in standard_receive3()
1059 cifs_reconnect(server, true); in standard_receive3()
1065 server->large_buf = true; in standard_receive3()
1066 memcpy(server->bigbuf, buf, server->total_read); in standard_receive3()
1067 buf = server->bigbuf; in standard_receive3()
1071 length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, in standard_receive3()
1072 pdu_length - MID_HEADER_SIZE(server)); in standard_receive3()
1076 server->total_read += length; in standard_receive3()
1078 dump_smb(buf, server->total_read); in standard_receive3()
1080 return cifs_handle_standard(server, mid); in standard_receive3()
1084 cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) in cifs_handle_standard() argument
1086 char *buf = server->large_buf ? server->bigbuf : server->smallbuf; in cifs_handle_standard()
1097 rc = server->ops->check_message(buf, server->total_read, server); in cifs_handle_standard()
1100 min_t(unsigned int, server->total_read, 48)); in cifs_handle_standard()
1102 if (server->ops->is_session_expired && in cifs_handle_standard()
1103 server->ops->is_session_expired(buf)) { in cifs_handle_standard()
1104 cifs_reconnect(server, true); in cifs_handle_standard()
1108 if (server->ops->is_status_pending && in cifs_handle_standard()
1109 server->ops->is_status_pending(buf, server)) in cifs_handle_standard()
1115 handle_mid(mid, server, buf, rc); in cifs_handle_standard()
1120 smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) in smb2_add_credits_from_hdr() argument
1128 if (is_smb1(server)) in smb2_add_credits_from_hdr()
1132 spin_lock(&server->req_lock); in smb2_add_credits_from_hdr()
1133 server->credits += le16_to_cpu(shdr->CreditRequest); in smb2_add_credits_from_hdr()
1134 scredits = server->credits; in smb2_add_credits_from_hdr()
1135 in_flight = server->in_flight; in smb2_add_credits_from_hdr()
1136 spin_unlock(&server->req_lock); in smb2_add_credits_from_hdr()
1137 wake_up(&server->request_q); in smb2_add_credits_from_hdr()
1139 trace_smb3_hdr_credits(server->CurrentMid, in smb2_add_credits_from_hdr()
1140 server->conn_id, server->hostname, scredits, in smb2_add_credits_from_hdr()
1153 struct TCP_Server_Info *server = p; in cifs_demultiplex_thread() local
1172 while (server->tcpStatus != CifsExiting) { in cifs_demultiplex_thread()
1176 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1179 server->large_buf = false; in cifs_demultiplex_thread()
1180 buf = server->smallbuf; in cifs_demultiplex_thread()
1183 length = cifs_read_from_socket(server, buf, pdu_length); in cifs_demultiplex_thread()
1187 if (is_smb1(server)) in cifs_demultiplex_thread()
1188 server->total_read = length; in cifs_demultiplex_thread()
1190 server->total_read = 0; in cifs_demultiplex_thread()
1199 if (!is_smb_response(server, buf[0])) in cifs_demultiplex_thread()
1204 server->pdu_size = pdu_length; in cifs_demultiplex_thread()
1207 if (server->pdu_size < MID_HEADER_SIZE(server)) { in cifs_demultiplex_thread()
1209 server->pdu_size); in cifs_demultiplex_thread()
1210 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1215 length = cifs_read_from_socket(server, in cifs_demultiplex_thread()
1216 buf + HEADER_PREAMBLE_SIZE(server), in cifs_demultiplex_thread()
1217 MID_HEADER_SIZE(server)); in cifs_demultiplex_thread()
1220 server->total_read += length; in cifs_demultiplex_thread()
1222 if (server->ops->next_header) { in cifs_demultiplex_thread()
1223 if (server->ops->next_header(server, buf, &next_offset)) { in cifs_demultiplex_thread()
1226 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1230 server->pdu_size = next_offset; in cifs_demultiplex_thread()
1237 if (server->ops->is_transform_hdr && in cifs_demultiplex_thread()
1238 server->ops->receive_transform && in cifs_demultiplex_thread()
1239 server->ops->is_transform_hdr(buf)) { in cifs_demultiplex_thread()
1240 length = server->ops->receive_transform(server, in cifs_demultiplex_thread()
1245 mids[0] = server->ops->find_mid(server, buf); in cifs_demultiplex_thread()
1250 length = standard_receive3(server, mids[0]); in cifs_demultiplex_thread()
1252 length = mids[0]->receive(server, mids[0]); in cifs_demultiplex_thread()
1262 if (server->ops->is_status_io_timeout && in cifs_demultiplex_thread()
1263 server->ops->is_status_io_timeout(buf)) { in cifs_demultiplex_thread()
1275 server->lstrp = jiffies; in cifs_demultiplex_thread()
1279 mids[i]->resp_buf_size = server->pdu_size; in cifs_demultiplex_thread()
1282 if (server->ops->is_network_name_deleted && in cifs_demultiplex_thread()
1283 server->ops->is_network_name_deleted(bufs[i], in cifs_demultiplex_thread()
1284 server)) { in cifs_demultiplex_thread()
1294 } else if (server->ops->is_oplock_break && in cifs_demultiplex_thread()
1295 server->ops->is_oplock_break(bufs[i], in cifs_demultiplex_thread()
1296 server)) { in cifs_demultiplex_thread()
1297 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1303 HEADER_SIZE(server)); in cifs_demultiplex_thread()
1304 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1306 if (server->ops->dump_detail) in cifs_demultiplex_thread()
1307 server->ops->dump_detail(bufs[i], in cifs_demultiplex_thread()
1308 server); in cifs_demultiplex_thread()
1309 cifs_dump_mids(server); in cifs_demultiplex_thread()
1314 if (pdu_length > server->pdu_size) { in cifs_demultiplex_thread()
1315 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1317 pdu_length -= server->pdu_size; in cifs_demultiplex_thread()
1318 server->total_read = 0; in cifs_demultiplex_thread()
1319 server->large_buf = false; in cifs_demultiplex_thread()
1320 buf = server->smallbuf; in cifs_demultiplex_thread()
1326 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1331 cifs_buf_release(server->bigbuf); in cifs_demultiplex_thread()
1332 if (server->smallbuf) /* no sense logging a debug message if NULL */ in cifs_demultiplex_thread()
1333 cifs_small_buf_release(server->smallbuf); in cifs_demultiplex_thread()
1335 task_to_wake = xchg(&server->tsk, NULL); in cifs_demultiplex_thread()
1336 clean_demultiplex_info(server); in cifs_demultiplex_thread()
1338 /* if server->tsk was NULL then wait for a signal before exiting */ in cifs_demultiplex_thread()
1434 * families of server and addr are equal.
1437 match_port(struct TCP_Server_Info *server, struct sockaddr *addr) in match_port() argument
1442 if (server->rdma) in match_port()
1447 sport = &((struct sockaddr_in *) &server->dstaddr)->sin_port; in match_port()
1451 sport = &((struct sockaddr_in6 *) &server->dstaddr)->sin6_port; in match_port()
1470 static bool match_server_address(struct TCP_Server_Info *server, struct sockaddr *addr) in match_server_address() argument
1472 if (!cifs_match_ipaddr(addr, (struct sockaddr *)&server->dstaddr)) in match_server_address()
1479 match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in match_security() argument
1486 if (server->ops->select_sectype(server, ctx->sectype) in match_security()
1493 * the server->sign had better be too. in match_security()
1495 if (ctx->sign && !server->sign) in match_security()
1502 static int match_server(struct TCP_Server_Info *server, in match_server() argument
1508 lockdep_assert_held(&server->srv_lock); in match_server()
1513 /* this server does not share socket */ in match_server()
1514 if (server->nosharesock) in match_server()
1517 if (!match_super && (ctx->dfs_conn || server->dfs_conn)) in match_server()
1522 if (server->vals->protocol_id < SMB30_PROT_ID) in match_server()
1526 if (server->vals->protocol_id < SMB21_PROT_ID) in match_server()
1528 } else if ((server->vals != ctx->vals) || (server->ops != ctx->ops)) in match_server()
1531 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) in match_server()
1535 (struct sockaddr *)&server->srcaddr)) in match_server()
1539 * really match either @server->leaf_fullpath or @server->dstaddr in match_server()
1540 * directly since this @server might belong to a completely different in match_server()
1541 * server -- in case of domain-based DFS referrals or DFS links -- as in match_server()
1544 * Otherwise, match the DFS referral in @server->leaf_fullpath or the in match_server()
1545 * destination address in @server->dstaddr. in match_server()
1552 if (server->leaf_fullpath) { in match_server()
1554 strcasecmp(server->leaf_fullpath, in match_server()
1560 } else if (server->leaf_fullpath) { in match_server()
1569 if (!server->leaf_fullpath && in match_server()
1570 (strcasecmp(server->hostname, ctx->server_hostname) || in match_server()
1571 !match_server_address(server, addr) || in match_server()
1572 !match_port(server, addr))) in match_server()
1575 if (!match_security(server, ctx)) in match_server()
1578 if (server->echo_interval != ctx->echo_interval * HZ) in match_server()
1581 if (server->rdma != ctx->rdma) in match_server()
1584 if (server->ignore_signature != ctx->ignore_signature) in match_server()
1587 if (server->min_offload != ctx->min_offload) in match_server()
1590 if (server->retrans != ctx->retrans) in match_server()
1599 struct TCP_Server_Info *server; in cifs_find_tcp_session() local
1602 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { in cifs_find_tcp_session()
1603 spin_lock(&server->srv_lock); in cifs_find_tcp_session()
1608 if (SERVER_IS_CHAN(server) || in cifs_find_tcp_session()
1609 !match_server(server, ctx, false)) { in cifs_find_tcp_session()
1610 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1613 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1615 ++server->srv_count; in cifs_find_tcp_session()
1617 cifs_dbg(FYI, "Existing tcp session with server found\n"); in cifs_find_tcp_session()
1618 return server; in cifs_find_tcp_session()
1625 cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) in cifs_put_tcp_session() argument
1630 if (--server->srv_count > 0) { in cifs_put_tcp_session()
1636 WARN_ON(server->srv_count < 0); in cifs_put_tcp_session()
1638 put_net(cifs_net_ns(server)); in cifs_put_tcp_session()
1640 list_del_init(&server->tcp_ses_list); in cifs_put_tcp_session()
1643 cancel_delayed_work_sync(&server->echo); in cifs_put_tcp_session()
1649 * that reconnect work does nothing with server pointer after in cifs_put_tcp_session()
1652 cancel_delayed_work(&server->reconnect); in cifs_put_tcp_session()
1654 cancel_delayed_work_sync(&server->reconnect); in cifs_put_tcp_session()
1656 /* For secondary channels, we pick up ref-count on the primary server */ in cifs_put_tcp_session()
1657 if (SERVER_IS_CHAN(server)) in cifs_put_tcp_session()
1658 cifs_put_tcp_session(server->primary_server, from_reconnect); in cifs_put_tcp_session()
1660 spin_lock(&server->srv_lock); in cifs_put_tcp_session()
1661 server->tcpStatus = CifsExiting; in cifs_put_tcp_session()
1662 spin_unlock(&server->srv_lock); in cifs_put_tcp_session()
1664 cifs_crypto_secmech_release(server); in cifs_put_tcp_session()
1666 kfree_sensitive(server->session_key.response); in cifs_put_tcp_session()
1667 server->session_key.response = NULL; in cifs_put_tcp_session()
1668 server->session_key.len = 0; in cifs_put_tcp_session()
1669 kfree(server->hostname); in cifs_put_tcp_session()
1670 server->hostname = NULL; in cifs_put_tcp_session()
1672 task = xchg(&server->tsk, NULL); in cifs_put_tcp_session()
1930 struct TCP_Server_Info *server = ses->server; in cifs_setup_ipc() local
1937 if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) in cifs_setup_ipc()
1941 "IPC: server doesn't support encryption\n"); in cifs_setup_ipc()
1951 spin_lock(&server->srv_lock); in cifs_setup_ipc()
1952 scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname); in cifs_setup_ipc()
1953 spin_unlock(&server->srv_lock); in cifs_setup_ipc()
1959 rc = server->ops->tree_connect(xid, ses, unc, tcon, ctx->local_nls); in cifs_setup_ipc()
1979 cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_find_smb_ses() argument
1984 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { in cifs_find_smb_ses()
2008 struct TCP_Server_Info *server = ses->server; in __cifs_put_smb_ses() local
2029 cifs_chan_clear_need_reconnect(ses, server); in __cifs_put_smb_ses()
2032 do_logoff = ses->ses_status == SES_GOOD && server->ops->logoff; in __cifs_put_smb_ses()
2040 * On session close, the IPC is closed and the server must release all in __cifs_put_smb_ses()
2043 * Besides, it will make the server to not close durable and resilient in __cifs_put_smb_ses()
2050 rc = server->ops->logoff(xid, ses); in __cifs_put_smb_ses()
2066 cifs_put_tcp_session(ses->chans[i].server, 0); in __cifs_put_smb_ses()
2067 ses->chans[i].server = NULL; in __cifs_put_smb_ses()
2073 ses->chans[0].server = NULL; in __cifs_put_smb_ses()
2077 cifs_put_tcp_session(server, 0); in __cifs_put_smb_ses()
2095 struct TCP_Server_Info *server = ses->server; in cifs_set_cifscreds() local
2105 switch (server->dstaddr.ss_family) { in cifs_set_cifscreds()
2107 sa = (struct sockaddr_in *)&server->dstaddr; in cifs_set_cifscreds()
2111 sa6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_set_cifscreds()
2116 server->dstaddr.ss_family); in cifs_set_cifscreds()
2236 * cifs_get_smb_ses - get a session matching @ctx data from @server
2237 * @server: server to setup the session to
2241 * already got a server reference (server refcount +1). See
2245 cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_get_smb_ses() argument
2250 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in cifs_get_smb_ses()
2251 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_get_smb_ses()
2255 ses = cifs_find_smb_ses(server, ctx); in cifs_get_smb_ses()
2261 if (cifs_chan_needs_reconnect(ses, server)) { in cifs_get_smb_ses()
2266 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2275 rc = cifs_setup_session(xid, ses, server, in cifs_get_smb_ses()
2290 /* existing SMB ses has a server reference already */ in cifs_get_smb_ses()
2291 cifs_put_tcp_session(server, 0); in cifs_get_smb_ses()
2303 /* new SMB session uses our server ref */ in cifs_get_smb_ses()
2304 ses->server = server; in cifs_get_smb_ses()
2305 if (server->dstaddr.ss_family == AF_INET6) in cifs_get_smb_ses()
2345 /* add server as first channel */ in cifs_get_smb_ses()
2347 ses->chans[0].server = server; in cifs_get_smb_ses()
2354 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2356 rc = cifs_setup_session(xid, ses, server, ctx->local_nls); in cifs_get_smb_ses()
2375 list_add(&ses->smb_ses_list, &server->smb_ses_list); in cifs_get_smb_ses()
2393 struct TCP_Server_Info *server = tcon->ses->server; in match_tcon() local
2403 } else if (!server->leaf_fullpath && in match_tcon()
2496 if (ses->server->ops->tree_disconnect) in cifs_put_tcon()
2497 ses->server->ops->tree_disconnect(xid, tcon); in cifs_put_tcon()
2548 if (!ses->server->ops->tree_connect) { in cifs_get_tcon()
2553 if (ses->server->dialect >= SMB20_PROT_ID && in cifs_get_tcon()
2554 (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)) in cifs_get_tcon()
2566 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2576 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2595 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2600 } else if (tcon->ses->server->capabilities & in cifs_get_tcon()
2611 if (ses->server->posix_ext_supported) { in cifs_get_tcon()
2614 } else if ((ses->server->vals->protocol_id == SMB311_PROT_ID) || in cifs_get_tcon()
2615 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2617 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2619 cifs_dbg(VFS, "Server does not support mounting with posix SMB3.11 extensions\n"); in cifs_get_tcon()
2622 } else if (ses->server->vals->protocol_id == SMB10_PROT_ID) in cifs_get_tcon()
2626 cifs_dbg(VFS, "SMB1 Unix Extensions not supported by server\n"); in cifs_get_tcon()
2638 rc = ses->server->ops->tree_connect(xid, ses, ctx->UNC, tcon, in cifs_get_tcon()
2648 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2653 } else if (ses->server->capabilities & in cifs_get_tcon()
2663 && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) in cifs_get_tcon()
2668 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2679 if (ses->server->vals->protocol_id >= SMB30_PROT_ID) { in cifs_get_tcon()
2714 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2725 * resources mounted more than once to the same server share the last in cifs_get_tcon()
2739 if (ses->server->dialect >= SMB30_PROT_ID && in cifs_get_tcon()
2740 (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { in cifs_get_tcon()
2880 tcp_srv = ses->server; in cifs_match_super()
2958 bind_socket(struct TCP_Server_Info *server) in bind_socket() argument
2962 if (server->srcaddr.ss_family != AF_UNSPEC) { in bind_socket()
2964 struct socket *socket = server->ssocket; in bind_socket()
2967 (struct sockaddr *) &server->srcaddr, in bind_socket()
2968 sizeof(server->srcaddr)); in bind_socket()
2973 saddr4 = (struct sockaddr_in *)&server->srcaddr; in bind_socket()
2974 saddr6 = (struct sockaddr_in6 *)&server->srcaddr; in bind_socket()
2987 ip_rfc1001_connect(struct TCP_Server_Info *server) in ip_rfc1001_connect() argument
3001 if (server->server_RFC1001_name[0] != 0) in ip_rfc1001_connect()
3003 server->server_RFC1001_name, in ip_rfc1001_connect()
3013 if (server->workstation_RFC1001_name[0] != 0) in ip_rfc1001_connect()
3015 server->workstation_RFC1001_name, in ip_rfc1001_connect()
3029 rc = smb_send(server, smb_buf, len); in ip_rfc1001_connect()
3031 * RFC1001 layer in at least one server requires very short break before in ip_rfc1001_connect()
3042 generic_ip_connect(struct TCP_Server_Info *server) in generic_ip_connect() argument
3050 saddr = (struct sockaddr *) &server->dstaddr; in generic_ip_connect()
3052 if (server->dstaddr.ss_family == AF_INET6) { in generic_ip_connect()
3053 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&server->dstaddr; in generic_ip_connect()
3061 struct sockaddr_in *ipv4 = (struct sockaddr_in *)&server->dstaddr; in generic_ip_connect()
3070 if (server->ssocket) { in generic_ip_connect()
3071 socket = server->ssocket; in generic_ip_connect()
3073 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM, in generic_ip_connect()
3074 IPPROTO_TCP, &server->ssocket, 1); in generic_ip_connect()
3082 socket = server->ssocket; in generic_ip_connect()
3091 rc = bind_socket(server); in generic_ip_connect()
3104 if (server->noautotune) { in generic_ip_connect()
3111 if (server->tcp_nodelay) in generic_ip_connect()
3119 server->noblockcnt ? O_NONBLOCK : 0); in generic_ip_connect()
3125 if (server->noblockcnt && rc == -EINPROGRESS) in generic_ip_connect()
3128 cifs_dbg(FYI, "Error %d connecting to server\n", rc); in generic_ip_connect()
3129 trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc); in generic_ip_connect()
3131 server->ssocket = NULL; in generic_ip_connect()
3134 trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr); in generic_ip_connect()
3136 rc = ip_rfc1001_connect(server); in generic_ip_connect()
3142 ip_connect(struct TCP_Server_Info *server) in ip_connect() argument
3145 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in ip_connect()
3146 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in ip_connect()
3148 if (server->dstaddr.ss_family == AF_INET6) in ip_connect()
3159 rc = generic_ip_connect(server); in ip_connect()
3167 return generic_ip_connect(server); in ip_connect()
3182 * What if we wanted to mount the server share twice once with in reset_cifs_unix_caps()
3203 cifs_dbg(FYI, "unix caps which server supports %lld\n", cap); in reset_cifs_unix_caps()
3221 cifs_dbg(VFS, "server disabled POSIX path support\n"); in reset_cifs_unix_caps()
3272 …cifs_dbg(VFS, "Negotiating Unix capabilities with the server failed. Consider mounting with the Un… in reset_cifs_unix_caps()
3340 else if (mnt_ctx->server) in cifs_mount_put_conns()
3341 cifs_put_tcp_session(mnt_ctx->server, 0); in cifs_mount_put_conns()
3344 mnt_ctx->server = NULL; in cifs_mount_put_conns()
3351 struct TCP_Server_Info *server = NULL; in cifs_mount_get_session() local
3366 server = cifs_get_tcp_session(ctx, NULL); in cifs_mount_get_session()
3367 if (IS_ERR(server)) { in cifs_mount_get_session()
3368 rc = PTR_ERR(server); in cifs_mount_get_session()
3369 server = NULL; in cifs_mount_get_session()
3374 ses = cifs_get_smb_ses(server, ctx); in cifs_mount_get_session()
3381 if ((ctx->persistent == true) && (!(ses->server->capabilities & in cifs_mount_get_session()
3383 cifs_server_dbg(VFS, "persistent handles not supported by server\n"); in cifs_mount_get_session()
3389 mnt_ctx->server = server; in cifs_mount_get_session()
3398 struct TCP_Server_Info *server; in cifs_mount_get_tcon() local
3404 if (WARN_ON_ONCE(!mnt_ctx || !mnt_ctx->server || !mnt_ctx->ses || !mnt_ctx->fs_ctx || in cifs_mount_get_tcon()
3409 server = mnt_ctx->server; in cifs_mount_get_tcon()
3413 /* search for existing tcon to this server share */ in cifs_mount_get_tcon()
3426 /* tell server which Unix caps we support */ in cifs_mount_get_tcon()
3433 spin_lock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3434 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && in cifs_mount_get_tcon()
3437 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3441 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3444 tcon->unix_ext = 0; /* server does not support them */ in cifs_mount_get_tcon()
3447 if (!tcon->pipe && server->ops->qfs_tcon) { in cifs_mount_get_tcon()
3448 server->ops->qfs_tcon(mnt_ctx->xid, tcon, cifs_sb); in cifs_mount_get_tcon()
3461 * Clamp the rsize/wsize mount arguments if they are too big for the server in cifs_mount_get_tcon()
3466 (cifs_sb->ctx->wsize > server->ops->negotiate_wsize(tcon, ctx))) { in cifs_mount_get_tcon()
3468 round_down(server->ops->negotiate_wsize(tcon, ctx), PAGE_SIZE); in cifs_mount_get_tcon()
3470 * in the very unlikely event that the server sent a max write size under PAGE_SIZE, in cifs_mount_get_tcon()
3479 (cifs_sb->ctx->rsize > server->ops->negotiate_rsize(tcon, ctx))) in cifs_mount_get_tcon()
3480 cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tcon, ctx); in cifs_mount_get_tcon()
3522 cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, in cifs_are_all_path_components_accessible() argument
3537 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); in cifs_are_all_path_components_accessible()
3561 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_are_all_path_components_accessible()
3577 struct TCP_Server_Info *server = mnt_ctx->server; in cifs_is_path_remote() local
3583 if (!server->ops->is_path_accessible) in cifs_is_path_remote()
3596 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_is_path_remote()
3602 rc = cifs_are_all_path_components_accessible(server, xid, tcon, in cifs_is_path_remote()
3629 * After reconnecting to a different server, unique ids won't match anymore, so we disable in cifs_mount()
3671 if (WARN_ON(!mnt_ctx.server)) in cifs_mount()
3730 smb_buffer->Mid = get_next_mid(ses->server); in CIFSTCon()
3744 if (ses->server->sign) in CIFSTCon()
3758 (/* server len*/ + 256 /* share len */), nls_codepage); in CIFSTCon()
3879 struct TCP_Server_Info *server) in cifs_negotiate_protocol() argument
3883 if (!server->ops->need_neg || !server->ops->negotiate) in cifs_negotiate_protocol()
3887 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3888 if (server->tcpStatus != CifsGood && in cifs_negotiate_protocol()
3889 server->tcpStatus != CifsNew && in cifs_negotiate_protocol()
3890 server->tcpStatus != CifsNeedNegotiate) { in cifs_negotiate_protocol()
3891 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3895 if (!server->ops->need_neg(server) && in cifs_negotiate_protocol()
3896 server->tcpStatus == CifsGood) { in cifs_negotiate_protocol()
3897 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3901 server->tcpStatus = CifsInNegotiate; in cifs_negotiate_protocol()
3902 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3904 rc = server->ops->negotiate(xid, ses, server); in cifs_negotiate_protocol()
3906 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3907 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3908 server->tcpStatus = CifsGood; in cifs_negotiate_protocol()
3911 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3913 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3914 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3915 server->tcpStatus = CifsNeedNegotiate; in cifs_negotiate_protocol()
3916 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3924 struct TCP_Server_Info *server, in cifs_setup_session() argument
3928 struct TCP_Server_Info *pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_setup_session()
3954 cifs_chan_set_in_reconnect(ses, server); in cifs_setup_session()
3967 if (server == pserver) { in cifs_setup_session()
3968 if (server->dstaddr.ss_family == AF_INET6) in cifs_setup_session()
3975 ses->capabilities = server->capabilities; in cifs_setup_session()
3977 ses->capabilities &= (~server->vals->cap_unix); in cifs_setup_session()
3989 server->sec_mode, server->capabilities, server->timeAdj); in cifs_setup_session()
3991 if (server->ops->sess_setup) in cifs_setup_session()
3992 rc = server->ops->sess_setup(xid, ses, server, nls_info); in cifs_setup_session()
4000 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
4008 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
4009 cifs_chan_clear_need_reconnect(ses, server); in cifs_setup_session()
4071 ++master_tcon->ses->server->srv_count; in cifs_construct_tcon()
4074 ses = cifs_get_smb_ses(master_tcon->ses->server, ctx); in cifs_construct_tcon()
4077 cifs_put_tcp_session(master_tcon->ses->server, 0); in cifs_construct_tcon()
4322 const struct smb_version_operations *ops = tcon->ses->server->ops; in cifs_tree_connect()