Re: [PATCH] fs: rotate inodes whose page cache could not be dropped

From: Zhihao Cheng

Date: Sat Oct 17 2026 - 03:43:29 EST


在 2026/10/16 18:25, Nikolaos Karaolidis 写道:
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.
[...]
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;
}

Hi Nikolaos,
I find a possible BUG_ON if this patch applied, details shown as:
P1 P2
prune_icache_sb
lock(lru->lock)
inode_lru_isolate
if (!mapping_empty(&inode->i_data))
unlock(lru->lock)
spin_lock(&inode->i_lock)
inode_state_set(inode, I_REFERENCED)
inode_unpin_lru_isolating
spin_unlock(&inode->i_lock)
unlink
iget_locked // find_inode_fast gets the inode
iput
iput_final
drop = 1
evict
BUG_ON(inode_state_read_once(inode) != (I_FREEING | I_CLEAR)) // inode state with I_REFERENCED

Could that be possible?