Skip to content

Commit 6be0958

Browse files
dhowellssmfrench
authored andcommitted
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>
1 parent 83bfbd0 commit 6be0958

1 file changed

Lines changed: 10 additions & 72 deletions

File tree

fs/smb/client/cifstransport.c

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
236236
struct smb_hdr *in_buf, unsigned int in_len,
237237
struct smb_hdr *out_buf, int *pbytes_returned, const int flags)
238238
{
239-
int rc = 0;
240-
struct mid_q_entry *mid;
239+
struct TCP_Server_Info *server;
240+
struct kvec resp_iov = {};
241241
struct kvec iov = { .iov_base = in_buf, .iov_len = in_len };
242242
struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
243-
struct cifs_credits credits = { .value = 1, .instance = 0 };
244-
struct TCP_Server_Info *server;
243+
int resp_buf_type;
244+
int rc = 0;
245245

246246
if (WARN_ON_ONCE(in_len > 0xffffff))
247247
return -EIO;
@@ -272,77 +272,15 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
272272
return -EIO;
273273
}
274274

275-
rc = wait_for_free_request(server, flags, &credits.instance);
276-
if (rc)
277-
return rc;
278-
279-
/* make sure that we sign in the same order that we send on this socket
280-
and avoid races inside tcp sendmsg code that could cause corruption
281-
of smb data */
282-
283-
cifs_server_lock(server);
284-
285-
rc = allocate_mid(ses, in_buf, &mid);
286-
if (rc) {
287-
cifs_server_unlock(server);
288-
/* Update # of requests on wire to server */
289-
add_credits(server, &credits, 0);
290-
return rc;
291-
}
292-
293-
rc = cifs_sign_smb(in_buf, in_len, server, &mid->sequence_number);
294-
if (rc) {
295-
cifs_server_unlock(server);
296-
goto out;
297-
}
298-
299-
mid->mid_state = MID_REQUEST_SUBMITTED;
300-
301-
rc = smb_send(server, in_buf, in_len);
302-
cifs_save_when_sent(mid);
303-
304-
if (rc < 0)
305-
server->sequence_number -= 2;
306-
307-
cifs_server_unlock(server);
308-
275+
rc = cifs_send_recv(xid, ses, ses->server,
276+
&rqst, &resp_buf_type, flags, &resp_iov);
309277
if (rc < 0)
310-
goto out;
311-
312-
rc = wait_for_response(server, mid);
313-
if (rc != 0) {
314-
send_cancel(server, &rqst, mid);
315-
spin_lock(&mid->mid_lock);
316-
if (mid->callback) {
317-
/* no longer considered to be "in-flight" */
318-
mid->callback = release_mid;
319-
spin_unlock(&mid->mid_lock);
320-
add_credits(server, &credits, 0);
321-
return rc;
322-
}
323-
spin_unlock(&mid->mid_lock);
324-
}
325-
326-
rc = cifs_sync_mid_result(mid, server);
327-
if (rc != 0) {
328-
add_credits(server, &credits, 0);
329278
return rc;
330-
}
331-
332-
if (!mid->resp_buf || !out_buf ||
333-
mid->mid_state != MID_RESPONSE_READY) {
334-
rc = -EIO;
335-
cifs_server_dbg(VFS, "Bad MID state?\n");
336-
goto out;
337-
}
338-
339-
*pbytes_returned = mid->response_pdu_len;
340-
memcpy(out_buf, mid->resp_buf, *pbytes_returned);
341-
rc = cifs_check_receive(mid, server, 0);
342-
out:
343-
delete_mid(mid);
344-
add_credits(server, &credits, 0);
345279

280+
*pbytes_returned = resp_iov.iov_len;
281+
if (resp_iov.iov_len)
282+
memcpy(out_buf, resp_iov.iov_base, resp_iov.iov_len);
283+
free_rsp_buf(resp_buf_type, resp_iov.iov_base);
346284
return rc;
347285
}
348286

0 commit comments

Comments
 (0)