summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2013-06-08 21:25:40 +0900
committerChanho Park <chanho61.park@samsung.com>2014-11-18 11:43:51 +0900
commit3154d7c88c5935d2bb0ed49f85c5ea962722ed04 (patch)
tree8457d0ef23ed271836cff88409f407e29613a5cb
parent34d937cf16a876babd2c932683b9c51d2963c1a2 (diff)
downloadlinux-3.10-3154d7c88c5935d2bb0ed49f85c5ea962722ed04.tar.gz
linux-3.10-3154d7c88c5935d2bb0ed49f85c5ea962722ed04.tar.bz2
linux-3.10-3154d7c88c5935d2bb0ed49f85c5ea962722ed04.zip
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: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 85b665d176a..2f649b84852 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -185,10 +185,10 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
update_extent_cache(NULL_ADDR, dn);
invalidate_blocks(sbi, blkaddr);
- dec_valid_block_count(sbi, dn->inode, 1);
nr_free++;
}
if (nr_free) {
+ dec_valid_block_count(sbi, dn->inode, nr_free);
set_page_dirty(dn->node_page);
sync_inode_page(dn);
}