mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>, Chao Yu <chao@kernel.org>
Subject: [PATCH] f2fs: let f2fs_write_cache_pages() flush a partially written folio
Date: Thu, 19 Nov 2026 12:42:29 -0800	[thread overview]
Message-ID: <20261119204229.3895622-1-daeho43@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-19 20:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119204229.3895622-1-daeho43@gmail.com \
    --to=daeho43@gmail.com \
    --cc=chao@kernel.org \
    --cc=daehojeong@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®