[3/5] xfs_db: clean up the salvage read callsites in set_cur()
diff mbox series

Message ID 158619916259.469742.7875972212442996405.stgit@magnolia
State Accepted
Headers show
Series
  • xfsprogs: rollup of various fixes for 5.6
Related show

Commit Message

Darrick J. Wong April 6, 2020, 6:52 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Clean up the LIBXFS_READBUF_SALVAGE call sites in set_cur so that we
use the return value directly instead of scraping it out later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 db/io.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Allison Collins April 6, 2020, 10:07 p.m. UTC | #1
On 4/6/20 11:52 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Clean up the LIBXFS_READBUF_SALVAGE call sites in set_cur so that we
> use the return value directly instead of scraping it out later.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Looks ok:
Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> ---
>   db/io.c |   16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/db/io.c b/db/io.c
> index 384e4c0f..6628d061 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -516,6 +516,7 @@ set_cur(
>   	xfs_ino_t	ino;
>   	uint16_t	mode;
>   	const struct xfs_buf_ops *ops = type ? type->bops : NULL;
> +	int		error;
>   
>   	if (iocur_sp < 0) {
>   		dbprintf(_("set_cur no stack element to set\n"));
> @@ -542,20 +543,21 @@ set_cur(
>   		if (!iocur_top->bbmap)
>   			return;
>   		memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap));
> -		libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b, bbmap->nmaps,
> -				LIBXFS_READBUF_SALVAGE, &bp, ops);
> +		error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b,
> +				bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp,
> +				ops);
>   	} else {
> -		libxfs_buf_read(mp->m_ddev_targp, blknum, len,
> +		error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len,
>   				LIBXFS_READBUF_SALVAGE, &bp, ops);
>   		iocur_top->bbmap = NULL;
>   	}
>   
>   	/*
> -	 * Keep the buffer even if the verifier says it is corrupted.
> -	 * We're a diagnostic tool, after all.
> +	 * Salvage mode means that we still get a buffer even if the verifier
> +	 * says the metadata is corrupt.  Therefore, the only errors we should
> +	 * get are for IO errors or runtime errors.
>   	 */
> -	if (!bp || (bp->b_error && bp->b_error != -EFSCORRUPTED &&
> -				   bp->b_error != -EFSBADCRC))
> +	if (error)
>   		return;
>   	iocur_top->buf = bp->b_addr;
>   	iocur_top->bp = bp;
>

Patch
diff mbox series

diff --git a/db/io.c b/db/io.c
index 384e4c0f..6628d061 100644
--- a/db/io.c
+++ b/db/io.c
@@ -516,6 +516,7 @@  set_cur(
 	xfs_ino_t	ino;
 	uint16_t	mode;
 	const struct xfs_buf_ops *ops = type ? type->bops : NULL;
+	int		error;
 
 	if (iocur_sp < 0) {
 		dbprintf(_("set_cur no stack element to set\n"));
@@ -542,20 +543,21 @@  set_cur(
 		if (!iocur_top->bbmap)
 			return;
 		memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap));
-		libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b, bbmap->nmaps,
-				LIBXFS_READBUF_SALVAGE, &bp, ops);
+		error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b,
+				bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp,
+				ops);
 	} else {
-		libxfs_buf_read(mp->m_ddev_targp, blknum, len,
+		error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len,
 				LIBXFS_READBUF_SALVAGE, &bp, ops);
 		iocur_top->bbmap = NULL;
 	}
 
 	/*
-	 * Keep the buffer even if the verifier says it is corrupted.
-	 * We're a diagnostic tool, after all.
+	 * Salvage mode means that we still get a buffer even if the verifier
+	 * says the metadata is corrupt.  Therefore, the only errors we should
+	 * get are for IO errors or runtime errors.
 	 */
-	if (!bp || (bp->b_error && bp->b_error != -EFSCORRUPTED &&
-				   bp->b_error != -EFSBADCRC))
+	if (error)
 		return;
 	iocur_top->buf = bp->b_addr;
 	iocur_top->bp = bp;