diff mbox series

[6/6] xfs_scrub: fix weirdness in directory name check code

Message ID 161284390991.3058224.12921304382202456726.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series various: random fixes | expand

Commit Message

Darrick J. Wong Feb. 9, 2021, 4:11 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Remove the redundant second check of fd and ISDIR in check_inode_names,
and rework the comment to describe why we can't run phase 5 if we found
other corruptions in the filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 scrub/phase5.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Feb. 9, 2021, 9:31 a.m. UTC | #1
On Mon, Feb 08, 2021 at 08:11:49PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Remove the redundant second check of fd and ISDIR in check_inode_names,
> and rework the comment to describe why we can't run phase 5 if we found
> other corruptions in the filesystem.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Chandan Babu R Feb. 10, 2021, 10:04 a.m. UTC | #2
On 09 Feb 2021 at 09:41, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Remove the redundant second check of fd and ISDIR in check_inode_names,
> and rework the comment to describe why we can't run phase 5 if we found
> other corruptions in the filesystem.
>

Looks good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  scrub/phase5.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
>
> diff --git a/scrub/phase5.c b/scrub/phase5.c
> index ee1e5d6c..1ef234bf 100644
> --- a/scrub/phase5.c
> +++ b/scrub/phase5.c
> @@ -278,7 +278,12 @@ check_inode_names(
>  			goto out;
>  	}
>  
> -	/* Open the dir, let the kernel try to reconnect it to the root. */
> +	/*
> +	 * Warn about naming problems in the directory entries.  Opening the
> +	 * dir by handle means the kernel will try to reconnect it to the root.
> +	 * If the reconnection fails due to corruption in the parents we get
> +	 * ESTALE, which is why we skip phase 5 if we found corruption.
> +	 */
>  	if (S_ISDIR(bstat->bs_mode)) {
>  		fd = scrub_open_handle(handle);
>  		if (fd < 0) {
> @@ -288,10 +293,7 @@ check_inode_names(
>  			str_errno(ctx, descr_render(&dsc));
>  			goto out;
>  		}
> -	}
>  
> -	/* Warn about naming problems in the directory entries. */
> -	if (fd >= 0 && S_ISDIR(bstat->bs_mode)) {
>  		error = check_dirent_names(ctx, &dsc, &fd, bstat);
>  		if (error)
>  			goto out;
diff mbox series

Patch

diff --git a/scrub/phase5.c b/scrub/phase5.c
index ee1e5d6c..1ef234bf 100644
--- a/scrub/phase5.c
+++ b/scrub/phase5.c
@@ -278,7 +278,12 @@  check_inode_names(
 			goto out;
 	}
 
-	/* Open the dir, let the kernel try to reconnect it to the root. */
+	/*
+	 * Warn about naming problems in the directory entries.  Opening the
+	 * dir by handle means the kernel will try to reconnect it to the root.
+	 * If the reconnection fails due to corruption in the parents we get
+	 * ESTALE, which is why we skip phase 5 if we found corruption.
+	 */
 	if (S_ISDIR(bstat->bs_mode)) {
 		fd = scrub_open_handle(handle);
 		if (fd < 0) {
@@ -288,10 +293,7 @@  check_inode_names(
 			str_errno(ctx, descr_render(&dsc));
 			goto out;
 		}
-	}
 
-	/* Warn about naming problems in the directory entries. */
-	if (fd >= 0 && S_ISDIR(bstat->bs_mode)) {
 		error = check_dirent_names(ctx, &dsc, &fd, bstat);
 		if (error)
 			goto out;