From: Ronnie Sahlberg <lsahlber@redhat.com>
To: linux-cifs <linux-cifs@vger.kernel.org>
Cc: Steve French <smfrench@gmail.com>,
Pavel Shilovsky <pshilov@microsoft.com>,
Ronnie Sahlberg <lsahlber@redhat.com>
Subject: [PATCH] cifs: fix credits leak for SMB1 oplock breaks
Date: Tue, 23 Apr 2019 13:27:49 +1000 [thread overview]
Message-ID: <20190423032749.30799-1-lsahlber@redhat.com> (raw)
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/transport.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 5c59c498f56a..3b80884ddf0f 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -971,7 +971,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
const int flags, const int num_rqst, struct smb_rqst *rqst,
int *resp_buf_type, struct kvec *resp_iov)
{
- int i, j, optype, rc = 0;
+ int i, j, optype, opmask, rc = 0;
struct mid_q_entry *midQ[MAX_COMPOUND];
bool cancelled_mid[MAX_COMPOUND] = {false};
struct cifs_credits credits[MAX_COMPOUND] = {
@@ -981,6 +981,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
char *buf;
optype = flags & CIFS_OP_MASK;
+ opmask = flags & (CIFS_ASYNC_OP|CIFS_NO_RESP);
for (i = 0; i < num_rqst; i++)
resp_buf_type[i] = CIFS_NO_BUFFER; /* no response buf yet */
@@ -1073,8 +1074,13 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
mutex_unlock(&ses->server->srv_mutex);
- if (rc < 0) {
- /* Sending failed for some reason - return credits back */
+ /*
+ * If sending failed for some reason or it is an oplock break that we
+ * will not receive a response to - return credits back
+ */
+ if (rc < 0 ||
+ (optype == CIFS_OBREAK_OP &&
+ opmask == (CIFS_ASYNC_OP|CIFS_NO_RESP))) {
for (i = 0; i < num_rqst; i++)
add_credits(ses->server, &credits[i], optype);
goto out;
--
2.13.6
next reply other threads:[~2019-04-23 3:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 3:27 Ronnie Sahlberg [this message]
2019-04-23 18:02 ` [PATCH] cifs: fix credits leak for SMB1 oplock breaks Pavel Shilovsky
2019-04-24 0:45 ` ronnie sahlberg
2019-04-24 19:28 ` Pavel Shilovsky
2019-04-26 3:44 ` ronnie sahlberg
-- strict thread matches above, loose matches on Subject: below --
2019-04-26 0:32 [PATCH 0/1] " Ronnie Sahlberg
2019-04-26 0:32 ` [PATCH] " Ronnie Sahlberg
2019-04-26 16:38 ` Pavel Shilovsky
2019-04-27 8:08 ` ronnie sahlberg
2019-04-29 18:58 ` Pavel Shilovsky
2019-05-01 2:03 Ronnie Sahlberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190423032749.30799-1-lsahlber@redhat.com \
--to=lsahlber@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=pshilov@microsoft.com \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox