Commit a6559cc1 authored by Stefan Metzmacher's avatar Stefan Metzmacher Committed by Steve French

cifs: split out smb3_use_rdma_offload() helper

We should have the logic to decide if we want rdma offload
in a single spot in order to advance it in future.
Signed-off-by: default avatarStefan Metzmacher <metze@samba.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: linux-cifs@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent d643a8a4
......@@ -4063,6 +4063,32 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
return rc;
}
#ifdef CONFIG_CIFS_SMB_DIRECT
static inline bool smb3_use_rdma_offload(struct cifs_io_parms *io_parms)
{
struct TCP_Server_Info *server = io_parms->server;
struct cifs_tcon *tcon = io_parms->tcon;
/* we can only offload if we're connected */
if (!server || !tcon)
return false;
/* we can only offload on an rdma connection */
if (!server->rdma || !server->smbd_conn)
return false;
/* we don't support signed offload yet */
if (server->sign)
return false;
/* offload also has its overhead, so only do it if desired */
if (io_parms->length < server->smbd_conn->rdma_readwrite_threshold)
return false;
return true;
}
#endif /* CONFIG_CIFS_SMB_DIRECT */
/*
* To form a chain of read requests, any read requests after the first should
* have the end_of_chain boolean set to true.
......@@ -4106,9 +4132,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
* If we want to do a RDMA write, fill in and append
* smbd_buffer_descriptor_v1 to the end of read request
*/
if (server->rdma && rdata && !server->sign &&
rdata->bytes >= server->smbd_conn->rdma_readwrite_threshold) {
if (smb3_use_rdma_offload(io_parms)) {
struct smbd_buffer_descriptor_v1 *v1;
bool need_invalidate = server->dialect == SMB30_PROT_ID;
......@@ -4558,9 +4582,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
* If we want to do a server RDMA read, fill in and append
* smbd_buffer_descriptor_v1 to the end of write request
*/
if (server->rdma && !server->sign && io_parms->length >=
server->smbd_conn->rdma_readwrite_threshold) {
if (smb3_use_rdma_offload(io_parms)) {
struct smbd_buffer_descriptor_v1 *v1;
bool need_invalidate = server->dialect == SMB30_PROT_ID;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment