Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7df3a431 authored by Fan Li's avatar Fan Li Committed by Jaegeuk Kim
Browse files

f2fs: optimize the flow of f2fs_map_blocks



check map->m_len right after it changes to avoid excess call
to update dnode_of_data.

Signed-off-by: default avatarFan li <fanofcode.li@samsung.com>
Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 36b35a0d
Loading
Loading
Loading
Loading
+36 −33
Original line number Diff line number Diff line
@@ -573,6 +573,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
	int err = 0, ofs = 1;
	struct extent_info ei;
	bool allocated = false;
	block_t blkaddr;

	map->m_len = 0;
	map->m_flags = 0;
@@ -636,6 +637,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
	pgofs++;

get_next:
	if (map->m_len >= maxblocks)
		goto sync_out;

	if (dn.ofs_in_node >= end_offset) {
		if (allocated)
			sync_inode_page(&dn);
@@ -653,8 +657,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
		end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
	}

	if (maxblocks > map->m_len) {
		block_t blkaddr = datablock_addr(dn.node_page, dn.ofs_in_node);
	blkaddr = datablock_addr(dn.node_page, dn.ofs_in_node);

	if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR) {
		if (create) {
@@ -690,7 +693,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
		map->m_len++;
		goto get_next;
	}
	}

sync_out:
	if (allocated)
		sync_inode_page(&dn);