From patchwork Wed Jan 23 21:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10777889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2EA891E for ; Wed, 23 Jan 2019 21:11:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C25B82D7AB for ; Wed, 23 Jan 2019 21:11:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B69FB2D7B2; Wed, 23 Jan 2019 21:11:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F8402D7AB for ; Wed, 23 Jan 2019 21:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbfAWVLA (ORCPT ); Wed, 23 Jan 2019 16:11:00 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36822 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfAWVK7 (ORCPT ); Wed, 23 Jan 2019 16:10:59 -0500 Received: by mail-pl1-f196.google.com with SMTP id g9so1785339plo.3 for ; Wed, 23 Jan 2019 13:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=KWS+t4qBEih1RfDvytHOz/Tx1COye69eCvLN8HOsnPY=; b=RB38AQzkOOJskl3b4S5gbIr2UmCzP5342WxGExh03Vm/lICNEgQhzO/3eFqABXJSkm BMZFFaXSqina9vXXjfjAg/1Oud+Lias9Dmm6WyHTBa87MrLJ6CypwfwHf145iR7KEQ4V o9T2yBThOxAzEvKcHPs+EjwcHmdOfyb1psfiSotYI6Asj/vNlA6aB+erCBDDhag2OToJ fcIjLhT7i7QFcMYLyizU0v9I/U0olYl5jrlcpzWa7xorObs7XWqC+/N2WkH8/AmseF6O ccb5X1aHJ9FG0MAD0v1EaHCmq49qfH0LQyVHU+DjH3CFOmweQt5tK64OI/gF/gN+L5kC uroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=KWS+t4qBEih1RfDvytHOz/Tx1COye69eCvLN8HOsnPY=; b=narJ/4yzOAALvCXxFcUNI3zWzdMd+8P4RhL6eZvRhpKPUxmxTbL5tCwjjgXt/xacCX gL4qk6leZgaHSEZ5gAQAbt/e3QTartAbMTPmY121wJ9eNRbMzmspYmKj/zDS2Ch/1uxf RobNfHr/c9EKLbs6aXnlPOBcyut0UsF/6m3+BnoF4Hvju+m/jwsd/HqqrsKBre8td0f8 wusdCw/di8o6NhHr/GKM6+f/Kn5ugo03Y+5gSbf/k+/cDZSrW25zBEhfa3b50Ia/mZt2 ThxdJAQHfn0OdJNoMM9dnZlunA3JU45OpJBZwqoRZ4j0aRVZJdXsuVyOEqfQGIWnreqT t2DQ== X-Gm-Message-State: AJcUukcn5IRVUg40pRCJEAJEss3k2FVCc3DEUZU7xLAaigoi1l2gvCfP 6scwwvba822AnfWM2BoE+NKBNKk= X-Google-Smtp-Source: ALg8bN5K3zPP/szxhClSkgI/3hlu2K2Jkgjg16vucms5wPxA/I+pOCP2QY9fp6jG7bm1mKHlQOZ5qw== X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11mr3943568plb.332.1548277858533; Wed, 23 Jan 2019 13:10:58 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:f:a17f:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id n73sm28063714pfj.148.2019.01.23.13.10.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jan 2019 13:10:57 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org, Steve French , Ronnie Sahlberg Subject: [PATCH 05/15] CIFS: Do not assume one credit for async responses Date: Wed, 23 Jan 2019 13:10:35 -0800 Message-Id: <1548277845-6746-6-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548277845-6746-1-git-send-email-pshilov@microsoft.com> References: <1548277845-6746-1-git-send-email-pshilov@microsoft.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we don't receive a response we can't assume that the server granted one credit. Assume zero credits in such cases. Signed-off-by: Pavel Shilovsky --- fs/cifs/smb2pdu.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index f158825..9bd7f3d 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2893,9 +2893,10 @@ smb2_echo_callback(struct mid_q_entry *mid) { struct TCP_Server_Info *server = mid->callback_data; struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf; - unsigned int credits_received = 1; + unsigned int credits_received = 0; - if (mid->mid_state == MID_RESPONSE_RECEIVED) + if (mid->mid_state == MID_RESPONSE_RECEIVED + || mid->mid_state == MID_RESPONSE_MALFORMED) credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); DeleteMidQEntry(mid); @@ -3152,7 +3153,7 @@ smb2_readv_callback(struct mid_q_entry *mid) struct TCP_Server_Info *server = tcon->ses->server; struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)rdata->iov[0].iov_base; - unsigned int credits_received = 1; + unsigned int credits_received = 0; struct smb_rqst rqst = { .rq_iov = rdata->iov, .rq_nvec = 2, .rq_pages = rdata->pages, @@ -3191,6 +3192,9 @@ smb2_readv_callback(struct mid_q_entry *mid) task_io_account_read(rdata->got_bytes); cifs_stats_bytes_read(tcon, rdata->got_bytes); break; + case MID_RESPONSE_MALFORMED: + credits_received = le16_to_cpu(shdr->CreditRequest); + /* fall through */ default: if (rdata->result != -ENODATA) rdata->result = -EIO; @@ -3376,7 +3380,7 @@ smb2_writev_callback(struct mid_q_entry *mid) struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); unsigned int written; struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf; - unsigned int credits_received = 1; + unsigned int credits_received = 0; switch (mid->mid_state) { case MID_RESPONSE_RECEIVED: @@ -3404,6 +3408,9 @@ smb2_writev_callback(struct mid_q_entry *mid) case MID_RETRY_NEEDED: wdata->result = -EAGAIN; break; + case MID_RESPONSE_MALFORMED: + credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); + /* fall through */ default: wdata->result = -EIO; break;