From patchwork Thu Sep 2 21:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12472761 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 34F65C4167D for ; Thu, 2 Sep 2021 21:53:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E20F661158 for ; Thu, 2 Sep 2021 21:53:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E20F661158 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 852E36B00A6; Thu, 2 Sep 2021 17:53:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 803FE6B00A7; Thu, 2 Sep 2021 17:53:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CC238D0001; Thu, 2 Sep 2021 17:53:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 590C16B00A6 for ; Thu, 2 Sep 2021 17:53:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 17AF980EAD42 for ; Thu, 2 Sep 2021 21:53:23 +0000 (UTC) X-FDA: 78543985086.16.A782D9B Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf29.hostedemail.com (Postfix) with ESMTP id CD8FB9000094 for ; Thu, 2 Sep 2021 21:53:22 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id F025661166; Thu, 2 Sep 2021 21:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1630619602; bh=HaIFv9pD4Bs/Rvsd5bh17DZqs2PR1T9rPtVXHZyVkHY=; h=Date:From:To:Subject:In-Reply-To:From; b=WvezcGqAy7b5+7DN+IHO3DCdZcrOEyiBn+YZqOlPSsHNCVP+XWqmU1ySUAtEtccrK +N0i4bMnLM2kf4ZWhtPaISPnuC/h/Q2uqrvVkOVZ6yq/Pviaqd4d4hUOM2uVkgASET Hahlidxh9WNznVNybeOFLUjseJur1uAkQ1fxvwD0= Date: Thu, 02 Sep 2021 14:53:21 -0700 From: Andrew Morton To: akpm@linux-foundation.org, guro@fb.com, hannes@cmpxchg.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 064/212] fs: drop_caches: fix skipping over shadow cache inodes Message-ID: <20210902215321.8weaTZ9iQ%akpm@linux-foundation.org> In-Reply-To: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=WvezcGqA; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CD8FB9000094 X-Stat-Signature: x6soj3j6muak9sbjecue7f7qut4xn1q1 X-HE-Tag: 1630619602-926881 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Johannes Weiner Subject: fs: drop_caches: fix skipping over shadow cache inodes 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 --- fs/drop_caches.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/drop_caches.c~fs-drop_caches-fix-skipping-over-shadow-cache-inodes +++ a/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 sup * 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; }