From patchwork Wed Jan 23 21:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10777887 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 367AD91E for ; Wed, 23 Jan 2019 21:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2619B2D7AB for ; Wed, 23 Jan 2019 21:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A1E02D7B2; Wed, 23 Jan 2019 21:10:59 +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 BB7572D7AB for ; Wed, 23 Jan 2019 21:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbfAWVK6 (ORCPT ); Wed, 23 Jan 2019 16:10:58 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:47044 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfAWVK6 (ORCPT ); Wed, 23 Jan 2019 16:10:58 -0500 Received: by mail-pl1-f193.google.com with SMTP id t13so1762051ply.13 for ; Wed, 23 Jan 2019 13:10:58 -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=diovf7Ox7u4EeWwJKbU6eYkmQyBJoUhmhEOaD60tBVw=; b=lkGdsJDS2ZB/lMNyntE2DLnPZGF2ZQdTVU36G1zBS/ydR1AGR05IVfVGvXe07qgtga F94tqkPODKnt0l8YzOC3mNn1k2gK5MPIVEQqm8rS5Jb4p9UmFkATZmMKwcZIgK8woAu4 PeLbkPIzQWT1LGHJ6Kj9IUSX9+BoMBvCuUraMmrTR6LhQT2Q2tFZIkmQTqszyIMzLDqt QgxltLGp3u33u4IpX5kflkE2rvyzVTmAUSVFNql5/SsdKU3td+tip9lmbzXz35OzrmDu zNjN8iIz4HbyfA88yc4kWa2fWyS1RcYkNSqbog6n1d9DVElbtVLqspSVNSEQl9wum4dt vkiw== 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=diovf7Ox7u4EeWwJKbU6eYkmQyBJoUhmhEOaD60tBVw=; b=oPe3FpViQ1aHHZeZPrwrkoL88gyMCmgQDATHi7R0uXzTMQoUkBBlu4j5aUBJmPTcws RBDx0e5VDjqz4dZMKX6DmJ+myEfQp+LlrCU7z0Noq6Xw5VMVcvkQDSUscmRtya180seI exz3SnanPeSVOGNRnLN7B8KQXzcYzo6nDzOALsLi0AvQC9hszOn2AWQGgFcgmCBl7lE+ Wrd+ej7bkpQbqriLDh/8Lvstn3Mp9iByK4SM0U8MN3Zfdv5dgyDmtAevdCnRcnQRlP3E wSjXOTW48fSS4gc9wC13vlMl/PqPKoC2xNjvEL8IHRgwY58GWZnkn3brox7bH0KQIj0w Ql3Q== X-Gm-Message-State: AJcUuke77vu6diRNWzPE6XeoyDhoDQUmMl61MCbzoQptz9LccfRKw5sv Rf8LKPXVonKHLxv3iamxRKKzz/A= X-Google-Smtp-Source: ALg8bN6k443M4tN2Nmuo+jLmEvCYou8E2fxrdAmuDri8nH6IE0r/fmEjFRKfNggaN8DudGvywOKKDg== X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr3872231plz.110.1548277857270; Wed, 23 Jan 2019 13:10:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jan 2019 13:10:56 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org, Steve French , Ronnie Sahlberg Subject: [PATCH 04/15] CIFS: Fix credit calculations in compound mid callback Date: Wed, 23 Jan 2019 13:10:34 -0800 Message-Id: <1548277845-6746-5-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 The current code doesn't do proper accounting for credits in SMB1 case: it adds one credit per response only if we get a complete response while it needs to return it unconditionally. Fix this and also include malformed responses for SMB2+ into accounting for credits because such responses have Credit Granted field, thus nothing prevents to get a proper credit value from them. Signed-off-by: Pavel Shilovsky --- fs/cifs/smb2ops.c | 6 +++++- fs/cifs/transport.c | 11 +---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 24a19f2..73eb0e5 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -151,7 +151,11 @@ smb2_get_credits(struct mid_q_entry *mid) { struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf; - return le16_to_cpu(shdr->CreditRequest); + if (mid->mid_state == MID_RESPONSE_RECEIVED + || mid->mid_state == MID_RESPONSE_MALFORMED) + return le16_to_cpu(shdr->CreditRequest); + + return 0; } static int diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 202e0e8..53532bd 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -786,17 +786,8 @@ static void cifs_compound_callback(struct mid_q_entry *mid) { struct TCP_Server_Info *server = mid->server; - unsigned int optype = mid->optype; - unsigned int credits_received = 0; - if (mid->mid_state == MID_RESPONSE_RECEIVED) { - if (mid->resp_buf) - credits_received = server->ops->get_credits(mid); - else - cifs_dbg(FYI, "Bad state for cancelled MID\n"); - } - - add_credits(server, credits_received, optype); + add_credits(server, server->ops->get_credits(mid), mid->optype); } static void