summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorDaejun Park <daejun7.park@samsung.com>2024-09-05 14:24:33 +0900
committerJaegeuk Kim <jaegeuk@kernel.org>2024-09-11 03:30:27 +0000
commit0638a3197c194bed837c157c3574685e36febc7b (patch)
tree6c772d7a3d7df2c2687d60506c97cf74a4ac31c3 /fs/f2fs
parentbfe5c02654261bfb8bd9cb174a67f3279ea99e58 (diff)
downloadlwn-0638a3197c194bed837c157c3574685e36febc7b.tar.gz
lwn-0638a3197c194bed837c157c3574685e36febc7b.zip
f2fs: avoid unused block when dio write in LFS mode
This patch addresses the problem that when using LFS mode, unused blocks may occur in f2fs_map_blocks() during block allocation for dio writes. If a new section is allocated during block allocation, it will not be included in the map struct by map_is_mergeable() if the LBA of the allocated block is not contiguous. However, the block already allocated in this process will remain unused due to the LFS mode. This patch avoids the possibility of unused blocks by escaping f2fs_map_blocks() when allocating the last block in a section. Signed-off-by: Daejun Park <daejun7.park@samsung.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c6d688208f8b..b94cf6eea2f9 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1712,6 +1712,14 @@ skip:
dn.ofs_in_node = end_offset;
}
+ if (flag == F2FS_GET_BLOCK_DIO && f2fs_lfs_mode(sbi) &&
+ map->m_may_create) {
+ /* the next block to be allocated may not be contiguous. */
+ if (GET_SEGOFF_FROM_SEG0(sbi, blkaddr) % BLKS_PER_SEC(sbi) ==
+ CAP_BLKS_PER_SEC(sbi) - 1)
+ goto sync_out;
+ }
+
if (pgofs >= end)
goto sync_out;
else if (dn.ofs_in_node < end_offset)