Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp206574imj; Thu, 14 Feb 2019 18:41:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IbaoXnqXSY2sGQF3hDMQPk3WDtijk1O+Q6o2cWgYoZJpA48O3/5LsGZpGlCo5e91aLSQfUh X-Received: by 2002:a63:c40a:: with SMTP id h10mr3036294pgd.131.1550198473294; Thu, 14 Feb 2019 18:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198473; cv=none; d=google.com; s=arc-20160816; b=Sf3/8tUFTb6ywyFctgFLildWC5i1euMIId0g5Bkjr+tJq4FrKZbMhfJ5x5Sw3fU7bE z6zuMHlITlRpdYEajkYuyZ0Azuel+4vwFQLWLl7i5R/2K8VScbRNjLKmJ58PfKY1PP7k G0qpmw+Dkn0Uu+df68iBwDHuSwglLkYsLBwmMS880D/Yp7Ojw6MXDAZv1fSHNtPbg9nG fJm6r1NlCFyugZhJWOKgVutQi/fKiKDQ5Ge6slEXVnS0s//g9NeN+nNbHRmYImSzOMRK OD16f1i+uS69ZUai3G7maMGDdu0zQ/inSUWUvx4OtD5WWec9ijGaJUxf4yvhSrmvfoGd DJDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MKr+NZO3SH07ZbtvY9P1j7eGOO+2gHYpjjJSQuzyuBU=; b=xGcPK6E00nfiZot2mHjgx2jFOHTyug1Fue+3lW5Oeo7+pSBqWv7TKAHDDUVKmaxXUd 5cmg3NQFbJPEUj1XJdUpL3n2G5+43wDSt1FJcE1q78dFf292l5aUGE/ZrmsDdjIjRwVW HpGw0HWehNogE7DBGvfwYIBwu0PvdkFC4RBg2QiCo/MHPVKijdaj64ZQyOsYcHcSYF6V EOYQRkDqxM4KohmNiCQ2cj48m9qFcDIHuBI4YF18Q29zOkCYSqDFLgxzdimA9GCpBIcL a+bxOrOfGu6MCEG8zNKQE6/to20AuvfdY35WS1JoLZBpZwVtBS4RJhmTtbT6faGH0xid +elg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LBacrgFs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n59si4284142plb.388.2019.02.14.18.40.57; Thu, 14 Feb 2019 18:41:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LBacrgFs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728582AbfBOCgi (ORCPT + 99 others); Thu, 14 Feb 2019 21:36:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:50998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731925AbfBOCKw (ORCPT ); Thu, 14 Feb 2019 21:10:52 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BF22222D4; Fri, 15 Feb 2019 02:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196651; bh=3Ofq+yH8oR3dBcfiUcgUXePwhupmTumFtJHdVDIGK4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBacrgFskLC4fbHGk7RB3qC5pZLJIuJRnYrYiw9eKa6oFm+/UDfb3o5tbLh7C3iwH cG4TreYin/5QmgcKnYXvEM/Wld9/wV611+8cMDwIeyxYUR2Hejcl/3zJlBKR+zarUn zQ0Ff9Z345lifmG5z/vUSp5x4617mZYZVbdoOJek= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Shilovsky , Steve French , Sasha Levin , linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 65/77] CIFS: Do not assume one credit for async responses Date: Thu, 14 Feb 2019 21:08:43 -0500 Message-Id: <20190215020855.176727-65-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Shilovsky [ Upstream commit 0fd1d37b0501efc6e295f56ab55cdaff784aa50c ] 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 Reviewed-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- 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 d1ae7cdb236d..3c44c51310c4 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2834,9 +2834,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); @@ -3093,7 +3094,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, @@ -3132,6 +3133,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; @@ -3325,7 +3329,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: @@ -3353,6 +3357,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; -- 2.19.1