From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CEA2C2BA83 for ; Fri, 14 Feb 2020 17:25:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1713E2082F for ; Fri, 14 Feb 2020 17:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581701157; bh=nV2rG360gPkk6R2U9iXdSMSM4aIx3EOLH+KRbqeh7XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OVmfbC+mNBnPeKqyKEiox7h3SOmOTx0CqBjquczxuDCPMLeV2lfgKnPPpxv8dBxO8 ELCYyriddQzLmYj//eAyG2hBIQKaT29pf9Gj0PDjfKhp4LWqBZUqXOdx6U/mTWnN0R QyLvrUCLNLBZ8NyE9kq89sShT84EO02JLGLjzbc0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391738AbgBNRZ4 (ORCPT ); Fri, 14 Feb 2020 12:25:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:60754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391020AbgBNQIk (ORCPT ); Fri, 14 Feb 2020 11:08:40 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F28EA2467E; Fri, 14 Feb 2020 16:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581696519; bh=nV2rG360gPkk6R2U9iXdSMSM4aIx3EOLH+KRbqeh7XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ULIjdQ1xi5K0PjogMcoqK5peCcxxcxsdrjZTnu2smpKxXspoAhzGf6oqc+XLlOWs7 sXYBsAMGaZqkS7equucEporgkI1Cw/OjZKJI04MnhWEsDmYu6m9tZm9kfhfotL1cHl A7yY9qem19Ht3+vreJT4cQnyxyHwQhbu2gMvqzMM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Trond Myklebust , Trond Myklebust , Anna Schumaker , Sasha Levin , linux-nfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 320/459] NFS: Revalidate the file size on a fatal write error Date: Fri, 14 Feb 2020 10:59:30 -0500 Message-Id: <20200214160149.11681-320-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214160149.11681-1-sashal@kernel.org> References: <20200214160149.11681-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 0df68ced55443243951d02cc497be31fadf28173 ] If we suffer a fatal error upon writing a file, which causes us to need to revalidate the entire mapping, then we should also revalidate the file size. Fixes: d2ceb7e57086 ("NFS: Don't use page_file_mapping after removing the page") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/write.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 52cab65f91cf0..f5170bc839aa2 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -243,7 +243,15 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c /* A writeback failed: mark the page as bad, and invalidate the page cache */ static void nfs_set_pageerror(struct address_space *mapping) { + struct inode *inode = mapping->host; + nfs_zap_mapping(mapping->host, mapping); + /* Force file size revalidation */ + spin_lock(&inode->i_lock); + NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED | + NFS_INO_REVAL_PAGECACHE | + NFS_INO_INVALID_SIZE; + spin_unlock(&inode->i_lock); } static void nfs_mapping_set_error(struct page *page, int error) -- 2.20.1