Skip to content

Commit

Permalink
f2fs: introduce map_is_mergeable() for cleanup
Browse files Browse the repository at this point in the history
No logic changes.

Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
chaseyu authored and Jaegeuk Kim committed Apr 2, 2024
1 parent fe6868f commit 44e253e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,22 @@ static bool f2fs_map_blocks_cached(struct inode *inode,
return true;
}

static bool map_is_mergeable(struct f2fs_sb_info *sbi,
struct f2fs_map_blocks *map,
block_t blkaddr, int flag, int bidx,
int ofs)
{
if (map->m_multidev_dio && map->m_bdev != FDEV(bidx).bdev)
return false;
if (map->m_pblk != NEW_ADDR && blkaddr == (map->m_pblk + ofs))
return true;
if (map->m_pblk == NEW_ADDR && blkaddr == NEW_ADDR)
return true;
if (flag == F2FS_GET_BLOCK_PRE_DIO)
return true;
return false;
}

/*
* f2fs_map_blocks() tries to find or build mapping relationship which
* maps continuous logical blocks to physical blocks, and return such
Expand Down Expand Up @@ -1653,12 +1669,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)

if (map->m_multidev_dio)
map->m_bdev = FDEV(bidx).bdev;
} else if ((map->m_pblk != NEW_ADDR &&
blkaddr == (map->m_pblk + ofs)) ||
(map->m_pblk == NEW_ADDR && blkaddr == NEW_ADDR) ||
flag == F2FS_GET_BLOCK_PRE_DIO) {
if (map->m_multidev_dio && map->m_bdev != FDEV(bidx).bdev)
goto sync_out;
} else if (map_is_mergeable(sbi, map, blkaddr, flag, bidx, ofs)) {
ofs++;
map->m_len++;
} else {
Expand Down

0 comments on commit 44e253e

Please sign in to comment.