FAILED: patch "[PATCH] f2fs: fix submit accounting for IPU writeback" failed to apply to 5.10-stable tree
Subsystems (2)
Sasha Levin
maintainerThe 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 <[email protected]>.
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 '<[email protected]>' --in-reply-to '[email protected]' --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 <[email protected]>
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.
--- fs/f2fs/segment.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/segment.c +1 -0
@@ -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),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/4 f2fs: rename logical_to_blk and blk_to_logical
From: Jaegeuk Kim <[email protected]>
[ 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
Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback")
--- fs/f2fs/data.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
fs/f2fs/data.c +20 -20
@@ -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;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 f2fs: use new conversion functions between blks and bytes
From: Jaegeuk Kim <[email protected]>
[ Upstream commit 43b9d4b4d91c02ca1159507d46e3687d98b4cb8f ]
This patch cleans up blks and bytes conversions.
Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback")
--- fs/f2fs/data.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-)
fs/f2fs/data.c +21 -25
@@ -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;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 f2fs: remove allow_outplace_dio()
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
[ 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).
Stable-dep-of: 6d1f622b9c06 ("f2fs: fix submit accounting for IPU writeback")
--- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 10 ---------- fs/f2fs/file.c | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-)
fs/f2fs/data.c +1 -1
@@ -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);
fs/f2fs/f2fs.h +0 -10
@@ -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) {
fs/f2fs/file.c +1 -1
@@ -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;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 f2fs: fix submit accounting for IPU writeback
In reply to Sasha LevinFrom: Seongjae Jeong <[email protected]>
[ 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.
--- fs/f2fs/segment.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/segment.c +1 -0
@@ -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 ); }
Signature · 1 line
2.53.0