diff options
Diffstat (limited to 'fs/cifs/transport.c')
-rw-r--r-- | fs/cifs/transport.c | 120 |
1 files changed, 64 insertions, 56 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 5d6d44bfe10a..308ad0f495e1 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -118,7 +118,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry) #ifdef CONFIG_CIFS_STATS2 now = jiffies; if (now < midEntry->when_alloc) - cifs_dbg(VFS, "invalid mid allocation time\n"); + cifs_server_dbg(VFS, "invalid mid allocation time\n"); roundtrip_time = now - midEntry->when_alloc; if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) { @@ -232,7 +232,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, retries++; if (retries >= 14 || (!server->noblocksnd && (retries > 2))) { - cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n", + cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n", ssocket); return -EAGAIN; } @@ -246,7 +246,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, if (rc == 0) { /* should never happen, letting socket clear before retrying is our only obvious option here */ - cifs_dbg(VFS, "tcp sent no data\n"); + cifs_server_dbg(VFS, "tcp sent no data\n"); msleep(500); continue; } @@ -440,7 +440,7 @@ unmask: } smbd_done: if (rc < 0 && rc != -EINTR) - cifs_dbg(VFS, "Error %d sending data on socket to server\n", + cifs_server_dbg(VFS, "Error %d sending data on socket to server\n", rc); else if (rc > 0) rc = 0; @@ -473,8 +473,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, cur_rqst[0].rq_nvec = 1; if (!server->ops->init_transform_rq) { - cifs_dbg(VFS, "Encryption requested but transform callback " - "is missing\n"); + cifs_server_dbg(VFS, "Encryption requested but transform " + "callback is missing\n"); return -EIO; } @@ -532,6 +532,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, if ((flags & CIFS_TIMEOUT_MASK) == CIFS_NON_BLOCKING) { /* oplock breaks must not be held up */ server->in_flight++; + if (server->in_flight > server->max_in_flight) + server->max_in_flight = server->in_flight; *credits -= 1; *instance = server->reconnect_instance; spin_unlock(&server->req_lock); @@ -548,7 +550,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, if (!rc) { trace_smb3_credit_timeout(server->CurrentMid, server->hostname, num_credits); - cifs_dbg(VFS, "wait timed out after %d ms\n", + cifs_server_dbg(VFS, "wait timed out after %d ms\n", timeout); return -ENOTSUPP; } @@ -589,7 +591,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, trace_smb3_credit_timeout( server->CurrentMid, server->hostname, num_credits); - cifs_dbg(VFS, "wait timed out after %d ms\n", + cifs_server_dbg(VFS, "wait timed out after %d ms\n", timeout); return -ENOTSUPP; } @@ -608,6 +610,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) { *credits -= num_credits; server->in_flight += num_credits; + if (server->in_flight > server->max_in_flight) + server->max_in_flight = server->in_flight; *instance = server->reconnect_instance; } spin_unlock(&server->req_lock); @@ -869,7 +873,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) break; default: list_del_init(&mid->qhead); - cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", + cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", __func__, mid->mid, mid->mid_state); rc = -EIO; } @@ -910,7 +914,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, rc = cifs_verify_signature(&rqst, server, mid->sequence_number); if (rc) - cifs_dbg(VFS, "SMB signature verification returned error = %d\n", + cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", rc); } @@ -1107,7 +1111,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, } if (rc != 0) { for (; i < num_rqst; i++) { - cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", + cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", midQ[i]->mid, le16_to_cpu(midQ[i]->command)); send_cancel(server, &rqst[i], midQ[i]); spin_lock(&GlobalMid_Lock); @@ -1242,17 +1246,19 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, struct kvec iov = { .iov_base = in_buf, .iov_len = len }; struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; struct cifs_credits credits = { .value = 1, .instance = 0 }; + struct TCP_Server_Info *server; if (ses == NULL) { cifs_dbg(VFS, "Null smb session\n"); return -EIO; } - if (ses->server == NULL) { + server = ses->server; + if (server == NULL) { cifs_dbg(VFS, "Null tcp session\n"); return -EIO; } - if (ses->server->tcpStatus == CifsExiting) + if (server->tcpStatus == CifsExiting) return -ENOENT; /* Ensure that we do not send more than 50 overlapping requests @@ -1260,12 +1266,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, use ses->maxReq */ if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { - cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", + cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", len); return -EIO; } - rc = wait_for_free_request(ses->server, flags, &credits.instance); + rc = wait_for_free_request(server, flags, &credits.instance); if (rc) return rc; @@ -1273,70 +1279,70 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, and avoid races inside tcp sendmsg code that could cause corruption of smb data */ - mutex_lock(&ses->server->srv_mutex); + mutex_lock(&server->srv_mutex); rc = allocate_mid(ses, in_buf, &midQ); if (rc) { mutex_unlock(&ses->server->srv_mutex); /* Update # of requests on wire to server */ - add_credits(ses->server, &credits, 0); + add_credits(server, &credits, 0); return rc; } - rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); + rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number); if (rc) { - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); goto out; } midQ->mid_state = MID_REQUEST_SUBMITTED; - cifs_in_send_inc(ses->server); - rc = smb_send(ses->server, in_buf, len); - cifs_in_send_dec(ses->server); + 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) - ses->server->sequence_number -= 2; + server->sequence_number -= 2; - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); if (rc < 0) goto out; - rc = wait_for_response(ses->server, midQ); + rc = wait_for_response(server, midQ); if (rc != 0) { - send_cancel(ses->server, &rqst, midQ); + send_cancel(server, &rqst, midQ); spin_lock(&GlobalMid_Lock); if (midQ->mid_state == MID_REQUEST_SUBMITTED) { /* no longer considered to be "in-flight" */ midQ->callback = DeleteMidQEntry; spin_unlock(&GlobalMid_Lock); - add_credits(ses->server, &credits, 0); + add_credits(server, &credits, 0); return rc; } spin_unlock(&GlobalMid_Lock); } - rc = cifs_sync_mid_result(midQ, ses->server); + rc = cifs_sync_mid_result(midQ, server); if (rc != 0) { - add_credits(ses->server, &credits, 0); + add_credits(server, &credits, 0); return rc; } if (!midQ->resp_buf || !out_buf || midQ->mid_state != MID_RESPONSE_RECEIVED) { rc = -EIO; - cifs_dbg(VFS, "Bad MID state?\n"); + cifs_server_dbg(VFS, "Bad MID state?\n"); goto out; } *pbytes_returned = get_rfc1002_length(midQ->resp_buf); memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); - rc = cifs_check_receive(midQ, ses->server, 0); + rc = cifs_check_receive(midQ, server, 0); out: cifs_delete_mid(midQ); - add_credits(ses->server, &credits, 0); + add_credits(server, &credits, 0); return rc; } @@ -1379,19 +1385,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, struct kvec iov = { .iov_base = in_buf, .iov_len = len }; struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; unsigned int instance; + struct TCP_Server_Info *server; if (tcon == NULL || tcon->ses == NULL) { cifs_dbg(VFS, "Null smb session\n"); return -EIO; } ses = tcon->ses; + server = ses->server; - if (ses->server == NULL) { + if (server == NULL) { cifs_dbg(VFS, "Null tcp session\n"); return -EIO; } - if (ses->server->tcpStatus == CifsExiting) + if (server->tcpStatus == CifsExiting) return -ENOENT; /* Ensure that we do not send more than 50 overlapping requests @@ -1399,12 +1407,12 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, use ses->maxReq */ if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { - cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", + cifs_tcon_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", len); return -EIO; } - rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance); + rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance); if (rc) return rc; @@ -1412,31 +1420,31 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, and avoid races inside tcp sendmsg code that could cause corruption of smb data */ - mutex_lock(&ses->server->srv_mutex); + mutex_lock(&server->srv_mutex); rc = allocate_mid(ses, in_buf, &midQ); if (rc) { - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); return rc; } - rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); + rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number); if (rc) { cifs_delete_mid(midQ); - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); return rc; } midQ->mid_state = MID_REQUEST_SUBMITTED; - cifs_in_send_inc(ses->server); - rc = smb_send(ses->server, in_buf, len); - cifs_in_send_dec(ses->server); + 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) - ses->server->sequence_number -= 2; + server->sequence_number -= 2; - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); if (rc < 0) { cifs_delete_mid(midQ); @@ -1444,21 +1452,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, } /* Wait for a reply - allow signals to interrupt. */ - rc = wait_event_interruptible(ses->server->response_q, + rc = wait_event_interruptible(server->response_q, (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) || - ((ses->server->tcpStatus != CifsGood) && - (ses->server->tcpStatus != CifsNew))); + ((server->tcpStatus != CifsGood) && + (server->tcpStatus != CifsNew))); /* Were we interrupted by a signal ? */ if ((rc == -ERESTARTSYS) && (midQ->mid_state == MID_REQUEST_SUBMITTED) && - ((ses->server->tcpStatus == CifsGood) || - (ses->server->tcpStatus == CifsNew))) { + ((server->tcpStatus == CifsGood) || + (server->tcpStatus == CifsNew))) { if (in_buf->Command == SMB_COM_TRANSACTION2) { /* POSIX lock. We send a NT_CANCEL SMB to cause the blocking lock to return. */ - rc = send_cancel(ses->server, &rqst, midQ); + rc = send_cancel(server, &rqst, midQ); if (rc) { cifs_delete_mid(midQ); return rc; @@ -1477,9 +1485,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, } } - rc = wait_for_response(ses->server, midQ); + rc = wait_for_response(server, midQ); if (rc) { - send_cancel(ses->server, &rqst, midQ); + send_cancel(server, &rqst, midQ); spin_lock(&GlobalMid_Lock); if (midQ->mid_state == MID_REQUEST_SUBMITTED) { /* no longer considered to be "in-flight" */ @@ -1494,20 +1502,20 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, rstart = 1; } - rc = cifs_sync_mid_result(midQ, ses->server); + rc = cifs_sync_mid_result(midQ, server); if (rc != 0) return rc; /* rcvd frame is ok */ if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) { rc = -EIO; - cifs_dbg(VFS, "Bad MID state?\n"); + cifs_tcon_dbg(VFS, "Bad MID state?\n"); goto out; } *pbytes_returned = get_rfc1002_length(midQ->resp_buf); memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); - rc = cifs_check_receive(midQ, ses->server, 0); + rc = cifs_check_receive(midQ, server, 0); out: cifs_delete_mid(midQ); if (rstart && rc == -EACCES) |