summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorFan Li <fanofcode.li@samsung.com>2017-03-08 13:39:16 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2017-03-21 22:34:27 -0400
commit8a6aa32502549b1f15f0a28e3d2fcc5edabc3f19 (patch)
tree04c60f06bb57e2282da0239973ec3aaf5001805f /fs/f2fs
parent14b44d238ce7402a99db30b806e08b3e4eddcdbe (diff)
downloadlinux-8a6aa32502549b1f15f0a28e3d2fcc5edabc3f19.tar.gz
linux-8a6aa32502549b1f15f0a28e3d2fcc5edabc3f19.tar.bz2
linux-8a6aa32502549b1f15f0a28e3d2fcc5edabc3f19.zip
f2fs: adjust the way of calculating nat block
use a slightly simpler expression to calculate nat block with nid. Signed-off-by: Fan Li <fanofcode.li@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/node.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 2f9603fa85a5..ebed0240aa53 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -200,13 +200,16 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
struct f2fs_nm_info *nm_i = NM_I(sbi);
pgoff_t block_off;
pgoff_t block_addr;
- int seg_off;
+ /*
+ * block_off = segment_off * 512 + off_in_segment
+ * OLD = (segment_off * 512) * 2 + off_in_segment
+ * NEW = 2 * (segment_off * 512 + off_in_segment) - off_in_segment
+ */
block_off = NAT_BLOCK_OFFSET(start);
- seg_off = block_off >> sbi->log_blocks_per_seg;
block_addr = (pgoff_t)(nm_i->nat_blkaddr +
- (seg_off << sbi->log_blocks_per_seg << 1) +
+ (block_off << 1) -
(block_off & (sbi->blocks_per_seg - 1)));
if (f2fs_test_bit(block_off, nm_i->nat_bitmap))