Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smb: server: pass ksmbd_transport to get_smbd_max_read_write_size()

We should use the per connection value.

And for TCP return NT_STATUS_INVALID_PARAMETER if any
SMB2_CHANNEL_RDMA_V1* is used.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Stefan Metzmacher and committed by
Steve French
03a38d84 341b6c69

+25 -6
+10 -2
fs/smb/server/smb2pdu.c
··· 6762 6762 if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE || 6763 6763 req->Channel == SMB2_CHANNEL_RDMA_V1) { 6764 6764 is_rdma_channel = true; 6765 - max_read_size = get_smbd_max_read_write_size(); 6765 + max_read_size = get_smbd_max_read_write_size(work->conn->transport); 6766 + if (max_read_size == 0) { 6767 + err = -EINVAL; 6768 + goto out; 6769 + } 6766 6770 } 6767 6771 6768 6772 if (is_rdma_channel == true) { ··· 7024 7020 if (req->Channel == SMB2_CHANNEL_RDMA_V1 || 7025 7021 req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE) { 7026 7022 is_rdma_channel = true; 7027 - max_write_size = get_smbd_max_read_write_size(); 7023 + max_write_size = get_smbd_max_read_write_size(work->conn->transport); 7024 + if (max_write_size == 0) { 7025 + err = -EINVAL; 7026 + goto out; 7027 + } 7028 7028 length = le32_to_cpu(req->RemainingBytes); 7029 7029 } 7030 7030
+13 -2
fs/smb/server/transport_rdma.c
··· 111 111 smb_direct_max_read_write_size = sz; 112 112 } 113 113 114 - unsigned int get_smbd_max_read_write_size(void) 114 + unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt) 115 115 { 116 - return smb_direct_max_read_write_size; 116 + struct smb_direct_transport *t; 117 + struct smbdirect_socket *sc; 118 + struct smbdirect_socket_parameters *sp; 119 + 120 + if (kt->ops != &ksmbd_smb_direct_transport_ops) 121 + return 0; 122 + 123 + t = SMBD_TRANS(kt); 124 + sc = &t->socket; 125 + sp = &sc->parameters; 126 + 127 + return sp->max_read_write_size; 117 128 } 118 129 119 130 static inline int get_buf_page_count(void *buf, int size)
+2 -2
fs/smb/server/transport_rdma.h
··· 17 17 void ksmbd_rdma_destroy(void); 18 18 bool ksmbd_rdma_capable_netdev(struct net_device *netdev); 19 19 void init_smbd_max_io_size(unsigned int sz); 20 - unsigned int get_smbd_max_read_write_size(void); 20 + unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt); 21 21 #else 22 22 static inline int ksmbd_rdma_init(void) { return 0; } 23 23 static inline void ksmbd_rdma_stop_listening(void) { } 24 24 static inline void ksmbd_rdma_destroy(void) { } 25 25 static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; } 26 26 static inline void init_smbd_max_io_size(unsigned int sz) { } 27 - static inline unsigned int get_smbd_max_read_write_size(void) { return 0; } 27 + static inline unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt) { return 0; } 28 28 #endif 29 29 30 30 #endif /* __KSMBD_TRANSPORT_RDMA_H__ */