f2fs: simplify the way of calulating next nat address
authorFan Li <fanofcode.li@samsung.com>
Fri, 2 Jun 2017 07:45:42 +0000 (15:45 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 4 Jul 2017 09:11:34 +0000 (02:11 -0700)
The index of segment which the next nat block is in has only one different
bit than the current one, so to get the next nat address, we can simply
alter that one bit.

Signed-off-by: Fan Li <fanofcode.li@samsung.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.h

index 558048e33cf9a6c1920f03673a98409c34325f4c..bb53e9955ff2ab8456dd75c0d83ebdf9e6ef3b55 100644 (file)
@@ -224,11 +224,7 @@ static inline pgoff_t next_nat_addr(struct f2fs_sb_info *sbi,
        struct f2fs_nm_info *nm_i = NM_I(sbi);
 
        block_addr -= nm_i->nat_blkaddr;
-       if ((block_addr >> sbi->log_blocks_per_seg) % 2)
-               block_addr -= sbi->blocks_per_seg;
-       else
-               block_addr += sbi->blocks_per_seg;
-
+       block_addr ^= 1 << sbi->log_blocks_per_seg;
        return block_addr + nm_i->nat_blkaddr;
 }