cifs: Make smb1's SendReceive() wrap cifs_send_recv()

Make the smb1 transport's SendReceive() simply wrap cifs_send_recv() as
does SendReceive2().  This will then allow that to pick up the transport
changes there.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
David Howells 2025-08-05 13:58:43 +01:00 committed by Steve French
parent 83bfbd0bb9
commit 6be09580df

View File

@ -236,12 +236,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
struct smb_hdr *in_buf, unsigned int in_len, struct smb_hdr *in_buf, unsigned int in_len,
struct smb_hdr *out_buf, int *pbytes_returned, const int flags) struct smb_hdr *out_buf, int *pbytes_returned, const int flags)
{ {
int rc = 0; struct TCP_Server_Info *server;
struct mid_q_entry *mid; struct kvec resp_iov = {};
struct kvec iov = { .iov_base = in_buf, .iov_len = in_len }; struct kvec iov = { .iov_base = in_buf, .iov_len = in_len };
struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
struct cifs_credits credits = { .value = 1, .instance = 0 }; int resp_buf_type;
struct TCP_Server_Info *server; int rc = 0;
if (WARN_ON_ONCE(in_len > 0xffffff)) if (WARN_ON_ONCE(in_len > 0xffffff))
return -EIO; return -EIO;
@ -272,77 +272,15 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
return -EIO; return -EIO;
} }
rc = wait_for_free_request(server, flags, &credits.instance); rc = cifs_send_recv(xid, ses, ses->server,
if (rc) &rqst, &resp_buf_type, flags, &resp_iov);
return rc;
/* make sure that we sign in the same order that we send on this socket
and avoid races inside tcp sendmsg code that could cause corruption
of smb data */
cifs_server_lock(server);
rc = allocate_mid(ses, in_buf, &mid);
if (rc) {
cifs_server_unlock(server);
/* Update # of requests on wire to server */
add_credits(server, &credits, 0);
return rc;
}
rc = cifs_sign_smb(in_buf, in_len, server, &mid->sequence_number);
if (rc) {
cifs_server_unlock(server);
goto out;
}
mid->mid_state = MID_REQUEST_SUBMITTED;
rc = smb_send(server, in_buf, in_len);
cifs_save_when_sent(mid);
if (rc < 0) if (rc < 0)
server->sequence_number -= 2;
cifs_server_unlock(server);
if (rc < 0)
goto out;
rc = wait_for_response(server, mid);
if (rc != 0) {
send_cancel(server, &rqst, mid);
spin_lock(&mid->mid_lock);
if (mid->callback) {
/* no longer considered to be "in-flight" */
mid->callback = release_mid;
spin_unlock(&mid->mid_lock);
add_credits(server, &credits, 0);
return rc;
}
spin_unlock(&mid->mid_lock);
}
rc = cifs_sync_mid_result(mid, server);
if (rc != 0) {
add_credits(server, &credits, 0);
return rc; return rc;
}
if (!mid->resp_buf || !out_buf ||
mid->mid_state != MID_RESPONSE_READY) {
rc = -EIO;
cifs_server_dbg(VFS, "Bad MID state?\n");
goto out;
}
*pbytes_returned = mid->response_pdu_len;
memcpy(out_buf, mid->resp_buf, *pbytes_returned);
rc = cifs_check_receive(mid, server, 0);
out:
delete_mid(mid);
add_credits(server, &credits, 0);
*pbytes_returned = resp_iov.iov_len;
if (resp_iov.iov_len)
memcpy(out_buf, resp_iov.iov_base, resp_iov.iov_len);
free_rsp_buf(resp_buf_type, resp_iov.iov_base);
return rc; return rc;
} }