Lines Matching +full:tcon +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0
36 server->credits += server->echo_credits + server->oplock_credits; in change_conf()
37 server->oplock_credits = server->echo_credits = 0; in change_conf()
38 switch (server->credits) { in change_conf()
42 server->echoes = false; in change_conf()
43 server->oplocks = false; in change_conf()
46 server->echoes = true; in change_conf()
47 server->oplocks = false; in change_conf()
48 server->echo_credits = 1; in change_conf()
51 server->echoes = true; in change_conf()
53 server->oplocks = true; in change_conf()
54 server->oplock_credits = 1; in change_conf()
56 server->oplocks = false; in change_conf()
58 server->echo_credits = 1; in change_conf()
60 server->credits -= server->echo_credits + server->oplock_credits; in change_conf()
61 return server->credits + server->echo_credits + server->oplock_credits; in change_conf()
68 int *val, rc = -1; in smb2_add_credits()
70 unsigned int add = credits->value; in smb2_add_credits()
71 unsigned int instance = credits->instance; in smb2_add_credits()
75 spin_lock(&server->req_lock); in smb2_add_credits()
76 val = server->ops->get_credits_field(server, optype); in smb2_add_credits()
82 if ((instance == 0) || (instance == server->reconnect_instance)) in smb2_add_credits()
90 trace_smb3_overflow_credits(server->CurrentMid, in smb2_add_credits()
91 server->conn_id, server->hostname, *val, in smb2_add_credits()
92 add, server->in_flight); in smb2_add_credits()
94 server->in_flight--; in smb2_add_credits()
95 if (server->in_flight == 0 && in smb2_add_credits()
100 * Sometimes server returns 0 credits on oplock break ack - we need to in smb2_add_credits()
103 else if (server->in_flight > 0 && server->oplock_credits == 0 && in smb2_add_credits()
104 server->oplocks) { in smb2_add_credits()
105 if (server->credits > 1) { in smb2_add_credits()
106 server->credits--; in smb2_add_credits()
107 server->oplock_credits++; in smb2_add_credits()
111 in_flight = server->in_flight; in smb2_add_credits()
112 spin_unlock(&server->req_lock); in smb2_add_credits()
113 wake_up(&server->request_q); in smb2_add_credits()
116 trace_smb3_reconnect_detected(server->CurrentMid, in smb2_add_credits()
117 server->conn_id, server->hostname, scredits, add, in_flight); in smb2_add_credits()
124 trace_smb3_reconnect_with_invalid_credits(server->CurrentMid, in smb2_add_credits()
125 server->conn_id, server->hostname, scredits, add, in_flight); in smb2_add_credits()
126 …cifs_dbg(FYI, "Negotiate operation when server credits is non-zero. Optype: %d, server credits: %d… in smb2_add_credits()
130 spin_lock(&server->srv_lock); in smb2_add_credits()
131 if (server->tcpStatus == CifsNeedReconnect in smb2_add_credits()
132 || server->tcpStatus == CifsExiting) { in smb2_add_credits()
133 spin_unlock(&server->srv_lock); in smb2_add_credits()
136 spin_unlock(&server->srv_lock); in smb2_add_credits()
139 case -1: in smb2_add_credits()
143 cifs_server_dbg(VFS, "Possible client or server bug - zero credits\n"); in smb2_add_credits()
156 trace_smb3_add_credits(server->CurrentMid, in smb2_add_credits()
157 server->conn_id, server->hostname, scredits, add, in_flight); in smb2_add_credits()
166 spin_lock(&server->req_lock); in smb2_set_credits()
167 server->credits = val; in smb2_set_credits()
169 server->reconnect_instance++; in smb2_set_credits()
170 scredits = server->credits; in smb2_set_credits()
171 in_flight = server->in_flight; in smb2_set_credits()
172 spin_unlock(&server->req_lock); in smb2_set_credits()
174 trace_smb3_set_credits(server->CurrentMid, in smb2_set_credits()
175 server->conn_id, server->hostname, scredits, val, in_flight); in smb2_set_credits()
188 return &server->echo_credits; in smb2_get_credits_field()
190 return &server->oplock_credits; in smb2_get_credits_field()
192 return &server->credits; in smb2_get_credits_field()
199 return mid->credits_received; in smb2_get_credits()
209 spin_lock(&server->req_lock); in smb2_wait_mtu_credits()
211 if (server->credits <= 0) { in smb2_wait_mtu_credits()
212 spin_unlock(&server->req_lock); in smb2_wait_mtu_credits()
214 rc = wait_event_killable(server->request_q, in smb2_wait_mtu_credits()
215 has_credits(server, &server->credits, 1)); in smb2_wait_mtu_credits()
219 spin_lock(&server->req_lock); in smb2_wait_mtu_credits()
221 spin_unlock(&server->req_lock); in smb2_wait_mtu_credits()
222 spin_lock(&server->srv_lock); in smb2_wait_mtu_credits()
223 if (server->tcpStatus == CifsExiting) { in smb2_wait_mtu_credits()
224 spin_unlock(&server->srv_lock); in smb2_wait_mtu_credits()
225 return -ENOENT; in smb2_wait_mtu_credits()
227 spin_unlock(&server->srv_lock); in smb2_wait_mtu_credits()
229 spin_lock(&server->req_lock); in smb2_wait_mtu_credits()
230 scredits = server->credits; in smb2_wait_mtu_credits()
234 credits->value = 0; in smb2_wait_mtu_credits()
235 credits->instance = 0; in smb2_wait_mtu_credits()
240 scredits -= 8; in smb2_wait_mtu_credits()
244 credits->value = in smb2_wait_mtu_credits()
246 credits->instance = server->reconnect_instance; in smb2_wait_mtu_credits()
247 server->credits -= credits->value; in smb2_wait_mtu_credits()
248 server->in_flight++; in smb2_wait_mtu_credits()
249 if (server->in_flight > server->max_in_flight) in smb2_wait_mtu_credits()
250 server->max_in_flight = server->in_flight; in smb2_wait_mtu_credits()
254 scredits = server->credits; in smb2_wait_mtu_credits()
255 in_flight = server->in_flight; in smb2_wait_mtu_credits()
256 spin_unlock(&server->req_lock); in smb2_wait_mtu_credits()
258 trace_smb3_wait_credits(server->CurrentMid, in smb2_wait_mtu_credits()
259 server->conn_id, server->hostname, scredits, -(credits->value), in_flight); in smb2_wait_mtu_credits()
261 __func__, credits->value, scredits); in smb2_wait_mtu_credits()
274 if (!credits->value || credits->value == new_val) in smb2_adjust_credits()
277 if (credits->value < new_val) { in smb2_adjust_credits()
278 trace_smb3_too_many_credits(server->CurrentMid, in smb2_adjust_credits()
279 server->conn_id, server->hostname, 0, credits->value - new_val, 0); in smb2_adjust_credits()
281 credits->value, new_val); in smb2_adjust_credits()
283 return -ENOTSUPP; in smb2_adjust_credits()
286 spin_lock(&server->req_lock); in smb2_adjust_credits()
288 if (server->reconnect_instance != credits->instance) { in smb2_adjust_credits()
289 scredits = server->credits; in smb2_adjust_credits()
290 in_flight = server->in_flight; in smb2_adjust_credits()
291 spin_unlock(&server->req_lock); in smb2_adjust_credits()
293 trace_smb3_reconnect_detected(server->CurrentMid, in smb2_adjust_credits()
294 server->conn_id, server->hostname, scredits, in smb2_adjust_credits()
295 credits->value - new_val, in_flight); in smb2_adjust_credits()
297 credits->value - new_val); in smb2_adjust_credits()
298 return -EAGAIN; in smb2_adjust_credits()
301 server->credits += credits->value - new_val; in smb2_adjust_credits()
302 scredits = server->credits; in smb2_adjust_credits()
303 in_flight = server->in_flight; in smb2_adjust_credits()
304 spin_unlock(&server->req_lock); in smb2_adjust_credits()
305 wake_up(&server->request_q); in smb2_adjust_credits()
307 trace_smb3_adj_credits(server->CurrentMid, in smb2_adjust_credits()
308 server->conn_id, server->hostname, scredits, in smb2_adjust_credits()
309 credits->value - new_val, in_flight); in smb2_adjust_credits()
311 __func__, credits->value - new_val, scredits); in smb2_adjust_credits()
313 credits->value = new_val; in smb2_adjust_credits()
323 spin_lock(&server->mid_lock); in smb2_get_next_mid()
324 mid = server->CurrentMid++; in smb2_get_next_mid()
325 spin_unlock(&server->mid_lock); in smb2_get_next_mid()
332 spin_lock(&server->mid_lock); in smb2_revert_current_mid()
333 if (server->CurrentMid >= val) in smb2_revert_current_mid()
334 server->CurrentMid -= val; in smb2_revert_current_mid()
335 spin_unlock(&server->mid_lock); in smb2_revert_current_mid()
343 __u64 wire_mid = le64_to_cpu(shdr->MessageId); in __smb2_find_mid()
345 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) { in __smb2_find_mid()
350 spin_lock(&server->mid_lock); in __smb2_find_mid()
351 list_for_each_entry(mid, &server->pending_mid_q, qhead) { in __smb2_find_mid()
352 if ((mid->mid == wire_mid) && in __smb2_find_mid()
353 (mid->mid_state == MID_REQUEST_SUBMITTED) && in __smb2_find_mid()
354 (mid->command == shdr->Command)) { in __smb2_find_mid()
355 kref_get(&mid->refcount); in __smb2_find_mid()
357 list_del_init(&mid->qhead); in __smb2_find_mid()
358 mid->mid_flags |= MID_DELETED; in __smb2_find_mid()
360 spin_unlock(&server->mid_lock); in __smb2_find_mid()
364 spin_unlock(&server->mid_lock); in __smb2_find_mid()
387 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, in smb2_dump_detail()
388 shdr->Id.SyncId.ProcessId); in smb2_dump_detail()
390 server->ops->calc_smb_size(buf)); in smb2_dump_detail()
397 return server->max_read == 0; in smb2_need_neg()
407 spin_lock(&server->mid_lock); in smb2_negotiate()
408 server->CurrentMid = 0; in smb2_negotiate()
409 spin_unlock(&server->mid_lock); in smb2_negotiate()
412 if (rc == -EAGAIN) in smb2_negotiate()
413 rc = -EHOSTDOWN; in smb2_negotiate()
418 smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) in smb2_negotiate_wsize() argument
420 struct TCP_Server_Info *server = tcon->ses->server; in smb2_negotiate_wsize()
424 wsize = ctx->wsize ? ctx->wsize : CIFS_DEFAULT_IOSIZE; in smb2_negotiate_wsize()
425 wsize = min_t(unsigned int, wsize, server->max_write); in smb2_negotiate_wsize()
426 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU)) in smb2_negotiate_wsize()
433 smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) in smb3_negotiate_wsize() argument
435 struct TCP_Server_Info *server = tcon->ses->server; in smb3_negotiate_wsize()
439 wsize = ctx->wsize ? ctx->wsize : SMB3_DEFAULT_IOSIZE; in smb3_negotiate_wsize()
440 wsize = min_t(unsigned int, wsize, server->max_write); in smb3_negotiate_wsize()
442 if (server->rdma) { in smb3_negotiate_wsize()
443 if (server->sign) in smb3_negotiate_wsize()
450 server->smbd_conn->max_fragmented_send_size - in smb3_negotiate_wsize()
451 SMB2_READWRITE_PDU_HEADER_SIZE - in smb3_negotiate_wsize()
455 wsize, server->smbd_conn->max_readwrite_size); in smb3_negotiate_wsize()
458 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU)) in smb3_negotiate_wsize()
465 smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) in smb2_negotiate_rsize() argument
467 struct TCP_Server_Info *server = tcon->ses->server; in smb2_negotiate_rsize()
471 rsize = ctx->rsize ? ctx->rsize : CIFS_DEFAULT_IOSIZE; in smb2_negotiate_rsize()
472 rsize = min_t(unsigned int, rsize, server->max_read); in smb2_negotiate_rsize()
474 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU)) in smb2_negotiate_rsize()
481 smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) in smb3_negotiate_rsize() argument
483 struct TCP_Server_Info *server = tcon->ses->server; in smb3_negotiate_rsize()
487 rsize = ctx->rsize ? ctx->rsize : SMB3_DEFAULT_IOSIZE; in smb3_negotiate_rsize()
488 rsize = min_t(unsigned int, rsize, server->max_read); in smb3_negotiate_rsize()
490 if (server->rdma) { in smb3_negotiate_rsize()
491 if (server->sign) in smb3_negotiate_rsize()
498 server->smbd_conn->max_fragmented_recv_size - in smb3_negotiate_rsize()
499 SMB2_READWRITE_PDU_HEADER_SIZE - in smb3_negotiate_rsize()
503 rsize, server->smbd_conn->max_readwrite_size); in smb3_negotiate_rsize()
507 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU)) in smb3_negotiate_rsize()
532 spin_lock(&ses->iface_lock); in parse_server_interfaces()
533 ses->iface_count = 0; in parse_server_interfaces()
539 list_for_each_entry_safe(iface, niface, &ses->iface_list, in parse_server_interfaces()
541 iface->is_active = 0; in parse_server_interfaces()
542 kref_put(&iface->refcount, release_iface); in parse_server_interfaces()
544 spin_unlock(&ses->iface_lock); in parse_server_interfaces()
552 if ((ses->chan_max > 1) && in_mount) in parse_server_interfaces()
556 ses->server->hostname); in parse_server_interfaces()
557 rc = -EINVAL; in parse_server_interfaces()
563 tmp_iface.speed = le64_to_cpu(p->LinkSpeed); in parse_server_interfaces()
564 tmp_iface.rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE) ? 1 : 0; in parse_server_interfaces()
565 tmp_iface.rss_capable = le32_to_cpu(p->Capability & RSS_CAPABLE) ? 1 : 0; in parse_server_interfaces()
567 switch (p->Family) { in parse_server_interfaces()
575 p4 = (struct iface_info_ipv4 *)p->Buffer; in parse_server_interfaces()
576 addr4->sin_family = AF_INET; in parse_server_interfaces()
577 memcpy(&addr4->sin_addr, &p4->IPv4Address, 4); in parse_server_interfaces()
579 /* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these */ in parse_server_interfaces()
580 addr4->sin_port = cpu_to_be16(CIFS_PORT); in parse_server_interfaces()
583 &addr4->sin_addr); in parse_server_interfaces()
587 p6 = (struct iface_info_ipv6 *)p->Buffer; in parse_server_interfaces()
588 addr6->sin6_family = AF_INET6; in parse_server_interfaces()
589 memcpy(&addr6->sin6_addr, &p6->IPv6Address, 16); in parse_server_interfaces()
591 /* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these */ in parse_server_interfaces()
592 addr6->sin6_flowinfo = 0; in parse_server_interfaces()
593 addr6->sin6_scope_id = 0; in parse_server_interfaces()
594 addr6->sin6_port = cpu_to_be16(CIFS_PORT); in parse_server_interfaces()
597 &addr6->sin6_addr); in parse_server_interfaces()
612 spin_lock(&ses->iface_lock); in parse_server_interfaces()
614 list_for_each_entry_safe(iface, niface, &ses->iface_list, in parse_server_interfaces()
619 iface->is_active = 1; in parse_server_interfaces()
620 kref_get(&iface->refcount); in parse_server_interfaces()
621 spin_unlock(&ses->iface_lock); in parse_server_interfaces()
625 kref_get(&iface->refcount); in parse_server_interfaces()
629 spin_unlock(&ses->iface_lock); in parse_server_interfaces()
635 rc = -ENOMEM; in parse_server_interfaces()
641 kref_init(&info->refcount); in parse_server_interfaces()
642 info->is_active = 1; in parse_server_interfaces()
644 cifs_dbg(FYI, "%s: adding iface %zu\n", __func__, ses->iface_count); in parse_server_interfaces()
645 cifs_dbg(FYI, "%s: speed %zu bps\n", __func__, info->speed); in parse_server_interfaces()
647 le32_to_cpu(p->Capability)); in parse_server_interfaces()
649 spin_lock(&ses->iface_lock); in parse_server_interfaces()
650 if (!list_entry_is_head(iface, &ses->iface_list, iface_head)) { in parse_server_interfaces()
651 list_add_tail(&info->iface_head, &iface->iface_head); in parse_server_interfaces()
652 kref_put(&iface->refcount, release_iface); in parse_server_interfaces()
654 list_add_tail(&info->iface_head, &ses->iface_list); in parse_server_interfaces()
656 ses->iface_count++; in parse_server_interfaces()
657 spin_unlock(&ses->iface_lock); in parse_server_interfaces()
658 ses->iface_last_update = jiffies; in parse_server_interfaces()
661 next = le32_to_cpu(p->Next); in parse_server_interfaces()
663 bytes_left -= sizeof(*p); in parse_server_interfaces()
667 bytes_left -= next; in parse_server_interfaces()
672 rc = -EINVAL; in parse_server_interfaces()
677 if ((bytes_left > 8) || p->Next) in parse_server_interfaces()
681 if (!ses->iface_count) { in parse_server_interfaces()
682 rc = -EINVAL; in parse_server_interfaces()
691 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount) in SMB3_request_interfaces() argument
696 struct cifs_ses *ses = tcon->ses; in SMB3_request_interfaces()
698 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, in SMB3_request_interfaces()
702 if (rc == -EOPNOTSUPP) { in SMB3_request_interfaces()
721 smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, in smb3_qfs_tcon() argument
725 __le16 srch_path = 0; /* Null - open root of share */ in smb3_qfs_tcon()
731 oparms.tcon = tcon; in smb3_qfs_tcon()
738 rc = open_cached_dir(xid, tcon, "", cifs_sb, false, &cfid); in smb3_qfs_tcon()
740 memcpy(&fid, &cfid->fid, sizeof(struct cifs_fid)); in smb3_qfs_tcon()
747 SMB3_request_interfaces(xid, tcon, true /* called during mount */); in smb3_qfs_tcon()
749 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb3_qfs_tcon()
751 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb3_qfs_tcon()
753 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb3_qfs_tcon()
755 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb3_qfs_tcon()
758 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in smb3_qfs_tcon()
764 smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, in smb2_qfs_tcon() argument
768 __le16 srch_path = 0; /* Null - open root of share */ in smb2_qfs_tcon()
773 oparms.tcon = tcon; in smb2_qfs_tcon()
785 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb2_qfs_tcon()
787 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb2_qfs_tcon()
789 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in smb2_qfs_tcon()
793 smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, in smb2_is_path_accessible() argument
803 rc = open_cached_dir(xid, tcon, full_path, cifs_sb, true, &cfid); in smb2_is_path_accessible()
805 if (cfid->has_lease) { in smb2_is_path_accessible()
814 return -ENOMEM; in smb2_is_path_accessible()
816 oparms.tcon = tcon; in smb2_is_path_accessible()
830 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in smb2_is_path_accessible()
835 static int smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon, in smb2_get_srv_inum() argument
839 *uniqueid = le64_to_cpu(data->fi.IndexNumber); in smb2_get_srv_inum()
843 static int smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_file_info() argument
846 struct cifs_fid *fid = &cfile->fid; in smb2_query_file_info()
848 if (cfile->symlink_target) { in smb2_query_file_info()
849 data->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL); in smb2_query_file_info()
850 if (!data->symlink_target) in smb2_query_file_info()
851 return -ENOMEM; in smb2_query_file_info()
853 return SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid, &data->fi); in smb2_query_file_info()
869 name_len = (size_t)src->ea_name_length; in move_smb2_ea_to_cifs()
870 value_len = (size_t)le16_to_cpu(src->ea_value_length); in move_smb2_ea_to_cifs()
877 rc = -EIO; in move_smb2_ea_to_cifs()
881 name = &src->ea_data[0]; in move_smb2_ea_to_cifs()
882 value = &src->ea_data[src->ea_name_length + 1]; in move_smb2_ea_to_cifs()
891 rc = -ERANGE; in move_smb2_ea_to_cifs()
902 /* skip copy - calc size only */ in move_smb2_ea_to_cifs()
905 dst_size -= user_name_len; in move_smb2_ea_to_cifs()
908 memcpy(dst, src->ea_data, name_len); in move_smb2_ea_to_cifs()
915 rc = -ERANGE; in move_smb2_ea_to_cifs()
920 if (!src->next_entry_offset) in move_smb2_ea_to_cifs()
923 if (src_size < le32_to_cpu(src->next_entry_offset)) { in move_smb2_ea_to_cifs()
925 rc = -ERANGE; in move_smb2_ea_to_cifs()
928 src_size -= le32_to_cpu(src->next_entry_offset); in move_smb2_ea_to_cifs()
930 le32_to_cpu(src->next_entry_offset)); in move_smb2_ea_to_cifs()
935 rc = -ENODATA; in move_smb2_ea_to_cifs()
942 smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_eas() argument
953 rc = smb2_query_info_compound(xid, tcon, path, in smb2_query_eas()
957 CIFSMaxBufSize - in smb2_query_eas()
958 MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_query_eas()
967 if (!ea_name && rc == -ENODATA) in smb2_query_eas()
973 rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset), in smb2_query_eas()
974 le32_to_cpu(rsp->OutputBufferLength), in smb2_query_eas()
981 le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp); in smb2_query_eas()
983 le32_to_cpu(rsp->OutputBufferLength), ea_name); in smb2_query_eas()
992 smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, in smb2_set_ea() argument
997 struct cifs_ses *ses = tcon->ses; in smb2_set_ea()
1018 if (smb3_encryption_required(tcon)) in smb2_set_ea()
1022 return -EINVAL; in smb2_set_ea()
1026 return -ENOMEM; in smb2_set_ea()
1032 if (ses->server->ops->query_all_EAs) { in smb2_set_ea()
1034 rc = ses->server->ops->query_all_EAs(xid, tcon, path, in smb2_set_ea()
1037 if (rc == -ENODATA) in smb2_set_ea()
1045 rc = smb2_query_info_compound(xid, tcon, path, in smb2_set_ea()
1049 CIFSMaxBufSize - in smb2_set_ea()
1050 MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_set_ea()
1055 used_len = le32_to_cpu(rsp->OutputBufferLength); in smb2_set_ea()
1065 if(CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_set_ea()
1066 MAX_SMB2_CLOSE_RESPONSE_SIZE - 256 < in smb2_set_ea()
1068 rc = -ENOSPC; in smb2_set_ea()
1080 oparms.tcon = tcon; in smb2_set_ea()
1087 rc = SMB2_open_init(tcon, server, in smb2_set_ea()
1091 smb2_set_next_command(tcon, &rqst[0]); in smb2_set_ea()
1102 rc = -ENOMEM; in smb2_set_ea()
1106 ea->ea_name_length = ea_name_len; in smb2_set_ea()
1107 ea->ea_value_length = cpu_to_le16(ea_value_len); in smb2_set_ea()
1108 memcpy(ea->ea_data, ea_name, ea_name_len + 1); in smb2_set_ea()
1109 memcpy(ea->ea_data + ea_name_len + 1, ea_value, ea_value_len); in smb2_set_ea()
1114 rc = SMB2_set_info_init(tcon, server, in smb2_set_ea()
1116 COMPOUND_FID, current->tgid, in smb2_set_ea()
1121 smb2_set_next_command(tcon, &rqst[1]); in smb2_set_ea()
1129 rc = SMB2_close_init(tcon, server, in smb2_set_ea()
1156 return server->echoes; in smb2_can_echo()
1160 smb2_clear_stats(struct cifs_tcon *tcon) in smb2_clear_stats() argument
1165 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0); in smb2_clear_stats()
1166 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0); in smb2_clear_stats()
1171 smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon) in smb2_dump_share_caps() argument
1174 if (tcon->capabilities & SMB2_SHARE_CAP_DFS) in smb2_dump_share_caps()
1176 if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY) in smb2_dump_share_caps()
1178 if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT) in smb2_dump_share_caps()
1180 if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER) in smb2_dump_share_caps()
1182 if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC) in smb2_dump_share_caps()
1184 if (tcon->capabilities == 0) in smb2_dump_share_caps()
1186 if (tcon->ss_flags & SSINFO_FLAGS_ALIGNED_DEVICE) in smb2_dump_share_caps()
1188 if (tcon->ss_flags & SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE) in smb2_dump_share_caps()
1190 if (tcon->ss_flags & SSINFO_FLAGS_NO_SEEK_PENALTY) in smb2_dump_share_caps()
1192 if (tcon->ss_flags & SSINFO_FLAGS_TRIM_ENABLED) in smb2_dump_share_caps()
1193 seq_puts(m, " TRIM-support,"); in smb2_dump_share_caps()
1195 seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags); in smb2_dump_share_caps()
1196 seq_printf(m, "\n\ttid: 0x%x", tcon->tid); in smb2_dump_share_caps()
1197 if (tcon->perf_sector_size) in smb2_dump_share_caps()
1199 tcon->perf_sector_size); in smb2_dump_share_caps()
1200 seq_printf(m, "\tMaximal Access: 0x%x", tcon->maximal_access); in smb2_dump_share_caps()
1204 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon) in smb2_print_stats() argument
1206 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent; in smb2_print_stats()
1207 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed; in smb2_print_stats()
1211 * totals (requests sent) since those SMBs are per-session not per tcon in smb2_print_stats()
1214 (long long)(tcon->bytes_read), in smb2_print_stats()
1215 (long long)(tcon->bytes_written)); in smb2_print_stats()
1217 atomic_read(&tcon->num_local_opens), in smb2_print_stats()
1218 atomic_read(&tcon->num_remote_opens)); in smb2_print_stats()
1266 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in smb2_set_fid()
1267 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; in smb2_set_fid()
1269 cfile->fid.persistent_fid = fid->persistent_fid; in smb2_set_fid()
1270 cfile->fid.volatile_fid = fid->volatile_fid; in smb2_set_fid()
1271 cfile->fid.access = fid->access; in smb2_set_fid()
1273 cfile->fid.mid = fid->mid; in smb2_set_fid()
1275 server->ops->set_oplock_level(cinode, oplock, fid->epoch, in smb2_set_fid()
1276 &fid->purge_cache); in smb2_set_fid()
1277 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); in smb2_set_fid()
1278 memcpy(cfile->fid.create_guid, fid->create_guid, 16); in smb2_set_fid()
1282 smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon, in smb2_close_file() argument
1285 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); in smb2_close_file()
1289 smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon, in smb2_close_getattr() argument
1296 rc = __SMB2_close(xid, tcon, cfile->fid.persistent_fid, in smb2_close_getattr()
1297 cfile->fid.volatile_fid, &file_inf); in smb2_close_getattr()
1301 inode = d_inode(cfile->dentry); in smb2_close_getattr()
1303 spin_lock(&inode->i_lock); in smb2_close_getattr()
1304 CIFS_I(inode)->time = jiffies; in smb2_close_getattr()
1308 inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime); in smb2_close_getattr()
1310 inode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime); in smb2_close_getattr()
1312 inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime); in smb2_close_getattr()
1320 inode->i_blocks = in smb2_close_getattr()
1321 (512 - 1 + le64_to_cpu(file_inf.AllocationSize)) >> 9; in smb2_close_getattr()
1324 spin_unlock(&inode->i_lock); in smb2_close_getattr()
1328 SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon, in SMB2_request_res_key() argument
1336 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, in SMB2_request_res_key()
1340 if (rc == -EOPNOTSUPP) { in SMB2_request_res_key()
1341 pr_warn_once("Server share %s does not support copy range\n", tcon->tree_name); in SMB2_request_res_key()
1349 rc = -EINVAL; in SMB2_request_res_key()
1352 memcpy(pcchunk->SourceKey, res_key->ResumeKey, COPY_CHUNK_RES_KEY_SIZE); in SMB2_request_res_key()
1371 struct cifs_tcon *tcon, in smb2_ioctl_query_info() argument
1379 struct cifs_ses *ses = tcon->ses; in smb2_ioctl_query_info()
1400 return -ENOMEM; in smb2_ioctl_query_info()
1401 rqst = &vars->rqst[0]; in smb2_ioctl_query_info()
1402 rsp_iov = &vars->rsp_iov[0]; in smb2_ioctl_query_info()
1407 rc = -EFAULT; in smb2_ioctl_query_info()
1411 rc = -EINVAL; in smb2_ioctl_query_info()
1416 rc = -EIO; in smb2_ioctl_query_info()
1420 if (smb3_encryption_required(tcon)) in smb2_ioctl_query_info()
1432 rqst[0].rq_iov = &vars->open_iov[0]; in smb2_ioctl_query_info()
1436 oparms.tcon = tcon; in smb2_ioctl_query_info()
1463 rc = SMB2_open_init(tcon, server, in smb2_ioctl_query_info()
1467 smb2_set_next_command(tcon, &rqst[0]); in smb2_ioctl_query_info()
1473 rc = -EPERM; in smb2_ioctl_query_info()
1476 rqst[1].rq_iov = &vars->io_iov[0]; in smb2_ioctl_query_info()
1479 rc = SMB2_ioctl_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID, in smb2_ioctl_query_info()
1481 CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_ioctl_query_info()
1487 rc = -EPERM; in smb2_ioctl_query_info()
1491 rc = -EINVAL; in smb2_ioctl_query_info()
1494 rqst[1].rq_iov = &vars->si_iov[0]; in smb2_ioctl_query_info()
1497 /* MS-FSCC 2.4.13 FileEndOfFileInformation */ in smb2_ioctl_query_info()
1501 rc = SMB2_set_info_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID, in smb2_ioctl_query_info()
1502 current->tgid, FILE_END_OF_FILE_INFORMATION, in smb2_ioctl_query_info()
1506 rqst[1].rq_iov = &vars->qi_iov[0]; in smb2_ioctl_query_info()
1509 rc = SMB2_query_info_init(tcon, server, in smb2_ioctl_query_info()
1519 rc = -EINVAL; in smb2_ioctl_query_info()
1524 smb2_set_next_command(tcon, &rqst[1]); in smb2_ioctl_query_info()
1528 rqst[2].rq_iov = &vars->close_iov[0]; in smb2_ioctl_query_info()
1531 rc = SMB2_close_init(tcon, server, in smb2_ioctl_query_info()
1547 if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length) in smb2_ioctl_query_info()
1548 qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount); in smb2_ioctl_query_info()
1550 le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length in smb2_ioctl_query_info()
1552 rc = -EFAULT; in smb2_ioctl_query_info()
1556 if (copy_to_user(&pqi->input_buffer_length, in smb2_ioctl_query_info()
1559 rc = -EFAULT; in smb2_ioctl_query_info()
1564 (const void *)io_rsp + le32_to_cpu(io_rsp->OutputOffset), in smb2_ioctl_query_info()
1566 rc = -EFAULT; in smb2_ioctl_query_info()
1570 if (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length) in smb2_ioctl_query_info()
1571 qi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength); in smb2_ioctl_query_info()
1572 if (copy_to_user(&pqi->input_buffer_length, in smb2_ioctl_query_info()
1575 rc = -EFAULT; in smb2_ioctl_query_info()
1579 if (copy_to_user(pqi + 1, qi_rsp->Buffer, in smb2_ioctl_query_info()
1581 rc = -EFAULT; in smb2_ioctl_query_info()
1610 struct cifs_tcon *tcon; in smb2_copychunk_range() local
1617 return -ENOMEM; in smb2_copychunk_range()
1621 rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink), in smb2_copychunk_range()
1622 srcfile->fid.persistent_fid, in smb2_copychunk_range()
1623 srcfile->fid.volatile_fid, pcchunk); in smb2_copychunk_range()
1630 pcchunk->ChunkCount = cpu_to_le32(1); in smb2_copychunk_range()
1631 pcchunk->Reserved = 0; in smb2_copychunk_range()
1632 pcchunk->Reserved2 = 0; in smb2_copychunk_range()
1634 tcon = tlink_tcon(trgtfile->tlink); in smb2_copychunk_range()
1637 pcchunk->SourceOffset = cpu_to_le64(src_off); in smb2_copychunk_range()
1638 pcchunk->TargetOffset = cpu_to_le64(dest_off); in smb2_copychunk_range()
1639 pcchunk->Length = in smb2_copychunk_range()
1640 cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk)); in smb2_copychunk_range()
1645 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, in smb2_copychunk_range()
1646 trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE, in smb2_copychunk_range()
1653 rc = -EIO; in smb2_copychunk_range()
1656 if (retbuf->TotalBytesWritten == 0) { in smb2_copychunk_range()
1658 rc = -EIO; in smb2_copychunk_range()
1664 if (le32_to_cpu(retbuf->TotalBytesWritten) > in smb2_copychunk_range()
1665 le32_to_cpu(pcchunk->Length)) { in smb2_copychunk_range()
1667 rc = -EIO; in smb2_copychunk_range()
1670 if (le32_to_cpu(retbuf->ChunksWritten) != 1) { in smb2_copychunk_range()
1672 rc = -EIO; in smb2_copychunk_range()
1677 bytes_written = le32_to_cpu(retbuf->TotalBytesWritten); in smb2_copychunk_range()
1680 len -= bytes_written; in smb2_copychunk_range()
1684 le32_to_cpu(retbuf->ChunksWritten), in smb2_copychunk_range()
1685 le32_to_cpu(retbuf->ChunkBytesWritten), in smb2_copychunk_range()
1687 } else if (rc == -EINVAL) { in smb2_copychunk_range()
1692 le32_to_cpu(retbuf->ChunksWritten), in smb2_copychunk_range()
1693 le32_to_cpu(retbuf->ChunkBytesWritten), in smb2_copychunk_range()
1694 le32_to_cpu(retbuf->TotalBytesWritten)); in smb2_copychunk_range()
1707 if (le32_to_cpu(retbuf->ChunkBytesWritten) < in smb2_copychunk_range()
1708 tcon->max_bytes_chunk) in smb2_copychunk_range()
1709 tcon->max_bytes_chunk = in smb2_copychunk_range()
1710 le32_to_cpu(retbuf->ChunkBytesWritten); in smb2_copychunk_range()
1730 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon, in smb2_flush_file() argument
1733 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid); in smb2_flush_file()
1741 return rsp->DataOffset; in smb2_read_data_offset()
1750 return le32_to_cpu(rsp->DataRemaining); in smb2_read_data_length()
1752 return le32_to_cpu(rsp->DataLength); in smb2_read_data_length()
1761 parms->persistent_fid = pfid->persistent_fid; in smb2_sync_read()
1762 parms->volatile_fid = pfid->volatile_fid; in smb2_sync_read()
1772 parms->persistent_fid = pfid->persistent_fid; in smb2_sync_write()
1773 parms->volatile_fid = pfid->volatile_fid; in smb2_sync_write()
1778 static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon, in smb2_set_sparse() argument
1787 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && setsparse) in smb2_set_sparse()
1790 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && !setsparse) in smb2_set_sparse()
1803 if (tcon->broken_sparse_sup) in smb2_set_sparse()
1806 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb2_set_sparse()
1807 cfile->fid.volatile_fid, FSCTL_SET_SPARSE, in smb2_set_sparse()
1810 tcon->broken_sparse_sup = true; in smb2_set_sparse()
1816 cifsi->cifsAttrs |= FILE_ATTRIBUTE_SPARSE_FILE; in smb2_set_sparse()
1818 cifsi->cifsAttrs &= (~FILE_ATTRIBUTE_SPARSE_FILE); in smb2_set_sparse()
1824 smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon, in smb2_set_file_size() argument
1834 inode = d_inode(cfile->dentry); in smb2_set_file_size()
1836 if (!set_alloc && (size > inode->i_size + 8192)) { in smb2_set_file_size()
1840 smb2_set_sparse(xid, tcon, cfile, inode, set_sparse); in smb2_set_file_size()
1843 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, in smb2_set_file_size()
1844 cfile->fid.volatile_fid, cfile->pid, &eof); in smb2_set_file_size()
1857 struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink); in smb2_duplicate_extents() local
1860 if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) & in smb2_duplicate_extents()
1862 return -EOPNOTSUPP; in smb2_duplicate_extents()
1864 dup_ext_buf.VolatileFileHandle = srcfile->fid.volatile_fid; in smb2_duplicate_extents()
1865 dup_ext_buf.PersistentFileHandle = srcfile->fid.persistent_fid; in smb2_duplicate_extents()
1872 inode = d_inode(trgtfile->dentry); in smb2_duplicate_extents()
1873 if (inode->i_size < dest_off + len) { in smb2_duplicate_extents()
1874 rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false); in smb2_duplicate_extents()
1887 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, in smb2_duplicate_extents()
1888 trgtfile->fid.volatile_fid, in smb2_duplicate_extents()
1896 cifs_dbg(FYI, "Non-zero response length in duplicate extents\n"); in smb2_duplicate_extents()
1903 smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, in smb2_set_compression() argument
1906 return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid, in smb2_set_compression()
1907 cfile->fid.volatile_fid); in smb2_set_compression()
1911 smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon, in smb3_set_integrity() argument
1921 return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_set_integrity()
1922 cfile->fid.volatile_fid, in smb3_set_integrity()
1931 /* GMT Token is @GMT-YYYY.MM.DD-HH.MM.SS Unicode which is 48 bytes + null */
1934 #define MIN_SNAPSHOT_ARRAY_SIZE 16 /* See MS-SMB2 section 3.3.5.15.1 */
1938 * For output see struct SRV_SNAPSHOT_ARRAY in MS-SMB2 section 2.2.32.2
1941 smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon, in smb3_enum_snapshots() argument
1959 return -EFAULT; in smb3_enum_snapshots()
1973 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_enum_snapshots()
1974 cfile->fid.volatile_fid, in smb3_enum_snapshots()
1988 rc = -EFAULT; in smb3_enum_snapshots()
2015 rc = -EFAULT; in smb3_enum_snapshots()
2030 struct dentry *dentry = pfile->f_path.dentry; in smb3_notify()
2032 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in smb3_notify()
2035 struct cifs_tcon *tcon; in smb3_notify() local
2052 rc = -ENOMEM; in smb3_notify()
2058 rc = -EFAULT; in smb3_notify()
2063 rc = -EFAULT; in smb3_notify()
2069 tcon = cifs_sb_master_tcon(cifs_sb); in smb3_notify()
2070 oparms.tcon = tcon; in smb3_notify()
2082 rc = SMB2_change_notify(xid, tcon, fid.persistent_fid, fid.volatile_fid, in smb3_notify()
2086 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in smb3_notify()
2093 if (copy_to_user(pnotify_buf->notify_data, returned_ioctl_info, ret_len)) in smb3_notify()
2094 rc = -EFAULT; in smb3_notify()
2095 else if (copy_to_user(&pnotify_buf->data_len, &ret_len, sizeof(ret_len))) in smb3_notify()
2096 rc = -EFAULT; in smb3_notify()
2106 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_dir_first() argument
2122 struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses); in smb2_query_dir_first()
2127 return -ENOMEM; in smb2_query_dir_first()
2129 if (smb3_encryption_required(tcon)) in smb2_query_dir_first()
2141 oparms.tcon = tcon; in smb2_query_dir_first()
2148 rc = SMB2_open_init(tcon, server, in smb2_query_dir_first()
2152 smb2_set_next_command(tcon, &rqst[0]); in smb2_query_dir_first()
2155 srch_inf->entries_in_buffer = 0; in smb2_query_dir_first()
2156 srch_inf->index_of_last_entry = 2; in smb2_query_dir_first()
2162 rc = SMB2_query_directory_init(xid, tcon, server, in smb2_query_dir_first()
2165 0, srch_inf->info_level); in smb2_query_dir_first()
2172 rc = compound_send_recv(xid, tcon->ses, server, in smb2_query_dir_first()
2176 if (rc == -EAGAIN && retry_count++ < 10) in smb2_query_dir_first()
2181 if (op_rsp == NULL || op_rsp->hdr.Status != STATUS_SUCCESS) { in smb2_query_dir_first()
2185 fid->persistent_fid = op_rsp->PersistentFileId; in smb2_query_dir_first()
2186 fid->volatile_fid = op_rsp->VolatileFileId; in smb2_query_dir_first()
2189 if (rc && rc != -ENODATA) { in smb2_query_dir_first()
2190 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); in smb2_query_dir_first()
2192 trace_smb3_query_dir_err(xid, fid->persistent_fid, in smb2_query_dir_first()
2193 tcon->tid, tcon->ses->Suid, 0, 0, rc); in smb2_query_dir_first()
2197 atomic_inc(&tcon->num_remote_opens); in smb2_query_dir_first()
2200 if (qd_rsp->hdr.Status == STATUS_NO_MORE_FILES) { in smb2_query_dir_first()
2201 trace_smb3_query_dir_done(xid, fid->persistent_fid, in smb2_query_dir_first()
2202 tcon->tid, tcon->ses->Suid, 0, 0); in smb2_query_dir_first()
2203 srch_inf->endOfSearch = true; in smb2_query_dir_first()
2208 rc = smb2_parse_query_directory(tcon, &rsp_iov[1], resp_buftype[1], in smb2_query_dir_first()
2211 trace_smb3_query_dir_err(xid, fid->persistent_fid, tcon->tid, in smb2_query_dir_first()
2212 tcon->ses->Suid, 0, 0, rc); in smb2_query_dir_first()
2217 trace_smb3_query_dir_done(xid, fid->persistent_fid, tcon->tid, in smb2_query_dir_first()
2218 tcon->ses->Suid, 0, srch_inf->entries_in_buffer); in smb2_query_dir_first()
2230 smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_dir_next() argument
2234 return SMB2_query_directory(xid, tcon, fid->persistent_fid, in smb2_query_dir_next()
2235 fid->volatile_fid, 0, srch_inf); in smb2_query_dir_next()
2239 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon, in smb2_close_dir() argument
2242 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); in smb2_close_dir()
2246 * If we negotiate SMB2 protocol and get STATUS_PENDING - update
2247 * the number of credits and return true. Otherwise - return false.
2255 if (shdr->Status != STATUS_PENDING) in smb2_is_status_pending()
2258 if (shdr->CreditRequest) { in smb2_is_status_pending()
2259 spin_lock(&server->req_lock); in smb2_is_status_pending()
2260 server->credits += le16_to_cpu(shdr->CreditRequest); in smb2_is_status_pending()
2261 scredits = server->credits; in smb2_is_status_pending()
2262 in_flight = server->in_flight; in smb2_is_status_pending()
2263 spin_unlock(&server->req_lock); in smb2_is_status_pending()
2264 wake_up(&server->request_q); in smb2_is_status_pending()
2266 trace_smb3_pend_credits(server->CurrentMid, in smb2_is_status_pending()
2267 server->conn_id, server->hostname, scredits, in smb2_is_status_pending()
2268 le16_to_cpu(shdr->CreditRequest), in_flight); in smb2_is_status_pending()
2270 __func__, le16_to_cpu(shdr->CreditRequest), scredits); in smb2_is_status_pending()
2281 if (shdr->Status != STATUS_NETWORK_SESSION_EXPIRED && in smb2_is_session_expired()
2282 shdr->Status != STATUS_USER_SESSION_DELETED) in smb2_is_session_expired()
2285 trace_smb3_ses_expired(le32_to_cpu(shdr->Id.SyncId.TreeId), in smb2_is_session_expired()
2286 le64_to_cpu(shdr->SessionId), in smb2_is_session_expired()
2287 le16_to_cpu(shdr->Command), in smb2_is_session_expired()
2288 le64_to_cpu(shdr->MessageId)); in smb2_is_session_expired()
2299 if (shdr->Status == STATUS_IO_TIMEOUT) in smb2_is_status_io_timeout()
2311 struct cifs_tcon *tcon; in smb2_is_network_name_deleted() local
2313 if (shdr->Status != STATUS_NETWORK_NAME_DELETED) in smb2_is_network_name_deleted()
2316 /* If server is a channel, select the primary channel */ in smb2_is_network_name_deleted()
2317 pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server; in smb2_is_network_name_deleted()
2320 list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { in smb2_is_network_name_deleted()
2321 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { in smb2_is_network_name_deleted()
2322 if (tcon->tid == le32_to_cpu(shdr->Id.SyncId.TreeId)) { in smb2_is_network_name_deleted()
2323 spin_lock(&tcon->tc_lock); in smb2_is_network_name_deleted()
2324 tcon->need_reconnect = true; in smb2_is_network_name_deleted()
2325 spin_unlock(&tcon->tc_lock); in smb2_is_network_name_deleted()
2328 tcon->tree_name); in smb2_is_network_name_deleted()
2337 smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, in smb2_oplock_response() argument
2340 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) in smb2_oplock_response()
2341 return SMB2_lease_break(0, tcon, cinode->lease_key, in smb2_oplock_response()
2344 return SMB2_oplock_break(0, tcon, fid->persistent_fid, in smb2_oplock_response()
2345 fid->volatile_fid, in smb2_oplock_response()
2354 shdr = (struct smb2_hdr *)(rqst->rq_iov[0].iov_base); in smb2_set_related()
2359 shdr->Flags |= SMB2_FLAGS_RELATED_OPERATIONS; in smb2_set_related()
2365 smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst) in smb2_set_next_command() argument
2368 struct cifs_ses *ses = tcon->ses; in smb2_set_next_command()
2369 struct TCP_Server_Info *server = ses->server; in smb2_set_next_command()
2373 shdr = (struct smb2_hdr *)(rqst->rq_iov[0].iov_base); in smb2_set_next_command()
2385 num_padding = 8 - (len & 7); in smb2_set_next_command()
2386 if (!smb3_encryption_required(tcon)) { in smb2_set_next_command()
2391 rqst->rq_iov[rqst->rq_nvec].iov_base = smb2_padding; in smb2_set_next_command()
2392 rqst->rq_iov[rqst->rq_nvec].iov_len = num_padding; in smb2_set_next_command()
2393 rqst->rq_nvec++; in smb2_set_next_command()
2403 for (i = 1; i < rqst->rq_nvec; i++) { in smb2_set_next_command()
2404 memcpy(rqst->rq_iov[0].iov_base + in smb2_set_next_command()
2405 rqst->rq_iov[0].iov_len, in smb2_set_next_command()
2406 rqst->rq_iov[i].iov_base, in smb2_set_next_command()
2407 rqst->rq_iov[i].iov_len); in smb2_set_next_command()
2408 rqst->rq_iov[0].iov_len += rqst->rq_iov[i].iov_len; in smb2_set_next_command()
2410 memset(rqst->rq_iov[0].iov_base + rqst->rq_iov[0].iov_len, in smb2_set_next_command()
2412 rqst->rq_iov[0].iov_len += num_padding; in smb2_set_next_command()
2414 rqst->rq_nvec = 1; in smb2_set_next_command()
2418 shdr->NextCommand = cpu_to_le32(len); in smb2_set_next_command()
2426 smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_info_compound() argument
2432 struct cifs_ses *ses = tcon->ses; in smb2_query_info_compound()
2452 return -ENOMEM; in smb2_query_info_compound()
2454 if (smb3_encryption_required(tcon)) in smb2_query_info_compound()
2465 open_cached_dir(xid, tcon, path, cifs_sb, false, in smb2_query_info_compound()
2472 oparms.tcon = tcon; in smb2_query_info_compound()
2479 rc = SMB2_open_init(tcon, server, in smb2_query_info_compound()
2483 smb2_set_next_command(tcon, &rqst[0]); in smb2_query_info_compound()
2490 rc = SMB2_query_info_init(tcon, server, in smb2_query_info_compound()
2492 cfid->fid.persistent_fid, in smb2_query_info_compound()
2493 cfid->fid.volatile_fid, in smb2_query_info_compound()
2498 rc = SMB2_query_info_init(tcon, server, in smb2_query_info_compound()
2509 smb2_set_next_command(tcon, &rqst[1]); in smb2_query_info_compound()
2517 rc = SMB2_close_init(tcon, server, in smb2_query_info_compound()
2534 if (rc == -EREMCHG) { in smb2_query_info_compound()
2535 tcon->need_reconnect = true; in smb2_query_info_compound()
2537 tcon->tree_name); in smb2_query_info_compound()
2557 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, in smb2_queryfs() argument
2567 rc = smb2_query_info_compound(xid, tcon, "", in smb2_queryfs()
2577 buf->f_type = SMB2_SUPER_MAGIC; in smb2_queryfs()
2579 le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp); in smb2_queryfs()
2580 rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset), in smb2_queryfs()
2581 le32_to_cpu(rsp->OutputBufferLength), in smb2_queryfs()
2593 smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon, in smb311_queryfs() argument
2597 __le16 srch_path = 0; /* Null - open root of share */ in smb311_queryfs()
2602 if (!tcon->posix_extensions) in smb311_queryfs()
2603 return smb2_queryfs(xid, tcon, cifs_sb, buf); in smb311_queryfs()
2605 oparms.tcon = tcon; in smb311_queryfs()
2617 rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid, in smb311_queryfs()
2619 buf->f_type = SMB2_SUPER_MAGIC; in smb311_queryfs()
2620 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in smb311_queryfs()
2627 return ob1->fid.persistent_fid == ob2->fid.persistent_fid && in smb2_compare_fids()
2628 ob1->fid.volatile_fid == ob2->fid.volatile_fid; in smb2_compare_fids()
2637 return SMB2_lock(xid, tlink_tcon(cfile->tlink), in smb2_mand_lock()
2638 cfile->fid.persistent_fid, cfile->fid.volatile_fid, in smb2_mand_lock()
2639 current->tgid, length, offset, type, wait); in smb2_mand_lock()
2645 memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE); in smb2_get_lease_key()
2651 memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE); in smb2_set_lease_key()
2657 generate_random_uuid(fid->lease_key); in smb2_new_lease_key()
2670 struct cifs_tcon *tcon; in smb2_get_dfs_refer() local
2679 * Try to use the IPC tcon, otherwise just use any in smb2_get_dfs_refer()
2681 tcon = ses->tcon_ipc; in smb2_get_dfs_refer()
2682 if (tcon == NULL) { in smb2_get_dfs_refer()
2684 tcon = list_first_entry_or_null(&ses->tcon_list, in smb2_get_dfs_refer()
2687 if (tcon) in smb2_get_dfs_refer()
2688 tcon->tc_count++; in smb2_get_dfs_refer()
2692 if (tcon == NULL) { in smb2_get_dfs_refer()
2693 cifs_dbg(VFS, "session %p has no tcon available for a dfs referral request\n", in smb2_get_dfs_refer()
2695 rc = -ENOTCONN; in smb2_get_dfs_refer()
2703 rc = -ENOMEM; in smb2_get_dfs_refer()
2710 rc = -ENOMEM; in smb2_get_dfs_refer()
2715 dfs_req->MaxReferralLevel = DFS_VERSION; in smb2_get_dfs_refer()
2717 /* Path to resolve in an UTF-16 null-terminated string */ in smb2_get_dfs_refer()
2718 memcpy(dfs_req->RequestFileName, utf16_path, utf16_path_len); in smb2_get_dfs_refer()
2721 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, in smb2_get_dfs_refer()
2731 if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP) in smb2_get_dfs_refer()
2746 if (tcon && !tcon->ipc) { in smb2_get_dfs_refer()
2749 tcon->tc_count--; in smb2_get_dfs_refer()
2751 WARN_ON(tcon->tc_count < 0); in smb2_get_dfs_refer()
2767 /* See MS-FSCC 2.1.2.6 for the 'NFS' style reparse tags */ in parse_reparse_posix()
2768 len = le16_to_cpu(symlink_buf->ReparseDataLength); in parse_reparse_posix()
2770 if (le64_to_cpu(symlink_buf->InodeType) != NFS_SPECFILE_LNK) { in parse_reparse_posix()
2772 le64_to_cpu(symlink_buf->InodeType)); in parse_reparse_posix()
2773 return -EOPNOTSUPP; in parse_reparse_posix()
2777 symlink_buf->PathBuffer, in parse_reparse_posix()
2778 len, true, cifs_sb->local_nls); in parse_reparse_posix()
2780 return -ENOMEM; in parse_reparse_posix()
2796 /* We handle Symbolic Link reparse tag here. See: MS-FSCC 2.1.2.4 */ in parse_reparse_symlink()
2798 sub_offset = le16_to_cpu(symlink_buf->SubstituteNameOffset); in parse_reparse_symlink()
2799 sub_len = le16_to_cpu(symlink_buf->SubstituteNameLength); in parse_reparse_symlink()
2803 return -EIO; in parse_reparse_symlink()
2807 symlink_buf->PathBuffer + sub_offset, in parse_reparse_symlink()
2808 sub_len, true, cifs_sb->local_nls); in parse_reparse_symlink()
2810 return -ENOMEM; in parse_reparse_symlink()
2826 return -EIO; in parse_reparse_point()
2829 if (plen < le16_to_cpu(buf->ReparseDataLength) + in parse_reparse_point()
2833 return -EIO; in parse_reparse_point()
2836 /* See MS-FSCC 2.1.2 */ in parse_reparse_point()
2837 switch (le32_to_cpu(buf->ReparseTag)) { in parse_reparse_point()
2848 le32_to_cpu(buf->ReparseTag)); in parse_reparse_point()
2849 return -EOPNOTSUPP; in parse_reparse_point()
2854 smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_symlink() argument
2864 struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses); in smb2_query_symlink()
2882 if (smb3_encryption_required(tcon)) in smb2_query_symlink()
2891 return -ENOMEM; in smb2_query_symlink()
2899 oparms.tcon = tcon; in smb2_query_symlink()
2906 rc = SMB2_open_init(tcon, server, in smb2_query_symlink()
2910 smb2_set_next_command(tcon, &rqst[0]); in smb2_query_symlink()
2918 rc = SMB2_ioctl_init(tcon, server, in smb2_query_symlink()
2921 CIFSMaxBufSize - in smb2_query_symlink()
2922 MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_query_symlink()
2927 smb2_set_next_command(tcon, &rqst[1]); in smb2_query_symlink()
2936 rc = SMB2_close_init(tcon, server, in smb2_query_symlink()
2943 rc = compound_send_recv(xid, tcon->ses, server, in smb2_query_symlink()
2948 if (create_rsp && create_rsp->hdr.Status) in smb2_query_symlink()
2956 /* See MS-FSCC 2.3.23 */ in smb2_query_symlink()
2960 le32_to_cpu(ioctl_rsp->OutputOffset)); in smb2_query_symlink()
2961 plen = le32_to_cpu(ioctl_rsp->OutputCount); in smb2_query_symlink()
2963 if (plen + le32_to_cpu(ioctl_rsp->OutputOffset) > in smb2_query_symlink()
2967 rc = -EIO; in smb2_query_symlink()
2977 rc = -ENOENT; in smb2_query_symlink()
2996 smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon, in smb2_query_reparse_tag() argument
3005 struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses); in smb2_query_reparse_tag()
3019 if (smb3_encryption_required(tcon)) in smb2_query_reparse_tag()
3028 return -ENOMEM; in smb2_query_reparse_tag()
3031 * setup smb2open - TODO add optimization to call cifs_get_readable_path in smb2_query_reparse_tag()
3039 oparms.tcon = tcon; in smb2_query_reparse_tag()
3046 rc = SMB2_open_init(tcon, server, in smb2_query_reparse_tag()
3050 smb2_set_next_command(tcon, &rqst[0]); in smb2_query_reparse_tag()
3058 rc = SMB2_ioctl_init(tcon, server, in smb2_query_reparse_tag()
3061 CIFSMaxBufSize - in smb2_query_reparse_tag()
3062 MAX_SMB2_CREATE_RESPONSE_SIZE - in smb2_query_reparse_tag()
3067 smb2_set_next_command(tcon, &rqst[1]); in smb2_query_reparse_tag()
3076 rc = SMB2_close_init(tcon, server, in smb2_query_reparse_tag()
3083 rc = compound_send_recv(xid, tcon->ses, server, in smb2_query_reparse_tag()
3093 /* See MS-FSCC 2.3.23 */ in smb2_query_reparse_tag()
3097 le32_to_cpu(ioctl_rsp->OutputOffset)); in smb2_query_reparse_tag()
3098 plen = le32_to_cpu(ioctl_rsp->OutputCount); in smb2_query_reparse_tag()
3100 if (plen + le32_to_cpu(ioctl_rsp->OutputOffset) > in smb2_query_reparse_tag()
3104 rc = -EIO; in smb2_query_reparse_tag()
3107 *tag = le32_to_cpu(reparse_buf->ReparseTag); in smb2_query_reparse_tag()
3127 int rc = -EOPNOTSUPP; in get_smb2_acl_by_fid()
3136 rc = SMB2_query_acl(xid, tlink_tcon(tlink), cifsfid->persistent_fid, in get_smb2_acl_by_fid()
3137 cifsfid->volatile_fid, (void **)&pntsd, pacllen, in get_smb2_acl_by_fid()
3158 struct cifs_tcon *tcon; in get_smb2_acl_by_path() local
3168 tcon = tlink_tcon(tlink); in get_smb2_acl_by_path()
3173 rc = -ENOMEM; in get_smb2_acl_by_path()
3178 oparms.tcon = tcon; in get_smb2_acl_by_path()
3200 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in get_smb2_acl_by_path()
3219 struct cifs_tcon *tcon; in set_smb2_acl() local
3220 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in set_smb2_acl()
3230 tcon = tlink_tcon(tlink); in set_smb2_acl()
3242 rc = -ENOMEM; in set_smb2_acl()
3247 oparms.tcon = tcon; in set_smb2_acl()
3261 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); in set_smb2_acl()
3283 pntsd = get_smb2_acl_by_fid(cifs_sb, &open_file->fid, pacllen, info); in get_smb2_acl()
3288 static long smb3_zero_data(struct file *file, struct cifs_tcon *tcon, in smb3_zero_data() argument
3291 struct cifsFileInfo *cfile = file->private_data; in smb3_zero_data()
3299 return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_zero_data()
3300 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, in smb3_zero_data()
3306 static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, in smb3_zero_range() argument
3309 struct cifs_ses *ses = tcon->ses; in smb3_zero_range()
3312 struct cifsFileInfo *cfile = file->private_data; in smb3_zero_range()
3319 trace_smb3_zero_enter(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_zero_range()
3320 ses->Suid, offset, len); in smb3_zero_range()
3323 filemap_invalidate_lock(inode->i_mapping); in smb3_zero_range()
3329 truncate_pagecache_range(inode, offset, offset + len - 1); in smb3_zero_range()
3332 rc = -EOPNOTSUPP; in smb3_zero_range()
3336 rc = smb3_zero_data(file, tcon, offset, len, xid); in smb3_zero_range()
3345 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, in smb3_zero_range()
3346 cfile->fid.volatile_fid, cfile->pid, &eof); in smb3_zero_range()
3350 filemap_invalidate_unlock(inode->i_mapping); in smb3_zero_range()
3354 trace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_zero_range()
3355 ses->Suid, offset, len, rc); in smb3_zero_range()
3357 trace_smb3_zero_done(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_zero_range()
3358 ses->Suid, offset, len); in smb3_zero_range()
3362 static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, in smb3_punch_hole() argument
3366 struct cifsFileInfo *cfile = file->private_data; in smb3_punch_hole()
3377 if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse)) { in smb3_punch_hole()
3378 rc = -EOPNOTSUPP; in smb3_punch_hole()
3382 filemap_invalidate_lock(inode->i_mapping); in smb3_punch_hole()
3387 truncate_pagecache_range(inode, offset, offset + len - 1); in smb3_punch_hole()
3394 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_punch_hole()
3395 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, in smb3_punch_hole()
3399 filemap_invalidate_unlock(inode->i_mapping); in smb3_punch_hole()
3407 struct cifs_tcon *tcon, in smb3_simple_fallocate_write_range() argument
3417 io_parms.netfid = cfile->fid.netfid; in smb3_simple_fallocate_write_range()
3418 io_parms.pid = current->tgid; in smb3_simple_fallocate_write_range()
3419 io_parms.tcon = tcon; in smb3_simple_fallocate_write_range()
3420 io_parms.persistent_fid = cfile->fid.persistent_fid; in smb3_simple_fallocate_write_range()
3421 io_parms.volatile_fid = cfile->fid.volatile_fid; in smb3_simple_fallocate_write_range()
3435 return -EINVAL; in smb3_simple_fallocate_write_range()
3438 len -= nbytes; in smb3_simple_fallocate_write_range()
3444 struct cifs_tcon *tcon, in smb3_simple_fallocate_range() argument
3456 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_simple_fallocate_range()
3457 cfile->fid.volatile_fid, in smb3_simple_fallocate_range()
3467 rc = -ENOMEM; in smb3_simple_fallocate_range()
3477 rc = smb3_simple_fallocate_write_range(xid, tcon, in smb3_simple_fallocate_range()
3483 rc = -EINVAL; in smb3_simple_fallocate_range()
3487 if (off < le64_to_cpu(tmp_data->file_offset)) { in smb3_simple_fallocate_range()
3493 l = le64_to_cpu(tmp_data->file_offset) - off; in smb3_simple_fallocate_range()
3496 rc = smb3_simple_fallocate_write_range(xid, tcon, in smb3_simple_fallocate_range()
3501 len = len - l; in smb3_simple_fallocate_range()
3510 l = le64_to_cpu(tmp_data->length); in smb3_simple_fallocate_range()
3514 len -= l; in smb3_simple_fallocate_range()
3517 out_data_len -= sizeof(struct file_allocated_range_buffer); in smb3_simple_fallocate_range()
3527 static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, in smb3_simple_falloc() argument
3532 struct cifsFileInfo *cfile = file->private_data; in smb3_simple_falloc()
3533 long rc = -EOPNOTSUPP; in smb3_simple_falloc()
3539 inode = d_inode(cfile->dentry); in smb3_simple_falloc()
3542 trace_smb3_falloc_enter(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_simple_falloc()
3543 tcon->ses->Suid, off, len); in smb3_simple_falloc()
3547 trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, in smb3_simple_falloc()
3548 tcon->tid, tcon->ses->Suid, off, len, rc); in smb3_simple_falloc()
3561 if (cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) in smb3_simple_falloc()
3562 smb2_set_sparse(xid, tcon, cfile, inode, false); in smb3_simple_falloc()
3565 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, in smb3_simple_falloc()
3566 cfile->fid.volatile_fid, cfile->pid, &eof); in smb3_simple_falloc()
3568 cifsi->server_eof = off + len; in smb3_simple_falloc()
3570 cifs_truncate_page(inode->i_mapping, inode->i_size); in smb3_simple_falloc()
3577 * Files are non-sparse by default so falloc may be a no-op in smb3_simple_falloc()
3581 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) { in smb3_simple_falloc()
3600 len = i_size_read(inode) - off; in smb3_simple_falloc()
3609 * We can either turn the entire file to become non-sparse in smb3_simple_falloc()
3620 rc = smb3_simple_fallocate_range(xid, tcon, cfile, in smb3_simple_falloc()
3631 * or end of the file non-sparse via set_sparse is harmless. in smb3_simple_falloc()
3634 rc = -EOPNOTSUPP; in smb3_simple_falloc()
3639 smb2_set_sparse(xid, tcon, cfile, inode, false); in smb3_simple_falloc()
3644 trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_simple_falloc()
3645 tcon->ses->Suid, off, len, rc); in smb3_simple_falloc()
3647 trace_smb3_falloc_done(xid, cfile->fid.persistent_fid, tcon->tid, in smb3_simple_falloc()
3648 tcon->ses->Suid, off, len); in smb3_simple_falloc()
3654 static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon, in smb3_collapse_range() argument
3660 struct cifsFileInfo *cfile = file->private_data; in smb3_collapse_range()
3672 rc = -EINVAL; in smb3_collapse_range()
3676 filemap_invalidate_lock(inode->i_mapping); in smb3_collapse_range()
3677 rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof - 1); in smb3_collapse_range()
3684 old_eof - off - len, off); in smb3_collapse_range()
3688 eof = cpu_to_le64(old_eof - len); in smb3_collapse_range()
3689 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, in smb3_collapse_range()
3690 cfile->fid.volatile_fid, cfile->pid, &eof); in smb3_collapse_range()
3696 cifsi->server_eof = i_size_read(inode) - len; in smb3_collapse_range()
3697 truncate_setsize(inode, cifsi->server_eof); in smb3_collapse_range()
3698 fscache_resize_cookie(cifs_inode_cookie(inode), cifsi->server_eof); in smb3_collapse_range()
3700 filemap_invalidate_unlock(inode->i_mapping); in smb3_collapse_range()
3707 static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon, in smb3_insert_range() argument
3712 struct cifsFileInfo *cfile = file->private_data; in smb3_insert_range()
3723 rc = -EINVAL; in smb3_insert_range()
3727 count = old_eof - off; in smb3_insert_range()
3730 filemap_invalidate_lock(inode->i_mapping); in smb3_insert_range()
3731 rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof + len - 1); in smb3_insert_range()
3736 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, in smb3_insert_range()
3737 cfile->fid.volatile_fid, cfile->pid, &eof); in smb3_insert_range()
3745 rc = smb3_zero_data(file, tcon, off, len, xid); in smb3_insert_range()
3751 filemap_invalidate_unlock(inode->i_mapping); in smb3_insert_range()
3758 static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offset, int whence) in smb3_llseek() argument
3760 struct cifsFileInfo *wrcfile, *cfile = file->private_data; in smb3_llseek()
3771 inode = d_inode(cfile->dentry); in smb3_llseek()
3775 return -ENXIO; in smb3_llseek()
3787 filemap_write_and_wait(inode->i_mapping); in smb3_llseek()
3788 smb2_flush_file(xid, tcon, &wrcfile->fid); in smb3_llseek()
3792 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) { in smb3_llseek()
3801 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_llseek()
3802 cfile->fid.volatile_fid, in smb3_llseek()
3807 if (rc == -E2BIG) in smb3_llseek()
3816 rc = -ENXIO; in smb3_llseek()
3821 rc = -EINVAL; in smb3_llseek()
3825 offset = le64_to_cpu(out_data->file_offset); in smb3_llseek()
3828 if (offset < le64_to_cpu(out_data->file_offset)) in smb3_llseek()
3831 offset = le64_to_cpu(out_data->file_offset) + le64_to_cpu(out_data->length); in smb3_llseek()
3837 return vfs_setpos(file, offset, inode->i_sb->s_maxbytes); in smb3_llseek()
3842 static int smb3_fiemap(struct cifs_tcon *tcon, in smb3_fiemap() argument
3852 rc = fiemap_prep(d_inode(cfile->dentry), fei, start, &len, 0); in smb3_fiemap()
3861 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, in smb3_fiemap()
3862 cfile->fid.volatile_fid, in smb3_fiemap()
3867 if (rc == -E2BIG) { in smb3_fiemap()
3876 rc = -EINVAL; in smb3_fiemap()
3880 rc = -EINVAL; in smb3_fiemap()
3887 if (i == num - 1 && last_blob) in smb3_fiemap()
3904 next = le64_to_cpu(out_data[num - 1].file_offset) + in smb3_fiemap()
3905 le64_to_cpu(out_data[num - 1].length); in smb3_fiemap()
3906 len = len - (next - start); in smb3_fiemap()
3917 static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode, in smb3_fallocate() argument
3922 return smb3_punch_hole(file, tcon, off, len); in smb3_fallocate()
3925 return smb3_zero_range(file, tcon, off, len, true); in smb3_fallocate()
3926 return smb3_zero_range(file, tcon, off, len, false); in smb3_fallocate()
3928 return smb3_simple_falloc(file, tcon, off, len, true); in smb3_fallocate()
3930 return smb3_collapse_range(file, tcon, off, len); in smb3_fallocate()
3932 return smb3_insert_range(file, tcon, off, len); in smb3_fallocate()
3934 return smb3_simple_falloc(file, tcon, off, len, false); in smb3_fallocate()
3936 return -EOPNOTSUPP; in smb3_fallocate()
3944 server->ops->set_oplock_level(cinode, oplock, 0, NULL); in smb2_downgrade_oplock()
3956 unsigned int old_state = cinode->oplock; in smb3_downgrade_oplock()
3957 unsigned int old_epoch = cinode->epoch; in smb3_downgrade_oplock()
3962 cinode->epoch = epoch; in smb3_downgrade_oplock()
3965 new_state = cinode->oplock; in smb3_downgrade_oplock()
3971 else if (old_state == new_state && (epoch - old_epoch > 1)) in smb3_downgrade_oplock()
3980 cinode->lease_granted = false; in smb2_set_oplock_level()
3984 cinode->oplock = CIFS_CACHE_RHW_FLG; in smb2_set_oplock_level()
3986 &cinode->netfs.inode); in smb2_set_oplock_level()
3988 cinode->oplock = CIFS_CACHE_RW_FLG; in smb2_set_oplock_level()
3990 &cinode->netfs.inode); in smb2_set_oplock_level()
3992 cinode->oplock = CIFS_CACHE_READ_FLG; in smb2_set_oplock_level()
3994 &cinode->netfs.inode); in smb2_set_oplock_level()
3996 cinode->oplock = 0; in smb2_set_oplock_level()
4007 cinode->lease_granted = true; in smb21_set_oplock_level()
4031 cinode->oplock = new_oplock; in smb21_set_oplock_level()
4033 &cinode->netfs.inode); in smb21_set_oplock_level()
4040 unsigned int old_oplock = cinode->oplock; in smb3_set_oplock_level()
4047 if (cinode->oplock == CIFS_CACHE_READ_FLG && in smb3_set_oplock_level()
4048 (epoch - cinode->epoch > 0)) in smb3_set_oplock_level()
4050 else if (cinode->oplock == CIFS_CACHE_RH_FLG && in smb3_set_oplock_level()
4051 (epoch - cinode->epoch > 1)) in smb3_set_oplock_level()
4053 else if (cinode->oplock == CIFS_CACHE_RHW_FLG && in smb3_set_oplock_level()
4054 (epoch - cinode->epoch > 1)) in smb3_set_oplock_level()
4056 else if (cinode->oplock == 0 && in smb3_set_oplock_level()
4057 (epoch - cinode->epoch > 0)) in smb3_set_oplock_level()
4060 if (cinode->oplock == CIFS_CACHE_RH_FLG && in smb3_set_oplock_level()
4061 (epoch - cinode->epoch > 0)) in smb3_set_oplock_level()
4063 else if (cinode->oplock == CIFS_CACHE_RHW_FLG && in smb3_set_oplock_level()
4064 (epoch - cinode->epoch > 1)) in smb3_set_oplock_level()
4067 cinode->epoch = epoch; in smb3_set_oplock_level()
4108 memcpy(&buf->lcontext.LeaseKey, lease_key, SMB2_LEASE_KEY_SIZE); in smb2_create_lease_buf()
4109 buf->lcontext.LeaseState = map_oplock_to_lease(oplock); in smb2_create_lease_buf()
4111 buf->ccontext.DataOffset = cpu_to_le16(offsetof in smb2_create_lease_buf()
4113 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context)); in smb2_create_lease_buf()
4114 buf->ccontext.NameOffset = cpu_to_le16(offsetof in smb2_create_lease_buf()
4116 buf->ccontext.NameLength = cpu_to_le16(4); in smb2_create_lease_buf()
4118 buf->Name[0] = 'R'; in smb2_create_lease_buf()
4119 buf->Name[1] = 'q'; in smb2_create_lease_buf()
4120 buf->Name[2] = 'L'; in smb2_create_lease_buf()
4121 buf->Name[3] = 's'; in smb2_create_lease_buf()
4134 memcpy(&buf->lcontext.LeaseKey, lease_key, SMB2_LEASE_KEY_SIZE); in smb3_create_lease_buf()
4135 buf->lcontext.LeaseState = map_oplock_to_lease(oplock); in smb3_create_lease_buf()
4137 buf->ccontext.DataOffset = cpu_to_le16(offsetof in smb3_create_lease_buf()
4139 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2)); in smb3_create_lease_buf()
4140 buf->ccontext.NameOffset = cpu_to_le16(offsetof in smb3_create_lease_buf()
4142 buf->ccontext.NameLength = cpu_to_le16(4); in smb3_create_lease_buf()
4144 buf->Name[0] = 'R'; in smb3_create_lease_buf()
4145 buf->Name[1] = 'q'; in smb3_create_lease_buf()
4146 buf->Name[2] = 'L'; in smb3_create_lease_buf()
4147 buf->Name[3] = 's'; in smb3_create_lease_buf()
4157 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE) in smb2_parse_lease_buf()
4159 return le32_to_cpu(lc->lcontext.LeaseState); in smb2_parse_lease_buf()
4167 *epoch = le16_to_cpu(lc->lcontext.Epoch); in smb3_parse_lease_buf()
4168 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE) in smb3_parse_lease_buf()
4171 memcpy(lease_key, &lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE); in smb3_parse_lease_buf()
4172 return le32_to_cpu(lc->lcontext.LeaseState); in smb3_parse_lease_buf()
4178 return min_t(unsigned int, CIFS_SB(inode->i_sb)->ctx->wsize, in smb2_wp_retry_size()
4185 return !cfile->invalidHandle; in smb2_dir_needs_close()
4193 (struct smb2_hdr *)old_rq->rq_iov[0].iov_base; in fill_transform_hdr()
4196 tr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM; in fill_transform_hdr()
4197 tr_hdr->OriginalMessageSize = cpu_to_le32(orig_len); in fill_transform_hdr()
4198 tr_hdr->Flags = cpu_to_le16(0x01); in fill_transform_hdr()
4201 get_random_bytes(&tr_hdr->Nonce, SMB3_AES_GCM_NONCE); in fill_transform_hdr()
4203 get_random_bytes(&tr_hdr->Nonce, SMB3_AES_CCM_NONCE); in fill_transform_hdr()
4204 memcpy(&tr_hdr->SessionId, &shdr->SessionId, 8); in fill_transform_hdr()
4258 rqst[i].rq_iov[j].iov_len - skip); in init_sg()
4279 /* If server is a channel, select the primary channel */ in smb2_get_enc_key()
4280 pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server; in smb2_get_enc_key()
4283 list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { in smb2_get_enc_key()
4284 if (ses->Suid == ses_id) { in smb2_get_enc_key()
4285 spin_lock(&ses->ses_lock); in smb2_get_enc_key()
4286 ses_enc_key = enc ? ses->smb3encryptionkey : in smb2_get_enc_key()
4287 ses->smb3decryptionkey; in smb2_get_enc_key()
4289 spin_unlock(&ses->ses_lock); in smb2_get_enc_key()
4296 return -EAGAIN; in smb2_get_enc_key()
4300 * iov[0] - transform header (associate data),
4301 * iov[1-N] - SMB2 header and pages - data to encrypt.
4302 * On success return encrypted data in iov[1-N] and pages, leave iov[0]
4311 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20; in crypt_message()
4321 unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); in crypt_message()
4323 rc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key); in crypt_message()
4336 tfm = enc ? server->secmech.enc : server->secmech.dec; in crypt_message()
4338 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) || in crypt_message()
4339 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in crypt_message()
4358 return -ENOMEM; in crypt_message()
4362 memcpy(sign, &tr_hdr->Signature, SMB2_SIGNATURE_SIZE); in crypt_message()
4369 rc = -ENOMEM; in crypt_message()
4377 rc = -ENOMEM; in crypt_message()
4381 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) || in crypt_message()
4382 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in crypt_message()
4383 memcpy(iv, (char *)tr_hdr->Nonce, SMB3_AES_GCM_NONCE); in crypt_message()
4386 memcpy(iv + 1, (char *)tr_hdr->Nonce, SMB3_AES_CCM_NONCE); in crypt_message()
4399 memcpy(&tr_hdr->Signature, sign, SMB2_SIGNATURE_SIZE); in crypt_message()
4416 for (j = rqst[i].rq_npages - 1; j >= 0; j--) in smb3_free_compound_rqst()
4426 * a smb2_transform_hdr and is pre-allocated by the caller.
4433 * new_rq[0].rq_iov[0] : smb2_transform_hdr pre-allocated by the caller
4445 int rc = -ENOMEM; in smb3_init_transform_rq()
4448 npages = old_rq[i - 1].rq_npages; in smb3_init_transform_rq()
4456 new_rq[i].rq_offset = old_rq[i - 1].rq_offset; in smb3_init_transform_rq()
4457 new_rq[i].rq_pagesz = old_rq[i - 1].rq_pagesz; in smb3_init_transform_rq()
4458 new_rq[i].rq_tailsz = old_rq[i - 1].rq_tailsz; in smb3_init_transform_rq()
4459 new_rq[i].rq_iov = old_rq[i - 1].rq_iov; in smb3_init_transform_rq()
4460 new_rq[i].rq_nvec = old_rq[i - 1].rq_nvec; in smb3_init_transform_rq()
4462 orig_len += smb_rqst_len(server, &old_rq[i - 1]); in smb3_init_transform_rq()
4478 src = (char *) kmap(old_rq[i - 1].rq_pages[j]) + offset; in smb3_init_transform_rq()
4482 kunmap(old_rq[i - 1].rq_pages[j]); in smb3_init_transform_rq()
4487 fill_transform_hdr(tr_hdr, orig_len, old_rq, server->cipher_type); in smb3_init_transform_rq()
4497 smb3_free_compound_rqst(num_rqst - 1, &new_rq[1]); in smb3_init_transform_rq()
4506 return trhdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM; in smb3_is_transform_hdr()
4540 server->total_read = buf_data_size + page_data_size; in decrypt_raw_data()
4560 len -= n; in read_data_into_pages()
4562 zero_user(page, len, PAGE_SIZE - len); in read_data_into_pages()
4568 server->total_read += length; in read_data_into_pages()
4583 return -ENOMEM; in init_read_bvec()
4589 data_size -= bvec[i].bv_len; in init_read_bvec()
4595 return -EIO; in init_read_bvec()
4613 struct cifs_readdata *rdata = mid->callback_data; in handle_read_data()
4621 if (shdr->Command != SMB2_READ) { in handle_read_data()
4623 return -ENOTSUPP; in handle_read_data()
4626 if (server->ops->is_session_expired && in handle_read_data()
4627 server->ops->is_session_expired(buf)) { in handle_read_data()
4630 return -1; in handle_read_data()
4633 if (server->ops->is_status_pending && in handle_read_data()
4634 server->ops->is_status_pending(buf, server)) in handle_read_data()
4635 return -1; in handle_read_data()
4638 rdata->iov[0].iov_base = buf; in handle_read_data()
4639 rdata->iov[0].iov_len = 0; in handle_read_data()
4640 rdata->iov[1].iov_base = buf; in handle_read_data()
4641 rdata->iov[1].iov_len = in handle_read_data()
4642 min_t(unsigned int, buf_len, server->vals->read_rsp_size); in handle_read_data()
4644 rdata->iov[0].iov_base, rdata->iov[0].iov_len); in handle_read_data()
4646 rdata->iov[1].iov_base, rdata->iov[1].iov_len); in handle_read_data()
4648 rdata->result = server->ops->map_error(buf, true); in handle_read_data()
4649 if (rdata->result != 0) { in handle_read_data()
4651 __func__, rdata->result); in handle_read_data()
4654 mid->mid_state = MID_RESPONSE_RECEIVED; in handle_read_data()
4660 data_offset = server->ops->read_data_offset(buf); in handle_read_data()
4662 use_rdma_mr = rdata->mr; in handle_read_data()
4664 data_len = server->ops->read_data_length(buf, use_rdma_mr); in handle_read_data()
4666 if (data_offset < server->vals->read_rsp_size) { in handle_read_data()
4674 data_offset = server->vals->read_rsp_size; in handle_read_data()
4679 rdata->result = -EIO; in handle_read_data()
4681 mid->mid_state = MID_RESPONSE_MALFORMED; in handle_read_data()
4683 dequeue_mid(mid, rdata->result); in handle_read_data()
4687 pad_len = data_offset - server->vals->read_rsp_size; in handle_read_data()
4698 rdata->result = -EIO; in handle_read_data()
4700 mid->mid_state = MID_RESPONSE_MALFORMED; in handle_read_data()
4702 dequeue_mid(mid, rdata->result); in handle_read_data()
4706 if (data_len > page_data_size - pad_len) { in handle_read_data()
4707 /* data_len is corrupt -- discard frame */ in handle_read_data()
4708 rdata->result = -EIO; in handle_read_data()
4710 mid->mid_state = MID_RESPONSE_MALFORMED; in handle_read_data()
4712 dequeue_mid(mid, rdata->result); in handle_read_data()
4716 rdata->result = init_read_bvec(pages, npages, page_data_size, in handle_read_data()
4718 if (rdata->result != 0) { in handle_read_data()
4720 mid->mid_state = MID_RESPONSE_MALFORMED; in handle_read_data()
4722 dequeue_mid(mid, rdata->result); in handle_read_data()
4736 rdata->result = -EIO; in handle_read_data()
4738 mid->mid_state = MID_RESPONSE_MALFORMED; in handle_read_data()
4740 dequeue_mid(mid, rdata->result); in handle_read_data()
4744 length = rdata->copy_into_pages(server, rdata, &iter); in handle_read_data()
4752 mid->mid_state = MID_RESPONSE_RECEIVED; in handle_read_data()
4775 rc = decrypt_raw_data(dw->server, dw->buf, dw->server->vals->read_rsp_size, in smb2_decrypt_offload()
4776 dw->ppages, dw->npages, dw->len, true); in smb2_decrypt_offload()
4782 dw->server->lstrp = jiffies; in smb2_decrypt_offload()
4783 mid = smb2_find_dequeue_mid(dw->server, dw->buf); in smb2_decrypt_offload()
4787 mid->decrypted = true; in smb2_decrypt_offload()
4788 rc = handle_read_data(dw->server, mid, dw->buf, in smb2_decrypt_offload()
4789 dw->server->vals->read_rsp_size, in smb2_decrypt_offload()
4790 dw->ppages, dw->npages, dw->len, in smb2_decrypt_offload()
4794 mid->when_received = jiffies; in smb2_decrypt_offload()
4796 if (dw->server->ops->is_network_name_deleted) in smb2_decrypt_offload()
4797 dw->server->ops->is_network_name_deleted(dw->buf, in smb2_decrypt_offload()
4798 dw->server); in smb2_decrypt_offload()
4800 mid->callback(mid); in smb2_decrypt_offload()
4802 spin_lock(&dw->server->srv_lock); in smb2_decrypt_offload()
4803 if (dw->server->tcpStatus == CifsNeedReconnect) { in smb2_decrypt_offload()
4804 spin_lock(&dw->server->mid_lock); in smb2_decrypt_offload()
4805 mid->mid_state = MID_RETRY_NEEDED; in smb2_decrypt_offload()
4806 spin_unlock(&dw->server->mid_lock); in smb2_decrypt_offload()
4807 spin_unlock(&dw->server->srv_lock); in smb2_decrypt_offload()
4808 mid->callback(mid); in smb2_decrypt_offload()
4810 spin_lock(&dw->server->mid_lock); in smb2_decrypt_offload()
4811 mid->mid_state = MID_REQUEST_SUBMITTED; in smb2_decrypt_offload()
4812 mid->mid_flags &= ~(MID_DELETED); in smb2_decrypt_offload()
4813 list_add_tail(&mid->qhead, in smb2_decrypt_offload()
4814 &dw->server->pending_mid_q); in smb2_decrypt_offload()
4815 spin_unlock(&dw->server->mid_lock); in smb2_decrypt_offload()
4816 spin_unlock(&dw->server->srv_lock); in smb2_decrypt_offload()
4823 for (i = dw->npages-1; i >= 0; i--) in smb2_decrypt_offload()
4824 put_page(dw->ppages[i]); in smb2_decrypt_offload()
4826 kfree(dw->ppages); in smb2_decrypt_offload()
4827 cifs_small_buf_release(dw->buf); in smb2_decrypt_offload()
4836 char *buf = server->smallbuf; in receive_encrypted_read()
4841 unsigned int buflen = server->pdu_size; in receive_encrypted_read()
4847 len = min_t(unsigned int, buflen, server->vals->read_rsp_size + in receive_encrypted_read()
4848 sizeof(struct smb2_transform_hdr)) - HEADER_SIZE(server) + 1; in receive_encrypted_read()
4850 rc = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, len); in receive_encrypted_read()
4853 server->total_read += rc; in receive_encrypted_read()
4855 len = le32_to_cpu(tr_hdr->OriginalMessageSize) - in receive_encrypted_read()
4856 server->vals->read_rsp_size; in receive_encrypted_read()
4861 rc = -ENOMEM; in receive_encrypted_read()
4868 rc = -ENOMEM; in receive_encrypted_read()
4887 if ((server->min_offload) && (server->in_flight > 1) && in receive_encrypted_read()
4888 (server->pdu_size >= server->min_offload)) { in receive_encrypted_read()
4893 dw->buf = server->smallbuf; in receive_encrypted_read()
4894 server->smallbuf = (char *)cifs_small_buf_get(); in receive_encrypted_read()
4896 INIT_WORK(&dw->decrypt, smb2_decrypt_offload); in receive_encrypted_read()
4898 dw->npages = npages; in receive_encrypted_read()
4899 dw->server = server; in receive_encrypted_read()
4900 dw->ppages = pages; in receive_encrypted_read()
4901 dw->len = len; in receive_encrypted_read()
4902 queue_work(decrypt_wq, &dw->decrypt); in receive_encrypted_read()
4904 return -1; in receive_encrypted_read()
4908 rc = decrypt_raw_data(server, buf, server->vals->read_rsp_size, in receive_encrypted_read()
4918 (*mid)->decrypted = true; in receive_encrypted_read()
4920 server->vals->read_rsp_size, in receive_encrypted_read()
4923 if (server->ops->is_network_name_deleted) { in receive_encrypted_read()
4924 server->ops->is_network_name_deleted(buf, in receive_encrypted_read()
4931 for (i = i - 1; i >= 0; i--) in receive_encrypted_read()
4946 char *buf = server->smallbuf; in receive_encrypted_standard()
4948 unsigned int pdu_length = server->pdu_size; in receive_encrypted_standard()
4958 server->large_buf = true; in receive_encrypted_standard()
4959 memcpy(server->bigbuf, buf, server->total_read); in receive_encrypted_standard()
4960 buf = server->bigbuf; in receive_encrypted_standard()
4964 length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, in receive_encrypted_standard()
4965 pdu_length - HEADER_SIZE(server) + 1); in receive_encrypted_standard()
4968 server->total_read += length; in receive_encrypted_standard()
4970 buf_size = pdu_length - sizeof(struct smb2_transform_hdr); in receive_encrypted_standard()
4975 next_is_large = server->large_buf; in receive_encrypted_standard()
4978 if (shdr->NextCommand) { in receive_encrypted_standard()
4984 buf + le32_to_cpu(shdr->NextCommand), in receive_encrypted_standard()
4985 pdu_length - le32_to_cpu(shdr->NextCommand)); in receive_encrypted_standard()
4993 mid_entry->decrypted = true; in receive_encrypted_standard()
4994 mid_entry->resp_buf_size = server->pdu_size; in receive_encrypted_standard()
4999 return -1; in receive_encrypted_standard()
5004 if (mid_entry && mid_entry->handle) in receive_encrypted_standard()
5005 ret = mid_entry->handle(server, mid_entry); in receive_encrypted_standard()
5009 if (ret == 0 && shdr->NextCommand) { in receive_encrypted_standard()
5010 pdu_length -= le32_to_cpu(shdr->NextCommand); in receive_encrypted_standard()
5011 server->large_buf = next_is_large; in receive_encrypted_standard()
5013 server->bigbuf = buf = next_buffer; in receive_encrypted_standard()
5015 server->smallbuf = buf = next_buffer; in receive_encrypted_standard()
5020 * server->smallbuf and server->bigbuf are still valid. We need in receive_encrypted_standard()
5037 char *buf = server->smallbuf; in smb3_receive_transform()
5038 unsigned int pdu_length = server->pdu_size; in smb3_receive_transform()
5040 unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize); in smb3_receive_transform()
5047 return -ECONNABORTED; in smb3_receive_transform()
5053 return -ECONNABORTED; in smb3_receive_transform()
5067 char *buf = server->large_buf ? server->bigbuf : server->smallbuf; in smb3_handle_read_data()
5069 return handle_read_data(server, mid, buf, server->pdu_size, in smb3_handle_read_data()
5079 if (hdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) in smb2_next_header()
5081 le32_to_cpu(t_hdr->OriginalMessageSize); in smb2_next_header()
5083 return le32_to_cpu(hdr->NextCommand); in smb2_next_header()
5088 struct dentry *dentry, struct cifs_tcon *tcon, in smb2_make_node() argument
5091 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in smb2_make_node()
5092 int rc = -EPERM; in smb2_make_node()
5108 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) in smb2_make_node()
5122 oparms.tcon = tcon; in smb2_make_node()
5132 if (tcon->ses->server->oplocks) in smb2_make_node()
5136 rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, &buf); in smb2_make_node()
5146 io_parms.pid = current->tgid; in smb2_make_node()
5147 io_parms.tcon = tcon; in smb2_make_node()
5153 memcpy(pdev->type, "IntxCHR", 8); in smb2_make_node()
5154 pdev->major = cpu_to_le64(MAJOR(dev)); in smb2_make_node()
5155 pdev->minor = cpu_to_le64(MINOR(dev)); in smb2_make_node()
5156 rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms, in smb2_make_node()
5159 memcpy(pdev->type, "IntxBLK", 8); in smb2_make_node()
5160 pdev->major = cpu_to_le64(MAJOR(dev)); in smb2_make_node()
5161 pdev->minor = cpu_to_le64(MINOR(dev)); in smb2_make_node()
5162 rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms, in smb2_make_node()
5165 tcon->ses->server->ops->close(xid, tcon, &fid); in smb2_make_node()
5617 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5639 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5660 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5681 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5702 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5723 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
5744 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,