[06/15] btrfs-progs: lowmem check: let check_dir_item() return if repaired
diff mbox

Message ID 20180126083519.28373-7-suy.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Su Yue Jan. 26, 2018, 8:35 a.m. UTC
If repair_dir_item deleted the item, goto last checked then returns
instead of searching di_key again then returns -ENOENT.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 cmds-check.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Qu Wenruo Jan. 26, 2018, 9:43 a.m. UTC | #1
On 2018年01月26日 16:35, Su Yue wrote:
> If repair_dir_item deleted the item, goto last checked then returns
> instead of searching di_key again then returns -ENOENT.
> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
>  cmds-check.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/cmds-check.c b/cmds-check.c
> index eb65a18fe64b..4ce6139b3ab1 100644
> --- a/cmds-check.c
> +++ b/cmds-check.c
> @@ -5931,7 +5931,7 @@ begin:
>  				path->slots[0]--;

Well, not a problem of this patch, but I found previous lines have problem:
------
		ret = btrfs_search_slot(NULL, root, di_key, path, 0, 0);
		/* the item was deleted, let path point the last checked item */
		if (ret > 0) {
			if (path->slots[0] == 0)
				btrfs_prev_leaf(root, path);
			else
				path->slots[0]--;
		}
------

Here return value of btrfs_prev_leaf() is ignored, which can return
error or >1.

Thanks,
Qu

>  		}
>  		if (ret)
> -			goto out;
> +			return err;>  	}
>  
>  	node = path->nodes[0];
> @@ -6040,7 +6040,7 @@ next:
>  			break;
>  		}
>  	}
> -out:
> +
>  	/* research path */
>  	btrfs_release_path(path);
>  	ret = btrfs_search_slot(NULL, root, di_key, path, 0, 0);
>

Patch
diff mbox

diff --git a/cmds-check.c b/cmds-check.c
index eb65a18fe64b..4ce6139b3ab1 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -5931,7 +5931,7 @@  begin:
 				path->slots[0]--;
 		}
 		if (ret)
-			goto out;
+			return err;
 	}
 
 	node = path->nodes[0];
@@ -6040,7 +6040,7 @@  next:
 			break;
 		}
 	}
-out:
+
 	/* research path */
 	btrfs_release_path(path);
 	ret = btrfs_search_slot(NULL, root, di_key, path, 0, 0);