From patchwork Sat Oct 22 07:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7137 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087359wrr; Sat, 22 Oct 2022 00:36:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TvQIcKSB1XkrRFY8N2S4Ta0APuC4+oIwAawqUjuWG7Pc+EWYQUt5O/joqMOuD3BanJXDo X-Received: by 2002:a50:9519:0:b0:45f:ca89:cf9a with SMTP id u25-20020a509519000000b0045fca89cf9amr12773893eda.248.1666424166772; Sat, 22 Oct 2022 00:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424166; cv=none; d=google.com; s=arc-20160816; b=lSBOBpcG3Z5HXjvvIqoRbl4Zg5v9VYWCZ6b/htNPNvT4llW3cKaCaIw4OC/Sw2Rcni N3qgi6G4VbFRaYK0CHL7e13+J2LrwEAuvFNTWwbDonh1J+tjSyoaDlf+bh06wCxCgSgk oGUQ8CCsb5HE2aeTVL8shwviGjKMI7lj72sJdtd3i9sGneysOOKEQKzxH03idW5foCz8 GV9hSTa6AgX+c166FG3+hnvdE/6i3lfg/5RnTZ/5zMFuYKPrG9TQUs4+9P9qKBonm0c2 O87rnqa99MIvuy1rq5OOsJq99T8HqNoh44HilRj/F9/BbXn1S1Ui5+3omWXNea2sHV5A GMRQ== 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=YSZ4hcP452Veo+hrwyJREgE2Xyk3t5GdTFBsh2ngQN8=; b=UEGp8sRwDnbMrNJAT8frdFppuuRgU+TYxGCeeTOVza8CrJJVSeY/RJobSNzkavz8O2 d0b9upaRxUE29D1m0XajYhIGgGzYbMeiAmyQc2cRs7YZR2Jo+ZPEpolpY0gUZe2Oo4kJ Mwesr7lqzjsexnCulnU438iGu6/M16pZ9ikRAZLqxptwJWupZQMZz3U0zvkVgEr5158R tBJb3XvPrbVONHLUoHFugoUVJiCb8e+IEM0vjsjcPDgHxGpuu1CS/WOQT8EM46aAqHrG yDB+Viwt4cJWeDeGkjEaU+UxxDj9sNc2NnC3EGsxMc0NS45keOo+Gt6Vic6Ol1HMMG/+ +Nyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wn8jEu89; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz18-20020a17090775f200b0078d00203ab4si17186257ejc.691.2022.10.22.00.35.42; Sat, 22 Oct 2022 00:36:06 -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=Wn8jEu89; 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 S230241AbiJVHex (ORCPT + 99 others); Sat, 22 Oct 2022 03:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbiJVHed (ORCPT ); Sat, 22 Oct 2022 03:34:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7E926561; Sat, 22 Oct 2022 00:34:26 -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 8752860A5C; Sat, 22 Oct 2022 07:34:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ABB4C433C1; Sat, 22 Oct 2022 07:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424065; bh=CObaSo7Y/jwaBtljqRsg6xczal4y423u8EiZaZKe4sY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wn8jEu899xwfYwJcqc0YNOlvXbwdJfkFyiJfi5mnzUEF3gjXfvnUrvfUCOOQ4dtqO eFzONSrUkALiYxd1BlglBLHcCE0ygI4HLDGhaKQ/3+vvqgGl6Zx5e3bqhrwgJ5G9uv zbugEYXlHLLJlcYqMbqwRN8GaM4SWeqcywN0B4C0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paulo Alcantara (SUSE)" , Enzo Matsumiya , Ronnie Sahlberg , Steve French Subject: [PATCH 5.19 017/717] cifs: destage dirty pages before re-reading them for cache=none Date: Sat, 22 Oct 2022 09:18:16 +0200 Message-Id: <20221022072418.117632497@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372386991221948?= X-GMAIL-MSGID: =?utf-8?q?1747372386991221948?= From: Ronnie Sahlberg commit bb44c31cdcac107344dd2fcc3bd0504a53575c51 upstream. This is the opposite case of kernel bugzilla 216301. If we mmap a file using cache=none and then proceed to update the mmapped area these updates are not reflected in a later pread() of that part of the file. To fix this we must first destage any dirty pages in the range before we allow the pread() to proceed. Cc: stable@vger.kernel.org Reviewed-by: Paulo Alcantara (SUSE) Reviewed-by: Enzo Matsumiya Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -4024,6 +4024,15 @@ static ssize_t __cifs_readv( len = ctx->len; } + if (direct) { + rc = filemap_write_and_wait_range(file->f_inode->i_mapping, + offset, offset + len - 1); + if (rc) { + kref_put(&ctx->refcount, cifs_aio_ctx_release); + return -EAGAIN; + } + } + /* grab a lock here due to read response handlers can access ctx */ mutex_lock(&ctx->aio_mutex);