mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: let f2fs_write_cache_pages() flush a partially written folio
@ 2026-11-19 20:42 Daeho Jeong
  0 siblings, 0 replies; only message in thread
From: Daeho Jeong @ 2026-11-19 20:42 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong, Chao Yu

From: Daeho Jeong <daehojeong@google.com>

f2fs_write_single_data_page() writes a multi-block folio block by block,
so it can fail after it put some of the blocks into the merged bio. It
does not report them on an error, and f2fs_write_raw_pages() does not
count a folio that failed, so f2fs_write_cache_pages() may not flush the
bio at the end and the folio stays under writeback. For that reason
f2fs_write_single_data_page() flushes the bio by itself on an error.

Report the submitted blocks on an error as well, and count them in
f2fs_write_raw_pages() before its error handling. Then
f2fs_write_cache_pages() flushes the bio as it does after a successful
write, which is also what f2fs_write_cache_folios() does, and the flush
in f2fs_write_single_data_page() can go.

Suggested-by: Chao Yu <chao@kernel.org>
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fs/f2fs/compress.c | 4 ++--
 fs/f2fs/data.c     | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index d0e989254ffe..b8001953be15 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1743,6 +1743,8 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
 		ret = f2fs_write_single_data_page(folio, &submitted,
 						NULL, NULL, wbc, io_type,
 						compr_blocks, false);
+		/* Some blocks can be submitted before an error. */
+		*submitted_p += submitted;
 		if (ret) {
 			if (ret == 1) {
 				ret = 0;
@@ -1760,8 +1762,6 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
 			}
 			goto out;
 		}
-
-		*submitted_p += submitted;
 	}
 
 out:
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index cdc9e6e8633c..c0fc24d0b2ac 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -4381,9 +4381,10 @@ int f2fs_write_single_data_page(struct folio *folio, int *submitted,
 		if (!compr_blocks)
 			f2fs_unlock_op(sbi, &lc);
 
-		/* The callers drop the submitted count on error. */
-		if (err && local_submitted)
-			f2fs_submit_merged_write_cond(sbi, NULL, folio);
+		/* Let the caller flush the blocks submitted before an error. */
+		if (err && submitted)
+			*submitted = DIV_ROUND_UP(local_submitted,
+						  F2FS_BLKS_PER_PAGE(sbi));
 
 		if (!err)
 			f2fs_ffs_clear_subrange_dirty_and_test(folio, 0,
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19 20:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 20:42 [PATCH] f2fs: let f2fs_write_cache_pages() flush a partially written folio Daeho Jeong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®