Skip to contentSkip to conversation

f2fs: return immediately after submitting the specified folio in __submit_merged_write_cond

PATCH In review Yongpeng Yang 3 participants 5 messages Dec 25, 2025 – Dec 27, 2025 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: return immediately after submitting the specified folio in __submit_merged_write_cond

From: Yongpeng Yang <[email protected]>

f2fs_folio_wait_writeback ensures the folio write is submitted to the block layer via __submit_merged_write_cond, then waits for the folio to complete. Other I/O submissions are irrelevant to f2fs_folio_wait_writeback. Thus, if the folio write bio is already submitted, the function can return immediately.

---
 fs/f2fs/data.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/data.c +5 -1
index 12bf4b6e0075..c743352b686d 100644
@@ -678,8 +678,12 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
 			ret = __has_merged_page(io->bio, inode, folio, ino);
 			f2fs_up_read(&io->io_rwsem);
 		}
-		if (ret)
+		if (ret) {
 			__f2fs_submit_merged_write(sbi, type, temp);
+			/* don't need to submit other types of bio. */
+			if (folio)
+				break;
+		}
 
 		/* TODO: use HOT temp only for meta pages now. */
 		if (type >= META)
Signature · 8 lines
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 3 lines · Yongpeng Yang

From: Yongpeng Yang <[email protected]>

f2fs_folio_wait_writeback ensures the folio write is submitted to the

Actually, __submit_merged_write_cond() was called from many other places, for those scenario, we can not ensure whether the DATA or NODE type pages were cached in one bio cache or not, so we decide to submit all cached bios w/ DATA or NODE type.

Quoted 3 lines

block layer via __submit_merged_write_cond, then waits for the folio to complete. Other I/O submissions are irrelevant to f2fs_folio_wait_writeback. Thus, if the folio write bio is already

For f2fs_folio_wait_writeback() case, I guess you can optimize it separately, maybe passing a parameter to __submit_merged_write_cond() as a hint?

Thanks,

Quoted 15 lines

submitted, the function can return immediately.

---
  fs/f2fs/data.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 12bf4b6e0075..c743352b686d 100644
@@ -678,8 +678,12 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
  			ret = __has_merged_page(io->bio, inode, folio, ino);
  			f2fs_up_read(&io->io_rwsem);
  		}

fs/f2fs/data.c static void __submit_merged_write_cond(struct f2fs_sb_info *sbi, · line 689

Quoted 10 lines
fs/f2fs/data.c +5 -1
-		if (ret)
+		if (ret) {
  			__f2fs_submit_merged_write(sbi, type, temp);
+			/* don't need to submit other types of bio. */
+			if (folio)
+				break;
+		}
 
  		/* TODO: use HOT temp only for meta pages now. */
  		if (type >= META)

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
Quoted 10 lines · On 12/26/25 09:52, Chao Yu via Linux-f2fs-devel wrote:
Quoted 3 lines · Yongpeng Yang

From: Yongpeng Yang <[email protected]>

f2fs_folio_wait_writeback ensures the folio write is submitted to the

Actually, __submit_merged_write_cond() was called from many other places, for those scenario, we can not ensure whether the DATA or NODE type pages were cached in one bio cache or not, so we decide to submit all cached bios w/ DATA or NODE type.

Quoted 7 lines
Quoted 3 lines

block layer via __submit_merged_write_cond, then waits for the folio to complete. Other I/O submissions are irrelevant to f2fs_folio_wait_writeback. Thus, if the folio write bio is already

For f2fs_folio_wait_writeback() case, I guess you can optimize it separately,
maybe passing a parameter to __submit_merged_write_cond() as a hint?

Currently, only the call chain f2fs_folio_wait_writeback -> f2fs_submit_merged_write_cond->__submit_merged_write_cond passes a non-NULL folio with a NULL inode. When the return value of __has_merged_page is true and the folio is non-NULL, it indicates the call is from f2fs_folio_wait_writeback. Indeed, this is unclear.

The force parameter seems redundant, where force = true implies inode == NULL && folio == NULL && ino == 0 is true, and force = false implies inode != NULL || folio != NULL || ino != 0 is true.

How about removing the force parameter and adding a bool writeback parameter to indicate calls from f2fs_folio_wait_writeback?

Thanks
Yongpeng,

Quoted 27 lines

Thanks,

Quoted 24 lines

submitted, the function can return immediately.

---
  fs/f2fs/data.c | 6 +++++-

  1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/data.c +5 -1
index 12bf4b6e0075..c743352b686d 100644
@@ -678,8 +678,12 @@ static void __submit_merged_write_cond(struct
 f2fs_sb_info *sbi,
               ret = __has_merged_page(io->bio, inode, folio, ino);
               f2fs_up_read(&io->io_rwsem);
           }
-        if (ret)
+        if (ret) {
               __f2fs_submit_merged_write(sbi, type, temp);
+            /* don't need to submit other types of bio. */
+            if (folio)
+                break;
+        }
             /* TODO: use HOT temp only for meta pages now. */
Quoted 8 lines

fs/f2fs/data.c static void __submit_merged_write_cond(struct f2fs_sb_info *sbi, · line 689

Quoted 1 line
fs/f2fs/data.c +0 -0
           if (type >= META)

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
Quoted 25 lines · Yongpeng Yang
Quoted 10 lines · On 12/26/25 09:52, Chao Yu via Linux-f2fs-devel wrote:
Quoted 3 lines · Yongpeng Yang

From: Yongpeng Yang <[email protected]>

f2fs_folio_wait_writeback ensures the folio write is submitted to the

Actually, __submit_merged_write_cond() was called from many other places, for those scenario, we can not ensure whether the DATA or NODE type pages were cached in one bio cache or not, so we decide to submit all cached bios w/ DATA or NODE type.

Quoted 7 lines
Quoted 3 lines

block layer via __submit_merged_write_cond, then waits for the folio to complete. Other I/O submissions are irrelevant to f2fs_folio_wait_writeback. Thus, if the folio write bio is already

For f2fs_folio_wait_writeback() case, I guess you can optimize it separately,
maybe passing a parameter to __submit_merged_write_cond() as a hint?

Currently, only the call chain f2fs_folio_wait_writeback -> f2fs_submit_merged_write_cond->__submit_merged_write_cond passes a non-NULL folio with a NULL inode. When the return value of __has_merged_page is true and the folio is non-NULL, it indicates the call is from f2fs_folio_wait_writeback. Indeed, this is unclear.

Quoted 6 lines

The force parameter seems redundant, where force = true implies inode == NULL && folio == NULL && ino == 0 is true, and force = false implies inode != NULL || folio != NULL || ino != 0 is true.

How about removing the force parameter and adding a bool writeback parameter to indicate calls from f2fs_folio_wait_writeback?

Sure, can we clean up force parameter in separated patch?

Thanks,

Quoted 40 lines

Thanks
Yongpeng,

Quoted 35 lines

Thanks,

Quoted 15 lines

submitted, the function can return immediately.

---
   fs/f2fs/data.c | 6 +++++-
   1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 12bf4b6e0075..c743352b686d 100644
@@ -678,8 +678,12 @@ static void __submit_merged_write_cond(struct
 f2fs_sb_info *sbi,
               ret = __has_merged_page(io->bio, inode, folio, ino);
               f2fs_up_read(&io->io_rwsem);

fs/f2fs/data.c static void __submit_merged_write_cond(struct · line 689

Quoted 10 lines
fs/f2fs/data.c +5 -1
           }
-        if (ret)
+        if (ret) {
               __f2fs_submit_merged_write(sbi, type, temp);
+            /* don't need to submit other types of bio. */
+            if (folio)
+                break;
+        }
             /* TODO: use HOT temp only for meta pages now. */
           if (type >= META)

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#4 lore raw
Quoted 26 lines · On 12/27/25 9:22 AM, Chao Yu via Linux-f2fs-devel wrote:
Quoted 25 lines · Yongpeng Yang
Quoted 10 lines · On 12/26/25 09:52, Chao Yu via Linux-f2fs-devel wrote:
Quoted 3 lines · Yongpeng Yang

From: Yongpeng Yang <[email protected]>

f2fs_folio_wait_writeback ensures the folio write is submitted to the

Actually, __submit_merged_write_cond() was called from many other places, for those scenario, we can not ensure whether the DATA or NODE type pages were cached in one bio cache or not, so we decide to submit all cached bios w/ DATA or NODE type.

Quoted 7 lines
Quoted 3 lines

block layer via __submit_merged_write_cond, then waits for the folio to complete. Other I/O submissions are irrelevant to f2fs_folio_wait_writeback. Thus, if the folio write bio is already

For f2fs_folio_wait_writeback() case, I guess you can optimize it separately,
maybe passing a parameter to __submit_merged_write_cond() as a hint?

Currently, only the call chain f2fs_folio_wait_writeback -> f2fs_submit_merged_write_cond->__submit_merged_write_cond passes a non-NULL folio with a NULL inode. When the return value of __has_merged_page is true and the folio is non-NULL, it indicates the call is from f2fs_folio_wait_writeback. Indeed, this is unclear.

Quoted 9 lines
Quoted 6 lines

The force parameter seems redundant, where force = true implies inode == NULL && folio == NULL && ino == 0 is true, and force = false implies inode != NULL || folio != NULL || ino != 0 is true.

How about removing the force parameter and adding a bool writeback parameter to indicate calls from f2fs_folio_wait_writeback?

Sure, can we clean up force parameter in separated patch?

OK, I'll clean it up and optmize f2fs_folio_wait_writeback in v2 patch.

Thanks
Yongpeng,

Quoted 45 lines

Thanks,

Quoted 40 lines

Thanks
Yongpeng,

Quoted 35 lines

Thanks,

Quoted 15 lines

submitted, the function can return immediately.

---
   fs/f2fs/data.c | 6 +++++-

   1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 12bf4b6e0075..c743352b686d 100644
@@ -678,8 +678,12 @@ static void __submit_merged_write_cond(struct
 f2fs_sb_info *sbi,
                ret = __has_merged_page(io->bio, inode, folio, ino);
                f2fs_up_read(&io->io_rwsem);

fs/f2fs/data.c static void __submit_merged_write_cond(struct · line 689

Quoted 10 lines
fs/f2fs/data.c +5 -1
            }
-        if (ret)
+        if (ret) {
                __f2fs_submit_merged_write(sbi, type, temp);
+            /* don't need to submit other types of bio. */
+            if (folio)
+                break;
+        }
              /* TODO: use HOT temp only for meta pages now. */
            if (type >= META)

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel