Lines Matching refs:tcon
86 int smb3_encryption_required(const struct cifs_tcon *tcon)
88 if (!tcon || !tcon->ses)
90 if ((tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) ||
91 (tcon->share_flags & SHI1005_FLAGS_ENCRYPT_DATA))
93 if (tcon->seal &&
94 (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
101 const struct cifs_tcon *tcon,
122 if (!tcon)
131 shdr->TreeId = tcon->tid;
133 if (tcon->ses)
134 shdr->SessionId = tcon->ses->Suid;
146 /* if (tcon->share_flags & SHI1005_FLAGS_DFS)
149 if (server && server->sign && !smb3_encryption_required(tcon))
156 smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
165 * SMB2s NegProt, SessSetup, Logoff do not have tcon yet so
169 if (tcon == NULL)
175 if (tcon->tidStatus == CifsExiting) {
178 * (and ulogoff which does not have tcon)
189 if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
190 (!tcon->ses->server) || !server)
193 ses = tcon->ses;
238 if (!tcon->retry) {
245 if (!tcon->ses->need_reconnect && !tcon->need_reconnect)
254 mutex_lock(&tcon->ses->session_mutex);
263 mutex_unlock(&tcon->ses->session_mutex);
275 rc = cifs_negotiate_protocol(0, tcon->ses);
276 if (!rc && tcon->ses->need_reconnect) {
277 rc = cifs_setup_session(0, tcon->ses, nls_codepage);
278 if ((rc == -EACCES) && !tcon->retry) {
282 mutex_unlock(&tcon->ses->session_mutex);
295 if (rc || !tcon->need_reconnect) {
296 mutex_unlock(&tcon->ses->session_mutex);
300 cifs_mark_open_files_invalid(tcon);
301 if (tcon->use_persistent)
302 tcon->need_reopen_files = true;
304 rc = cifs_tree_connect(0, tcon, nls_codepage);
305 mutex_unlock(&tcon->ses->session_mutex);
307 cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
309 /* If sess reconnected but tcon didn't, something strange ... */
310 pr_warn_once("reconnect tcon failed rc = %d\n", rc);
345 fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon,
360 smb2_hdr_assemble(&spdu->sync_hdr, smb2_command, tcon, server);
371 static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
390 fill_small_buf(smb2_command, tcon, server,
394 if (tcon != NULL) {
396 cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]);
397 cifs_stats_inc(&tcon->num_smbs_sent);
403 static int smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
409 rc = smb2_reconnect(smb2_command, tcon, server);
413 return __smb2_plain_req_init(smb2_command, tcon, server, request_buf,
417 static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,
423 return __smb2_plain_req_init(SMB2_IOCTL, tcon, server,
426 return smb2_plain_req_init(SMB2_IOCTL, tcon, server,
877 * No tcon so can't do
878 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
1006 int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
1013 struct TCP_Server_Info *server = tcon->ses->server;
1028 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
1031 if (tcon->ses->user_name == NULL) {
1036 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
1045 if (tcon->ses->chan_max > 1)
1051 if (tcon->ses->sign)
1088 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
1665 /* since no tcon, smb2_init can not do this, so do here */
1686 * No tcon so can't do
1687 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
1694 static inline void cifs_stats_fail_inc(struct cifs_tcon *tcon, uint16_t code)
1696 cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_failed[code]);
1702 static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
1704 tcon->max_chunks = 256;
1705 tcon->max_bytes_chunk = 1048576;
1706 tcon->max_bytes_copy = 16777216;
1711 struct cifs_tcon *tcon, const struct nls_table *cp)
1746 tcon->tid = 0;
1747 atomic_set(&tcon->num_remote_opens, 0);
1748 rc = smb2_plain_req_init(SMB2_TREE_CONNECT, tcon, server,
1755 if (smb3_encryption_required(tcon))
1769 * 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1
1774 !smb3_encryption_required(tcon) &&
1791 trace_smb3_tcon(xid, tcon->tid, ses->Suid, tree, rc);
1793 if (tcon) {
1794 cifs_stats_fail_inc(tcon, SMB2_TREE_CONNECT_HE);
1795 tcon->need_reconnect = true;
1805 tcon->pipe = true;
1809 tcon->print = true;
1818 tcon->share_flags = le32_to_cpu(rsp->ShareFlags);
1819 tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */
1820 tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess);
1821 tcon->tidStatus = CifsGood;
1822 tcon->need_reconnect = false;
1823 tcon->tid = rsp->sync_hdr.TreeId;
1824 strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
1827 ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
1830 if (tcon->seal &&
1834 init_copy_chunk_defaults(tcon);
1836 rc = server->ops->validate_negotiate(xid, tcon);
1851 SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
1856 struct cifs_ses *ses = tcon->ses;
1868 if ((tcon->need_reconnect) || (tcon->ses->need_reconnect))
1871 close_shroot_lease(&tcon->crfid);
1873 rc = smb2_plain_req_init(SMB2_TREE_DISCONNECT, tcon, ses->server,
1879 if (smb3_encryption_required(tcon))
1895 cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE);
2100 buf->dcontext.Timeout = cpu_to_le32(oparms->tcon->handle_timeout);
2491 umode_t mode, struct cifs_tcon *tcon,
2498 struct cifs_ses *ses = tcon->ses;
2527 rc = smb2_plain_req_init(SMB2_CREATE, tcon, server,
2533 if (smb3_encryption_required(tcon))
2558 if (tcon->share_flags & SHI1005_FLAGS_DFS) {
2564 tcon->treeName, utf16_path);
2597 if (tcon->posix_extensions) {
2611 trace_smb3_posix_mkdir_enter(xid, tcon->tid, ses->Suid, CREATE_NOT_FILE,
2617 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
2618 trace_smb3_posix_mkdir_err(xid, tcon->tid, ses->Suid,
2625 trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid,
2629 SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId);
2644 SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
2658 rc = smb2_plain_req_init(SMB2_CREATE, tcon, server,
2690 if (tcon->share_flags & SHI1005_FLAGS_DFS) {
2696 tcon->treeName, path);
2721 if ((!server->oplocks) || (tcon->no_lease))
2747 tcon->use_persistent);
2752 if (tcon->posix_extensions) {
2765 if (tcon->snapshot_time) {
2774 rc = add_twarp_context(iov, &n_iov, tcon->snapshot_time);
2845 struct cifs_tcon *tcon = oparms->tcon;
2846 struct cifs_ses *ses = tcon->ses;
2858 if (smb3_encryption_required(tcon))
2866 rc = SMB2_open_init(tcon, server,
2871 trace_smb3_open_enter(xid, tcon->tid, tcon->ses->Suid,
2880 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
2887 trace_smb3_open_err(xid, tcon->tid, ses->Suid,
2891 tcon->treeName);
2892 tcon->need_reconnect = true;
2896 trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid,
2900 atomic_inc(&tcon->num_remote_opens);
2927 SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
2939 rc = smb2_ioctl_req_init(opcode, tcon, server,
3032 SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
3056 if (!tcon)
3059 ses = tcon->ses;
3067 if (smb3_encryption_required(tcon))
3075 rc = SMB2_ioctl_init(tcon, server,
3087 trace_smb3_fsctl_err(xid, persistent_fid, tcon->tid,
3091 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
3096 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
3101 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
3148 SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
3158 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
3170 SMB2_close_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3179 rc = smb2_plain_req_init(SMB2_CLOSE, tcon, server,
3204 __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
3210 struct cifs_ses *ses = tcon->ses;
3224 if (smb3_encryption_required(tcon))
3236 trace_smb3_close_enter(xid, persistent_fid, tcon->tid, ses->Suid);
3237 rc = SMB2_close_init(tcon, server,
3248 cifs_stats_fail_inc(tcon, SMB2_CLOSE_HE);
3249 trace_smb3_close_err(xid, persistent_fid, tcon->tid, ses->Suid,
3253 trace_smb3_close_done(xid, persistent_fid, tcon->tid,
3263 atomic_dec(&tcon->num_remote_opens);
3272 tmp_rc = smb2_handle_cancelled_close(tcon, persistent_fid,
3282 SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
3285 return __SMB2_close(xid, tcon, persistent_fid, volatile_fid, NULL);
3344 SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3360 rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, server,
3393 query_info(const unsigned int xid, struct cifs_tcon *tcon,
3404 struct cifs_ses *ses = tcon->ses;
3417 if (smb3_encryption_required(tcon))
3425 rc = SMB2_query_info_init(tcon, server,
3432 trace_smb3_query_info_enter(xid, persistent_fid, tcon->tid,
3440 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
3441 trace_smb3_query_info_err(xid, persistent_fid, tcon->tid,
3446 trace_smb3_query_info_done(xid, persistent_fid, tcon->tid,
3480 int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
3483 return query_info(xid, tcon, persistent_fid, volatile_fid,
3491 SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
3498 return query_info(xid, tcon, persistent_fid, volatile_fid,
3504 SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
3511 return query_info(xid, tcon, persistent_fid, volatile_fid,
3517 SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
3520 return query_info(xid, tcon, persistent_fid, volatile_fid,
3534 struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3543 rc = smb2_plain_req_init(SMB2_CHANGE_NOTIFY, tcon, server,
3566 SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
3570 struct cifs_ses *ses = tcon->ses;
3583 if (smb3_encryption_required(tcon))
3591 rc = SMB2_notify_init(xid, &rqst, tcon, server,
3597 trace_smb3_notify_enter(xid, persistent_fid, tcon->tid, ses->Suid,
3603 cifs_stats_fail_inc(tcon, SMB2_CHANGE_NOTIFY_HE);
3604 trace_smb3_notify_err(xid, persistent_fid, tcon->tid, ses->Suid,
3607 trace_smb3_notify_done(xid, persistent_fid, tcon->tid,
3648 struct cifs_tcon *tcon, *tcon2;
3655 /* Prevent simultaneous reconnects that can corrupt tcon->rlist list */
3663 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
3664 if (tcon->need_reconnect || tcon->need_reopen_files) {
3665 tcon->tc_count++;
3666 list_add_tail(&tcon->rlist, &tmp_list);
3689 list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) {
3690 rc = smb2_reconnect(SMB2_INTERNAL_CMD, tcon, server);
3692 cifs_reopen_persistent_handles(tcon);
3695 list_del_init(&tcon->rlist);
3696 if (tcon->ipc)
3697 cifs_put_smb_ses(tcon->ses);
3699 cifs_put_tcon(tcon);
3758 struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3766 rc = smb2_plain_req_init(SMB2_FLUSH, tcon, server,
3781 SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
3784 struct cifs_ses *ses = tcon->ses;
3797 if (smb3_encryption_required(tcon))
3805 rc = SMB2_flush_init(xid, &rqst, tcon, server,
3810 trace_smb3_flush_enter(xid, persistent_fid, tcon->tid, ses->Suid);
3815 cifs_stats_fail_inc(tcon, SMB2_FLUSH_HE);
3816 trace_smb3_flush_err(xid, persistent_fid, tcon->tid, ses->Suid,
3819 trace_smb3_flush_done(xid, persistent_fid, tcon->tid,
3842 rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, server,
3864 io_parms->tcon->tid, io_parms->tcon->ses->Suid,
3931 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
3970 cifs_stats_bytes_read(tcon, rdata->got_bytes);
3980 cifs_stats_bytes_read(tcon, rdata->got_bytes);
4001 cifs_stats_fail_inc(tcon, SMB2_READ_HE);
4004 tcon->tid, tcon->ses->Suid, rdata->offset,
4009 tcon->tid, tcon->ses->Suid,
4028 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
4035 rdata->server = cifs_pick_channel(tcon->ses);
4037 io_parms.tcon = tlink_tcon(rdata->cfile->tlink);
4050 if (smb3_encryption_required(io_parms.tcon))
4077 cifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE);
4079 io_parms.tcon->tid,
4080 io_parms.tcon->ses->Suid,
4101 struct cifs_ses *ses = io_parms->tcon->ses;
4104 io_parms->server = cifs_pick_channel(io_parms->tcon->ses);
4111 if (smb3_encryption_required(io_parms->tcon))
4127 cifs_stats_fail_inc(io_parms->tcon, SMB2_READ_HE);
4130 io_parms->tcon->tid, ses->Suid,
4135 io_parms->tcon->tid, ses->Suid,
4142 io_parms->tcon->tid, ses->Suid,
4177 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
4236 cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
4239 tcon->tid, tcon->ses->Suid, wdata->offset,
4243 tcon->treeName);
4247 tcon->tid, tcon->ses->Suid,
4263 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
4270 server = wdata->server = cifs_pick_channel(tcon->ses);
4272 rc = smb2_plain_req_init(SMB2_WRITE, tcon, server,
4277 if (smb3_encryption_required(tcon))
4294 tcon->tid, tcon->ses->Suid, wdata->offset, wdata->bytes);
4382 tcon->tid, tcon->ses->Suid, wdata->offset,
4385 cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
4419 io_parms->server = cifs_pick_channel(io_parms->tcon->ses);
4424 rc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, server,
4429 if (smb3_encryption_required(io_parms->tcon))
4446 io_parms->tcon->tid, io_parms->tcon->ses->Suid,
4457 rc = cifs_send_recv(xid, io_parms->tcon->ses, server,
4464 io_parms->tcon->tid,
4465 io_parms->tcon->ses->Suid,
4467 cifs_stats_fail_inc(io_parms->tcon, SMB2_WRITE_HE);
4472 io_parms->tcon->tid,
4473 io_parms->tcon->ses->Suid,
4632 struct cifs_tcon *tcon,
4648 rc = smb2_plain_req_init(SMB2_QUERY_DIRECTORY, tcon, server,
4695 trace_smb3_query_dir_enter(xid, persistent_fid, tcon->tid,
4696 tcon->ses->Suid, index, output_size);
4709 smb2_parse_query_directory(struct cifs_tcon *tcon,
4781 SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
4791 struct cifs_ses *ses = tcon->ses;
4798 if (smb3_encryption_required(tcon))
4806 rc = SMB2_query_directory_init(xid, tcon, server,
4821 tcon->tid, tcon->ses->Suid, index, 0);
4825 trace_smb3_query_dir_err(xid, persistent_fid, tcon->tid,
4826 tcon->ses->Suid, index, 0, rc);
4827 cifs_stats_fail_inc(tcon, SMB2_QUERY_DIRECTORY_HE);
4832 rc = smb2_parse_query_directory(tcon, &rsp_iov, resp_buftype,
4835 trace_smb3_query_dir_err(xid, persistent_fid, tcon->tid,
4836 tcon->ses->Suid, index, 0, rc);
4841 trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid,
4842 tcon->ses->Suid, index, srch_inf->entries_in_buffer);
4851 SMB2_set_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
4862 rc = smb2_plain_req_init(SMB2_SET_INFO, tcon, server,
4902 send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
4913 struct cifs_ses *ses = tcon->ses;
4923 if (smb3_encryption_required(tcon))
4934 rc = SMB2_set_info_init(tcon, server,
4951 cifs_stats_fail_inc(tcon, SMB2_SET_INFO_HE);
4952 trace_smb3_set_info_err(xid, persistent_fid, tcon->tid,
4962 SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
4974 return send_set_info(xid, tcon, persistent_fid, volatile_fid,
4980 SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
4984 return send_set_info(xid, tcon, persistent_fid, volatile_fid,
4990 SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
4994 return send_set_info(xid, tcon, persistent_fid, volatile_fid,
5000 SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
5007 struct cifs_ses *ses = tcon->ses;
5016 rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, server,
5021 if (smb3_encryption_required(tcon))
5043 cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
5082 build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5093 if ((tcon->ses == NULL) || server == NULL)
5096 rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, server,
5122 SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
5131 struct cifs_ses *ses = tcon->ses;
5136 rc = build_qfs_info_req(&iov, tcon, server,
5143 if (smb3_encryption_required(tcon))
5154 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
5173 SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5182 struct cifs_ses *ses = tcon->ses;
5187 rc = build_qfs_info_req(&iov, tcon, server,
5194 if (smb3_encryption_required(tcon))
5205 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
5224 SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5233 struct cifs_ses *ses = tcon->ses;
5255 rc = build_qfs_info_req(&iov, tcon, server,
5261 if (smb3_encryption_required(tcon))
5272 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
5284 memcpy(&tcon->fsAttrInfo, offset
5288 memcpy(&tcon->fsDevInfo, offset
5293 tcon->ss_flags = le32_to_cpu(ss_info->Flags);
5294 tcon->perf_sector_size =
5299 tcon->vol_serial_number = vol_info->VolumeSerialNumber;
5300 tcon->vol_create_time = vol_info->VolumeCreationTime;
5309 smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
5322 struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses);
5326 rc = smb2_plain_req_init(SMB2_LOCK, tcon, server,
5331 if (smb3_encryption_required(tcon))
5347 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks);
5353 rc = cifs_send_recv(xid, tcon->ses, server,
5359 cifs_stats_fail_inc(tcon, SMB2_LOCK_HE);
5360 trace_smb3_lock_err(xid, persist_fid, tcon->tid,
5361 tcon->ses->Suid, rc);
5368 SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
5381 return smb2_lockv(xid, tcon, persist_fid, volatile_fid, pid, 1, &lock);
5385 SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
5391 struct cifs_ses *ses = tcon->ses;
5399 struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses);
5402 rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, server,
5407 if (smb3_encryption_required(tcon))
5433 cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
5434 trace_smb3_lease_err(le32_to_cpu(lease_state), tcon->tid,
5438 trace_smb3_lease_done(le32_to_cpu(lease_state), tcon->tid,