Skip to content

Commit a6559cc

Browse files
metze-sambasmfrench
authored andcommitted
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: Stefan 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: Steve French <stfrench@microsoft.com>
1 parent d643a8a commit a6559cc

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

fs/cifs/smb2pdu.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,32 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
40634063
return rc;
40644064
}
40654065

4066+
#ifdef CONFIG_CIFS_SMB_DIRECT
4067+
static inline bool smb3_use_rdma_offload(struct cifs_io_parms *io_parms)
4068+
{
4069+
struct TCP_Server_Info *server = io_parms->server;
4070+
struct cifs_tcon *tcon = io_parms->tcon;
4071+
4072+
/* we can only offload if we're connected */
4073+
if (!server || !tcon)
4074+
return false;
4075+
4076+
/* we can only offload on an rdma connection */
4077+
if (!server->rdma || !server->smbd_conn)
4078+
return false;
4079+
4080+
/* we don't support signed offload yet */
4081+
if (server->sign)
4082+
return false;
4083+
4084+
/* offload also has its overhead, so only do it if desired */
4085+
if (io_parms->length < server->smbd_conn->rdma_readwrite_threshold)
4086+
return false;
4087+
4088+
return true;
4089+
}
4090+
#endif /* CONFIG_CIFS_SMB_DIRECT */
4091+
40664092
/*
40674093
* To form a chain of read requests, any read requests after the first should
40684094
* have the end_of_chain boolean set to true.
@@ -4106,9 +4132,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
41064132
* If we want to do a RDMA write, fill in and append
41074133
* smbd_buffer_descriptor_v1 to the end of read request
41084134
*/
4109-
if (server->rdma && rdata && !server->sign &&
4110-
rdata->bytes >= server->smbd_conn->rdma_readwrite_threshold) {
4111-
4135+
if (smb3_use_rdma_offload(io_parms)) {
41124136
struct smbd_buffer_descriptor_v1 *v1;
41134137
bool need_invalidate = server->dialect == SMB30_PROT_ID;
41144138

@@ -4558,9 +4582,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
45584582
* If we want to do a server RDMA read, fill in and append
45594583
* smbd_buffer_descriptor_v1 to the end of write request
45604584
*/
4561-
if (server->rdma && !server->sign && io_parms->length >=
4562-
server->smbd_conn->rdma_readwrite_threshold) {
4563-
4585+
if (smb3_use_rdma_offload(io_parms)) {
45644586
struct smbd_buffer_descriptor_v1 *v1;
45654587
bool need_invalidate = server->dialect == SMB30_PROT_ID;
45664588

0 commit comments

Comments
 (0)