Re: [f2fs-dev] [PATCH v3 09/12] f2fs: cache: use compress cache

From: Chao Yu

Date: Fri Aug 28 2026 - 08:25:38 EST


On 8/28/26 20:00, Chao Yu wrote:
On 8/27/26 04:04, Daeho Jeong wrote:
On Tue, Aug 25, 2026 at 6:03 AM Chao Yu via Linux-f2fs-devel
+               f2fs_lock_cache(entry);

-                       if (ino != folio_get_f2fs_data(folio)) {
-                               folio_unlock(folio);
-                               continue;
-                       }
-
-                       generic_error_remove_folio(mapping, folio);
-                       folio_unlock(folio);
+               if (!f2fs_is_compress_cache(entry)) {

How is this possible?
or if (!entry->cache)?

I suffer a panic from f2fs_bug_on(sbi, !f2fs_is_compress_cache(entry)) here,
it may suffer race condition w/ shrinker.

I changed like this, because:
1. we will never update entry->ino after initialization, so it's safe to
check w/o lock.
2. f2fs_truncate_cache() has checked entry->cache by itself, so it doesn't
need to check w/ f2fs_is_compress_cache() outside __f2fs_truncate_cache().

for (i = 0; i < nr; i++) {
struct f2fs_cached_block *entry = entries[i];

index = entry->index + 1;

if (entry->ino != ino)
continue;

f2fs_truncate_cache(entry, false);
}

Let me know if you have any concern about this.

Thanks,