* FAILED: patch "[PATCH] f2fs: fix submit accounting for IPU writeback" failed to apply to 5.10-stable tree
@ 2026-11-07 11:25 Sasha Levin
2026-11-11 15:41 ` [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical Sasha Levin
0 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2026-11-07 11:25 UTC (permalink / raw)
To: jsjlee1020, chao, jaegeuk; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 6d1f622b9c069378cdb83088be2b15a9b480b8a3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261107062516-failed-5.10-6d1f622b9c06@kernel.org' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 6d1f622b9c069378cdb83088be2b15a9b480b8a3 Mon Sep 17 00:00:00 2001
From: Seongjae Jeong <jsjlee1020@gmail.com>
Date: Wed, 14 Oct 2026 11:26:29 +0000
Subject: [PATCH] f2fs: fix submit accounting for IPU writeback
f2fs_write_cache_pages() uses the submitted count, which is set to
fio.submitted in f2fs_write_single_data_page(), to update nwritten
and decrement wbc->nr_to_write.
In the OPU path, f2fs_submit_page_write() sets fio->submitted to 1.
However, in the IPU path, fio->submitted is never set and remains zero.
As a result, successful IPU writes are not accounted for.
This can cause asynchronous writeback to continue beyond its budget.
Set fio->submitted in f2fs_inplace_write_data() after a page is
successfully merged into a bio or submitted, so that successful
IPU writes are included in the writeback accounting.
Cc: stable@kernel.org
Fixes: d68f735b3bc9 ("f2fs: check io submission more precisely")
Signed-off-by: Seongjae Jeong <jsjlee1020@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/segment.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index f6e1cb1c0b71d..92c3f255ea8fa 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4292,6 +4292,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
else
err = f2fs_submit_page_bio(fio);
if (!err) {
+ fio->submitted = 1;
f2fs_update_device_state(fio->sbi, fio->ino,
fio->new_blkaddr, 1);
f2fs_update_iostat(fio->sbi, fio_inode(fio),
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical 2026-11-07 11:25 FAILED: patch "[PATCH] f2fs: fix submit accounting for IPU writeback" failed to apply to 5.10-stable tree Sasha Levin @ 2026-11-11 15:41 ` Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 2/4] f2fs: use new conversion functions between blks and bytes Sasha Levin ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Sasha Levin @ 2026-11-11 15:41 UTC (permalink / raw) To: stable; +Cc: Jaegeuk Kim, Chao Yu, Sasha Levin From: Jaegeuk Kim <jaegeuk@kernel.org> [ Upstream commit 6cbfcab5ff51491e67c75fd8d672cff97127fd55 ] This patch renames two functions like below having u64. - logical_to_blk to bytes_to_blks - blk_to_logical to blks_to_bytes Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback") Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/f2fs/data.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2933b32032e79..e681ff67d63ef 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1860,14 +1860,14 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock, NO_CHECK_TYPE, create); } -static inline sector_t logical_to_blk(struct inode *inode, loff_t offset) +static inline u64 bytes_to_blks(struct inode *inode, u64 bytes) { - return (offset >> inode->i_blkbits); + return (bytes >> inode->i_blkbits); } -static inline loff_t blk_to_logical(struct inode *inode, sector_t blk) +static inline u64 blks_to_bytes(struct inode *inode, u64 blks) { - return (blk << inode->i_blkbits); + return (blks << inode->i_blkbits); } static int f2fs_xattr_fiemap(struct inode *inode, @@ -1895,7 +1895,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, return err; } - phys = (__u64)blk_to_logical(inode, ni.blk_addr); + phys = blks_to_bytes(inode, ni.blk_addr); offset = offsetof(struct f2fs_inode, i_addr) + sizeof(__le32) * (DEF_ADDRS_PER_INODE - get_inline_xattr_addrs(inode)); @@ -1927,7 +1927,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, return err; } - phys = (__u64)blk_to_logical(inode, ni.blk_addr); + phys = blks_to_bytes(inode, ni.blk_addr); len = inode->i_sb->s_blocksize; f2fs_put_page(page, 1); @@ -1997,18 +1997,18 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, goto out; } - if (logical_to_blk(inode, len) == 0) - len = blk_to_logical(inode, 1); + if (bytes_to_blks(inode, len) == 0) + len = blks_to_bytes(inode, 1); - start_blk = logical_to_blk(inode, start); - last_blk = logical_to_blk(inode, start + len - 1); + start_blk = bytes_to_blks(inode, start); + last_blk = bytes_to_blks(inode, start + len - 1); next: memset(&map_bh, 0, sizeof(struct buffer_head)); map_bh.b_size = len; if (compr_cluster) - map_bh.b_size = blk_to_logical(inode, cluster_size - 1); + map_bh.b_size = blks_to_bytes(inode, cluster_size - 1); ret = get_data_block(inode, start_blk, &map_bh, 0, F2FS_GET_BLOCK_FIEMAP, &next_pgofs); @@ -2019,7 +2019,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (!buffer_mapped(&map_bh)) { start_blk = next_pgofs; - if (blk_to_logical(inode, start_blk) < blk_to_logical(inode, + if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode, max_inode_blocks(inode))) goto prep_next; @@ -2045,9 +2045,9 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, compr_cluster = false; - logical = blk_to_logical(inode, start_blk - 1); - phys = blk_to_logical(inode, map_bh.b_blocknr); - size = blk_to_logical(inode, cluster_size); + logical = blks_to_bytes(inode, start_blk - 1); + phys = blks_to_bytes(inode, map_bh.b_blocknr); + size = blks_to_bytes(inode, cluster_size); flags |= FIEMAP_EXTENT_ENCODED; @@ -2065,14 +2065,14 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, goto prep_next; } - logical = blk_to_logical(inode, start_blk); - phys = blk_to_logical(inode, map_bh.b_blocknr); + logical = blks_to_bytes(inode, start_blk); + phys = blks_to_bytes(inode, map_bh.b_blocknr); size = map_bh.b_size; flags = 0; if (buffer_unwritten(&map_bh)) flags = FIEMAP_EXTENT_UNWRITTEN; - start_blk += logical_to_blk(inode, size); + start_blk += bytes_to_blks(inode, size); prep_next: cond_resched(); @@ -4003,7 +4003,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis, * to be very smart. */ cur_lblock = 0; - last_lblock = logical_to_blk(inode, i_size_read(inode)); + last_lblock = bytes_to_blks(inode, i_size_read(inode)); len = i_size_read(inode); while (cur_lblock <= last_lblock && cur_lblock < sis->max) { @@ -4025,7 +4025,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis, goto err_out; pblock = map_bh.b_blocknr; - nr_pblocks = logical_to_blk(inode, map_bh.b_size); + nr_pblocks = bytes_to_blks(inode, map_bh.b_size); if (cur_lblock + nr_pblocks >= sis->max) nr_pblocks = sis->max - cur_lblock; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 2/4] f2fs: use new conversion functions between blks and bytes 2026-11-11 15:41 ` [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical Sasha Levin @ 2026-11-11 15:41 ` Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 3/4] f2fs: remove allow_outplace_dio() Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 4/4] f2fs: fix submit accounting for IPU writeback Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-11-11 15:41 UTC (permalink / raw) To: stable; +Cc: Jaegeuk Kim, Chao Yu, Sasha Levin From: Jaegeuk Kim <jaegeuk@kernel.org> [ Upstream commit 43b9d4b4d91c02ca1159507d46e3687d98b4cb8f ] This patch cleans up blks and bytes conversions. Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback") Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/f2fs/data.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index e681ff67d63ef..e033c8dfb0348 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1802,6 +1802,16 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) return true; } +static inline u64 bytes_to_blks(struct inode *inode, u64 bytes) +{ + return (bytes >> inode->i_blkbits); +} + +static inline u64 blks_to_bytes(struct inode *inode, u64 blks) +{ + return (blks << inode->i_blkbits); +} + static int __get_data_block(struct inode *inode, sector_t iblock, struct buffer_head *bh, int create, int flag, pgoff_t *next_pgofs, int seg_type, bool may_write) @@ -1810,7 +1820,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock, int err; map.m_lblk = iblock; - map.m_len = bh->b_size >> inode->i_blkbits; + map.m_len = bytes_to_blks(inode, bh->b_size); map.m_next_pgofs = next_pgofs; map.m_next_extent = NULL; map.m_seg_type = seg_type; @@ -1820,7 +1830,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock, if (!err) { map_bh(bh, inode->i_sb, map.m_pblk); bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags; - bh->b_size = (u64)map.m_len << inode->i_blkbits; + bh->b_size = blks_to_bytes(inode, map.m_len); } return err; } @@ -1860,16 +1870,6 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock, NO_CHECK_TYPE, create); } -static inline u64 bytes_to_blks(struct inode *inode, u64 bytes) -{ - return (bytes >> inode->i_blkbits); -} - -static inline u64 blks_to_bytes(struct inode *inode, u64 blks) -{ - return (blks << inode->i_blkbits); -} - static int f2fs_xattr_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo) { @@ -2105,8 +2105,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, bool is_readahead) { struct bio *bio = *bio_ret; - const unsigned blkbits = inode->i_blkbits; - const unsigned blocksize = 1 << blkbits; + const unsigned blocksize = blks_to_bytes(inode, 1); sector_t block_in_file; sector_t last_block; sector_t last_block_in_file; @@ -2115,8 +2114,8 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, block_in_file = (sector_t)page_index(page); last_block = block_in_file + nr_pages; - last_block_in_file = (f2fs_readpage_limit(inode) + blocksize - 1) >> - blkbits; + last_block_in_file = bytes_to_blks(inode, + f2fs_readpage_limit(inode) + blocksize - 1); if (last_block > last_block_in_file) last_block = last_block_in_file; @@ -2229,8 +2228,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, struct bio *bio = *bio_ret; unsigned int start_idx = cc->cluster_idx << cc->log_cluster_size; sector_t last_block_in_file; - const unsigned blkbits = inode->i_blkbits; - const unsigned blocksize = 1 << blkbits; + const unsigned blocksize = blks_to_bytes(inode, 1); struct decompress_io_ctx *dic = NULL; struct bio_post_read_ctx *ctx; bool for_verity = false; @@ -2239,8 +2237,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, f2fs_bug_on(sbi, f2fs_cluster_is_empty(cc)); - last_block_in_file = (f2fs_readpage_limit(inode) + - blocksize - 1) >> blkbits; + last_block_in_file = bytes_to_blks(inode, + f2fs_readpage_limit(inode) + blocksize - 1); /* get rid of pages beyond EOF */ for (i = 0; i < cc->cluster_size; i++) { @@ -4068,7 +4066,6 @@ static int check_swap_activate(struct swap_info_struct *sis, struct inode *inode = mapping->host; unsigned blocks_per_page; unsigned long page_no; - unsigned blkbits; sector_t probe_block; sector_t last_block; sector_t lowest_block = -1; @@ -4079,8 +4076,7 @@ static int check_swap_activate(struct swap_info_struct *sis, if (PAGE_SIZE == F2FS_BLKSIZE) return check_swap_activate_fast(sis, swap_file, span); - blkbits = inode->i_blkbits; - blocks_per_page = PAGE_SIZE >> blkbits; + blocks_per_page = bytes_to_blks(inode, PAGE_SIZE); /* * Map all the blocks into the extent list. This code doesn't try @@ -4088,7 +4084,7 @@ static int check_swap_activate(struct swap_info_struct *sis, */ probe_block = 0; page_no = 0; - last_block = i_size_read(inode) >> blkbits; + last_block = bytes_to_blks(inode, i_size_read(inode)); while ((probe_block + blocks_per_page) <= last_block && page_no < sis->max) { unsigned block_in_page; @@ -4128,7 +4124,7 @@ static int check_swap_activate(struct swap_info_struct *sis, } } - first_block >>= (PAGE_SHIFT - blkbits); + first_block >>= (PAGE_SHIFT - inode->i_blkbits); if (page_no) { /* exclude the header page */ if (first_block < lowest_block) lowest_block = first_block; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 3/4] f2fs: remove allow_outplace_dio() 2026-11-11 15:41 ` [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 2/4] f2fs: use new conversion functions between blks and bytes Sasha Levin @ 2026-11-11 15:41 ` Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 4/4] f2fs: fix submit accounting for IPU writeback Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-11-11 15:41 UTC (permalink / raw) To: stable; +Cc: Eric Biggers, Jaegeuk Kim, Sasha Levin From: Eric Biggers <ebiggers@google.com> [ Upstream commit 6de8687ccdefed40d617492f4e1b3962eb577b6b ] We can just check f2fs_lfs_mode() directly. The block_unaligned_IO() check is redundant because in LFS mode, f2fs doesn't do direct I/O writes that aren't block-aligned (due to f2fs_force_buffered_io() returning true in this case, triggering the fallback to buffered I/O). Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback") Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 10 ---------- fs/f2fs/file.c | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index e033c8dfb0348..3f7056f9971f5 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3725,7 +3725,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) if (f2fs_force_buffered_io(inode, iocb, iter)) return 0; - do_opu = allow_outplace_dio(inode, iocb, iter); + do_opu = rw == WRITE && f2fs_lfs_mode(sbi); trace_f2fs_direct_IO_enter(inode, offset, count, rw); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index cead30cab94bc..43f14bbfef49b 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4135,16 +4135,6 @@ static inline int block_unaligned_IO(struct inode *inode, return align & blocksize_mask; } -static inline int allow_outplace_dio(struct inode *inode, - struct kiocb *iocb, struct iov_iter *iter) -{ - struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - int rw = iov_iter_rw(iter); - - return (f2fs_lfs_mode(sbi) && (rw == WRITE) && - !block_unaligned_IO(inode, iocb, iter)); -} - static inline bool f2fs_force_buffered_io(struct inode *inode, struct kiocb *iocb, struct iov_iter *iter) { diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 9c12691ace0b6..f43cc0ba83837 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4250,7 +4250,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) * back to buffered IO. */ if (!f2fs_force_buffered_io(inode, iocb, from) && - allow_outplace_dio(inode, iocb, from)) + f2fs_lfs_mode(F2FS_I_SB(inode))) goto write; } preallocated = true; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 4/4] f2fs: fix submit accounting for IPU writeback 2026-11-11 15:41 ` [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 2/4] f2fs: use new conversion functions between blks and bytes Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 3/4] f2fs: remove allow_outplace_dio() Sasha Levin @ 2026-11-11 15:41 ` Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-11-11 15:41 UTC (permalink / raw) To: stable; +Cc: Seongjae Jeong, stable, Chao Yu, Jaegeuk Kim, Sasha Levin From: Seongjae Jeong <jsjlee1020@gmail.com> [ Upstream commit 6d1f622b9c069378cdb83088be2b15a9b480b8a3 ] f2fs_write_cache_pages() uses the submitted count, which is set to fio.submitted in f2fs_write_single_data_page(), to update nwritten and decrement wbc->nr_to_write. In the OPU path, f2fs_submit_page_write() sets fio->submitted to 1. However, in the IPU path, fio->submitted is never set and remains zero. As a result, successful IPU writes are not accounted for. This can cause asynchronous writeback to continue beyond its budget. Set fio->submitted in f2fs_inplace_write_data() after a page is successfully merged into a bio or submitted, so that successful IPU writes are included in the writeback accounting. Cc: stable@kernel.org Fixes: d68f735b3bc9 ("f2fs: check io submission more precisely") Signed-off-by: Seongjae Jeong <jsjlee1020@gmail.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> [ sashal: Adjusted context to preserve the older device-state and I/O-statistics calls. ] Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/f2fs/segment.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index fec3b4a9e9542..4d759917c2849 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3563,6 +3563,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) else err = f2fs_submit_page_bio(fio); if (!err) { + fio->submitted = 1; update_device_state(fio); f2fs_update_iostat(fio->sbi, fio->io_type, F2FS_BLKSIZE); } -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-11 15:41 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-07 11:25 FAILED: patch "[PATCH] f2fs: fix submit accounting for IPU writeback" failed to apply to 5.10-stable tree Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 1/4] f2fs: rename logical_to_blk and blk_to_logical Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 2/4] f2fs: use new conversion functions between blks and bytes Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 3/4] f2fs: remove allow_outplace_dio() Sasha Levin 2026-11-11 15:41 ` [PATCH 5.10.y 4/4] f2fs: fix submit accounting for IPU writeback Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox