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 put_net(cifs_net_ns(server)); in clean_demultiplex_info()
1041 kfree(server->leaf_fullpath); in clean_demultiplex_info()
1042 kfree(server); in clean_demultiplex_info()
1050 standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) in standard_receive3() argument
1053 char *buf = server->smallbuf; in standard_receive3()
1054 unsigned int pdu_length = server->pdu_size; in standard_receive3()
1057 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - in standard_receive3()
1058 HEADER_PREAMBLE_SIZE(server)) { in standard_receive3()
1060 cifs_reconnect(server, true); in standard_receive3()
1066 server->large_buf = true; in standard_receive3()
1067 memcpy(server->bigbuf, buf, server->total_read); in standard_receive3()
1068 buf = server->bigbuf; in standard_receive3()
1072 length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, in standard_receive3()
1073 pdu_length - MID_HEADER_SIZE(server)); in standard_receive3()
1077 server->total_read += length; in standard_receive3()
1079 dump_smb(buf, server->total_read); in standard_receive3()
1081 return cifs_handle_standard(server, mid); in standard_receive3()
1085 cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) in cifs_handle_standard() argument
1087 char *buf = server->large_buf ? server->bigbuf : server->smallbuf; in cifs_handle_standard()
1098 rc = server->ops->check_message(buf, server->total_read, server); in cifs_handle_standard()
1101 min_t(unsigned int, server->total_read, 48)); in cifs_handle_standard()
1103 if (server->ops->is_session_expired && in cifs_handle_standard()
1104 server->ops->is_session_expired(buf)) { in cifs_handle_standard()
1105 cifs_reconnect(server, true); in cifs_handle_standard()
1109 if (server->ops->is_status_pending && in cifs_handle_standard()
1110 server->ops->is_status_pending(buf, server)) in cifs_handle_standard()
1116 handle_mid(mid, server, buf, rc); in cifs_handle_standard()
1121 smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) in smb2_add_credits_from_hdr() argument
1129 if (is_smb1(server)) in smb2_add_credits_from_hdr()
1133 spin_lock(&server->req_lock); in smb2_add_credits_from_hdr()
1134 server->credits += le16_to_cpu(shdr->CreditRequest); in smb2_add_credits_from_hdr()
1135 scredits = server->credits; in smb2_add_credits_from_hdr()
1136 in_flight = server->in_flight; in smb2_add_credits_from_hdr()
1137 spin_unlock(&server->req_lock); in smb2_add_credits_from_hdr()
1138 wake_up(&server->request_q); in smb2_add_credits_from_hdr()
1140 trace_smb3_hdr_credits(server->CurrentMid, in smb2_add_credits_from_hdr()
1141 server->conn_id, server->hostname, scredits, in smb2_add_credits_from_hdr()
1154 struct TCP_Server_Info *server = p; in cifs_demultiplex_thread() local
1173 while (server->tcpStatus != CifsExiting) { in cifs_demultiplex_thread()
1177 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1180 server->large_buf = false; in cifs_demultiplex_thread()
1181 buf = server->smallbuf; in cifs_demultiplex_thread()
1184 length = cifs_read_from_socket(server, buf, pdu_length); in cifs_demultiplex_thread()
1188 if (is_smb1(server)) in cifs_demultiplex_thread()
1189 server->total_read = length; in cifs_demultiplex_thread()
1191 server->total_read = 0; in cifs_demultiplex_thread()
1200 if (!is_smb_response(server, buf[0])) in cifs_demultiplex_thread()
1205 server->pdu_size = pdu_length; in cifs_demultiplex_thread()
1208 if (server->pdu_size < MID_HEADER_SIZE(server)) { in cifs_demultiplex_thread()
1210 server->pdu_size); in cifs_demultiplex_thread()
1211 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1216 length = cifs_read_from_socket(server, in cifs_demultiplex_thread()
1217 buf + HEADER_PREAMBLE_SIZE(server), in cifs_demultiplex_thread()
1218 MID_HEADER_SIZE(server)); in cifs_demultiplex_thread()
1221 server->total_read += length; in cifs_demultiplex_thread()
1223 if (server->ops->next_header) { in cifs_demultiplex_thread()
1224 if (server->ops->next_header(server, buf, &next_offset)) { in cifs_demultiplex_thread()
1227 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1231 server->pdu_size = next_offset; in cifs_demultiplex_thread()
1238 if (server->ops->is_transform_hdr && in cifs_demultiplex_thread()
1239 server->ops->receive_transform && in cifs_demultiplex_thread()
1240 server->ops->is_transform_hdr(buf)) { in cifs_demultiplex_thread()
1241 length = server->ops->receive_transform(server, in cifs_demultiplex_thread()
1246 mids[0] = server->ops->find_mid(server, buf); in cifs_demultiplex_thread()
1251 length = standard_receive3(server, mids[0]); in cifs_demultiplex_thread()
1253 length = mids[0]->receive(server, mids[0]); in cifs_demultiplex_thread()
1263 if (server->ops->is_status_io_timeout && in cifs_demultiplex_thread()
1264 server->ops->is_status_io_timeout(buf)) { in cifs_demultiplex_thread()
1276 server->lstrp = jiffies; in cifs_demultiplex_thread()
1280 mids[i]->resp_buf_size = server->pdu_size; in cifs_demultiplex_thread()
1283 if (server->ops->is_network_name_deleted && in cifs_demultiplex_thread()
1284 server->ops->is_network_name_deleted(bufs[i], in cifs_demultiplex_thread()
1285 server)) { in cifs_demultiplex_thread()
1295 } else if (server->ops->is_oplock_break && in cifs_demultiplex_thread()
1296 server->ops->is_oplock_break(bufs[i], in cifs_demultiplex_thread()
1297 server)) { in cifs_demultiplex_thread()
1298 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1304 HEADER_SIZE(server)); in cifs_demultiplex_thread()
1305 smb2_add_credits_from_hdr(bufs[i], server); in cifs_demultiplex_thread()
1307 if (server->ops->dump_detail) in cifs_demultiplex_thread()
1308 server->ops->dump_detail(bufs[i], in cifs_demultiplex_thread()
1309 server); in cifs_demultiplex_thread()
1310 cifs_dump_mids(server); in cifs_demultiplex_thread()
1315 if (pdu_length > server->pdu_size) { in cifs_demultiplex_thread()
1316 if (!allocate_buffers(server)) in cifs_demultiplex_thread()
1318 pdu_length -= server->pdu_size; in cifs_demultiplex_thread()
1319 server->total_read = 0; in cifs_demultiplex_thread()
1320 server->large_buf = false; in cifs_demultiplex_thread()
1321 buf = server->smallbuf; in cifs_demultiplex_thread()
1327 cifs_reconnect(server, true); in cifs_demultiplex_thread()
1332 cifs_buf_release(server->bigbuf); in cifs_demultiplex_thread()
1333 if (server->smallbuf) /* no sense logging a debug message if NULL */ in cifs_demultiplex_thread()
1334 cifs_small_buf_release(server->smallbuf); in cifs_demultiplex_thread()
1336 task_to_wake = xchg(&server->tsk, NULL); in cifs_demultiplex_thread()
1337 clean_demultiplex_info(server); in cifs_demultiplex_thread()
1339 /* if server->tsk was NULL then wait for a signal before exiting */ in cifs_demultiplex_thread()
1435 * families of server and addr are equal.
1438 match_port(struct TCP_Server_Info *server, struct sockaddr *addr) in match_port() argument
1443 if (server->rdma) in match_port()
1448 sport = &((struct sockaddr_in *) &server->dstaddr)->sin_port; in match_port()
1452 sport = &((struct sockaddr_in6 *) &server->dstaddr)->sin6_port; in match_port()
1471 static bool match_server_address(struct TCP_Server_Info *server, struct sockaddr *addr) in match_server_address() argument
1473 if (!cifs_match_ipaddr(addr, (struct sockaddr *)&server->dstaddr)) in match_server_address()
1480 match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in match_security() argument
1487 if (server->ops->select_sectype(server, ctx->sectype) in match_security()
1494 * the server->sign had better be too. in match_security()
1496 if (ctx->sign && !server->sign) in match_security()
1503 static int match_server(struct TCP_Server_Info *server, in match_server() argument
1509 lockdep_assert_held(&server->srv_lock); in match_server()
1514 /* this server does not share socket */ in match_server()
1515 if (server->nosharesock) in match_server()
1518 if (!match_super && (ctx->dfs_conn || server->dfs_conn)) in match_server()
1523 if (server->vals->protocol_id < SMB30_PROT_ID) in match_server()
1527 if (server->vals->protocol_id < SMB21_PROT_ID) in match_server()
1529 } else if ((server->vals != ctx->vals) || (server->ops != ctx->ops)) in match_server()
1532 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) in match_server()
1536 (struct sockaddr *)&server->srcaddr)) in match_server()
1540 * really match either @server->leaf_fullpath or @server->dstaddr in match_server()
1541 * directly since this @server might belong to a completely different in match_server()
1542 * server -- in case of domain-based DFS referrals or DFS links -- as in match_server()
1545 * Otherwise, match the DFS referral in @server->leaf_fullpath or the in match_server()
1546 * destination address in @server->dstaddr. in match_server()
1553 if (server->leaf_fullpath) { in match_server()
1555 strcasecmp(server->leaf_fullpath, in match_server()
1561 } else if (server->leaf_fullpath) { in match_server()
1570 if (!server->leaf_fullpath && in match_server()
1571 (strcasecmp(server->hostname, ctx->server_hostname) || in match_server()
1572 !match_server_address(server, addr) || in match_server()
1573 !match_port(server, addr))) in match_server()
1576 if (!match_security(server, ctx)) in match_server()
1579 if (server->echo_interval != ctx->echo_interval * HZ) in match_server()
1582 if (server->rdma != ctx->rdma) in match_server()
1585 if (server->ignore_signature != ctx->ignore_signature) in match_server()
1588 if (server->min_offload != ctx->min_offload) in match_server()
1591 if (server->retrans != ctx->retrans) in match_server()
1600 struct TCP_Server_Info *server; in cifs_find_tcp_session() local
1603 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { in cifs_find_tcp_session()
1604 spin_lock(&server->srv_lock); in cifs_find_tcp_session()
1609 if (SERVER_IS_CHAN(server) || in cifs_find_tcp_session()
1610 !match_server(server, ctx, false)) { in cifs_find_tcp_session()
1611 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1614 spin_unlock(&server->srv_lock); in cifs_find_tcp_session()
1616 ++server->srv_count; in cifs_find_tcp_session()
1618 cifs_dbg(FYI, "Existing tcp session with server found\n"); in cifs_find_tcp_session()
1619 return server; in cifs_find_tcp_session()
1626 cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) in cifs_put_tcp_session() argument
1631 if (--server->srv_count > 0) { in cifs_put_tcp_session()
1637 WARN_ON(server->srv_count < 0); in cifs_put_tcp_session()
1639 list_del_init(&server->tcp_ses_list); in cifs_put_tcp_session()
1642 cancel_delayed_work_sync(&server->echo); in cifs_put_tcp_session()
1648 * that reconnect work does nothing with server pointer after in cifs_put_tcp_session()
1651 cancel_delayed_work(&server->reconnect); in cifs_put_tcp_session()
1653 cancel_delayed_work_sync(&server->reconnect); in cifs_put_tcp_session()
1655 /* For secondary channels, we pick up ref-count on the primary server */ in cifs_put_tcp_session()
1656 if (SERVER_IS_CHAN(server)) in cifs_put_tcp_session()
1657 cifs_put_tcp_session(server->primary_server, from_reconnect); in cifs_put_tcp_session()
1659 spin_lock(&server->srv_lock); in cifs_put_tcp_session()
1660 server->tcpStatus = CifsExiting; in cifs_put_tcp_session()
1661 spin_unlock(&server->srv_lock); in cifs_put_tcp_session()
1663 cifs_crypto_secmech_release(server); in cifs_put_tcp_session()
1665 kfree_sensitive(server->session_key.response); in cifs_put_tcp_session()
1666 server->session_key.response = NULL; in cifs_put_tcp_session()
1667 server->session_key.len = 0; in cifs_put_tcp_session()
1668 kfree(server->hostname); in cifs_put_tcp_session()
1669 server->hostname = NULL; in cifs_put_tcp_session()
1671 task = xchg(&server->tsk, NULL); in cifs_put_tcp_session()
1929 struct TCP_Server_Info *server = ses->server; in cifs_setup_ipc() local
1936 if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) in cifs_setup_ipc()
1940 "IPC: server doesn't support encryption\n"); in cifs_setup_ipc()
1950 spin_lock(&server->srv_lock); in cifs_setup_ipc()
1951 scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname); in cifs_setup_ipc()
1952 spin_unlock(&server->srv_lock); in cifs_setup_ipc()
1958 rc = server->ops->tree_connect(xid, ses, unc, tcon, ctx->local_nls); in cifs_setup_ipc()
1978 cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_find_smb_ses() argument
1983 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { in cifs_find_smb_ses()
2007 struct TCP_Server_Info *server = ses->server; in __cifs_put_smb_ses() local
2028 cifs_chan_clear_need_reconnect(ses, server); in __cifs_put_smb_ses()
2031 do_logoff = ses->ses_status == SES_GOOD && server->ops->logoff; in __cifs_put_smb_ses()
2039 * On session close, the IPC is closed and the server must release all in __cifs_put_smb_ses()
2042 * Besides, it will make the server to not close durable and resilient in __cifs_put_smb_ses()
2049 rc = server->ops->logoff(xid, ses); in __cifs_put_smb_ses()
2065 cifs_put_tcp_session(ses->chans[i].server, 0); in __cifs_put_smb_ses()
2066 ses->chans[i].server = NULL; in __cifs_put_smb_ses()
2072 ses->chans[0].server = NULL; in __cifs_put_smb_ses()
2076 cifs_put_tcp_session(server, 0); in __cifs_put_smb_ses()
2094 struct TCP_Server_Info *server = ses->server; in cifs_set_cifscreds() local
2104 switch (server->dstaddr.ss_family) { in cifs_set_cifscreds()
2106 sa = (struct sockaddr_in *)&server->dstaddr; in cifs_set_cifscreds()
2110 sa6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_set_cifscreds()
2115 server->dstaddr.ss_family); in cifs_set_cifscreds()
2235 * cifs_get_smb_ses - get a session matching @ctx data from @server
2236 * @server: server to setup the session to
2240 * already got a server reference (server refcount +1). See
2244 cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) in cifs_get_smb_ses() argument
2249 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in cifs_get_smb_ses()
2250 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in cifs_get_smb_ses()
2254 ses = cifs_find_smb_ses(server, ctx); in cifs_get_smb_ses()
2260 if (cifs_chan_needs_reconnect(ses, server)) { in cifs_get_smb_ses()
2265 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2274 rc = cifs_setup_session(xid, ses, server, in cifs_get_smb_ses()
2289 /* existing SMB ses has a server reference already */ in cifs_get_smb_ses()
2290 cifs_put_tcp_session(server, 0); in cifs_get_smb_ses()
2302 /* new SMB session uses our server ref */ in cifs_get_smb_ses()
2303 ses->server = server; in cifs_get_smb_ses()
2304 if (server->dstaddr.ss_family == AF_INET6) in cifs_get_smb_ses()
2344 /* add server as first channel */ in cifs_get_smb_ses()
2346 ses->chans[0].server = server; in cifs_get_smb_ses()
2353 rc = cifs_negotiate_protocol(xid, ses, server); in cifs_get_smb_ses()
2355 rc = cifs_setup_session(xid, ses, server, ctx->local_nls); in cifs_get_smb_ses()
2374 list_add(&ses->smb_ses_list, &server->smb_ses_list); in cifs_get_smb_ses()
2392 struct TCP_Server_Info *server = tcon->ses->server; in match_tcon() local
2402 } else if (!server->leaf_fullpath && in match_tcon()
2495 if (ses->server->ops->tree_disconnect) in cifs_put_tcon()
2496 ses->server->ops->tree_disconnect(xid, tcon); in cifs_put_tcon()
2547 if (!ses->server->ops->tree_connect) { in cifs_get_tcon()
2552 if (ses->server->dialect >= SMB20_PROT_ID && in cifs_get_tcon()
2553 (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)) in cifs_get_tcon()
2565 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2575 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2594 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2599 } else if (tcon->ses->server->capabilities & in cifs_get_tcon()
2610 if (ses->server->posix_ext_supported) { in cifs_get_tcon()
2613 } else if ((ses->server->vals->protocol_id == SMB311_PROT_ID) || in cifs_get_tcon()
2614 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2616 (strcmp(ses->server->vals->version_string, in cifs_get_tcon()
2618 cifs_dbg(VFS, "Server does not support mounting with posix SMB3.11 extensions\n"); in cifs_get_tcon()
2621 } else if (ses->server->vals->protocol_id == SMB10_PROT_ID) in cifs_get_tcon()
2625 cifs_dbg(VFS, "SMB1 Unix Extensions not supported by server\n"); in cifs_get_tcon()
2637 rc = ses->server->ops->tree_connect(xid, ses, ctx->UNC, tcon, in cifs_get_tcon()
2647 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2652 } else if (ses->server->capabilities & in cifs_get_tcon()
2662 && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) in cifs_get_tcon()
2667 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2678 if (ses->server->vals->protocol_id >= SMB30_PROT_ID) { in cifs_get_tcon()
2713 if (ses->server->vals->protocol_id == 0) { in cifs_get_tcon()
2724 * resources mounted more than once to the same server share the last in cifs_get_tcon()
2738 if (ses->server->dialect >= SMB30_PROT_ID && in cifs_get_tcon()
2739 (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { in cifs_get_tcon()
2879 tcp_srv = ses->server; in cifs_match_super()
2957 bind_socket(struct TCP_Server_Info *server) in bind_socket() argument
2961 if (server->srcaddr.ss_family != AF_UNSPEC) { in bind_socket()
2963 struct socket *socket = server->ssocket; in bind_socket()
2966 (struct sockaddr *) &server->srcaddr, in bind_socket()
2967 sizeof(server->srcaddr)); in bind_socket()
2972 saddr4 = (struct sockaddr_in *)&server->srcaddr; in bind_socket()
2973 saddr6 = (struct sockaddr_in6 *)&server->srcaddr; in bind_socket()
2986 ip_rfc1001_connect(struct TCP_Server_Info *server) in ip_rfc1001_connect() argument
3000 if (server->server_RFC1001_name[0] != 0) in ip_rfc1001_connect()
3002 server->server_RFC1001_name, in ip_rfc1001_connect()
3012 if (server->workstation_RFC1001_name[0] != 0) in ip_rfc1001_connect()
3014 server->workstation_RFC1001_name, in ip_rfc1001_connect()
3028 rc = smb_send(server, smb_buf, len); in ip_rfc1001_connect()
3030 * RFC1001 layer in at least one server requires very short break before in ip_rfc1001_connect()
3041 generic_ip_connect(struct TCP_Server_Info *server) in generic_ip_connect() argument
3049 saddr = (struct sockaddr *) &server->dstaddr; in generic_ip_connect()
3051 if (server->dstaddr.ss_family == AF_INET6) { in generic_ip_connect()
3052 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&server->dstaddr; in generic_ip_connect()
3060 struct sockaddr_in *ipv4 = (struct sockaddr_in *)&server->dstaddr; in generic_ip_connect()
3069 if (server->ssocket) { in generic_ip_connect()
3070 socket = server->ssocket; in generic_ip_connect()
3072 struct net *net = cifs_net_ns(server); in generic_ip_connect()
3076 IPPROTO_TCP, &server->ssocket, 1); in generic_ip_connect()
3082 sk = server->ssocket->sk; in generic_ip_connect()
3090 socket = server->ssocket; in generic_ip_connect()
3099 rc = bind_socket(server); in generic_ip_connect()
3112 if (server->noautotune) { in generic_ip_connect()
3119 if (server->tcp_nodelay) in generic_ip_connect()
3127 server->noblockcnt ? O_NONBLOCK : 0); in generic_ip_connect()
3133 if (server->noblockcnt && rc == -EINPROGRESS) in generic_ip_connect()
3136 cifs_dbg(FYI, "Error %d connecting to server\n", rc); in generic_ip_connect()
3137 trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc); in generic_ip_connect()
3139 server->ssocket = NULL; in generic_ip_connect()
3142 trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr); in generic_ip_connect()
3144 rc = ip_rfc1001_connect(server); in generic_ip_connect()
3150 ip_connect(struct TCP_Server_Info *server) in ip_connect() argument
3153 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&server->dstaddr; in ip_connect()
3154 struct sockaddr_in *addr = (struct sockaddr_in *)&server->dstaddr; in ip_connect()
3156 if (server->dstaddr.ss_family == AF_INET6) in ip_connect()
3167 rc = generic_ip_connect(server); in ip_connect()
3175 return generic_ip_connect(server); in ip_connect()
3190 * What if we wanted to mount the server share twice once with in reset_cifs_unix_caps()
3211 cifs_dbg(FYI, "unix caps which server supports %lld\n", cap); in reset_cifs_unix_caps()
3229 cifs_dbg(VFS, "server disabled POSIX path support\n"); in reset_cifs_unix_caps()
3280 …cifs_dbg(VFS, "Negotiating Unix capabilities with the server failed. Consider mounting with the Un… in reset_cifs_unix_caps()
3348 else if (mnt_ctx->server) in cifs_mount_put_conns()
3349 cifs_put_tcp_session(mnt_ctx->server, 0); in cifs_mount_put_conns()
3352 mnt_ctx->server = NULL; in cifs_mount_put_conns()
3359 struct TCP_Server_Info *server = NULL; in cifs_mount_get_session() local
3374 server = cifs_get_tcp_session(ctx, NULL); in cifs_mount_get_session()
3375 if (IS_ERR(server)) { in cifs_mount_get_session()
3376 rc = PTR_ERR(server); in cifs_mount_get_session()
3377 server = NULL; in cifs_mount_get_session()
3382 ses = cifs_get_smb_ses(server, ctx); in cifs_mount_get_session()
3389 if ((ctx->persistent == true) && (!(ses->server->capabilities & in cifs_mount_get_session()
3391 cifs_server_dbg(VFS, "persistent handles not supported by server\n"); in cifs_mount_get_session()
3397 mnt_ctx->server = server; in cifs_mount_get_session()
3406 struct TCP_Server_Info *server; in cifs_mount_get_tcon() local
3412 if (WARN_ON_ONCE(!mnt_ctx || !mnt_ctx->server || !mnt_ctx->ses || !mnt_ctx->fs_ctx || in cifs_mount_get_tcon()
3417 server = mnt_ctx->server; in cifs_mount_get_tcon()
3421 /* search for existing tcon to this server share */ in cifs_mount_get_tcon()
3434 /* tell server which Unix caps we support */ in cifs_mount_get_tcon()
3441 spin_lock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3442 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && in cifs_mount_get_tcon()
3445 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3449 spin_unlock(&tcon->ses->server->srv_lock); in cifs_mount_get_tcon()
3452 tcon->unix_ext = 0; /* server does not support them */ in cifs_mount_get_tcon()
3455 if (!tcon->pipe && server->ops->qfs_tcon) { in cifs_mount_get_tcon()
3456 server->ops->qfs_tcon(mnt_ctx->xid, tcon, cifs_sb); in cifs_mount_get_tcon()
3469 * Clamp the rsize/wsize mount arguments if they are too big for the server in cifs_mount_get_tcon()
3474 (cifs_sb->ctx->wsize > server->ops->negotiate_wsize(tcon, ctx))) { in cifs_mount_get_tcon()
3476 round_down(server->ops->negotiate_wsize(tcon, ctx), PAGE_SIZE); in cifs_mount_get_tcon()
3478 * in the very unlikely event that the server sent a max write size under PAGE_SIZE, in cifs_mount_get_tcon()
3487 (cifs_sb->ctx->rsize > server->ops->negotiate_rsize(tcon, ctx))) in cifs_mount_get_tcon()
3488 cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tcon, ctx); in cifs_mount_get_tcon()
3530 cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, in cifs_are_all_path_components_accessible() argument
3545 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); in cifs_are_all_path_components_accessible()
3569 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_are_all_path_components_accessible()
3585 struct TCP_Server_Info *server = mnt_ctx->server; in cifs_is_path_remote() local
3591 if (!server->ops->is_path_accessible) in cifs_is_path_remote()
3604 rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, in cifs_is_path_remote()
3610 rc = cifs_are_all_path_components_accessible(server, xid, tcon, in cifs_is_path_remote()
3637 * After reconnecting to a different server, unique ids won't match anymore, so we disable in cifs_mount()
3679 if (WARN_ON(!mnt_ctx.server)) in cifs_mount()
3738 smb_buffer->Mid = get_next_mid(ses->server); in CIFSTCon()
3752 if (ses->server->sign) in CIFSTCon()
3766 (/* server len*/ + 256 /* share len */), nls_codepage); in CIFSTCon()
3887 struct TCP_Server_Info *server) in cifs_negotiate_protocol() argument
3891 if (!server->ops->need_neg || !server->ops->negotiate) in cifs_negotiate_protocol()
3895 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3896 if (server->tcpStatus != CifsGood && in cifs_negotiate_protocol()
3897 server->tcpStatus != CifsNew && in cifs_negotiate_protocol()
3898 server->tcpStatus != CifsNeedNegotiate) { in cifs_negotiate_protocol()
3899 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3903 if (!server->ops->need_neg(server) && in cifs_negotiate_protocol()
3904 server->tcpStatus == CifsGood) { in cifs_negotiate_protocol()
3905 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3909 server->tcpStatus = CifsInNegotiate; in cifs_negotiate_protocol()
3910 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3912 rc = server->ops->negotiate(xid, ses, server); in cifs_negotiate_protocol()
3914 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3915 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3916 server->tcpStatus = CifsGood; in cifs_negotiate_protocol()
3919 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3921 spin_lock(&server->srv_lock); in cifs_negotiate_protocol()
3922 if (server->tcpStatus == CifsInNegotiate) in cifs_negotiate_protocol()
3923 server->tcpStatus = CifsNeedNegotiate; in cifs_negotiate_protocol()
3924 spin_unlock(&server->srv_lock); in cifs_negotiate_protocol()
3932 struct TCP_Server_Info *server, in cifs_setup_session() argument
3936 struct TCP_Server_Info *pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in cifs_setup_session()
3962 cifs_chan_set_in_reconnect(ses, server); in cifs_setup_session()
3975 if (server == pserver) { in cifs_setup_session()
3976 if (server->dstaddr.ss_family == AF_INET6) in cifs_setup_session()
3983 ses->capabilities = server->capabilities; in cifs_setup_session()
3985 ses->capabilities &= (~server->vals->cap_unix); in cifs_setup_session()
3997 server->sec_mode, server->capabilities, server->timeAdj); in cifs_setup_session()
3999 if (server->ops->sess_setup) in cifs_setup_session()
4000 rc = server->ops->sess_setup(xid, ses, server, nls_info); in cifs_setup_session()
4008 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
4016 cifs_chan_clear_in_reconnect(ses, server); in cifs_setup_session()
4017 cifs_chan_clear_need_reconnect(ses, server); in cifs_setup_session()
4079 ++master_tcon->ses->server->srv_count; in cifs_construct_tcon()
4082 ses = cifs_get_smb_ses(master_tcon->ses->server, ctx); in cifs_construct_tcon()
4085 cifs_put_tcp_session(master_tcon->ses->server, 0); in cifs_construct_tcon()
4330 const struct smb_version_operations *ops = tcon->ses->server->ops; in cifs_tree_connect()