Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794065227; b=xkO7njImjwdpW8zZ59qoSasPB3o4n3vyRV0o9J81TK+mKUWuwHbJD9K4Xy+PRmiA9OvP kZL2tLX7yqj4fi6EAw18K7Bhhmy5jO4szsEshAHJo9JInh1KeXb/UZWxx6wFLMAKZ3ObL dKaWSVBZSQPX2AaO/yuJAg16P6y35J7OXen1KuXNug1JKP4mY1/iKMZOXZzQPyx4O8dIM KUUY/emGvkJ2AfdUkLIWDsOhrBTLDb2vFxFKTVjCL9FbMbdz+0rMS+UjACZbdtiOP8MLl iyiWxFMKwderPVH9ut8Ce2m3kMHKVaJuQaf3YwOG33H01dfJKLbvZ1WMu8RUqnoyRsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794065227; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=G7Xhj4+uY/Mnnhc7a98Jvrh79RCpMNAlFHijoY8iM2o=; b=Pje+OpI7ywPrEDcfNvZxAN8UiVIEGXUbrM7XCzNpJM+lbkhSYrGAu6Pw+/uP5HWS0qX0 Btb0NgAhWV+zYgPRePWTQfN75NlApB3G5EqPqGqSg9+a1rIoJRJxEpc78k4k9uz4RxDDN mbKIZrMTcGCTdiHEgAUlg6mAY92Fdu25ENJJsSzhNYWZpBrcQYIuuuvr40lw7Q3cY2wji RIllyszxXF/fLTsaXkzCuaQE0QQmU4qMkcl1K7w5k+OJwHc8eOI8U/4kCTanmfVpO/byE N9e6Bx/K9AMHy3A4ptQ/igms4tvvT4SN+jMC/oOdnm8mOCsoCeeyVbpoL3ST6/YT9Ug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ies5b2EX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47F4E606A339; Sat, 7 Nov 2026 15:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ies5b2EX Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA20D1F0089F; Sat, 7 Nov 2026 15:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794065227; bh=G7Xhj4+uY/Mnnhc7a98Jvrh79RCpMNAlFHijoY8iM2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ies5b2EXvgAQGfiPpRJdv9HhGppBZnFYAOzWfmF7VkbU2LsFXyqShispdJ64SZtCm meEfaLX0/iqtiGn5GQQRrFvZbuOxFsR5cce/jtHIvLqMrKYNcU2kH5SeYmfj1I3jbs yVqtchdevkfzoFNgH7HJQPmTUFIBDdN4aBanLzNE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikolaos Karaolidis , Jan Kara , Zhihao Cheng , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 7.3 1017/1257] fs: rotate inodes whose page cache could not be dropped Date: Sat, 7 Nov 2026 08:55:13 -0500 Message-ID: <20261107135007.425048173@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134939.434104957@linuxfoundation.org> References: <20261107134939.434104957@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolaos Karaolidis [ Upstream commit 8ee09f597763acfd31c62a578ba88b792fc41b24 ] When inode_lru_isolate() drops the page cache of an unused inode, it has to unlock the list, so it returns LRU_RETRY and the walk restarts at the head of the list, where the inode still is. If invalidate_mapping_pages() could not empty the mapping, the restarted walk strips the same inode again, and so on until nr_to_walk runs out. Every walk of that list then ends on this inode, and nothing behind it is reclaimed for as long as its cache stays. Before commit 2a0629834cd8 ("vfs: Don't evict inode under the inode lru traversing context") the walker pinned the inode with a reference, and dropping it in iput_final() set I_REFERENCED, so the restarted walk rotated the inode to the tail. Set I_REFERENCED again when the mapping is still populated after the invalidation, in the same i_lock section that clears I_LRU_ISOLATING. inode_unpin_lru_isolating() now expects i_lock to be held, like inode_pin_lru_isolating(). On CONFIG_HIGHMEM kernels this can happen to any unused inode: a folio is left behind if it is locked, under writeback, spliced into a pipe, or still in another CPU's LRU-add batch after being read. Without HIGHMEM it happens to DAX inodes whose only entry is at index 0, which mapping_shrinkable() lets onto the LRU and invalidate_mapping_pages() never removes. Fixes: 2a0629834cd8 ("vfs: Don't evict inode under the inode lru traversing context") Cc: stable@vger.kernel.org Signed-off-by: Nikolaos Karaolidis Link: https://patch.msgid.link/20261016102515.111285-1-nick@karaolidis.com Reviewed-by: Jan Kara Reviewed-by: Zhihao Cheng Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Sasha Levin --- fs/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index a9d37be390a17..1614a97ce9531 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -593,12 +593,11 @@ static void inode_pin_lru_isolating(struct inode *inode) static void inode_unpin_lru_isolating(struct inode *inode) { - spin_lock(&inode->i_lock); + lockdep_assert_held(&inode->i_lock); WARN_ON(!(inode_state_read(inode) & I_LRU_ISOLATING)); inode_state_clear(inode, I_LRU_ISOLATING); /* Called with inode->i_lock which ensures memory ordering. */ inode_wake_up_bit(inode, __I_LRU_ISOLATING); - spin_unlock(&inode->i_lock); } static void inode_wait_for_lru_isolating(struct inode *inode) @@ -981,7 +980,13 @@ static enum lru_status inode_lru_isolate(struct list_head *item, else __count_vm_events(PGINODESTEAL, reap); mm_account_reclaimed_pages(reap); + + spin_lock(&inode->i_lock); + /* The walk restarts here: don't retry leftovers right away */ + if (!mapping_empty(&inode->i_data)) + inode_state_set(inode, I_REFERENCED); inode_unpin_lru_isolating(inode); + spin_unlock(&inode->i_lock); return LRU_RETRY; } -- 2.53.0