diff options
Diffstat (limited to 'fs/xfs/xfs_error.c')
| -rw-r--r-- | fs/xfs/xfs_error.c | 96 | 
1 files changed, 43 insertions, 53 deletions
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index ed999026766..edac5b057d2 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -16,18 +16,13 @@   * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA   */  #include "xfs.h" +#include "xfs_format.h"  #include "xfs_fs.h" -#include "xfs_types.h" -#include "xfs_log.h" -#include "xfs_inum.h" -#include "xfs_trans.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h"  #include "xfs_sb.h"  #include "xfs_ag.h"  #include "xfs_mount.h" -#include "xfs_bmap_btree.h" -#include "xfs_dinode.h" -#include "xfs_inode.h" -#include "xfs_utils.h"  #include "xfs_error.h"  #ifdef DEBUG @@ -48,7 +43,7 @@ xfs_error_trap(int e)  			break;  		if (e != xfs_etrap[i])  			continue; -		cmn_err(CE_NOTE, "xfs_error_trap: error %d", e); +		xfs_notice(NULL, "%s: error %d", __func__, e);  		BUG();  		break;  	} @@ -58,6 +53,7 @@ xfs_error_trap(int e)  int	xfs_etest[XFS_NUM_INJECT_ERROR];  int64_t	xfs_etest_fsid[XFS_NUM_INJECT_ERROR];  char *	xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; +int	xfs_error_test_active;  int  xfs_error_test(int error_tag, int *fsidp, char *expression, @@ -66,14 +62,14 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,  	int i;  	int64_t fsid; -	if (random32() % randfactor) +	if (prandom_u32() % randfactor)  		return 0;  	memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));  	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {  		if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) { -			cmn_err(CE_WARN, +			xfs_warn(NULL,  	"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",  				expression, file, line, xfs_etest_fsname[i]);  			return 1; @@ -94,25 +90,26 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp)  	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {  		if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) { -			cmn_err(CE_WARN, "XFS error tag #%d on", error_tag); +			xfs_warn(mp, "error tag #%d on", error_tag);  			return 0;  		}  	}  	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {  		if (xfs_etest[i] == 0) { -			cmn_err(CE_WARN, "Turned on XFS error tag #%d", +			xfs_warn(mp, "Turned on XFS error tag #%d",  				error_tag);  			xfs_etest[i] = error_tag;  			xfs_etest_fsid[i] = fsid;  			len = strlen(mp->m_fsname);  			xfs_etest_fsname[i] = kmem_alloc(len + 1, KM_SLEEP);  			strcpy(xfs_etest_fsname[i], mp->m_fsname); +			xfs_error_test_active++;  			return 0;  		}  	} -	cmn_err(CE_WARN, "error tag overflow, too many turned on"); +	xfs_warn(mp, "error tag overflow, too many turned on");  	return 1;  } @@ -131,55 +128,23 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud)  		if ((fsid == 0LL || xfs_etest_fsid[i] == fsid) &&  		     xfs_etest[i] != 0) {  			cleared = 1; -			cmn_err(CE_WARN, "Clearing XFS error tag #%d", +			xfs_warn(mp, "Clearing XFS error tag #%d",  				xfs_etest[i]);  			xfs_etest[i] = 0;  			xfs_etest_fsid[i] = 0LL;  			kmem_free(xfs_etest_fsname[i]);  			xfs_etest_fsname[i] = NULL; +			xfs_error_test_active--;  		}  	}  	if (loud || cleared) -		cmn_err(CE_WARN, -			"Cleared all XFS error tags for filesystem \"%s\"", -			mp->m_fsname); +		xfs_warn(mp, "Cleared all XFS error tags for filesystem");  	return 0;  }  #endif /* DEBUG */ - -void -xfs_fs_cmn_err(int level, xfs_mount_t *mp, char *fmt, ...) -{ -	va_list ap; - -	va_start(ap, fmt); -	xfs_fs_vcmn_err(level, mp, fmt, ap); -	va_end(ap); -} - -void -xfs_cmn_err(int panic_tag, int level, xfs_mount_t *mp, char *fmt, ...) -{ -	va_list ap; - -#ifdef DEBUG -	xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES); -#endif - -	if (xfs_panic_mask && (xfs_panic_mask & panic_tag) -	    && (level & CE_ALERT)) { -		level &= ~CE_ALERT; -		level |= CE_PANIC; -		cmn_err(CE_ALERT, "XFS: Transforming an alert into a BUG."); -	} -	va_start(ap, fmt); -	xfs_fs_vcmn_err(level, mp, fmt, ap); -	va_end(ap); -} -  void  xfs_error_report(  	const char		*tag, @@ -190,9 +155,8 @@ xfs_error_report(  	inst_t			*ra)  {  	if (level <= xfs_error_level) { -		xfs_cmn_err(XFS_PTAG_ERROR_REPORT, -			    CE_ALERT, mp, -		"XFS internal error %s at line %d of file %s.  Caller 0x%p\n", +		xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT, +		"Internal error %s at line %d of file %s.  Caller %pF",  			    tag, linenum, filename, ra);  		xfs_stack_trace(); @@ -210,6 +174,32 @@ xfs_corruption_error(  	inst_t			*ra)  {  	if (level <= xfs_error_level) -		xfs_hex_dump(p, 16); +		xfs_hex_dump(p, 64);  	xfs_error_report(tag, level, mp, filename, linenum, ra); +	xfs_alert(mp, "Corruption detected. Unmount and run xfs_repair"); +} + +/* + * 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) +{ +	struct xfs_mount *mp = bp->b_target->bt_mount; + +	xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx", +		  bp->b_error == EFSBADCRC ? "CRC error" : "corruption", +		  __return_address, bp->b_bn); + +	xfs_alert(mp, "Unmount and run xfs_repair"); + +	if (xfs_error_level >= XFS_ERRLEVEL_LOW) { +		xfs_alert(mp, "First 64 bytes of corrupted metadata buffer:"); +		xfs_hex_dump(xfs_buf_offset(bp, 0), 64); +	} + +	if (xfs_error_level >= XFS_ERRLEVEL_HIGH) +		xfs_stack_trace();  }  | 
