From: Chao Yu <chao@kernel.org>
To: Nanzhe Zhao <zhaonanzhe@xiaomi.com>,
linux-f2fs-devel@lists.sourceforge.net
Cc: chao@kernel.org, linux-kernel@vger.kernel.org,
Barry Song <baohua@kernel.org>,
Ryan Roberts <Ryan.Roberts@arm.com>,
Juan Yescas <jyescas@google.com>, Dev Jain <Dev.Jain@arm.com>,
David Hildenbrand <David.Hildenbrand@arm.com>,
Pengfei Li <lipengfei28@xiaomi.com>,
Bo Zhang <zhangbo56@xiaomi.com>,
Kalesh Singh <kaleshsingh@google.com>,
Jaegeuk Kim <jaegeuk@kernel.org>
Subject: Re: [f2fs-dev] [RFC PATCH v2 02/10] f2fs: carry subpage offset and count in write IO
Date: Tue, 30 Jun 2026 16:38:58 +0800 [thread overview]
Message-ID: <bc4b29f0-8309-4a36-bdbe-b5f375aec31a@kernel.org> (raw)
In-Reply-To: <20260622160830.324455-3-zhaonanzhe@xiaomi.com>
On 6/23/26 00:08, Nanzhe Zhao wrote:
> Large folio write paths need to submit I/O for a range inside a
> folio instead of always submitting the whole folio from offset zero.
> Add idx and cnt to f2fs_io_info to describe the block offset inside
> the folio and the number of contiguous blocks covered by the I/O.
>
> Apply the new fields to the bio submit paths that need the subpage
> offset or contiguous block count.
>
> Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
> ---
> fs/f2fs/data.c | 58 ++++++++++++++++++++++++++++++++---------------
> fs/f2fs/f2fs.h | 2 ++
> fs/f2fs/segment.c | 4 ++--
> 3 files changed, 44 insertions(+), 20 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 23758c00758d..9a2bb6d982df 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -779,6 +779,8 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
> struct folio *fio_folio = fio->folio;
> struct folio *data_folio = fio->encrypted_page ?
> page_folio(fio->encrypted_page) : fio_folio;
> + pgoff_t fio_lblk = fio_folio->index + fio->idx;
> + unsigned int fio_cnt = fio->cnt ? fio->cnt : 1;
How about cleaning up w/ below macros?
#define F2FS_FOLIO_INDEX(folio, fio) (folio->index + fio->folio_offset)
#define F2FS_FOLIO_BLKCNT(fio) (fio->folio_blkcnt ? fio->folio_blkcnt : 1)
>
> if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
> fio->is_por ? META_POR : (__is_meta_io(fio) ?
> @@ -791,11 +793,13 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
> bio = __bio_alloc(fio, 1);
>
> f2fs_set_bio_crypt_ctx(bio, fio_folio->mapping->host,
> - fio_folio->index, fio, GFP_NOIO);
> - bio_add_folio_nofail(bio, data_folio, folio_size(data_folio), 0);
> + fio_lblk, fio, GFP_NOIO);
> + bio_add_folio_nofail(bio, data_folio,
> + F2FS_BLK_TO_BYTES(fio_cnt), fio->idx << PAGE_SHIFT);
>
> if (fio->io_wbc && !is_read_io(fio->op))
> - wbc_account_cgroup_owner(fio->io_wbc, fio_folio, PAGE_SIZE);
> + wbc_account_cgroup_owner(fio->io_wbc, fio_folio,
> + F2FS_BLK_TO_BYTES(fio_cnt));
>
> inc_page_count(fio->sbi, is_read_io(fio->op) ?
> __read_io_type(data_folio) : WB_DATA_TYPE(fio->folio, false));
> @@ -840,7 +844,8 @@ static bool io_is_mergeable(struct f2fs_sb_info *sbi, struct bio *bio,
> }
>
> static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio,
> - struct folio *folio, enum temp_type temp)
> + struct folio *folio, size_t len, size_t offset,
> + enum temp_type temp)
> {
> struct f2fs_bio_info *io = sbi->write_io[DATA] + temp;
> struct bio_entry *be;
> @@ -849,7 +854,7 @@ static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio,
> be->bio = bio;
> bio_get(bio);
>
> - bio_add_folio_nofail(bio, folio, folio_size(folio), 0);
> + bio_add_folio_nofail(bio, folio, len, offset);
>
> f2fs_down_write(&io->bio_list_lock);
> list_add_tail(&be->list, &io->bio_list);
> @@ -866,6 +871,8 @@ static int add_ipu_page(struct f2fs_io_info *fio, struct bio **bio,
> struct folio *folio)
> {
> struct folio *fio_folio = fio->folio;
> + pgoff_t fio_lblk = fio_folio->index + fio->idx;
> + unsigned int fio_cnt = fio->cnt ? fio->cnt : 1;
> struct f2fs_sb_info *sbi = fio->sbi;
> enum temp_type temp;
> bool found = false;
> @@ -888,8 +895,10 @@ static int add_ipu_page(struct f2fs_io_info *fio, struct bio **bio,
> fio->new_blkaddr));
> if (f2fs_crypt_mergeable_bio(*bio,
> fio_folio->mapping->host,
> - fio_folio->index, fio) &&
> - bio_add_folio(*bio, folio, folio_size(folio), 0)) {
> + fio_lblk, fio) &&
> + bio_add_folio(*bio, folio,
> + F2FS_BLK_TO_BYTES(fio_cnt),
> + fio->idx << PAGE_SHIFT)) {
> ret = 0;
> break;
> }
> @@ -1003,6 +1012,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
> struct folio *data_folio = fio->encrypted_page ?
> page_folio(fio->encrypted_page) : fio->folio;
> struct folio *folio = fio->folio;
> + pgoff_t fio_lblk = folio->index + fio->idx;
>
> if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
> __is_meta_io(fio) ? META_GENERIC : DATA_GENERIC))
> @@ -1017,9 +1027,11 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
> if (!bio) {
> bio = __bio_alloc(fio, BIO_MAX_VECS);
> f2fs_set_bio_crypt_ctx(bio, folio->mapping->host,
> - folio->index, fio, GFP_NOIO);
> + fio_lblk, fio, GFP_NOIO);
>
> - add_bio_entry(fio->sbi, bio, data_folio, fio->temp);
> + add_bio_entry(fio->sbi, bio, data_folio,
> + F2FS_BLK_TO_BYTES(fio->cnt ? fio->cnt : 1),
> + fio->idx << PAGE_SHIFT, fio->temp);
> } else {
> if (add_ipu_page(fio, &bio, data_folio))
> goto alloc_new;
> @@ -1030,7 +1042,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>
> inc_page_count(fio->sbi, WB_DATA_TYPE(folio, false));
>
> - *fio->last_block = fio->new_blkaddr;
> + *fio->last_block = fio->new_blkaddr + (fio->cnt ? fio->cnt - 1 : 0);
> *fio->bio = bio;
>
> return 0;
> @@ -1066,6 +1078,10 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
> struct folio *bio_folio;
> struct f2fs_lock_context lc;
> enum count_type type;
> + pgoff_t fio_lblk;
> + unsigned int fio_cnt;
> + size_t bio_offset;
> + size_t bio_len;
>
> f2fs_bug_on(sbi, is_read_io(fio->op));
>
> @@ -1104,6 +1120,9 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
> /* set submitted = true as a return value */
> fio->submitted = 1;
>
> + fio_lblk = fio->folio->index + fio->idx;
> + fio_cnt = fio->cnt ? fio->cnt : 1;
> +
> type = WB_DATA_TYPE(bio_folio, fio->compressed_page);
> inc_page_count(sbi, type);
>
> @@ -1111,26 +1130,29 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
> (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio,
> fio->new_blkaddr) ||
> !f2fs_crypt_mergeable_bio(io->bio, fio_inode(fio),
> - bio_folio->index, fio)))
> + fio_lblk, fio)))
> __submit_merged_bio(io);
> alloc_new:
> if (io->bio == NULL) {
> io->bio = __bio_alloc(fio, BIO_MAX_VECS);
> f2fs_set_bio_crypt_ctx(io->bio, fio_inode(fio),
> - bio_folio->index, fio, GFP_NOIO);
> + fio_lblk, fio, GFP_NOIO);
> io->fio = *fio;
> }
>
> - if (!bio_add_folio(io->bio, bio_folio, folio_size(bio_folio), 0)) {
> + bio_offset = fio->idx << PAGE_SHIFT;
> + bio_len = F2FS_BLK_TO_BYTES(fio_cnt);
> +
> + if (!bio_add_folio(io->bio, bio_folio, bio_len, bio_offset)) {
> __submit_merged_bio(io);
> goto alloc_new;
> }
>
> if (fio->io_wbc)
> wbc_account_cgroup_owner(fio->io_wbc, fio->folio,
> - folio_size(fio->folio));
> + F2FS_BLK_TO_BYTES(fio_cnt));
bio_len));
>
> - io->last_block_in_bio = fio->new_blkaddr;
> + io->last_block_in_bio = fio->new_blkaddr + fio_cnt - 1;
>
> trace_f2fs_submit_folio_write(fio->folio, fio);
> #ifdef CONFIG_BLK_DEV_ZONED
> @@ -2992,7 +3014,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
> return true;
>
> if (fio) {
> - if (page_private_gcing(fio->page))
> + if (folio_test_f2fs_gcing(fio->folio))
Should this change belong to patch 1?
> return true;
> if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&
> f2fs_is_checkpointed_data(sbi, fio->old_blkaddr)))
> @@ -3031,7 +3053,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
> set_new_dnode(&dn, inode, NULL, NULL, 0);
>
> if (need_inplace_update(fio) &&
> - f2fs_lookup_read_extent_cache_block(inode, folio->index,
> + f2fs_lookup_read_extent_cache_block(inode, folio->index + fio->idx,
> &fio->old_blkaddr)) {
> if (!f2fs_is_valid_blkaddr(fio->sbi, fio->old_blkaddr,
> DATA_GENERIC_ENHANCE))
> @@ -3050,7 +3072,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
> if (fio->need_lock == LOCK_REQ && !f2fs_trylock_op(fio->sbi, &lc))
> return -EAGAIN;
>
> - err = f2fs_get_dnode_of_data(&dn, folio->index, LOOKUP_NODE);
> + err = f2fs_get_dnode_of_data(&dn, folio->index + fio->idx, LOOKUP_NODE);
> if (err)
> goto out;
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e4778c17394e..4c2902abe499 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1351,6 +1351,8 @@ struct f2fs_io_info {
> blk_opf_t op_flags; /* req_flag_bits */
> block_t new_blkaddr; /* new block address to be written */
> block_t old_blkaddr; /* old block address before Cow */
> + pgoff_t idx; /* start block offset in the folio */
How about
pgoff_t folio_offset; /* offset in large folio */
> + unsigned int cnt; /* block count in the folio */
unsigned int folio_blkcnt; /* block count in large folio */
> union {
> struct page *page; /* page to be written */
> struct folio *folio;
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index d71ddb3ee918..43d41bb3b4b1 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3686,7 +3686,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
> if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
> return CURSEG_COLD_DATA_PINNED;
>
> - if (page_private_gcing(fio->page)) {
> + if (folio_test_f2fs_gcing(fio->folio)) {
Should this change belong to patch 1?
Thanks,
> if (fio->sbi->am.atgc_enabled &&
> (fio->io_type == FS_DATA_IO) &&
> (fio->sbi->gc_mode != GC_URGENT_HIGH) &&
> @@ -3699,7 +3699,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
> if (file_is_cold(inode) || f2fs_need_compress_data(inode))
> return CURSEG_COLD_DATA;
>
> - type = __get_age_segment_type(inode, fio->folio->index);
> + type = __get_age_segment_type(inode, fio->folio->index + fio->idx);
> if (type != NO_CHECK_TYPE)
> return type;
>
next prev parent reply other threads:[~2026-06-30 8:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 16:08 [f2fs-dev] [RFC PATCH v2 00/10] f2fs: support & optimize large folios for writable files Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 01/10] f2fs: extend folio state for large folio write path Nanzhe Zhao
2026-06-30 7:37 ` Chao Yu
[not found] ` <20260710011534.2307696-2-zhaonanzhe@xiaomi.com>
2026-07-10 3:05 ` Chao Yu
2026-07-06 7:43 ` Nanzhe Zhao
2026-07-06 7:53 ` Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 02/10] f2fs: carry subpage offset and count in write IO Nanzhe Zhao
2026-06-30 8:38 ` Chao Yu [this message]
2026-07-10 1:15 ` Nanzhe Zhao
2026-07-10 3:04 ` Chao Yu
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 03/10] f2fs: support regular file buffered writes on large folios Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 04/10] f2fs: support atomic file large folios buffered write Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 05/10] f2fs: support large folio writeback Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 06/10] f2fs: prepare mmap write faults for large folios Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 07/10] f2fs: make GC migration large-folio aware Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 08/10] f2fs: allow large folio support to writeable files Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 09/10] f2fs: optimize small block size large folio read Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 10/10] f2fs: support partial uptodate " Nanzhe Zhao
2026-07-01 2:51 ` [f2fs-dev] [RFC PATCH v2 00/10] f2fs: support & optimize large folios for writable files Chao Yu
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=bc4b29f0-8309-4a36-bdbe-b5f375aec31a@kernel.org \
--to=chao@kernel.org \
--cc=David.Hildenbrand@arm.com \
--cc=Dev.Jain@arm.com \
--cc=Ryan.Roberts@arm.com \
--cc=baohua@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=jyescas@google.com \
--cc=kaleshsingh@google.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lipengfei28@xiaomi.com \
--cc=zhangbo56@xiaomi.com \
--cc=zhaonanzhe@xiaomi.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