linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] dump.f2fs: check block is valid or not before dump block info
@ 2017-08-22 10:51 Yunlei He
  2017-08-24 13:32 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Yunlei He @ 2017-08-22 10:51 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: heyunlei, morgan.wang

This patch add a block validate check in dump.f2fs

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fsck/dump.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 22e2265..a33969c 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -507,6 +507,9 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
 	int type;
 	struct f2fs_summary sum_entry;
 	struct node_info ni, ino_ni;
+	struct seg_entry * seg;
+	unsigned int segno;
+	u32 offset;
 	int ret = 0;
 
 	MSG(0, "\n== Dump data from block address ==\n\n");
@@ -538,6 +541,16 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
 		return ret;
 	}
 
+	segno = GET_SEGNO(sbi, blk_addr);
+	offset = OFFSET_IN_SEG(sbi, blk_addr);
+	seg = get_seg_entry(sbi, segno);
+	if (f2fs_test_bit(offset, (const char *)seg->cur_valid_map)) {
+		MSG(0, "\nblk_addr: 0x%x is valid block\n", blk_addr);
+	} else {
+		MSG(0, "\nblk_addr: 0x%x is not valid block\n", blk_addr);
+		return ret;
+	}
+
 	type = get_sum_entry(sbi, blk_addr, &sum_entry);
 	nid = le32_to_cpu(sum_entry.nid);
 
@@ -545,8 +558,8 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
 
 	DBG(1, "Note: blkaddr = main_blkaddr + segno * 512 + offset\n");
 	DBG(1, "Block_addr            [0x%x]\n", blk_addr);
-	DBG(1, " - Segno              [0x%x]\n", GET_SEGNO(sbi, blk_addr));
-	DBG(1, " - Offset             [0x%x]\n", OFFSET_IN_SEG(sbi, blk_addr));
+	DBG(1, " - Segno              [0x%x]\n", segno);
+	DBG(1, " - Offset             [0x%x]\n", offset);
 	DBG(1, "SUM.nid               [0x%x]\n", nid);
 	DBG(1, "SUM.type              [%s]\n", type >= 0 ?
 						seg_type_name[type] :
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH] dump.f2fs: check block is valid or not before dump block info
  2017-08-22 10:51 [PATCH] dump.f2fs: check block is valid or not before dump block info Yunlei He
@ 2017-08-24 13:32 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2017-08-24 13:32 UTC (permalink / raw)
  To: Yunlei He, jaegeuk, yuchao0, linux-f2fs-devel; +Cc: morgan.wang

On 2017/8/22 18:51, Yunlei He wrote:
> This patch add a block validate check in dump.f2fs
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fsck/dump.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/fsck/dump.c b/fsck/dump.c
> index 22e2265..a33969c 100644
> --- a/fsck/dump.c
> +++ b/fsck/dump.c
> @@ -507,6 +507,9 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
>  	int type;
>  	struct f2fs_summary sum_entry;
>  	struct node_info ni, ino_ni;
> +	struct seg_entry * seg;
> +	unsigned int segno;
> +	u32 offset;
>  	int ret = 0;
>  
>  	MSG(0, "\n== Dump data from block address ==\n\n");
> @@ -538,6 +541,16 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
>  		return ret;
>  	}
>  
> +	segno = GET_SEGNO(sbi, blk_addr);
> +	offset = OFFSET_IN_SEG(sbi, blk_addr);
> +	seg = get_seg_entry(sbi, segno);
> +	if (f2fs_test_bit(offset, (const char *)seg->cur_valid_map)) {
> +		MSG(0, "\nblk_addr: 0x%x is valid block\n", blk_addr);

We don't need to print such info which is redundant to below message.

DBG(1, "Block_addr            [0x%x]\n", blk_addr);

Thanks,

> +	} else {
> +		MSG(0, "\nblk_addr: 0x%x is not valid block\n", blk_addr);
> +		return ret;
> +	}
> +
>  	type = get_sum_entry(sbi, blk_addr, &sum_entry);
>  	nid = le32_to_cpu(sum_entry.nid);
>  
> @@ -545,8 +558,8 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
>  
>  	DBG(1, "Note: blkaddr = main_blkaddr + segno * 512 + offset\n");
>  	DBG(1, "Block_addr            [0x%x]\n", blk_addr);
> -	DBG(1, " - Segno              [0x%x]\n", GET_SEGNO(sbi, blk_addr));
> -	DBG(1, " - Offset             [0x%x]\n", OFFSET_IN_SEG(sbi, blk_addr));
> +	DBG(1, " - Segno              [0x%x]\n", segno);
> +	DBG(1, " - Offset             [0x%x]\n", offset);
>  	DBG(1, "SUM.nid               [0x%x]\n", nid);
>  	DBG(1, "SUM.type              [%s]\n", type >= 0 ?
>  						seg_type_name[type] :
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2017-08-24 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 10:51 [PATCH] dump.f2fs: check block is valid or not before dump block info Yunlei He
2017-08-24 13:32 ` Chao Yu

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).