From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: 김규진 <rolypolyvg295@gmail.com>, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [question] Design rationale behind f2fs_map_blocks block reuse in LFS mode with DIO
Date: Tue, 15 Jul 2025 16:56:49 +0800 [thread overview]
Message-ID: <742d1cc4-38c0-4f87-aab2-ab76a3825d01@kernel.org> (raw)
In-Reply-To: <CAA_oFbL+kxddwhS9-PWeO1EE4yJBHk6uwMwjB+r9wAW6+Zb45Q@mail.gmail.com>
Hi,
Sorry for the delay.
On 6/12/25 20:32, 김규진 wrote:
> Hi F2FS developers,
>
> I'm testing multi-threaded direct I/O in LFS mode on Linux kernel
> 6.8.0-57.59, and noticed what seems to be an inefficiency in block
> allocation behavior inside `fs/f2fs/data.c` (specifically
> `f2fs_map_blocks()`):
>
> 1. In LFS mode with direct I/O, `f2fs_map_blocks()` always calls
> `__allocate_data_block()` to reserve a new block and updates the
> node/NAT entry, regardless of extent continuity.
>
> 2. If the new block is not physically contiguous with the current
> extent, it submits the current bio and defers the write of the newly
> reserved block (which is now recorded in the node) to the next
> mapping.
>
> 3. On the next `f2fs_map_blocks()` call, it finds that the logical
> block is already mapped in the node/NAT entry and skips over
> it—despite the block never having been written—resulting in allocation
> of yet another block. Over time, this leaves behind holes in the
> current segment, especially under heavy multi-threaded DIO.
IIUC,
The problem is something like this, is my understanding right?
- user tries to write 768 blocks w/ direct IO.
- f2fs_iomap_begin(ofs:0, len:768)
- f2fs_map_blocks allocates two extents [ofs:0, blk:512, len:512] and
[ofs:512, blk:0, len:0], however f2fs_map_blocks() only return the first
extent,
- f2fs_iomap_begin(ofs:512, len:256)
f2fs_map_blocks allocates another physical block for ofs:512 even there is
a unwritten physical block allocated during previous f2fs_map_blocks.
Thanks,
>
>
> Since I'm still new to F2FS internals, I may be missing something —
> I'd like to understand the design rationale behind this behavior in
> LFS mode, if possible.
>
> **My questions are:**
>
> - Is there a specific reason F2FS does not distinguish between
> reserved-but-unwritten and already-written blocks in this case?
> - Would it be possible (or beneficial) to:
>
> 1. Delay block allocation until the extent can actually be extended?
>
> 2. Track "reserved-but-unwritten" blocks distinctly to avoid reallocation?
>
>
> Thanks in advance for any clarification or insight.
>
> Best regards,
>
> Gyjin Kim
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2025-07-15 8:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 12:32 [f2fs-dev] [question] Design rationale behind f2fs_map_blocks block reuse in LFS mode with DIO 김규진
2025-07-15 8:56 ` Chao Yu via Linux-f2fs-devel [this message]
2025-07-18 8:55 ` Chao Yu via Linux-f2fs-devel
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=742d1cc4-38c0-4f87-aab2-ab76a3825d01@kernel.org \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=chao@kernel.org \
--cc=rolypolyvg295@gmail.com \
/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