* [f2fs-dev] [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin [not found] <CGME20260116102347epcas1p46ed8360e1a69831f382dcf9d9ee486b0@epcas1p4.samsung.com> @ 2026-01-16 10:23 ` Yeongjin Gil 0 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2026-01-16 10:23 UTC (permalink / raw) To: jaegeuk, chao, jyh429, linux-f2fs-devel, linux-kernel; +Cc: Sungjong Seo When overwriting already allocated blocks, f2fs_iomap_begin() calls f2fs_overwrite_io() to check block mappings. However, f2fs_overwrite_io() iterates through all mapped blocks in the range, which can be inefficient for fragmented files with large I/O requests. This patch optimizes f2fs_overwrite_io() by adding a 'check_first' parameter and introducing __f2fs_overwrite_io() helper. When called from f2fs_iomap_begin(), we only check the first mapping to determine if the range is already allocated, which is sufficient for setting map.m_may_create. This optimization significantly reduces the number of f2fs_map_blocks() calls in f2fs_overwrite_io() when called from f2fs_iomap_begin(), especially for fragmented files with large I/O requests. Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> --- fs/f2fs/data.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2e133a723b99..bfbd717e628a 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) return err; } -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len, + bool check_first) { struct f2fs_map_blocks map; block_t last_lblk; @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) return true; } +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) +{ + return __f2fs_overwrite_io(inode, pos, len, false); +} + static int f2fs_xattr_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo) { @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, * f2fs_map_lock and f2fs_balance_fs are not necessary. */ if ((flags & IOMAP_WRITE) && - !f2fs_overwrite_io(inode, offset, length)) + !__f2fs_overwrite_io(inode, offset, length, true)) map.m_may_create = true; err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); -- 2.43.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin @ 2026-01-16 10:23 ` Yeongjin Gil 0 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2026-01-16 10:23 UTC (permalink / raw) To: jaegeuk, chao, jyh429, linux-f2fs-devel, linux-kernel Cc: Yeongjin Gil, Sungjong Seo, Sunmin Jeong When overwriting already allocated blocks, f2fs_iomap_begin() calls f2fs_overwrite_io() to check block mappings. However, f2fs_overwrite_io() iterates through all mapped blocks in the range, which can be inefficient for fragmented files with large I/O requests. This patch optimizes f2fs_overwrite_io() by adding a 'check_first' parameter and introducing __f2fs_overwrite_io() helper. When called from f2fs_iomap_begin(), we only check the first mapping to determine if the range is already allocated, which is sufficient for setting map.m_may_create. This optimization significantly reduces the number of f2fs_map_blocks() calls in f2fs_overwrite_io() when called from f2fs_iomap_begin(), especially for fragmented files with large I/O requests. Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> --- fs/f2fs/data.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2e133a723b99..bfbd717e628a 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) return err; } -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len, + bool check_first) { struct f2fs_map_blocks map; block_t last_lblk; @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) return true; } +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) +{ + return __f2fs_overwrite_io(inode, pos, len, false); +} + static int f2fs_xattr_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo) { @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, * f2fs_map_lock and f2fs_balance_fs are not necessary. */ if ((flags & IOMAP_WRITE) && - !f2fs_overwrite_io(inode, offset, length)) + !__f2fs_overwrite_io(inode, offset, length, true)) map.m_may_create = true; err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); -- 2.43.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin 2026-01-16 10:23 ` Yeongjin Gil @ 2026-01-22 9:15 ` Chao Yu -1 siblings, 0 replies; 6+ messages in thread From: Chao Yu via Linux-f2fs-devel @ 2026-01-22 9:15 UTC (permalink / raw) To: Yeongjin Gil, jaegeuk, jyh429, linux-f2fs-devel, linux-kernel Cc: Sungjong Seo On 1/16/2026 6:23 PM, Yeongjin Gil wrote: > When overwriting already allocated blocks, f2fs_iomap_begin() calls > f2fs_overwrite_io() to check block mappings. However, > f2fs_overwrite_io() iterates through all mapped blocks in the range, > which can be inefficient for fragmented files with large I/O requests. > > This patch optimizes f2fs_overwrite_io() by adding a 'check_first' > parameter and introducing __f2fs_overwrite_io() helper. When called from > f2fs_iomap_begin(), we only check the first mapping to determine if the > range is already allocated, which is sufficient for setting > map.m_may_create. > > This optimization significantly reduces the number of f2fs_map_blocks() > calls in f2fs_overwrite_io() when called from f2fs_iomap_begin(), > especially for fragmented files with large I/O requests. > > Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") > Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > --- > fs/f2fs/data.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 2e133a723b99..bfbd717e628a 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) > return err; > } > > -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len, > + bool check_first) Yeongjin, You may missed to add logic related to check_first parameter? Thanks, > { > struct f2fs_map_blocks map; > block_t last_lblk; > @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > return true; > } > > +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > +{ > + return __f2fs_overwrite_io(inode, pos, len, false); > +} > + > static int f2fs_xattr_fiemap(struct inode *inode, > struct fiemap_extent_info *fieinfo) > { > @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > * f2fs_map_lock and f2fs_balance_fs are not necessary. > */ > if ((flags & IOMAP_WRITE) && > - !f2fs_overwrite_io(inode, offset, length)) > + !__f2fs_overwrite_io(inode, offset, length, true)) > map.m_may_create = true; > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin @ 2026-01-22 9:15 ` Chao Yu 0 siblings, 0 replies; 6+ messages in thread From: Chao Yu @ 2026-01-22 9:15 UTC (permalink / raw) To: Yeongjin Gil, jaegeuk, jyh429, linux-f2fs-devel, linux-kernel Cc: chao, Sungjong Seo, Sunmin Jeong On 1/16/2026 6:23 PM, Yeongjin Gil wrote: > When overwriting already allocated blocks, f2fs_iomap_begin() calls > f2fs_overwrite_io() to check block mappings. However, > f2fs_overwrite_io() iterates through all mapped blocks in the range, > which can be inefficient for fragmented files with large I/O requests. > > This patch optimizes f2fs_overwrite_io() by adding a 'check_first' > parameter and introducing __f2fs_overwrite_io() helper. When called from > f2fs_iomap_begin(), we only check the first mapping to determine if the > range is already allocated, which is sufficient for setting > map.m_may_create. > > This optimization significantly reduces the number of f2fs_map_blocks() > calls in f2fs_overwrite_io() when called from f2fs_iomap_begin(), > especially for fragmented files with large I/O requests. > > Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") > Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > --- > fs/f2fs/data.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 2e133a723b99..bfbd717e628a 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) > return err; > } > > -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len, > + bool check_first) Yeongjin, You may missed to add logic related to check_first parameter? Thanks, > { > struct f2fs_map_blocks map; > block_t last_lblk; > @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > return true; > } > > +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > +{ > + return __f2fs_overwrite_io(inode, pos, len, false); > +} > + > static int f2fs_xattr_fiemap(struct inode *inode, > struct fiemap_extent_info *fieinfo) > { > @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > * f2fs_map_lock and f2fs_balance_fs are not necessary. > */ > if ((flags & IOMAP_WRITE) && > - !f2fs_overwrite_io(inode, offset, length)) > + !__f2fs_overwrite_io(inode, offset, length, true)) > map.m_may_create = true; > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin 2026-01-22 9:15 ` Chao Yu @ 2026-01-22 10:35 ` Yeongjin Gil -1 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2026-01-22 10:35 UTC (permalink / raw) To: 'Chao Yu', jaegeuk, jyh429, linux-f2fs-devel, linux-kernel Cc: 'Sungjong Seo' > On 1/16/2026 6:23 PM, Yeongjin Gil wrote: > > When overwriting already allocated blocks, f2fs_iomap_begin() calls > > f2fs_overwrite_io() to check block mappings. However, > > f2fs_overwrite_io() iterates through all mapped blocks in the range, > > which can be inefficient for fragmented files with large I/O requests. > > > > This patch optimizes f2fs_overwrite_io() by adding a 'check_first' > > parameter and introducing __f2fs_overwrite_io() helper. When called > > from f2fs_iomap_begin(), we only check the first mapping to determine > > if the range is already allocated, which is sufficient for setting > > map.m_may_create. > > > > This optimization significantly reduces the number of > > f2fs_map_blocks() calls in f2fs_overwrite_io() when called from > > f2fs_iomap_begin(), especially for fragmented files with large I/O > requests. > > > > Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") > > Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > > Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> > > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > > --- > > fs/f2fs/data.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index > > 2e133a723b99..bfbd717e628a 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct > f2fs_map_blocks *map, int flag) > > return err; > > } > > > > -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > > +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t > len, > > + bool check_first) > > Yeongjin, > > You may missed to add logic related to check_first parameter? > > Thanks, I made a mistake. I will resend the v2 patch. Thank you for the review. > > > { > > struct f2fs_map_blocks map; > > block_t last_lblk; > > @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, > loff_t pos, size_t len) > > return true; > > } > > > > +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) { > > + return __f2fs_overwrite_io(inode, pos, len, false); } > > + > > static int f2fs_xattr_fiemap(struct inode *inode, > > struct fiemap_extent_info *fieinfo) > > { > > @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, > loff_t offset, loff_t length, > > * f2fs_map_lock and f2fs_balance_fs are not necessary. > > */ > > if ((flags & IOMAP_WRITE) && > > - !f2fs_overwrite_io(inode, offset, length)) > > + !__f2fs_overwrite_io(inode, offset, length, true)) > > map.m_may_create = true; > > > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin @ 2026-01-22 10:35 ` Yeongjin Gil 0 siblings, 0 replies; 6+ messages in thread From: Yeongjin Gil @ 2026-01-22 10:35 UTC (permalink / raw) To: 'Chao Yu', jaegeuk, jyh429, linux-f2fs-devel, linux-kernel Cc: 'Sungjong Seo', 'Sunmin Jeong', 'Yeongjin Gil' > On 1/16/2026 6:23 PM, Yeongjin Gil wrote: > > When overwriting already allocated blocks, f2fs_iomap_begin() calls > > f2fs_overwrite_io() to check block mappings. However, > > f2fs_overwrite_io() iterates through all mapped blocks in the range, > > which can be inefficient for fragmented files with large I/O requests. > > > > This patch optimizes f2fs_overwrite_io() by adding a 'check_first' > > parameter and introducing __f2fs_overwrite_io() helper. When called > > from f2fs_iomap_begin(), we only check the first mapping to determine > > if the range is already allocated, which is sufficient for setting > > map.m_may_create. > > > > This optimization significantly reduces the number of > > f2fs_map_blocks() calls in f2fs_overwrite_io() when called from > > f2fs_iomap_begin(), especially for fragmented files with large I/O > requests. > > > > Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") > > Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > > Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> > > Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> > > --- > > fs/f2fs/data.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index > > 2e133a723b99..bfbd717e628a 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct > f2fs_map_blocks *map, int flag) > > return err; > > } > > > > -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > > +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t > len, > > + bool check_first) > > Yeongjin, > > You may missed to add logic related to check_first parameter? > > Thanks, I made a mistake. I will resend the v2 patch. Thank you for the review. > > > { > > struct f2fs_map_blocks map; > > block_t last_lblk; > > @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, > loff_t pos, size_t len) > > return true; > > } > > > > +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) { > > + return __f2fs_overwrite_io(inode, pos, len, false); } > > + > > static int f2fs_xattr_fiemap(struct inode *inode, > > struct fiemap_extent_info *fieinfo) > > { > > @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, > loff_t offset, loff_t length, > > * f2fs_map_lock and f2fs_balance_fs are not necessary. > > */ > > if ((flags & IOMAP_WRITE) && > > - !f2fs_overwrite_io(inode, offset, length)) > > + !__f2fs_overwrite_io(inode, offset, length, true)) > > map.m_may_create = true; > > > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO); ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-22 10:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20260116102347epcas1p46ed8360e1a69831f382dcf9d9ee486b0@epcas1p4.samsung.com>
2026-01-16 10:23 ` [f2fs-dev] [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin Yeongjin Gil
2026-01-16 10:23 ` Yeongjin Gil
2026-01-22 9:15 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2026-01-22 9:15 ` Chao Yu
2026-01-22 10:35 ` [f2fs-dev] " Yeongjin Gil
2026-01-22 10:35 ` Yeongjin Gil
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.