Commit 480b1cb9 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: change wait_for_free_request() to take flags as argument

and compute timeout and optyp from it.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
parent f261c4e5
...@@ -538,15 +538,20 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int timeout, ...@@ -538,15 +538,20 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
} }
static int static int
wait_for_free_request(struct TCP_Server_Info *server, const int timeout, wait_for_free_request(struct TCP_Server_Info *server, const int flags,
const int optype, unsigned int *instance) unsigned int *instance)
{ {
int *val; int *val;
int timeout, optype;
timeout = flags & CIFS_TIMEOUT_MASK;
optype = flags & CIFS_OP_MASK;
val = server->ops->get_credits_field(server, optype); val = server->ops->get_credits_field(server, optype);
/* Since an echo is already inflight, no need to wait to send another */ /* Since an echo is already inflight, no need to wait to send another */
if (*val <= 0 && optype == CIFS_ECHO_OP) if (*val <= 0 && optype == CIFS_ECHO_OP)
return -EAGAIN; return -EAGAIN;
return wait_for_free_credits(server, timeout, val, instance); return wait_for_free_credits(server, timeout, val, instance);
} }
...@@ -646,16 +651,16 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, ...@@ -646,16 +651,16 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
mid_handle_t *handle, void *cbdata, const int flags, mid_handle_t *handle, void *cbdata, const int flags,
const struct cifs_credits *exist_credits) const struct cifs_credits *exist_credits)
{ {
int rc, timeout, optype; int rc;
struct mid_q_entry *mid; struct mid_q_entry *mid;
struct cifs_credits credits = { .value = 0, .instance = 0 }; struct cifs_credits credits = { .value = 0, .instance = 0 };
unsigned int instance; unsigned int instance;
int optype;
timeout = flags & CIFS_TIMEOUT_MASK;
optype = flags & CIFS_OP_MASK; optype = flags & CIFS_OP_MASK;
if ((flags & CIFS_HAS_CREDITS) == 0) { if ((flags & CIFS_HAS_CREDITS) == 0) {
rc = wait_for_free_request(server, timeout, optype, &instance); rc = wait_for_free_request(server, flags, &instance);
if (rc) if (rc)
return rc; return rc;
credits.value = 1; credits.value = 1;
...@@ -871,8 +876,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -871,8 +876,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
const int flags, const int num_rqst, struct smb_rqst *rqst, const int flags, const int num_rqst, struct smb_rqst *rqst,
int *resp_buf_type, struct kvec *resp_iov) int *resp_buf_type, struct kvec *resp_iov)
{ {
int i, j, rc = 0; int i, j, optype, rc = 0;
int timeout, optype;
struct mid_q_entry *midQ[MAX_COMPOUND]; struct mid_q_entry *midQ[MAX_COMPOUND];
bool cancelled_mid[MAX_COMPOUND] = {false}; bool cancelled_mid[MAX_COMPOUND] = {false};
struct cifs_credits credits[MAX_COMPOUND] = { struct cifs_credits credits[MAX_COMPOUND] = {
...@@ -882,7 +886,6 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -882,7 +886,6 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
unsigned int first_instance = 0; unsigned int first_instance = 0;
char *buf; char *buf;
timeout = flags & CIFS_TIMEOUT_MASK;
optype = flags & CIFS_OP_MASK; optype = flags & CIFS_OP_MASK;
for (i = 0; i < num_rqst; i++) for (i = 0; i < num_rqst; i++)
...@@ -933,8 +936,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -933,8 +936,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
* Ensure we obtain 1 credit per request in the compound chain. * Ensure we obtain 1 credit per request in the compound chain.
*/ */
for (i = 0; i < num_rqst; i++) { for (i = 0; i < num_rqst; i++) {
rc = wait_for_free_request(ses->server, timeout, optype, rc = wait_for_free_request(ses->server, flags, &instance);
&instance);
if (rc == 0) { if (rc == 0) {
credits[i].value = 1; credits[i].value = 1;
...@@ -1057,7 +1059,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -1057,7 +1059,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
smb311_update_preauth_hash(ses, rqst[0].rq_iov, smb311_update_preauth_hash(ses, rqst[0].rq_iov,
rqst[0].rq_nvec); rqst[0].rq_nvec);
if (timeout == CIFS_ASYNC_OP) if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP)
goto out; goto out;
for (i = 0; i < num_rqst; i++) { for (i = 0; i < num_rqst; i++) {
...@@ -1194,7 +1196,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -1194,7 +1196,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
int int
SendReceive(const unsigned int xid, struct cifs_ses *ses, SendReceive(const unsigned int xid, struct cifs_ses *ses,
struct smb_hdr *in_buf, struct smb_hdr *out_buf, struct smb_hdr *in_buf, struct smb_hdr *out_buf,
int *pbytes_returned, const int timeout) int *pbytes_returned, const int flags)
{ {
int rc = 0; int rc = 0;
struct mid_q_entry *midQ; struct mid_q_entry *midQ;
...@@ -1225,7 +1227,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -1225,7 +1227,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
return -EIO; return -EIO;
} }
rc = wait_for_free_request(ses->server, timeout, 0, &credits.instance); rc = wait_for_free_request(ses->server, flags, &credits.instance);
if (rc) if (rc)
return rc; return rc;
...@@ -1264,7 +1266,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -1264,7 +1266,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
if (rc < 0) if (rc < 0)
goto out; goto out;
if (timeout == CIFS_ASYNC_OP) if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP)
goto out; goto out;
rc = wait_for_response(ses->server, midQ); rc = wait_for_response(ses->server, midQ);
...@@ -1367,8 +1369,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1367,8 +1369,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
return -EIO; return -EIO;
} }
rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, 0, rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance);
&instance);
if (rc) if (rc)
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment