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

Commit 313b8a28 authored by Fan Li's avatar Fan Li Committed by Jaegeuk Kim
Browse files

f2fs: simplify the way of calulating next nat address



commit 72fdbe2efe3e42a54e268d2ee2a8c0828d3996e7 upstream.

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: default avatarFan Li <fanofcode.li@samsung.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 08c075fa
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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;
}