linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level
@ 2016-07-15 12:01 Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 2/7] f2fs.fsck: fix endianess Sheng Yong
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/mount.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index e0223e0..3e3d176 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -70,6 +70,7 @@ void print_inode_info(struct f2fs_inode *inode, int name)
 	DISP_u32(inode, i_flags);
 	DISP_u32(inode, i_inline);
 	DISP_u32(inode, i_pino);
+	DISP_u32(inode, i_dir_level);
 
 	if (namelen) {
 		DISP_u32(inode, i_namelen);
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 2/7] f2fs.fsck: fix endianess
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 3/7] fsck.f2fs: correct variable type and name Sheng Yong
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/fsck.c  | 2 +-
 fsck/mount.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index c24eb58..8a6373b 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -383,7 +383,7 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
 				le32_to_cpu(node_blk->footer.ino));
 		return -EINVAL;
 	}
-	if (ni->ino != node_blk->footer.ino) {
+	if (ni->ino != le32_to_cpu(node_blk->footer.ino)) {
 		ASSERT_MSG("nid[0x%x] nat_entry->ino[0x%x] footer.ino[0x%x]",
 				nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
 		return -EINVAL;
diff --git a/fsck/mount.c b/fsck/mount.c
index 3e3d176..f3b47fd 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -79,9 +79,9 @@ void print_inode_info(struct f2fs_inode *inode, int name)
 	}
 
 	printf("i_ext: fofs:%x blkaddr:%x len:%x\n",
-			inode->i_ext.fofs,
-			inode->i_ext.blk_addr,
-			inode->i_ext.len);
+			le32_to_cpu(inode->i_ext.fofs),
+			le32_to_cpu(inode->i_ext.blk_addr),
+			le32_to_cpu(inode->i_ext.len));
 
 	DISP_u32(inode, i_addr[0]);	/* Pointers to data blocks */
 	DISP_u32(inode, i_addr[1]);	/* Pointers to data blocks */
@@ -91,7 +91,7 @@ void print_inode_info(struct f2fs_inode *inode, int name)
 	for (i = 4; i < ADDRS_PER_INODE(inode); i++) {
 		if (inode->i_addr[i] != 0x0) {
 			printf("i_addr[0x%x] points data block\r\t\t[0x%4x]\n",
-					i, inode->i_addr[i]);
+					i, le32_to_cpu(inode->i_addr[i]));
 			break;
 		}
 	}
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 3/7] fsck.f2fs: correct variable type and name
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 2/7] f2fs.fsck: fix endianess Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 4/7] fsck.f2fs: fix typo Sheng Yong
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/fsck.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 8a6373b..f349bd8 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -736,7 +736,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 
 	/* check node blocks in inode */
 	for (idx = 0; idx < 5; idx++) {
-		block_t blkaddr = le32_to_cpu(node_blk->i.i_nid[idx]);
+		nid_t i_nid = le32_to_cpu(node_blk->i.i_nid[idx]);
 
 		if (idx == 0 || idx == 1)
 			ntype = TYPE_DIRECT_NODE;
@@ -747,11 +747,10 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		else
 			ASSERT(0);
 
-		if (blkaddr == 0x0)
+		if (i_nid == 0x0)
 			goto skip;
 
-		ret = fsck_chk_node_blk(sbi, &node_blk->i,
-				blkaddr,
+		ret = fsck_chk_node_blk(sbi, &node_blk->i, i_nid,
 				NULL, ftype, ntype, blk_cnt, &child);
 		if (!ret) {
 			*blk_cnt = *blk_cnt + 1;
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 4/7] fsck.f2fs: fix typo
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 2/7] f2fs.fsck: fix endianess Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 3/7] fsck.f2fs: correct variable type and name Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 5/7] fsck.f2fs: free nat entry cache Sheng Yong
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/fsck.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index f349bd8..33e8cf7 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -369,7 +369,7 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
 	}
 
 	if (!IS_VALID_BLK_ADDR(sbi, ni->blk_addr)) {
-		ASSERT_MSG("blkaddres is not valid. [0x%x]", ni->blk_addr);
+		ASSERT_MSG("blkaddress is not valid. [0x%x]", ni->blk_addr);
 		return -EINVAL;
 	}
 
@@ -1431,7 +1431,7 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
 	}
 
 	if (!IS_VALID_BLK_ADDR(sbi, blk_addr)) {
-		ASSERT_MSG("blkaddres is not valid. [0x%x]", blk_addr);
+		ASSERT_MSG("blkaddress is not valid. [0x%x]", blk_addr);
 		return -EINVAL;
 	}
 
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 5/7] fsck.f2fs: free nat entry cache
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
                   ` (2 preceding siblings ...)
  2016-07-15 12:01 ` [PATCH trivial 4/7] fsck.f2fs: fix typo Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 6/7] f2fs-tools: update the format of output message Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 7/7] fsck.f2fs: clean up duplicated code Sheng Yong
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/fsck.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 33e8cf7..d2248c6 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1953,6 +1953,9 @@ void fsck_free(struct f2fs_sb_info *sbi)
 	if (fsck->sit_area_bitmap)
 		free(fsck->sit_area_bitmap);
 
+	if (fsck->entries)
+		free(fsck->entries);
+
 	if (tree_mark)
 		free(tree_mark);
 }
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 6/7] f2fs-tools: update the format of output message
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
                   ` (3 preceding siblings ...)
  2016-07-15 12:01 ` [PATCH trivial 5/7] fsck.f2fs: free nat entry cache Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  2016-07-15 12:01 ` [PATCH trivial 7/7] fsck.f2fs: clean up duplicated code Sheng Yong
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fsck/mount.c            |  4 ++--
 fsck/resize.c           |  4 ++--
 mkfs/f2fs_format.c      | 28 ++++++++++++++--------------
 mkfs/f2fs_format_main.c |  4 ++--
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index f3b47fd..7af684f 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1948,8 +1948,8 @@ static int check_sector_size(struct f2fs_super_block *sb)
 	DBG(1, "\tWriting super block, at offset 0x%08x\n", 0);
 	for (index = 0; index < 2; index++) {
 		if (dev_write(zero_buff, index * F2FS_BLKSIZE, F2FS_BLKSIZE)) {
-			MSG(1, "\tError: While while writing supe_blk \
-				on disk!!! index : %d\n", index);
+			MSG(1, "\tError: While while writing supe_blk "
+				"on disk!!! index : %d\n", index);
 			free(zero_buff);
 			return -1;
 		}
diff --git a/fsck/resize.c b/fsck/resize.c
index d2fd467..b53a6fa 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -123,8 +123,8 @@ static int get_new_sb(struct f2fs_sb_info *sbi, struct f2fs_super_block *sb)
 	if ((get_sb(segment_count_main) - 2) < config.new_reserved_segments ||
 		get_sb(segment_count_main) * blks_per_seg >
 						get_sb(block_count)) {
-		MSG(0, "\tError: Device size is not sufficient for F2FS volume,\
-			more segment needed =%u",
+		MSG(0, "\tError: Device size is not sufficient for F2FS volume, "
+			"more segment needed =%u",
 			config.new_reserved_segments -
 			(get_sb(segment_count_main) - 2));
 		return -1;
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 3173c30..6b1318a 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -284,8 +284,8 @@ static int f2fs_prepare_super_block(void)
 
 	if ((get_sb(segment_count_main) - 2) <
 					config.reserved_segments) {
-		MSG(1, "\tError: Device size is not sufficient for F2FS volume,\
-			more segment needed =%u",
+		MSG(1, "\tError: Device size is not sufficient for F2FS volume, "
+			"more segment needed =%u",
 			config.reserved_segments -
 			(get_sb(segment_count_main) - 2));
 		return -1;
@@ -300,8 +300,8 @@ static int f2fs_prepare_super_block(void)
 	set_sb(root_ino, 3);
 
 	if (total_zones <= 6) {
-		MSG(1, "\tError: %d zones: Need more zones \
-			by shrinking zone size\n", total_zones);
+		MSG(1, "\tError: %d zones: Need more zones "
+			"by shrinking zone size\n", total_zones);
 		return -1;
 	}
 
@@ -362,8 +362,8 @@ static int f2fs_init_sit_area(void)
 	DBG(1, "\tFilling sit area at offset 0x%08"PRIx64"\n", sit_seg_addr);
 	for (index = 0; index < (get_sb(segment_count_sit) / 2); index++) {
 		if (dev_fill(zero_buf, sit_seg_addr, seg_size)) {
-			MSG(1, "\tError: While zeroing out the sit area \
-					on disk!!!\n");
+			MSG(1, "\tError: While zeroing out the sit area "
+					"on disk!!!\n");
 			free(zero_buf);
 			return -1;
 		}
@@ -396,8 +396,8 @@ static int f2fs_init_nat_area(void)
 	DBG(1, "\tFilling nat area at offset 0x%08"PRIx64"\n", nat_seg_addr);
 	for (index = 0; index < get_sb(segment_count_nat) / 2; index++) {
 		if (dev_fill(nat_buf, nat_seg_addr, seg_size)) {
-			MSG(1, "\tError: While zeroing out the nat area \
-					on disk!!!\n");
+			MSG(1, "\tError: While zeroing out the nat area "
+					"on disk!!!\n");
 			free(nat_buf);
 			return -1;
 		}
@@ -510,8 +510,8 @@ static int f2fs_write_check_point_pack(void)
 	for (i = 0; i < get_sb(cp_payload); i++) {
 		cp_seg_blk_offset += blk_size_bytes;
 		if (dev_fill(cp_payload, cp_seg_blk_offset, blk_size_bytes)) {
-			MSG(1, "\tError: While zeroing out the sit bitmap area \
-					on disk!!!\n");
+			MSG(1, "\tError: While zeroing out the sit bitmap area "
+					"on disk!!!\n");
 			goto free_cp_payload;
 		}
 	}
@@ -650,8 +650,8 @@ static int f2fs_write_check_point_pack(void)
 	for (i = 0; i < get_sb(cp_payload); i++) {
 		cp_seg_blk_offset += blk_size_bytes;
 		if (dev_fill(cp_payload, cp_seg_blk_offset, blk_size_bytes)) {
-			MSG(1, "\tError: While zeroing out the sit bitmap area \
-					on disk!!!\n");
+			MSG(1, "\tError: While zeroing out the sit bitmap area "
+					"on disk!!!\n");
 			goto free_cp_payload;
 		}
 	}
@@ -689,8 +689,8 @@ static int f2fs_write_super_block(void)
 	DBG(1, "\tWriting super block, at offset 0x%08x\n", 0);
 	for (index = 0; index < 2; index++) {
 		if (dev_write(zero_buff, index * F2FS_BLKSIZE, F2FS_BLKSIZE)) {
-			MSG(1, "\tError: While while writing supe_blk \
-					on disk!!! index : %d\n", index);
+			MSG(1, "\tError: While while writing supe_blk "
+					"on disk!!! index : %d\n", index);
 			free(zero_buff);
 			return -1;
 		}
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index f69d03f..94a7286 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -93,8 +93,8 @@ static void f2fs_parse_options(int argc, char *argv[])
 			break;
 		case 'l':		/*v: volume label */
 			if (strlen(optarg) > 512) {
-				MSG(0, "Error: Volume Label should be less than\
-						512 characters\n");
+				MSG(0, "Error: Volume Label should be less than "
+						"512 characters\n");
 				mkfs_usage();
 			}
 			config.vol_label = optarg;
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH trivial 7/7] fsck.f2fs: clean up duplicated code
  2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
                   ` (4 preceding siblings ...)
  2016-07-15 12:01 ` [PATCH trivial 6/7] f2fs-tools: update the format of output message Sheng Yong
@ 2016-07-15 12:01 ` Sheng Yong
  5 siblings, 0 replies; 7+ messages in thread
From: Sheng Yong @ 2016-07-15 12:01 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel

From: Xue Liu <liuxueliu.liu@huawei.com>

From: Xue Liu <liuxueliu.liu@huawei.com>

Call current_nat_addr() to calculate nat block address.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
---
 fsck/mount.c | 56 ++++++++------------------------------------------------
 1 file changed, 8 insertions(+), 48 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 7af684f..3be60bb 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1168,11 +1168,9 @@ int get_sum_entry(struct f2fs_sb_info *sbi, u32 blk_addr,
 static void get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
 				struct f2fs_nat_entry *raw_nat)
 {
-	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct f2fs_nat_block *nat_block;
-	pgoff_t block_off;
 	pgoff_t block_addr;
-	int seg_off, entry_off;
+	int entry_off;
 	int ret;
 
 	if (lookup_nat_in_journal(sbi, nid, raw_nat) >= 0)
@@ -1180,16 +1178,8 @@ static void get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
 
 	nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
 
-	block_off = nid / NAT_ENTRY_PER_BLOCK;
 	entry_off = nid % NAT_ENTRY_PER_BLOCK;
-
-	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 << sbi->log_blocks_per_seg) - 1)));
-
-	if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
-		block_addr += sbi->blocks_per_seg;
+	block_addr = current_nat_addr(sbi, nid);
 
 	ret = dev_read_block(nat_block, block_addr);
 	ASSERT(ret >= 0);
@@ -1252,25 +1242,15 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
 void update_nat_blkaddr(struct f2fs_sb_info *sbi, nid_t ino,
 					nid_t nid, block_t newaddr)
 {
-	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct f2fs_nat_block *nat_block;
-	pgoff_t block_off;
 	pgoff_t block_addr;
-	int seg_off, entry_off;
+	int entry_off;
 	int ret;
 
 	nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
 
-	block_off = nid / NAT_ENTRY_PER_BLOCK;
 	entry_off = nid % NAT_ENTRY_PER_BLOCK;
-
-	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 << sbi->log_blocks_per_seg) - 1)));
-
-	if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
-		block_addr += sbi->blocks_per_seg;
+	block_addr = current_nat_addr(sbi, nid);
 
 	ret = dev_read_block(nat_block, block_addr);
 	ASSERT(ret >= 0);
@@ -1486,11 +1466,9 @@ static void flush_nat_journal_entries(struct f2fs_sb_info *sbi)
 {
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
 	struct f2fs_journal *journal = &curseg->sum_blk->journal;
-	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct f2fs_nat_block *nat_block;
-	pgoff_t block_off;
 	pgoff_t block_addr;
-	int seg_off, entry_off;
+	int entry_off;
 	nid_t nid;
 	int ret;
 	int i = 0;
@@ -1504,16 +1482,8 @@ next:
 	nid = le32_to_cpu(nid_in_journal(journal, i));
 	nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
 
-	block_off = nid / NAT_ENTRY_PER_BLOCK;
 	entry_off = nid % NAT_ENTRY_PER_BLOCK;
-
-	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 << sbi->log_blocks_per_seg) - 1)));
-
-	if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
-		block_addr += sbi->blocks_per_seg;
+	block_addr = current_nat_addr(sbi, nid);
 
 	ret = dev_read_block(nat_block, block_addr);
 	ASSERT(ret >= 0);
@@ -1704,11 +1674,9 @@ void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid)
 {
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
 	struct f2fs_journal *journal = &curseg->sum_blk->journal;
-	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct f2fs_nat_block *nat_block;
-	pgoff_t block_off;
 	pgoff_t block_addr;
-	int seg_off, entry_off;
+	int entry_off;
 	int ret;
 	int i = 0;
 
@@ -1723,16 +1691,8 @@ void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid)
 	}
 	nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
 
-	block_off = nid / NAT_ENTRY_PER_BLOCK;
 	entry_off = nid % NAT_ENTRY_PER_BLOCK;
-
-	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 << sbi->log_blocks_per_seg) - 1)));
-
-	if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
-		block_addr += sbi->blocks_per_seg;
+	block_addr = current_nat_addr(sbi, nid);
 
 	ret = dev_read_block(nat_block, block_addr);
 	ASSERT(ret >= 0);
-- 
2.7.1


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-15 12:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-15 12:01 [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 2/7] f2fs.fsck: fix endianess Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 3/7] fsck.f2fs: correct variable type and name Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 4/7] fsck.f2fs: fix typo Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 5/7] fsck.f2fs: free nat entry cache Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 6/7] f2fs-tools: update the format of output message Sheng Yong
2016-07-15 12:01 ` [PATCH trivial 7/7] fsck.f2fs: clean up duplicated code Sheng Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).