From patchwork Thu Mar 15 00:29:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10283793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D8406061F for ; Thu, 15 Mar 2018 00:29:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D47D2870D for ; Thu, 15 Mar 2018 00:29:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FB932872D; Thu, 15 Mar 2018 00:29:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D8DF2870D for ; Thu, 15 Mar 2018 00:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751426AbeCOA35 (ORCPT ); Wed, 14 Mar 2018 20:29:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38928 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751279AbeCOA35 (ORCPT ); Wed, 14 Mar 2018 20:29:57 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2F0RMDr158062 for ; Thu, 15 Mar 2018 00:29:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=YUH0x6ALTF6vMBYrx/be3PAQg0aRe449CNog/UiVyDk=; b=WbDbBCrlJvYb1bShNTEhemtAUG2YRfCmZJSirgIyU8BnVqlmHIQH0yJuLuionMqLXJTV dscaWKqvhNTbWop2ra+Xzj/A0441THID3wsAbMXTAabWbiPZIKzFYKU0NDPpvDUoh2zR atFLZuXlket3AftlykcIHr+OFxJbj3pmQ4gIDtkBpxYH5WQinLXLCSGJuLrqdJbr0mTh 2A8oZRjcA52YiHCCdGb0/9S4tLsfsXiEguQZ/hTTcjKTFaek1RZzpPvjdscuAfkAgqWX k1XqYk7PHuR5YOng4KHKxmN792oljc2ns9cQ6PTAoxDBXYhzzFV+jaGCaoPMaa4Lq1zj PA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2gqdhrg35s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Mar 2018 00:29:56 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2F0TtLW005947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Mar 2018 00:29:55 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2F0TtWC014025 for ; Thu, 15 Mar 2018 00:29:55 GMT Received: from localhost (/10.159.231.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Mar 2018 17:29:55 -0700 Subject: [PATCH 4/9] xfs: refactor inode buffer verifier error logging From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 14 Mar 2018 17:29:54 -0700 Message-ID: <152107379476.19571.15155451515464003337.stgit@magnolia> In-Reply-To: <152107377037.19571.8618901963505842632.stgit@magnolia> References: <152107377037.19571.8618901963505842632.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8832 signatures=668690 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803150003 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong When the inode buffer verifier encounters an error, it's much more helpful to print a buffer from the offending inode instead of just the start of the inode chunk buffer. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_inode_buf.c | 4 +++- fs/xfs/xfs_error.c | 29 ++++++++++++++++++++++++----- fs/xfs/xfs_error.h | 3 +++ 3 files changed, 30 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 4fe17b3..51019e5 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -115,13 +115,15 @@ xfs_inode_buf_verify( return; } - xfs_verifier_error(bp, -EFSCORRUPTED, __this_address); #ifdef DEBUG xfs_alert(mp, "bad inode magic/vsn daddr %lld #%d (magic=%x)", (unsigned long long)bp->b_bn, i, be16_to_cpu(dip->di_magic)); #endif + xfs_buf_verifier_error(bp, -EFSCORRUPTED, + __func__, dip, sizeof(*dip), + NULL); } } xfs_inobp_check(mp, bp); diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index ccf520f..a63f508 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -347,27 +347,32 @@ xfs_corruption_error( * values, and omit the stack trace unless the error level is tuned high. */ void -xfs_verifier_error( +xfs_buf_verifier_error( struct xfs_buf *bp, int error, + const char *name, + void *buf, + size_t bufsz, xfs_failaddr_t failaddr) { struct xfs_mount *mp = bp->b_target->bt_mount; xfs_failaddr_t fa; + int sz; fa = failaddr ? failaddr : __return_address; __xfs_buf_ioerror(bp, error, fa); - xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx", + xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s", bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", - fa, bp->b_ops->name, bp->b_bn); + fa, bp->b_ops->name, bp->b_bn, name); xfs_alert(mp, "Unmount and run xfs_repair"); if (xfs_error_level >= XFS_ERRLEVEL_LOW) { + sz = min_t(size_t, XFS_CORRUPTION_DUMP_LEN, bufsz); xfs_alert(mp, "First %d bytes of corrupted metadata buffer:", - XFS_CORRUPTION_DUMP_LEN); - xfs_hex_dump(xfs_buf_offset(bp, 0), XFS_CORRUPTION_DUMP_LEN); + sz); + xfs_hex_dump(buf, sz); } if (xfs_error_level >= XFS_ERRLEVEL_HIGH) @@ -375,6 +380,20 @@ xfs_verifier_error( } /* + * 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, + int error, + xfs_failaddr_t failaddr) +{ + return xfs_buf_verifier_error(bp, error, "", xfs_buf_offset(bp, 0), + XFS_CORRUPTION_DUMP_LEN, failaddr); +} + +/* * Warnings for inode corruption problems. Don't bother with the stack * trace unless the error level is turned up high. */ diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 7e728c5..ce39134 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -26,6 +26,9 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, extern void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp, void *p, const char *filename, int linenum, xfs_failaddr_t failaddr); +extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error, + const char *name, void *buf, size_t bufsz, + xfs_failaddr_t failaddr); extern void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr); extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,