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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 BF235C433F5 for ; Fri, 10 Sep 2021 00:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB39260F6B for ; Fri, 10 Sep 2021 00:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231411AbhIJAr6 (ORCPT ); Thu, 9 Sep 2021 20:47:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:44188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbhIJATQ (ORCPT ); Thu, 9 Sep 2021 20:19:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D058610E9; Fri, 10 Sep 2021 00:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631233086; bh=dIhQ6D+q7+4S+hd60dZ6SVU2WEjyBy8A3v6b+a3GppY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n96q72NmOlK1mWN/Bt3x1op4KRnC76kWTkSJ/ZuYLOpdRpGy4a18ekAONtxUQUfRI XCUQniAewxsspxSifA9X9xRg0VruwxM/NCW9tU1Jqqkdx5v2KTPqBJz63SOP6eTc4H 6Kb8FrosC6caZxBxIP7CZhdVfkoxr40qq6JImQQZwkjtQjtjK3NTNNPwSPmWWsrmK+ qEIEgSJkB+2EzS4D0d+dsLf4WDlpV594jz5iehclIgRLshVbT5Nhv+t0ZpTJ71c1pT nmRR846MTMEwX860+ZMJBR81J8LscG4VmxFpPTNPR60yQ66qkvgXN5lGuJRRSRwGy2 yiEosCBQ+PPTw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Weiner , Roman Gushchin , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 92/99] fs: drop_caches: fix skipping over shadow cache inodes Date: Thu, 9 Sep 2021 20:15:51 -0400 Message-Id: <20210910001558.173296-92-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910001558.173296-1-sashal@kernel.org> References: <20210910001558.173296-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Weiner [ Upstream commit 16e2df2a05d46c983bf310b19432c5ca4684b2bc ] When drop_caches truncates the page cache in an inode it also includes any shadow entries for evicted pages. However, there is a preliminary check on whether the inode has pages: if it has *only* shadow entries, it will skip running truncation on the inode and leave it behind. Fix the check to mapping_empty(), such that it runs truncation on any inode that has cache entries at all. Link: https://lkml.kernel.org/r/20210614211904.14420-2-hannes@cmpxchg.org Signed-off-by: Johannes Weiner Reported-by: Roman Gushchin Acked-by: Roman Gushchin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/drop_caches.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index f00fcc4a4f72..e619c31b6bd9 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -3,6 +3,7 @@ * Implement the manual drop-all-pagecache function */ +#include #include #include #include @@ -27,7 +28,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) * we need to reschedule to avoid softlockups. */ if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || - (inode->i_mapping->nrpages == 0 && !need_resched())) { + (mapping_empty(inode->i_mapping) && !need_resched())) { spin_unlock(&inode->i_lock); continue; } -- 2.30.2