Skip to content

Commit 017d170

Browse files
metze-sambasmfrench
authored andcommitted
smb/client: fix rdma usage in smb2_async_writev()
rqst.rq_iter needs to be truncated otherwise we'll also send the bytes into the stream socket... This is the logic behind rqst.rq_npages = 0, which was removed in "cifs: Change the I/O paths to use an iterator rather than a page list" (d08089f). Cc: [email protected] Fixes: d08089f ("cifs: Change the I/O paths to use an iterator rather than a page list") Reviewed-by: David Howells <[email protected]> Signed-off-by: Stefan Metzmacher <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b608e2c commit 017d170

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4913,6 +4913,13 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
49134913
if (rc)
49144914
goto out;
49154915

4916+
rqst.rq_iov = iov;
4917+
rqst.rq_iter = wdata->subreq.io_iter;
4918+
4919+
rqst.rq_iov[0].iov_len = total_len - 1;
4920+
rqst.rq_iov[0].iov_base = (char *)req;
4921+
rqst.rq_nvec += 1;
4922+
49164923
if (smb3_encryption_required(tcon))
49174924
flags |= CIFS_TRANSFORM_REQ;
49184925

@@ -4924,6 +4931,7 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
49244931
req->WriteChannelInfoOffset = 0;
49254932
req->WriteChannelInfoLength = 0;
49264933
req->Channel = SMB2_CHANNEL_NONE;
4934+
req->Length = cpu_to_le32(io_parms->length);
49274935
req->Offset = cpu_to_le64(io_parms->offset);
49284936
req->DataOffset = cpu_to_le16(
49294937
offsetof(struct smb2_write_req, Buffer));
@@ -4943,7 +4951,6 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
49434951
*/
49444952
if (smb3_use_rdma_offload(io_parms)) {
49454953
struct smbd_buffer_descriptor_v1 *v1;
4946-
size_t data_size = iov_iter_count(&wdata->subreq.io_iter);
49474954
bool need_invalidate = server->dialect == SMB30_PROT_ID;
49484955

49494956
wdata->mr = smbd_register_mr(server->smbd_conn, &wdata->subreq.io_iter,
@@ -4952,9 +4959,10 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
49524959
rc = -EAGAIN;
49534960
goto async_writev_out;
49544961
}
4962+
/* For RDMA read, I/O size is in RemainingBytes not in Length */
4963+
req->RemainingBytes = req->Length;
49554964
req->Length = 0;
49564965
req->DataOffset = 0;
4957-
req->RemainingBytes = cpu_to_le32(data_size);
49584966
req->Channel = SMB2_CHANNEL_RDMA_V1_INVALIDATE;
49594967
if (need_invalidate)
49604968
req->Channel = SMB2_CHANNEL_RDMA_V1;
@@ -4966,30 +4974,22 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
49664974
v1->offset = cpu_to_le64(wdata->mr->mr->iova);
49674975
v1->token = cpu_to_le32(wdata->mr->mr->rkey);
49684976
v1->length = cpu_to_le32(wdata->mr->mr->length);
4977+
4978+
rqst.rq_iov[0].iov_len += sizeof(*v1);
4979+
4980+
/*
4981+
* We keep wdata->subreq.io_iter,
4982+
* but we have to truncate rqst.rq_iter
4983+
*/
4984+
iov_iter_truncate(&rqst.rq_iter, 0);
49694985
}
49704986
#endif
4971-
iov[0].iov_len = total_len - 1;
4972-
iov[0].iov_base = (char *)req;
49734987

4974-
rqst.rq_iov = iov;
4975-
rqst.rq_nvec = 1;
4976-
rqst.rq_iter = wdata->subreq.io_iter;
49774988
if (test_bit(NETFS_SREQ_RETRYING, &wdata->subreq.flags))
49784989
smb2_set_replay(server, &rqst);
4979-
#ifdef CONFIG_CIFS_SMB_DIRECT
4980-
if (wdata->mr)
4981-
iov[0].iov_len += sizeof(struct smbd_buffer_descriptor_v1);
4982-
#endif
4983-
cifs_dbg(FYI, "async write at %llu %u bytes iter=%zx\n",
4984-
io_parms->offset, io_parms->length, iov_iter_count(&rqst.rq_iter));
49854990

4986-
#ifdef CONFIG_CIFS_SMB_DIRECT
4987-
/* For RDMA read, I/O size is in RemainingBytes not in Length */
4988-
if (!wdata->mr)
4989-
req->Length = cpu_to_le32(io_parms->length);
4990-
#else
4991-
req->Length = cpu_to_le32(io_parms->length);
4992-
#endif
4991+
cifs_dbg(FYI, "async write at %llu %u bytes iter=%zx\n",
4992+
io_parms->offset, io_parms->length, iov_iter_count(&wdata->subreq.io_iter));
49934993

49944994
if (wdata->credits.value > 0) {
49954995
shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->subreq.len,

0 commit comments

Comments
 (0)