Re: [f2fs-dev] [PATCH v3 01/12] f2fs: cache: implement metadata cache
From: Chao Yu
Date: Thu Aug 27 2026 - 21:36:46 EST
On 8/28/26 00:56, Daeho Jeong wrote:
> The idea is to drop list_lock completely from f2fs_find_cache() by
> deferring LRU rotation to the shrinker (like page cache's
> PG_referenced / clock algorithm):
Ah, I see, let me implement the logic as you suggested, thanks for the idea!
>
> In f2fs_find_cache() (no list_lock at all):
>
> if (entry) {
> f2fs_cache_get(entry);
> set_bit(F2FS_BLOCK_REFERENCED, &entry->state);
> }
>
> In f2fs_do_shrink_cache() Phase 1 (under list_lock):
>
> list_for_each_entry_safe(entry, next, &cache->lru_list, list) {
> /* If accessed, give it a second chance and rotate to tail */
> if (test_and_clear_bit(F2FS_BLOCK_REFERENCED, &entry->state)) {
> list_move_tail(&entry->list, &cache->lru_list);
> continue;
> }
> ...
> /* Reclaim cold entry */
> }
>
> This completely eliminates list_lock overhead from the read lookup
> path while keeping active entries protected from eviction.
Thanks,