From: Dave Chinner Date: Thu, 6 Mar 2014 23:25:55 +0000 (+1100) Subject: libxfs: add xfs_verifier_error() X-Git-Tag: v3.2.0-rc1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99c1ec967271c4268431f2476005a707e91d7301;p=thirdparty%2Fxfsprogs-dev.git libxfs: add xfs_verifier_error() [userspace port] We want to distinguish between corruption, CRC errors, etc. In addition, the full stack trace on verifier errors seems less than helpful; it looks more like an oops than corruption. Create a new function to specifically alert the user to verifier errors, which can differentiate between EFSCORRUPTED and CRC mismatches. It doesn't dump stack unless the xfs error level is turned up high. Define a new error message (EFSBADCRC) to clearly identify CRC errors. (Defined to EBADMSG, bad message) Signed-off-by: Dave Chinner Reviewed-by: Eric Sandeen Signed-off-by: Dave Chinner --- diff --git a/include/darwin.h b/include/darwin.h index 97b8990d2..95f865b7d 100644 --- a/include/darwin.h +++ b/include/darwin.h @@ -150,6 +150,7 @@ typedef unsigned char uchar_t; #define ENOATTR 989 /* Attribute not found */ #define EFSCORRUPTED 990 /* Filesystem is corrupted */ +#define EFSBADCRC 991 /* Bad CRC detected */ #define constpp char * const * #define HAVE_FID 1 diff --git a/include/freebsd.h b/include/freebsd.h index 2e1ae4984..b51688b5e 100644 --- a/include/freebsd.h +++ b/include/freebsd.h @@ -45,6 +45,7 @@ #define constpp char * const * #define EFSCORRUPTED 990 /* Filesystem is corrupted */ +#define EFSBADCRC 991 /* Bad CRC detected */ typedef off_t xfs_off_t; typedef off_t off64_t; diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h index 1ec291fdf..2140acd4e 100644 --- a/include/gnukfreebsd.h +++ b/include/gnukfreebsd.h @@ -36,6 +36,7 @@ #define constpp char * const * #define EFSCORRUPTED 990 /* Filesystem is corrupted */ +#define EFSBADCRC 991 /* Bad CRC detected */ typedef off_t xfs_off_t; typedef __uint64_t xfs_ino_t; diff --git a/include/irix.h b/include/irix.h index a450684ec..504045189 100644 --- a/include/irix.h +++ b/include/irix.h @@ -52,6 +52,8 @@ typedef char* xfs_caddr_t; #define xfs_flock64 flock64 #define xfs_flock64_t struct flock64 +#define EFSBADCRC 991 /* Bad CRC detected */ + typedef struct xfs_error_injection { __int32_t fd; __int32_t errtag; diff --git a/include/linux.h b/include/linux.h index 502fd1f81..55862905a 100644 --- a/include/linux.h +++ b/include/linux.h @@ -136,6 +136,7 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) #define ENOATTR ENODATA /* Attribute not found */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ +#define EFSBADCRC EBADMSG /* Bad CRC detected */ typedef loff_t xfs_off_t; typedef __uint64_t xfs_ino_t; diff --git a/libxfs/util.c b/libxfs/util.c index 8109ab3b7..1b0554067 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -730,3 +730,16 @@ cmn_err(int level, char *fmt, ...) fputs("\n", stderr); va_end(ap); } + +/* + * Warnings specifically for verifier errors. Differentiate CRC vs. invalid + * values, and omit the stack trace unless the error level is tuned high. + */ +void +xfs_verifier_error( + struct xfs_buf *bp) +{ + xfs_alert(NULL, "Metadata %s detected at block 0x%llx/0x%x", + bp->b_error == EFSBADCRC ? "CRC error" : "corruption", + bp->b_bn, BBTOB(bp->b_length)); +} diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 364fd83e6..5a21590b1 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -449,3 +449,4 @@ int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int); void xfs_trans_mod_sb(xfs_trans_t *, uint, long); void xfs_trans_init(struct xfs_mount *); int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *); +void xfs_verifier_error(struct xfs_buf *bp);