summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorFan Li <fanofcode.li@samsung.com>2017-10-30 15:19:48 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2017-11-05 16:42:00 -0800
commit37a0ab2a3b58d8b922393717442e1f4d4196282e (patch)
tree8f0338556dbe59fe2b7bb81a569ff761c10b3d83 /fs/f2fs/node.c
parentf15194fcfa6bfcb2a4b8dc49fc8c7af2d952e530 (diff)
downloadlinux-stable-37a0ab2a3b58d8b922393717442e1f4d4196282e.tar.gz
linux-stable-37a0ab2a3b58d8b922393717442e1f4d4196282e.tar.bz2
linux-stable-37a0ab2a3b58d8b922393717442e1f4d4196282e.zip
f2fs: optimize __update_nat_bits
Make three modification for __update_nat_bits: 1. Take the codes of dealing the nat with nid 0 out of the loop Such nat only needs to be dealt with once at beginning. 2. Use " nat_index == 0" instead of " start_nid == 0" to decide if it's the first nat block It's better that we don't assume @start_nid is the first nid of the nat block it's in. 3. Use " if (nat_blk->entries[i].block_addr != NULL_ADDR)" to explicitly comfirm the value of block_addr use constant to make sure the codes is right, even if the value of NULL_ADDR changes. Signed-off-by: Fan li <fanofcode.li@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/node.c')
-rw-r--r--fs/f2fs/node.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index c90e667885f7..a7f6603bfbea 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2421,15 +2421,17 @@ static void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid,
unsigned int nat_index = start_nid / NAT_ENTRY_PER_BLOCK;
struct f2fs_nat_block *nat_blk = page_address(page);
int valid = 0;
- int i;
+ int i = 0;
if (!enabled_nat_bits(sbi, NULL))
return;
- for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) {
- if (start_nid == 0 && i == 0)
- valid++;
- if (nat_blk->entries[i].block_addr)
+ if (nat_index == 0) {
+ valid = 1;
+ i = 1;
+ }
+ for (; i < NAT_ENTRY_PER_BLOCK; i++) {
+ if (nat_blk->entries[i].block_addr != NULL_ADDR)
valid++;
}
if (valid == 0) {