From patchwork Wed Jan 23 21:10:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10777883 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 D55626C2 for ; Wed, 23 Jan 2019 21:10:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5C1B2D7AB for ; Wed, 23 Jan 2019 21:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9DF22D8CC; Wed, 23 Jan 2019 21:10:56 +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 5D0952D7B2 for ; Wed, 23 Jan 2019 21:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbfAWVK4 (ORCPT ); Wed, 23 Jan 2019 16:10:56 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33653 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfAWVK4 (ORCPT ); Wed, 23 Jan 2019 16:10:56 -0500 Received: by mail-pf1-f193.google.com with SMTP id c123so1816315pfb.0 for ; Wed, 23 Jan 2019 13:10:55 -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=Xf+lP4X1WRt5+a5buBSCL3YphbH+csIt93ifvupqEJo=; b=kMKJcJRaz9N1J4rz9jHa9u/uORM3QALPv6Ky7dGyPmbtWNkxvwbzWUZi/xTuvWUnox 6LMIorEKIIKkrLun87qLPR3tSCX2GIXwt89Fszs38FdVYOAGV9BLdi1uow+lZAq/oCmx N+GWyZZKZ4VRgLkUxYcL36r6QJSI2SoV6LrnfAiW3xi/TxwuzTSS7HyJni5erCrwlMKF ou46bhVySD1Z9EBu40DkHqFBNkd03ykzEMDT5F2yuDpbtZAKHv8WJhl/K1JZcRyDAc91 +/tV/JSxtxNAi2b3xDitjMnYFBpn1wYdwsiE5B0Xt8vSiSYC/x83S2UsC3rTt2CrwD2l tdpA== 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=Xf+lP4X1WRt5+a5buBSCL3YphbH+csIt93ifvupqEJo=; b=GiIx0/q9upff06xRf+j6bz4FRHxOR4XUN7j80mNXmRZze7Y/3ex7LAdx4mWUz8uoih O6o6zo7XtNDau1uvyTsqeVGTuFPfhmkeyK9XGDonW/NB2HIgB83VZksHrETGXlnhcttK 30YrVpGcgGjGNVkJ5ITbjbYHiYl6Hhg/KrTRJrHZz73wFAVUURDIJJjKk79vhHvTWCUo ZoPrqYYQT+TCc+zeSwa+RuLQ488vE9x0i62n05O30cijat/PgdGaEzGIUMDMelS4JNdA PewzPNVj2ZddDeBe7rDPyxkeWOo/iuBqMueNpDnN0lvptay0rof4Fh1FAq3JVI0JvljT qmTg== X-Gm-Message-State: AJcUukfrfV2qHjcmkq0+xheCTmmPRep5jDjNd8p//QFD5FIX4imWHmIt 73rDT6ECHu2Hbo5JTStFLgIlGm4= X-Google-Smtp-Source: ALg8bN4Y2qUagomk8o0mVROrBYITTUMX6Rtz79GzHH6JSzH4GNvo/tvgADgieX/tjVOTVB9cVLL6aQ== X-Received: by 2002:a63:451a:: with SMTP id s26mr3540749pga.150.1548277854653; Wed, 23 Jan 2019 13:10:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jan 2019 13:10:53 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org, Steve French , Ronnie Sahlberg Subject: [PATCH 02/15] CIFS: Fix credits calculations for reads with errors Date: Wed, 23 Jan 2019 13:10:32 -0800 Message-Id: <1548277845-6746-3-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 Currently we mark MID as malformed if we get an error from server in a read response. This leads to not properly processing credits in the readv callback. Fix this by marking such a response as normal received response and process it appropriately. Cc: Signed-off-by: Pavel Shilovsky --- fs/cifs/cifssmb.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 6930cdb..920c9f5 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1540,18 +1540,26 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) } static int -cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid) +__cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid, + bool malformed) { int length; - struct cifs_readdata *rdata = mid->callback_data; length = cifs_discard_remaining_data(server); - dequeue_mid(mid, rdata->result); + dequeue_mid(mid, malformed); mid->resp_buf = server->smallbuf; server->smallbuf = NULL; return length; } +static int +cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid) +{ + struct cifs_readdata *rdata = mid->callback_data; + + return __cifs_readv_discard(server, mid, rdata->result); +} + int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) { @@ -1593,12 +1601,23 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) return -1; } + /* set up first two iov for signature check and to get credits */ + rdata->iov[0].iov_base = buf; + rdata->iov[0].iov_len = 4; + rdata->iov[1].iov_base = buf + 4; + rdata->iov[1].iov_len = server->total_read - 4; + cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n", + rdata->iov[0].iov_base, rdata->iov[0].iov_len); + cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n", + rdata->iov[1].iov_base, rdata->iov[1].iov_len); + /* Was the SMB read successful? */ rdata->result = server->ops->map_error(buf, false); if (rdata->result != 0) { cifs_dbg(FYI, "%s: server returned error %d\n", __func__, rdata->result); - return cifs_readv_discard(server, mid); + /* normal error on read response */ + return __cifs_readv_discard(server, mid, false); } /* Is there enough to get to the rest of the READ_RSP header? */ @@ -1642,14 +1661,6 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) server->total_read += length; } - /* set up first iov for signature check */ - rdata->iov[0].iov_base = buf; - rdata->iov[0].iov_len = 4; - rdata->iov[1].iov_base = buf + 4; - rdata->iov[1].iov_len = server->total_read - 4; - cifs_dbg(FYI, "0: iov_base=%p iov_len=%u\n", - rdata->iov[0].iov_base, server->total_read); - /* how much data is in the response? */ #ifdef CONFIG_CIFS_SMB_DIRECT use_rdma_mr = rdata->mr;