From patchwork Wed Oct 19 08:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp202473wrs; Wed, 19 Oct 2022 01:40:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TEKTDUdglXgPoO+2N66YuNzr3nn081v7f3ZxJQIvFeX37vR2vdzflKEUl4kFA4jvbPGjK X-Received: by 2002:a17:907:980e:b0:78d:b6ea:25b3 with SMTP id ji14-20020a170907980e00b0078db6ea25b3mr5839830ejc.98.1666168845315; Wed, 19 Oct 2022 01:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168845; cv=none; d=google.com; s=arc-20160816; b=r/LC5exLwqBe7gkB8TZ0DCQAO1kPYGd+yY5kpqnXyCq92qS52+eFewyjyoFLWlOa9C YlmZ1CV5JdQLGs/zDf6WIoE6dMrAlSzOhvzoYu4GtzwZ96GXr2ttW75kHUtFyg5Mx3b1 peJQxxTzVBRZ4bo7Kme6y+xjEcuDaG2m9/66IY58kgWZ+UoCQlq5ftYcIlySE+GTHhBu iCZS9Y/C6ZHZ+05Y0Xt5deNS0vzv9HclqYYYYbW2gNUWOorcJUd/I+jYm43AcmBdA2Jn uqp6ioC9BAdLY5kvHs+QlqmDohR3Yj5M+mVhR704/AOqbllAxQ3UMGlTawxil0+j4e0l nzZA== 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=pVqSJnxRug444jNEudr90ybTk+AQG+ZyiDQYDnlRYso=; b=ytgTXGwHT3FJYPYeN3p2tp2Sz8jFMbr3fMpMJ/LtSzRej0R9QeOma0tzhjuD2QBMG7 AzW9QMclbIosNVl43JzgYj4pxPo0iN75sEjnwRrxmTJU5uv4bcz+uSm2u4yR0xV/PLma VXkykl1iNI4aC9tchnqtPRwZbNe7nWrlSBmh0N96m2QEdVVVhm/HBpa5BE3W0qqJTKV9 37sckJa3llxJJ9ndScYSAF0cEf1PYJbmmoRNQq7LYqjccUZ/fsPYCxcrQUZMdPwsEaan 8HcqvKMtupfdxTAiubRcjyRBDDYUvRDmLnCC9kdEBIuxk4YXIFjIFQEs3XF6aN3xXPan akPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lqU0s2n3; 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 l11-20020a056402254b00b0045902845795si15181117edb.557.2022.10.19.01.40.21; Wed, 19 Oct 2022 01:40:45 -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=lqU0s2n3; 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 S230356AbiJSIjr (ORCPT + 99 others); Wed, 19 Oct 2022 04:39:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbiJSIi6 (ORCPT ); Wed, 19 Oct 2022 04:38:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B11937EFC5; Wed, 19 Oct 2022 01:38:33 -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 27581617E3; Wed, 19 Oct 2022 08:38:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19B28C433C1; Wed, 19 Oct 2022 08:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168691; bh=7QQ5BKb8fQQrkexa28bsUpOKY8efYTmV3Cm9V0UzJ9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqU0s2n34r+5tqAjkMfyME7E0w1B6JFnDtS+P7Qpl3IS2JJQWLmXei/5niAOpgy19 Znp/0y82JOcLlBMu8DUXZlv5i0fyM7lqRgB9Ct0FSSV7t54lkjcyOTU1lRtmu/4tap Bo1sOonyJxNcV/qedQyci4i0IpACa2PpOaQxGa/k= 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 6.0 022/862] cifs: destage dirty pages before re-reading them for cache=none Date: Wed, 19 Oct 2022 10:21:49 +0200 Message-Id: <20221019083250.989301100@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104662685781638?= X-GMAIL-MSGID: =?utf-8?q?1747104662685781638?= 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 @@ -4271,6 +4271,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);