f2fs: simplify the way of calulating next nat address
A message that is not in the archive (sent off-list or not yet received): CGME20170602074702epcas5p2afcfc8a3bb05e1916f6d93abe1958a5a@epcas5p2.samsung.com
PATCH 1/1 f2fs: simplify the way of calulating next nat address
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.
--- fs/f2fs/node.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/f2fs/node.h +1 -4
@@ -224,10 +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; }
--
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 5 lines · Fan Li
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 <[email protected]>
Thanks,
Quoted 24 lines
--- fs/f2fs/node.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/f2fs/node.h +1
-5@@ -224,10 +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; } --2.7.4
Quoted 8 lines
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot