Skip to content

Commit

Permalink
cifs: Move the in_send statistic to __smb_send_rqst()
Browse files Browse the repository at this point in the history
When send SMB_COM_NT_CANCEL and RFC1002_SESSION_REQUEST, the
in_send statistic was lost.

Let's move the in_send statistic to the send function to avoid
this scenario.

Fixes: 7ee1af7 ("[CIFS]")
Signed-off-by: Zhang Xiaoxu <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
z00467499 authored and Steve French committed Mar 5, 2023
1 parent fe15c26 commit d0dc411
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static int
__smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst)
{
int rc = 0;
int rc;
struct kvec *iov;
int n_vec;
unsigned int send_length = 0;
Expand All @@ -289,6 +289,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct msghdr smb_msg = {};
__be32 rfc1002_marker;

cifs_in_send_inc(server);
if (cifs_rdma_enabled(server)) {
/* return -EAGAIN when connecting or reconnecting */
rc = -EAGAIN;
Expand All @@ -297,14 +298,17 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
goto smbd_done;
}

rc = -EAGAIN;
if (ssocket == NULL)
return -EAGAIN;
goto out;

rc = -ERESTARTSYS;
if (fatal_signal_pending(current)) {
cifs_dbg(FYI, "signal pending before send request\n");
return -ERESTARTSYS;
goto out;
}

rc = 0;
/* cork the socket */
tcp_sock_set_cork(ssocket->sk, true);

Expand Down Expand Up @@ -407,7 +411,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
rc);
else if (rc > 0)
rc = 0;

out:
cifs_in_send_dec(server);
return rc;
}

Expand Down Expand Up @@ -826,9 +831,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
* I/O response may come back and free the mid entry on another thread.
*/
cifs_save_when_sent(mid);
cifs_in_send_inc(server);
rc = smb_send_rqst(server, 1, rqst, flags);
cifs_in_send_dec(server);

if (rc < 0) {
revert_current_mid(server, mid->credits);
Expand Down Expand Up @@ -1144,9 +1147,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
else
midQ[i]->callback = cifs_compound_last_callback;
}
cifs_in_send_inc(server);
rc = smb_send_rqst(server, num_rqst, rqst, flags);
cifs_in_send_dec(server);

for (i = 0; i < num_rqst; i++)
cifs_save_when_sent(midQ[i]);
Expand Down Expand Up @@ -1396,9 +1397,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,

midQ->mid_state = MID_REQUEST_SUBMITTED;

cifs_in_send_inc(server);
rc = smb_send(server, in_buf, len);
cifs_in_send_dec(server);
cifs_save_when_sent(midQ);

if (rc < 0)
Expand Down Expand Up @@ -1539,9 +1538,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
}

midQ->mid_state = MID_REQUEST_SUBMITTED;
cifs_in_send_inc(server);
rc = smb_send(server, in_buf, len);
cifs_in_send_dec(server);
cifs_save_when_sent(midQ);

if (rc < 0)
Expand Down

0 comments on commit d0dc411

Please sign in to comment.