Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp679140pxb; Tue, 5 Apr 2022 18:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWQlfx4TIE3yLcnCj/S+Ke7J3kcu/RRckULIrvFixYlo+hjftAQJV3OhJ6XmGQvvFhmrs5 X-Received: by 2002:a17:907:868a:b0:6e5:e35f:3b99 with SMTP id qa10-20020a170907868a00b006e5e35f3b99mr6222534ejc.33.1649208434176; Tue, 05 Apr 2022 18:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208434; cv=none; d=google.com; s=arc-20160816; b=ZsLdDEPe1MnJ93oZeh/rsAzUmSrppsPlbWmHzbd4aGtZC3CmvPuB2pYcyjVfbE+D5+ dYYdVRhxM4ivMXQ96wy7hyX8FKVT20MzqbTqkslg5vH6HqTVkEUP0QPKVdaHAknZX/2Q fLVudd8MaQ95OeMpA7GKBVybtDioLGqhmYe+vD1mwlsLvOAuVHqaB40SyYBG2Lzwp7AN 55D8HZK3Ag8BOFyavTg4k3OhFK27SIFgwSAKcp8UlR3IJ+Tdr3Cy8Y/Si7suGZyZSCEm TsfdpJ5DZZsPQuR4PZZSLbw1dXZFMOupX0/C9LD7pAjNXAHQC5hUKZMkBNdDo71B8xzQ /GDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kL4nsIK/ahOA2ihCRHA/ppHymcucVsIDO4x/y11Vbqs=; b=nMizz0g13sXZadBBv3BENWwThrzjlG+pv36uFN5IebZbniUnUnO0wnHdEDBJ0qDUq1 wAJbs77l5z4jOvrTruNT++x5jS9yyhM4MtDKyeH8O8jK7AVDrwpltgvqsXyXdqUOY5RE azZ9G66EfkOIf4bDB6sQEVmzyKVOdg49uLE357jkiNjxPzA9kfHfxAaaqEYKHLAse8PM a117LdEj0f5g3fqokHwe39Na2uzOPzHjaWEP78169jlx3b/thj2qDQvWbnWVDT7jZ64R MPAyZCRrozKRfVoUpobNliVxbdWcb8YaX8dy8QALUMADHeNLAan48r3xsi8XsbwMEz25 AF6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SjumYZUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a170906085200b006e7eed45422si5818767ejd.236.2022.04.05.18.26.35; Tue, 05 Apr 2022 18:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SjumYZUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244996AbiDEN12 (ORCPT + 99 others); Tue, 5 Apr 2022 09:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345221AbiDEJWW (ORCPT ); Tue, 5 Apr 2022 05:22:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC90233E32; Tue, 5 Apr 2022 02:09:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 11B0A61577; Tue, 5 Apr 2022 09:09:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20C0BC385A4; Tue, 5 Apr 2022 09:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149782; bh=llqJgTYACegqB44NcpbRqBW8VJNdaMoizTw2wttvUcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SjumYZUDiKEnN2aFFLtqNcxptVvJtCQ/61SW9SQ1BA+EFS4AguGpoFZuiklcNIMyr Ny/yEZDWlPYXRFBrughVPWlL+f+uM+XNCwb6lLmB8sJ4zUpjYOJLaEnsdlIwpbiTDy 8evww/aA+GAg6vUivF3BAkuLav6yzmBb7MkQmxOY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rohith Surabattula , "Paulo Alcantara (SUSE)" , Steve French , Sasha Levin Subject: [PATCH 5.16 0801/1017] Adjust cifssb maximum read size Date: Tue, 5 Apr 2022 09:28:34 +0200 Message-Id: <20220405070418.026433495@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rohith Surabattula [ Upstream commit 06a466565d54a1a42168f9033a062a3f5c40e73b ] When session gets reconnected during mount then read size in super block fs context gets set to zero and after negotiate, rsize is not modified which results in incorrect read with requested bytes as zero. Fixes intermittent failure of xfstest generic/240 Note that stable requires a different version of this patch which will be sent to the stable mailing list. Signed-off-by: Rohith Surabattula Acked-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/cifsfs.c | 3 +++ fs/cifs/file.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 9dd5f89557b7..02b762b7e3fd 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -209,6 +209,9 @@ cifs_read_super(struct super_block *sb) if (rc) goto out_no_root; /* tune readahead according to rsize if readahead size not set on mount */ + if (cifs_sb->ctx->rsize == 0) + cifs_sb->ctx->rsize = + tcon->ses->server->ops->negotiate_rsize(tcon, cifs_sb->ctx); if (cifs_sb->ctx->rasize) sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE; else diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 9fee3af83a73..abadc2f86dea 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3734,6 +3734,11 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, break; } + if (cifs_sb->ctx->rsize == 0) + cifs_sb->ctx->rsize = + server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), + cifs_sb->ctx); + rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize, &rsize, credits); if (rc) @@ -4512,6 +4517,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, break; } + if (cifs_sb->ctx->rsize == 0) + cifs_sb->ctx->rsize = + server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), + cifs_sb->ctx); + rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize, &rsize, credits); if (rc) -- 2.34.1