Commit d7cc950b authored by Namjae Jeon's avatar Namjae Jeon Committed by Jaegeuk Kim
Browse files

f2fs: optimise the truncate_data_blocks_range() range



The function truncate_data_blocks_range() decrements the valid
block count of inode via dec_valid_block_count(). Since this
function updates the i_blocks field of inode, we can update this
field once we have calculated total the number of blocks
to be freed.

Therefore we can decrement valid blocks outside of the for loop.

	if (nr_free) {
+		dec_valid_block_count(sbi, dn->inode, nr_free);
 		set_page_dirty(dn->node_page);
 		sync_inode_page(dn);
 	}

'nr_free' tells the total number of blocks freed. So, we can
just directly pass this value to dec_valid_block_count() and update
the i_blocks.
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: default avatarPankaj Kumar <pankaj.km@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent 6a3e8ef0
...@@ -185,10 +185,10 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count) ...@@ -185,10 +185,10 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
update_extent_cache(NULL_ADDR, dn); update_extent_cache(NULL_ADDR, dn);
invalidate_blocks(sbi, blkaddr); invalidate_blocks(sbi, blkaddr);
dec_valid_block_count(sbi, dn->inode, 1);
nr_free++; nr_free++;
} }
if (nr_free) { if (nr_free) {
dec_valid_block_count(sbi, dn->inode, nr_free);
set_page_dirty(dn->node_page); set_page_dirty(dn->node_page);
sync_inode_page(dn); sync_inode_page(dn);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment