All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsck.f2fs: read ahead xattr & direct node blocks
@ 2018-01-26  9:23 Yunlei He
  2018-01-27  3:46 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Yunlei He @ 2018-01-26  9:23 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: ning.jia, heyunlei

This patch read ahead xattr & direct node blocks

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

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 6c1b9a7..29a712c 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -621,6 +621,31 @@ unmatched:
 	child->state |= FSCK_UNMATCHED_EXTENT;
 }
 
+void fsck_reada_node_block(struct f2fs_sb_info *sbi, u32 nid)
+{
+	struct node_info ni;
+
+	if (nid != 0 && IS_VALID_NID(sbi, nid)) {
+		get_node_info(sbi, nid, &ni);
+		if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
+			dev_reada_block(ni.blk_addr);
+	}
+}
+
+void fsck_reada_all_direct_node_blocks(struct f2fs_sb_info *sbi,
+						struct f2fs_node *node_blk)
+{
+	int i;
+
+	for (i = 0; i < NIDS_PER_BLOCK; i++) {
+		u32 nid = le32_to_cpu(node_blk->in.nid[i]);
+
+		if (nid == 0x0)
+			continue;
+		fsck_reada_node_block(sbi, nid);
+	}
+}
+
 /* start with valid nid and blkaddr */
 void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		enum FILE_TYPE ftype, struct f2fs_node *node_blk,
@@ -680,15 +705,6 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		}
 	}
 
-	if (fsck_chk_xattr_blk(sbi, nid,
-			le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt) &&
-			c.fix_on) {
-		node_blk->i.i_xattr_nid = 0;
-		need_fix = 1;
-		FIX_MSG("Remove xattr block: 0x%x, x_nid = 0x%x",
-				nid, le32_to_cpu(node_blk->i.i_xattr_nid));
-	}
-
 	if (ftype == F2FS_FT_CHRDEV || ftype == F2FS_FT_BLKDEV ||
 			ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
 		goto check;
@@ -737,16 +753,12 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 	}
 
 	/* readahead node blocks */
+	if (le32_to_cpu(node_blk->i.i_xattr_nid))
+		fsck_reada_node_block(sbi,
+				le32_to_cpu(node_blk->i.i_xattr_nid));
 	for (idx = 0; idx < 5; idx++) {
 		u32 nid = le32_to_cpu(node_blk->i.i_nid[idx]);
-
-		if (nid != 0 && IS_VALID_NID(sbi, nid)) {
-			struct node_info ni;
-
-			get_node_info(sbi, nid, &ni);
-			if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
-				dev_reada_block(ni.blk_addr);
-		}
+		fsck_reada_node_block(sbi, nid);
 	}
 
 	/* init extent info */
@@ -778,6 +790,15 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		}
 	}
 
+	if (fsck_chk_xattr_blk(sbi, nid,
+			le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt) &&
+			c.fix_on) {
+		node_blk->i.i_xattr_nid = 0;
+		need_fix = 1;
+		FIX_MSG("Remove xattr block: 0x%x, x_nid = 0x%x",
+				nid, le32_to_cpu(node_blk->i.i_xattr_nid));
+	}
+
 	/* check node blocks in inode */
 	for (idx = 0; idx < 5; idx++) {
 		nid_t i_nid = le32_to_cpu(node_blk->i.i_nid[idx]);
@@ -997,6 +1018,8 @@ int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
 	int need_fix = 0, ret;
 	int i = 0;
 
+	fsck_reada_all_direct_node_blocks(sbi, node_blk);
+
 	for (i = 0; i < NIDS_PER_BLOCK; i++) {
 		if (le32_to_cpu(node_blk->in.nid[i]) == 0x0)
 			goto skip;
@@ -1037,6 +1060,8 @@ int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
 	int i = 0;
 	int need_fix = 0, ret = 0;
 
+	fsck_reada_all_direct_node_blocks(sbi, node_blk);
+
 	for (i = 0; i < NIDS_PER_BLOCK; i++) {
 		if (le32_to_cpu(node_blk->in.nid[i]) == 0x0)
 			goto skip;
-- 
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] fsck.f2fs: read ahead xattr & direct node blocks
  2018-01-26  9:23 [PATCH] fsck.f2fs: read ahead xattr & direct node blocks Yunlei He
@ 2018-01-27  3:46 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2018-01-27  3:46 UTC (permalink / raw)
  To: Yunlei He, jaegeuk, linux-f2fs-devel; +Cc: ning.jia

On 2018/1/26 17:23, Yunlei He wrote:
> This patch read ahead xattr & direct node blocks
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fsck/fsck.c | 59 ++++++++++++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 42 insertions(+), 17 deletions(-)
> 
> diff --git a/fsck/fsck.c b/fsck/fsck.c
> index 6c1b9a7..29a712c 100644
> --- a/fsck/fsck.c
> +++ b/fsck/fsck.c
> @@ -621,6 +621,31 @@ unmatched:
>  	child->state |= FSCK_UNMATCHED_EXTENT;
>  }
>  
> +void fsck_reada_node_block(struct f2fs_sb_info *sbi, u32 nid)
> +{
> +	struct node_info ni;
> +
> +	if (nid != 0 && IS_VALID_NID(sbi, nid)) {
> +		get_node_info(sbi, nid, &ni);
> +		if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
> +			dev_reada_block(ni.blk_addr);
> +	}
> +}
> +
> +void fsck_reada_all_direct_node_blocks(struct f2fs_sb_info *sbi,
> +						struct f2fs_node *node_blk)
> +{
> +	int i;
> +
> +	for (i = 0; i < NIDS_PER_BLOCK; i++) {
> +		u32 nid = le32_to_cpu(node_blk->in.nid[i]);
> +
> +		if (nid == 0x0)
> +			continue;

In fsck_reada_node_block, we have already checked all conditions that we
should skip doing readahead, here I think we can just be relaxed to remove
above check.

> +		fsck_reada_node_block(sbi, nid);
> +	}
> +}
> +
>  /* start with valid nid and blkaddr */
>  void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>  		enum FILE_TYPE ftype, struct f2fs_node *node_blk,
> @@ -680,15 +705,6 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>  		}
>  	}
>  
> -	if (fsck_chk_xattr_blk(sbi, nid,
> -			le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt) &&
> -			c.fix_on) {
> -		node_blk->i.i_xattr_nid = 0;
> -		need_fix = 1;
> -		FIX_MSG("Remove xattr block: 0x%x, x_nid = 0x%x",
> -				nid, le32_to_cpu(node_blk->i.i_xattr_nid));
> -	}
> -
>  	if (ftype == F2FS_FT_CHRDEV || ftype == F2FS_FT_BLKDEV ||
>  			ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
>  		goto check;
> @@ -737,16 +753,12 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>  	}
>  
>  	/* readahead node blocks */
> +	if (le32_to_cpu(node_blk->i.i_xattr_nid))

Ditto.

> +		fsck_reada_node_block(sbi,
> +				le32_to_cpu(node_blk->i.i_xattr_nid));
>  	for (idx = 0; idx < 5; idx++) {
>  		u32 nid = le32_to_cpu(node_blk->i.i_nid[idx]);
> -
> -		if (nid != 0 && IS_VALID_NID(sbi, nid)) {
> -			struct node_info ni;
> -
> -			get_node_info(sbi, nid, &ni);
> -			if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
> -				dev_reada_block(ni.blk_addr);
> -		}
> +		fsck_reada_node_block(sbi, nid);
>  	}
>  
>  	/* init extent info */
> @@ -778,6 +790,15 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
>  		}
>  	}
>  
> +	if (fsck_chk_xattr_blk(sbi, nid,
> +			le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt) &&
> +			c.fix_on) {
> +		node_blk->i.i_xattr_nid = 0;
> +		need_fix = 1;
> +		FIX_MSG("Remove xattr block: 0x%x, x_nid = 0x%x",
> +				nid, le32_to_cpu(node_blk->i.i_xattr_nid));
> +	}
> +
>  	/* check node blocks in inode */
>  	for (idx = 0; idx < 5; idx++) {
>  		nid_t i_nid = le32_to_cpu(node_blk->i.i_nid[idx]);
> @@ -997,6 +1018,8 @@ int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
>  	int need_fix = 0, ret;
>  	int i = 0;
>  
> +	fsck_reada_all_direct_node_blocks(sbi, node_blk);
> +
>  	for (i = 0; i < NIDS_PER_BLOCK; i++) {
>  		if (le32_to_cpu(node_blk->in.nid[i]) == 0x0)
>  			goto skip;
> @@ -1037,6 +1060,8 @@ int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
>  	int i = 0;
>  	int need_fix = 0, ret = 0;
>  
> +	fsck_reada_all_direct_node_blocks(sbi, node_blk);
> +
>  	for (i = 0; i < NIDS_PER_BLOCK; i++) {
>  		if (le32_to_cpu(node_blk->in.nid[i]) == 0x0)
>  			goto skip;

How about keeping the order:

1. check data blocks
2. readahead xattr block
3. fsck xattr block
4. readahead {d,id,did}node block
5. fsck {d,id,did}node block

With above order, I expect we can avoid unneeded readahead before
sub-directory iterated traversing or encountering error.

Thanks,

> 


------------------------------------------------------------------------------
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:[~2018-01-27  3:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26  9:23 [PATCH] fsck.f2fs: read ahead xattr & direct node blocks Yunlei He
2018-01-27  3:46 ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.