Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF1AC433F5 for ; Mon, 29 Nov 2021 18:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354728AbhK2Slw (ORCPT ); Mon, 29 Nov 2021 13:41:52 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:44598 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378760AbhK2Sjs (ORCPT ); Mon, 29 Nov 2021 13:39:48 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 839CDB815E0; Mon, 29 Nov 2021 18:36:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB1A0C53FCD; Mon, 29 Nov 2021 18:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1638210988; bh=zZeN/E2mXfExG/zWli1QcY+iY0lVs1lhvr4ratM40to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uFj/BeSx8D7tn2VBAQJtIvd6VSkd9See9Yu7jw1V1a10dCEZVUT9K8pMMi2Pab1U1 NUIpB2Al9Rw6TZDw92twBfDdKF5HKfvpidxOiozE63lgEPEB+h5zJS9F2HBBqZ+Rwb FD7sM3VX55ZvVWgEaoOUnrbj3Po1PzYUg796dZzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Coddington , Trond Myklebust Subject: [PATCH 5.15 057/179] NFSv42: Fix pagecache invalidation after COPY/CLONE Date: Mon, 29 Nov 2021 19:17:31 +0100 Message-Id: <20211129181720.845479877@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211129181718.913038547@linuxfoundation.org> References: <20211129181718.913038547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Coddington commit 3f015d89a47cd8855cd92f71fff770095bd885a1 upstream. The mechanism in use to allow the client to see the results of COPY/CLONE is to drop those pages from the pagecache. This forces the client to read those pages once more from the server. However, truncate_pagecache_range() zeros out partial pages instead of dropping them. Let us instead use invalidate_inode_pages2_range() with full-page offsets to ensure the client properly sees the results of COPY/CLONE operations. Cc: # v4.7+ Fixes: 2e72448b07dc ("NFS: Add COPY nfs operation") Signed-off-by: Benjamin Coddington Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs42proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -285,7 +285,9 @@ static void nfs42_copy_dest_done(struct loff_t newsize = pos + len; loff_t end = newsize - 1; - truncate_pagecache_range(inode, pos, end); + WARN_ON_ONCE(invalidate_inode_pages2_range(inode->i_mapping, + pos >> PAGE_SHIFT, end >> PAGE_SHIFT)); + spin_lock(&inode->i_lock); if (newsize > i_size_read(inode)) i_size_write(inode, newsize);