Commit d860974
f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin
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.
Cc: stable@kernel.org
Fixes: 351bc76 ("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>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>1 parent 91b76f1 commit d860974
1 file changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1865 | 1865 | | |
1866 | 1866 | | |
1867 | 1867 | | |
1868 | | - | |
| 1868 | + | |
| 1869 | + | |
1869 | 1870 | | |
1870 | 1871 | | |
1871 | 1872 | | |
| |||
1887 | 1888 | | |
1888 | 1889 | | |
1889 | 1890 | | |
| 1891 | + | |
| 1892 | + | |
1890 | 1893 | | |
1891 | 1894 | | |
1892 | 1895 | | |
1893 | 1896 | | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
1894 | 1902 | | |
1895 | 1903 | | |
1896 | 1904 | | |
| |||
4487 | 4495 | | |
4488 | 4496 | | |
4489 | 4497 | | |
4490 | | - | |
| 4498 | + | |
4491 | 4499 | | |
4492 | 4500 | | |
4493 | 4501 | | |
| |||
0 commit comments