Skip to content

Commit 0638a31

Browse files
Daejun7ParkJaegeuk Kim
authored andcommitted
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 <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent bfe5c02 commit 0638a31

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/f2fs/data.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,14 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
17121712
dn.ofs_in_node = end_offset;
17131713
}
17141714

1715+
if (flag == F2FS_GET_BLOCK_DIO && f2fs_lfs_mode(sbi) &&
1716+
map->m_may_create) {
1717+
/* the next block to be allocated may not be contiguous. */
1718+
if (GET_SEGOFF_FROM_SEG0(sbi, blkaddr) % BLKS_PER_SEC(sbi) ==
1719+
CAP_BLKS_PER_SEC(sbi) - 1)
1720+
goto sync_out;
1721+
}
1722+
17151723
if (pgofs >= end)
17161724
goto sync_out;
17171725
else if (dn.ofs_in_node < end_offset)

0 commit comments

Comments
 (0)