Skip to contentSkip to conversation

f2fs: fix wrong description in printed log

PATCH In review Chao Yu 4 participants 11 messages Jun 15 – Jun 16

Subsystems (2)
lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/6 f2fs: fix wrong description in printed log

This patch fixes wrong description in printed log:

"SSA and SIT" -> "SIT and SSA"

---
 fs/f2fs/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +1 -1
index 69e0a867219d..0e537508df20 100644
@@ -1897,7 +1897,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 			sum = SUM_BLK_PAGE_ADDR(sbi, sum_folio, cur_segno);
 			if (type != GET_SUM_TYPE(sum_footer(sbi, sum))) {
 				f2fs_err(sbi, "Inconsistent segment (%u) type "
-						"[%d, %d] in SSA and SIT",
+						"[%d, %d] in SIT and SSA",
 						cur_segno, type,
 						GET_SUM_TYPE(
 						sum_footer(sbi, sum)));
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 2/6 f2fs: misc cleanup in f2fs_record_stop_reason()

---
 fs/f2fs/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/super.c +1 -2
index 20577e33ee2a..ff2b9c6e8c32 100644
@@ -4648,8 +4648,7 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
 
 	spin_lock_irqsave(&sbi->error_lock, flags);
 	if (sbi->error_dirty) {
-		memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
-							MAX_F2FS_ERRORS);
+		memcpy(raw_super->s_errors, sbi->errors, MAX_F2FS_ERRORS);
 		sbi->error_dirty = false;
 	}
 	memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH 3/6 f2fs: avoid unnecessary sanity check on ckpt_valid_blocks

In reply to Chao Yu

The calculation of sec->ckpt_valid_blocks are the same in both set_ckpt_valid_blocks() and sanity_check_valid_blocks(), so it doesn't necessary to call sanity_check_valid_blocks() right after set_ckpt_valid_blocks().

---
 fs/f2fs/segment.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/f2fs/segment.c +2 -6
index 1ef4edb77078..f9c688d270e6 100644
@@ -4802,10 +4802,8 @@ void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 			}
 
 			/* update ckpt_valid_block */
-			if (__is_large_section(sbi)) {
+			if (__is_large_section(sbi))
 				set_ckpt_valid_blocks(sbi, segno);
-				sanity_check_valid_blocks(sbi, segno);
-			}
 
 			__clear_bit(segno, bitmap);
 			sit_i->dirty_sentries--;
@@ -5133,10 +5131,8 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
 	if (__is_large_section(sbi)) {
 		unsigned int segno;
 
-		for (segno = 0; segno < MAIN_SEGS(sbi); segno += SEGS_PER_SEC(sbi)) {
+		for (segno = 0; segno < MAIN_SEGS(sbi); segno += SEGS_PER_SEC(sbi))
 			set_ckpt_valid_blocks(sbi, segno);
-			sanity_check_valid_blocks(sbi, segno);
-		}
 	}
 
 	if (err)
Signature · 1 line
2.49.0
author maintainer
#3 lore raw

PATCH 4/6 f2fs: avoid unnecessary fscrypt_finalize_bounce_page()

In reply to Chao Yu

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().

---
 fs/f2fs/compress.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
fs/f2fs/compress.c +6 -4
index caf522d667d6..aaa0813eabcd 100644
@@ -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);
Signature · 1 line
2.49.0
maintainer
#4 lore raw

Re: [f2fs-dev] [PATCH 4/6] f2fs: avoid unnecessary fscrypt_finalize_bounce_page()

Quoted 22 lines · On 06/15, Chao Yu via Linux-f2fs-devel wrote:

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().

---
 fs/f2fs/compress.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
fs/f2fs/compress.c +0 -0
index caf522d667d6..aaa0813eabcd 100644
@@ -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);
 

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 1463

Quoted 10 lines
fs/f2fs/compress.c +6 -4
-	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]);
+		}

Applied as:

fs/f2fs/compress.c +3 -0
@@ -1455,6 +1455,9 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 out_destroy_crypt:
        page_array_free(sbi, cic->rpages, cc->cluster_size);
 
+       if (!fio.encrypted)
+               goto out_put_cic;
+
        for (--i; i >= 0; i--) {
                if (!cc->cpages[i])
                        continue;
Quoted 12 lines
fs/f2fs/compress.c +0 -0
 	}
 out_put_cic:
 	kmem_cache_free(cic_entry_slab, cic);
Signature · 8 lines
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author maintainer
#5 lore raw

Re: [f2fs-dev] [PATCH 4/6] f2fs: avoid unnecessary fscrypt_finalize_bounce_page()

Quoted 39 lines · Jaegeuk Kim
Quoted 22 lines · On 06/15, Chao Yu via Linux-f2fs-devel wrote:

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().

---
 fs/f2fs/compress.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
fs/f2fs/compress.c +0 -0
index caf522d667d6..aaa0813eabcd 100644
@@ -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);
 

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 1463

Quoted 10 lines
fs/f2fs/compress.c +6 -4
-	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]);
+		}

Applied as:

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 1459

Quoted 5 lines
fs/f2fs/compress.c +2 -0
@@ -1455,6 +1455,9 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 out_destroy_crypt:
        page_array_free(sbi, cic->rpages, cc->cluster_size);
 
+       if (!fio.encrypted)
+               goto out_put_cic;

Looks fine to me.

Thanks,

Quoted 18 lines
fs/f2fs/compress.c +1 -0
+
        for (--i; i >= 0; i--) {
                if (!cc->cpages[i])
                        continue;
Quoted 14 lines
fs/f2fs/compress.c +0 -0
 	}
 out_put_cic:
 	kmem_cache_free(cic_entry_slab, cic);
Signature · 8 lines
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author maintainer
#6 lore raw

PATCH 5/6 f2fs: use fscrypt_finalize_bounce_page() for cleanup

In reply to Chao Yu

No logic changes.

Cc Matthew Wilcox <[email protected]>
Cc Eric Biggers <[email protected]>
---
 fs/f2fs/data.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
fs/f2fs/data.c +3 -6
index 9c6440a7db0e..02d498d549b0 100644
@@ -358,14 +358,11 @@ static void f2fs_write_end_io(struct bio *bio)
 
 	bio_for_each_folio_all(fi, bio) {
 		struct folio *folio = fi.folio;
+		struct page *page = &folio->page;
 		enum count_type type;
 
-		if (fscrypt_is_bounce_folio(folio)) {
-			struct folio *io_folio = folio;
-
-			folio = fscrypt_pagecache_folio(io_folio);
-			fscrypt_free_bounce_page(&io_folio->page);
-		}
+		fscrypt_finalize_bounce_page(&page);
+		folio = page_folio(page);
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_is_compressed_page(folio)) {
Signature · 1 line
2.49.0
#7 lore raw

Re: [PATCH 5/6] f2fs: use fscrypt_finalize_bounce_page() for cleanup

Quoted 1 line · Chao Yu

No logic changes.

This seems like a step backwards. We should be looking to convert to a future fscrypt_finalize_bounce_folio(), if anything.

author maintainer
#8 lore raw

Re: [PATCH 5/6] f2fs: use fscrypt_finalize_bounce_page() for cleanup

Quoted 5 lines · Matthew Wilcox
Quoted 1 line · Chao Yu

No logic changes.

This seems like a step backwards. We should be looking to convert to a future fscrypt_finalize_bounce_folio(), if anything.

You're right, what do you think of this?

From 533ee72170c2ad451097db926dd713d9fea442f9 Mon Sep 17 00:00:00 2001
From: Chao Yu <[email protected]>
Date: Fri, 26 Sep 2025 01:43:06 +0800
Subject: [PATCH] fscrypt,f2fs: introduce fscrypt_finalize_bounce_folio() for
cleanup

As part of the linux kernel's migration to folio-based APIs, introduce fscrypt_finalize_bounce_folio() as the folio equivalent of fscrypt_finalize_bounce_page(), and clean up f2fs codes with this new helper.

---
 fs/f2fs/data.c          |  7 +------
 include/linux/fscrypt.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)
fs/f2fs/data.c +1 -6
index ac1cf4de3d62..e0fca6c60e34 100644
@@ -362,12 +362,7 @@ static void f2fs_write_end_bio(struct bio *bio)
 		struct folio *folio = fi.folio;
 		enum count_type type;
 
-		if (fscrypt_is_bounce_folio(folio)) {
-			struct folio *io_folio = folio;
-
-			folio = fscrypt_pagecache_folio(io_folio);
-			fscrypt_free_bounce_page(&io_folio->page);
-		}
+		fscrypt_finalize_bounce_folio(&folio);
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_is_compressed_page(folio)) {
include/linux/fscrypt.h +11 -0
index 54712ec61ffb..20b59b021c94 100644
@@ -1132,4 +1132,15 @@ static inline void fscrypt_finalize_bounce_page(struct page **pagep)
 	}
 }
 
+/* If *foliop is a bounce folio, free it and set *foliop to the pagecache folio */
+static inline void fscrypt_finalize_bounce_folio(struct folio **foliop)
+{
+	struct folio *folio = *foliop;
+
+	if (fscrypt_is_bounce_folio(folio)) {
+		*foliop = fscrypt_pagecache_folio(folio);
+		fscrypt_free_bounce_page(&folio->page);
+	}
+}
+
 #endif	/* _LINUX_FSCRYPT_H */
Signature · 1 line
2.49.0
author maintainer
#9 lore raw

PATCH 6/6 f2fs: remove unneeded f2fs_is_compressed_page()

In reply to Chao Yu

We have checked f2fs_is_compressed_page() before f2fs_compress_write_end_io(), so we don't need to check the status again, remove it.

---
 fs/f2fs/compress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/compress.c +1 -2
index aaa0813eabcd..b1209619bb64 100644
@@ -1486,8 +1486,7 @@ void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)
 	struct page *page = &folio->page;
 	struct f2fs_sb_info *sbi = bio->bi_private;
 	struct compress_io_ctx *cic = folio->private;
-	enum count_type type = WB_DATA_TYPE(folio,
-				f2fs_is_compressed_page(folio));
+	enum count_type type = WB_DATA_TYPE(folio, true);
 	int i;
 
 	if (unlikely(bio->bi_status != BLK_STS_OK))
Signature · 1 line
2.49.0
#10 lore raw
In reply to Chao Yu
This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 8 lines · On Mon, 15 Jun 2026 21:08:17 +0800 you wrote:

This patch fixes wrong description in printed log:

"SSA and SIT" -> "SIT and SSA"

---
 fs/f2fs/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [f2fs-dev,1/6] f2fs: fix wrong description in printed log

    https://git.kernel.org/jaegeuk/f2fs/c/123a88353dac
  - [f2fs-dev,2/6] f2fs: misc cleanup in f2fs_record_stop_reason()
    https://git.kernel.org/jaegeuk/f2fs/c/a1c83470ed0b
  - [f2fs-dev,3/6] f2fs: avoid unnecessary sanity check on ckpt_valid_blocks
    https://git.kernel.org/jaegeuk/f2fs/c/701959ef9b9f
  - [f2fs-dev,4/6] f2fs: avoid unnecessary fscrypt_finalize_bounce_page()
    (no matching commit)
  - [f2fs-dev,5/6] f2fs: use fscrypt_finalize_bounce_page() for cleanup
    (no matching commit)
  - [f2fs-dev,6/6] f2fs: remove unneeded f2fs_is_compressed_page()
    https://git.kernel.org/jaegeuk/f2fs/c/7cc48ead1a8a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html