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>
Subject: [PATCH] fsck.f2fs: flush device buffer before zone transition on zoned storage
Date: Tue, 21 Jul 2026 09:47:52 -0700	[thread overview]
Message-ID: <20260721164752.3853201-1-daeho43@gmail.com> (raw)

From: Daeho Jeong <daehojeong@google.com>

On zoned storage devices (F2FS_ZONED_HM), fsck.f2fs opens block devices
with buffered I/O (O_RDWR). When a curseg fills up its current zone and
moves to a new zone in find_next_free_block(), pending buffered writes
to the previous zone may still reside in the OS page cache / I/O queue.

As a result, issuing a write to the newly allocated zone can happen before
the device hardware finishes committing all blocks of the previous zone,
causing the hardware to see an additional open zone request that exceeds
the device's max open zone limit (e.g. open zones exceeded error).

Fix this by calling f2fs_fsync_device() right before allocating a new zone
when crossing zone boundaries (!(segno % segs_per_zone)). This flushes
all pending writes to physical media, ensuring the device hardware
auto-closes (FULL) the previous zone before opening the new zone.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fsck/mount.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index 6f640a0..3bd40fe 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -3073,6 +3073,9 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left,
 			if (!(segno % segs_per_zone)) {
 				u64 new_blkaddr = SM_I(sbi)->main_blkaddr;
 
+				if (c.zoned_model == F2FS_ZONED_HM)
+					f2fs_fsync_device();
+
 				ret = find_next_free_block(sbi, &new_blkaddr, 0,
 						want_type, true);
 				if (ret)
-- 
2.55.0.229.g6434b31f56-goog


             reply	other threads:[~2026-07-21 16:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 16:47 Daeho Jeong [this message]
2026-07-22 13:51 ` [f2fs-dev] " Bart Van Assche
2026-07-22 14:55   ` Daeho Jeong

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=20260721164752.3853201-1-daeho43@gmail.com \
    --to=daeho43@gmail.com \
    --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®