mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
341b6c69b9
commit
03a38d8467
|
|
@ -6762,7 +6762,11 @@ int smb2_read(struct ksmbd_work *work)
|
||||||
if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
|
if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
|
||||||
req->Channel == SMB2_CHANNEL_RDMA_V1) {
|
req->Channel == SMB2_CHANNEL_RDMA_V1) {
|
||||||
is_rdma_channel = true;
|
is_rdma_channel = true;
|
||||||
max_read_size = get_smbd_max_read_write_size();
|
max_read_size = get_smbd_max_read_write_size(work->conn->transport);
|
||||||
|
if (max_read_size == 0) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_rdma_channel == true) {
|
if (is_rdma_channel == true) {
|
||||||
|
|
@ -7020,7 +7024,11 @@ int smb2_write(struct ksmbd_work *work)
|
||||||
if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||
|
if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||
|
||||||
req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE) {
|
req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE) {
|
||||||
is_rdma_channel = true;
|
is_rdma_channel = true;
|
||||||
max_write_size = get_smbd_max_read_write_size();
|
max_write_size = get_smbd_max_read_write_size(work->conn->transport);
|
||||||
|
if (max_write_size == 0) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
length = le32_to_cpu(req->RemainingBytes);
|
length = le32_to_cpu(req->RemainingBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,20 @@ void init_smbd_max_io_size(unsigned int sz)
|
||||||
smb_direct_max_read_write_size = sz;
|
smb_direct_max_read_write_size = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_smbd_max_read_write_size(void)
|
unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt)
|
||||||
{
|
{
|
||||||
return smb_direct_max_read_write_size;
|
struct smb_direct_transport *t;
|
||||||
|
struct smbdirect_socket *sc;
|
||||||
|
struct smbdirect_socket_parameters *sp;
|
||||||
|
|
||||||
|
if (kt->ops != &ksmbd_smb_direct_transport_ops)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
t = SMBD_TRANS(kt);
|
||||||
|
sc = &t->socket;
|
||||||
|
sp = &sc->parameters;
|
||||||
|
|
||||||
|
return sp->max_read_write_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_buf_page_count(void *buf, int size)
|
static inline int get_buf_page_count(void *buf, int size)
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ void ksmbd_rdma_stop_listening(void);
|
||||||
void ksmbd_rdma_destroy(void);
|
void ksmbd_rdma_destroy(void);
|
||||||
bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
|
bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
|
||||||
void init_smbd_max_io_size(unsigned int sz);
|
void init_smbd_max_io_size(unsigned int sz);
|
||||||
unsigned int get_smbd_max_read_write_size(void);
|
unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt);
|
||||||
#else
|
#else
|
||||||
static inline int ksmbd_rdma_init(void) { return 0; }
|
static inline int ksmbd_rdma_init(void) { return 0; }
|
||||||
static inline void ksmbd_rdma_stop_listening(void) { }
|
static inline void ksmbd_rdma_stop_listening(void) { }
|
||||||
static inline void ksmbd_rdma_destroy(void) { }
|
static inline void ksmbd_rdma_destroy(void) { }
|
||||||
static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
|
static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
|
||||||
static inline void init_smbd_max_io_size(unsigned int sz) { }
|
static inline void init_smbd_max_io_size(unsigned int sz) { }
|
||||||
static inline unsigned int get_smbd_max_read_write_size(void) { return 0; }
|
static inline unsigned int get_smbd_max_read_write_size(struct ksmbd_transport *kt) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KSMBD_TRANSPORT_RDMA_H__ */
|
#endif /* __KSMBD_TRANSPORT_RDMA_H__ */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue