[PATCH 4/6] f2fs: avoid unnecessary fscrypt_finalize_bounce_page()
From: Chao Yu
Date: Mon Jun 15 2026 - 09:09:17 EST
fscrypt_finalize_bounce_page() should be called only if we use fs layer
crypto, let's avoid unnecessary fscrypt_finalize_bounce_page() in error
path of f2fs_write_compressed_pages().
BTW, fscrypt_finalize_bounce_page() will check mapping of bounced page
before retrieving original page, so, previously it won't cause any issue
w/ fscrypt_finalize_bounce_page(), but still we'd better avoid coupling
w/ any logic inside fscrypt_finalize_bounce_page().
Signed-off-by: Chao Yu <chao@xxxxxxxxxx>
---
fs/f2fs/compress.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index caf522d667d6..aaa0813eabcd 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1455,10 +1455,12 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
out_destroy_crypt:
page_array_free(sbi, cic->rpages, cc->cluster_size);
- for (--i; i >= 0; i--) {
- if (!cc->cpages[i])
- continue;
- fscrypt_finalize_bounce_page(&cc->cpages[i]);
+ if (fio.encrypted) {
+ for (--i; i >= 0; i--) {
+ if (!cc->cpages[i])
+ continue;
+ fscrypt_finalize_bounce_page(&cc->cpages[i]);
+ }
}
out_put_cic:
kmem_cache_free(cic_entry_slab, cic);
--
2.49.0