From patchwork Mon Oct 24 11:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp431568wru; Mon, 24 Oct 2022 05:44:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tZqy9r7/ZOBtbzdHu+kGCKbOySU8B39YWqYBq/Yf6grRdfCH6QDosWJsFr+fPCAzuIDQI X-Received: by 2002:a62:cec8:0:b0:56c:235:8399 with SMTP id y191-20020a62cec8000000b0056c02358399mr1245189pfg.64.1666615452311; Mon, 24 Oct 2022 05:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615452; cv=none; d=google.com; s=arc-20160816; b=EIRgksLIme5MKO1Z0rA9B+YnWPZE45+ApI/zfOSRmWpKBvQ9ns0uMlYwyfkX9kwAzY UeFwZme8Nxyq7RS/QNbfsCLqThKLFV7J/vehV27CuKAiuGoaVtjksIssPeFzCZTNXtCe fpxoP3avEhMT0PquXjJim3yaf+T5GQySRDf5mtCTyUAUYN0LQS3Z2KaxPXDdGDYp5aXG CxKAwLiXIK3imPWHWmWrL9rdh3HnJ8zeU+WNg7CwaWdg+ho2DXmppab88HXD0n2Hklks Z9zJYT7q3hIWe8Qayu1ySLgNWNasFqolhDUy2lWKRDsV7tTQLFsbVyVoun5h3LTkNS24 vB9g== 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=0IOE9zFUV+etTYE6rCBKsdZGe1Wx0NnXm10By5x9rgg=; b=qjKUx08/AjCRgR1dW4+VSNtWX+p5bzDEItB1tujANJseMQ+8mo+hPGYHCdr10FhwlU Z3lTFHlIxZM1Ca9oS4r6CcfODEBjrrlSlraJ0P3y4SR2YjMArDDhx+0JYhqNhiNl67oa r4fvfZarjSu3EATbjPM/HntZyGJTRcxEV0AKjEO8jfhFmUvZVIj2mrD4+3/1BIzIuBp1 qel8uWdbWda3lchyYlkqXeHkQRTmn7lu8NnmLXVhSIZeOCBDkB2jm2WdbnlaH291XRAO sMu4z02CETVRW1DSnyDTLNESDYOAF971GIhQi+SIHXM8WWrGyey9/1xYJJfjImr0HF7j RheA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ab0K6WPw; 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 v3-20020a632f03000000b004532834e821si35536951pgv.598.2022.10.24.05.43.57; Mon, 24 Oct 2022 05:44:12 -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=Ab0K6WPw; 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 S230367AbiJXMiR (ORCPT + 99 others); Mon, 24 Oct 2022 08:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234431AbiJXMfC (ORCPT ); Mon, 24 Oct 2022 08:35:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EA235DF31; Mon, 24 Oct 2022 05:05:20 -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 20443612D5; Mon, 24 Oct 2022 12:05:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA41C433D6; Mon, 24 Oct 2022 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613103; bh=sD+JhGplpPIp1k8OWFkADJvxtCDejQrhYkusRmjNOOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ab0K6WPwqh9orSjyhPLGF62ot9+RqmqUkHU5quzn6s2VX7YiETv5JxigryfvzZPVr PVxSNEbLaI5+GK/epkAW+F4nZibbclXv3dEuRY7ivHG+/Gf/dViF+0VZ+gjVJ3ANRV tsJwR7xMKfidydaluSare2qhRSLqy+AhLTZESX38= 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.4 010/255] cifs: destage dirty pages before re-reading them for cache=none Date: Mon, 24 Oct 2022 13:28:40 +0200 Message-Id: <20221024113002.788972179@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747572964403827756?= X-GMAIL-MSGID: =?utf-8?q?1747572964403827756?= 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 @@ -3877,6 +3877,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);