public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: "Darrick J. Wong" <djwong@alder.djwong.org>,
	david@fromorbit.com, darrick.wong@oracle.com
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 04/10] xfs_repair: fix broken EFSBADCRC/EFSCORRUPTED usage with buffer errors
Date: Mon, 17 Aug 2015 14:51:23 -0500	[thread overview]
Message-ID: <55D23B3B.6060803@sandeen.net> (raw)
In-Reply-To: <20150815014404.1839.75324.stgit@birch.djwong.org>

On 8/14/15 8:44 PM, Darrick J. Wong wrote:
> When we encounter CRC or verifier errors, bp->b_error is set to
> -EFSBADCRC and -EFSCORRUPTED; note the negative sign.  For whatever
> reason, repair and db use the positive versions, and therefore fail to
> notice the error, so fix all the broken uses.
> 
> Note however that the db and repair turn the negative codes returned
> by libxfs into positive codes that can be used with strerror.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

This looks right, but I think there's more; see:

XFS_WANT_CORRUPTED_GOTO
XFS_WANT_CORRUPTED_RETURN

(these return negative errors in kernelspace)

and a bunch of stuff in libxlog/xfs_log_recover.c...

FWIW, I guess it's expected that non-libxfs xfsprogs might carry around
positive error numbers, but of course it has to be consistent...

commit 12b5319796439c9442414f82049201d3c740e059
Author: Dave Chinner <dchinner@redhat.com>
Date:   Fri Jul 31 08:33:21 2015 +1000

    libxfs: error negation rework
    
    The libxfs core in the kernel now returns negative error numbers one
    failure rather than positive numbers. This commit switches the
    libxfs core to use negative error numbers and converts all
    the libxfs function callers to negate the returned error so that
    none of the other codeneeds tobe changed at this time.
    
    This allows us to drive negative errors through the xfsprogs code
    base at our leisure rather than having to do it all right now.
    
    Signed-off-by: Dave Chinner <dchinner@redhat.com>

So this is fine;

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

but there are a few more libxfs/ bits to fix, I guess.

-Eric

> ---
>  db/attr.c     |    4 ++--
>  db/dir2.c     |    4 ++--
>  db/io.c       |    4 ++--
>  db/io.h       |    2 +-
>  repair/dir2.c |    2 +-
>  repair/scan.c |   12 ++++++------
>  6 files changed, 14 insertions(+), 14 deletions(-)
> 
> 
> diff --git a/db/attr.c b/db/attr.c
> index 897834b..5e69100 100644
> --- a/db/attr.c
> +++ b/db/attr.c
> @@ -554,7 +554,7 @@ xfs_attr3_db_read_verify(
>  		break;
>  	default:
>  		dbprintf(_("Unknown attribute buffer type!\n"));
> -		xfs_buf_ioerror(bp, EFSCORRUPTED);
> +		xfs_buf_ioerror(bp, -EFSCORRUPTED);
>  		return;
>  	}
>  verify:
> @@ -566,7 +566,7 @@ xfs_attr3_db_write_verify(
>  	struct xfs_buf		*bp)
>  {
>  	dbprintf(_("Writing unknown attribute buffer type!\n"));
> -	xfs_buf_ioerror(bp, EFSCORRUPTED);
> +	xfs_buf_ioerror(bp, -EFSCORRUPTED);
>  }
>  
>  const struct xfs_buf_ops xfs_attr3_db_buf_ops = {
> diff --git a/db/dir2.c b/db/dir2.c
> index 7f69e6f..cc76662 100644
> --- a/db/dir2.c
> +++ b/db/dir2.c
> @@ -1021,7 +1021,7 @@ xfs_dir3_db_read_verify(
>  		break;
>  	default:
>  		dbprintf(_("Unknown directory buffer type!\n"));
> -		xfs_buf_ioerror(bp, EFSCORRUPTED);
> +		xfs_buf_ioerror(bp, -EFSCORRUPTED);
>  		return;
>  	}
>  verify:
> @@ -1033,7 +1033,7 @@ xfs_dir3_db_write_verify(
>  	struct xfs_buf		*bp)
>  {
>  	dbprintf(_("Writing unknown directory buffer type!\n"));
> -	xfs_buf_ioerror(bp, EFSCORRUPTED);
> +	xfs_buf_ioerror(bp, -EFSCORRUPTED);
>  }
>  
>  const struct xfs_buf_ops xfs_dir3_db_buf_ops = {
> diff --git a/db/io.c b/db/io.c
> index 9fa52b8..9452e07 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -535,8 +535,8 @@ set_cur(
>  	 * Keep the buffer even if the verifier says it is corrupted.
>  	 * We're a diagnostic tool, after all.
>  	 */
> -	if (!bp || (bp->b_error && bp->b_error != EFSCORRUPTED &&
> -				   bp->b_error != EFSBADCRC))
> +	if (!bp || (bp->b_error && bp->b_error != -EFSCORRUPTED &&
> +				   bp->b_error != -EFSBADCRC))
>  		return;
>  	iocur_top->buf = bp->b_addr;
>  	iocur_top->bp = bp;
> diff --git a/db/io.h b/db/io.h
> index 31d96b4..6201d7b 100644
> --- a/db/io.h
> +++ b/db/io.h
> @@ -75,6 +75,6 @@ iocur_crc_valid()
>  		return -1;
>  	if (iocur_top->bp->b_flags & LIBXFS_B_UNCHECKED)
>  		return -1;
> -	return (iocur_top->bp->b_error != EFSBADCRC &&
> +	return (iocur_top->bp->b_error != -EFSBADCRC &&
>  		(!iocur_top->ino_buf || iocur_top->ino_crc_ok));
>  }
> diff --git a/repair/dir2.c b/repair/dir2.c
> index 187e069..a5646f8 100644
> --- a/repair/dir2.c
> +++ b/repair/dir2.c
> @@ -199,7 +199,7 @@ _("bad dir magic number 0x%x in inode %" PRIu64 " bno = %u\n"),
>  			goto error_out;
>  		}
>  		/* corrupt node; rebuild the dir. */
> -		if (bp->b_error == EFSBADCRC || bp->b_error == EFSCORRUPTED) {
> +		if (bp->b_error == -EFSBADCRC || bp->b_error == -EFSCORRUPTED) {
>  			do_warn(
>  _("corrupt tree block %u for directory inode %" PRIu64 "\n"),
>  				bno, da_cursor->ino);
> diff --git a/repair/scan.c b/repair/scan.c
> index 58f45eb..1e7a4da 100644
> --- a/repair/scan.c
> +++ b/repair/scan.c
> @@ -82,7 +82,7 @@ scan_sbtree(
>  		do_error(_("can't read btree block %d/%d\n"), agno, root);
>  		return;
>  	}
> -	if (bp->b_error == EFSBADCRC || bp->b_error == EFSCORRUPTED) {
> +	if (bp->b_error == -EFSBADCRC || bp->b_error == -EFSCORRUPTED) {
>  		do_warn(_("btree block %d/%d is suspect, error %d\n"),
>  			agno, root, bp->b_error);
>  		suspect = 1;
> @@ -145,7 +145,7 @@ scan_lbtree(
>  	 * is a corruption or not and whether it got corrected and so needs
>  	 * writing back. CRC errors always imply we need to write the block.
>  	 */
> -	if (bp->b_error == EFSBADCRC) {
> +	if (bp->b_error == -EFSBADCRC) {
>  		do_warn(_("btree block %d/%d is suspect, error %d\n"),
>  			XFS_FSB_TO_AGNO(mp, root),
>  			XFS_FSB_TO_AGBNO(mp, root), bp->b_error);
> @@ -1432,7 +1432,7 @@ scan_freelist(
>  		do_abort(_("can't read agfl block for ag %d\n"), agno);
>  		return;
>  	}
> -	if (agflbuf->b_error == EFSBADCRC)
> +	if (agflbuf->b_error == -EFSBADCRC)
>  		do_warn(_("agfl has bad CRC for ag %d\n"), agno);
>  
>  	freelist = XFS_BUF_TO_AGFL_BNO(mp, agflbuf);
> @@ -1705,9 +1705,9 @@ scan_ag(
>  	 * immediately, though.
>  	 */
>  	if (!no_modify) {
> -		agi_dirty += (agibuf->b_error == EFSBADCRC);
> -		agf_dirty += (agfbuf->b_error == EFSBADCRC);
> -		sb_dirty += (sbbuf->b_error == EFSBADCRC);
> +		agi_dirty += (agibuf->b_error == -EFSBADCRC);
> +		agf_dirty += (agfbuf->b_error == -EFSBADCRC);
> +		sb_dirty += (sbbuf->b_error == -EFSBADCRC);
>  	}
>  
>  	if (agi_dirty && !no_modify)
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-08-17 19:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-15  1:43 [PATCH 00/10] xfsprogs August 2015 patchbomb Darrick J. Wong
2015-08-15  1:43 ` [PATCH 01/10] libxfs: readahead of dir3 data blocks should use the read verifier Darrick J. Wong
2015-08-17 18:31   ` Eric Sandeen
2015-08-17 20:30     ` Darrick J. Wong
2015-08-15  1:43 ` [PATCH 02/10] xfs_db: don't crash on a corrupt inode Darrick J. Wong
2015-08-17 18:52   ` Eric Sandeen
2015-08-17 20:45     ` Darrick J. Wong
2015-08-15  1:43 ` [PATCH 03/10] xfs_repair: ignore "repaired" flag after we decide to clear xattr block Darrick J. Wong
2015-08-17 19:20   ` Eric Sandeen
2015-08-17 20:50     ` Darrick J. Wong
2015-08-15  1:44 ` [PATCH 04/10] xfs_repair: fix broken EFSBADCRC/EFSCORRUPTED usage with buffer errors Darrick J. Wong
2015-08-17 19:51   ` Eric Sandeen [this message]
2015-08-17 19:57     ` Eric Sandeen
2015-08-15  1:44 ` [PATCH 05/10] xfs_repair: force not-so-bad bmbt blocks back through the verifier Darrick J. Wong
2015-08-17 21:14   ` Eric Sandeen
2015-08-17 23:48     ` Darrick J. Wong
2015-08-15  1:44 ` [PATCH 06/10] xfs_repair: mark unreachable prefetched metadata blocks stale Darrick J. Wong
2015-08-15  1:44 ` [PATCH 07/10] xfs_io: support reflinking and deduping file ranges Darrick J. Wong
2015-08-15  1:44 ` [PATCH 08/10] xfs_db: enable blocktrash for checksummed filesystems Darrick J. Wong
2015-08-18 19:26   ` Eric Sandeen
2015-08-19 15:22     ` Darrick J. Wong
2015-08-15  1:44 ` [PATCH 09/10] xfs_db: trash the block at the top of the cursor stack Darrick J. Wong
2015-08-18 19:59   ` Eric Sandeen
2015-08-19 15:12     ` Darrick J. Wong
2015-08-15  1:44 ` [PATCH 10/10] xfs_db: enable blockget for v5 filesystems Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55D23B3B.6060803@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=djwong@alder.djwong.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox