From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 10/11] xfs: refactor inode verifier corruption error printing
Date: Thu, 25 Jan 2018 12:31:40 -0500 [thread overview]
Message-ID: <20180125173139.GE44175@bfoster.bfoster> (raw)
In-Reply-To: <151676034665.12349.14442218679852748423.stgit@magnolia>
On Tue, Jan 23, 2018 at 06:19:06PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Refactor inode verifier error reporting into a non-libxfs function so
> that we aren't encoding the message format in libxfs. This also
> changes the kernel dmesg output to resemble buffer verifier errors
> more closely.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/libxfs/xfs_inode_buf.c | 6 ++----
> fs/xfs/xfs_error.c | 37 +++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_error.h | 3 +++
> fs/xfs/xfs_inode.c | 14 ++++++++------
> 4 files changed, 50 insertions(+), 10 deletions(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 6e9dcdb..6d05ba6 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -578,10 +578,8 @@ xfs_iread(
> /* even unallocated inodes are verified */
> fa = xfs_dinode_verify(mp, ip->i_ino, dip);
> if (fa) {
> - xfs_alert(mp, "%s: validation failed for inode %lld at %pS",
> - __func__, ip->i_ino, fa);
> -
> - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, dip);
> + xfs_inode_verifier_error(ip, -EFSCORRUPTED, "record", dip,
> + sizeof(*dip), fa);
What does "record" mean? "dinode" perhaps? Otherwise looks fine:
Reviewed-by: Brian Foster <bfoster@redhat.com>
> error = -EFSCORRUPTED;
> goto out_brelse;
> }
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 980d5f0..ccf520f 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -24,6 +24,7 @@
> #include "xfs_errortag.h"
> #include "xfs_error.h"
> #include "xfs_sysfs.h"
> +#include "xfs_inode.h"
>
> #ifdef DEBUG
>
> @@ -372,3 +373,39 @@ xfs_verifier_error(
> if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
> xfs_stack_trace();
> }
> +
> +/*
> + * Warnings for inode corruption problems. Don't bother with the stack
> + * trace unless the error level is turned up high.
> + */
> +void
> +xfs_inode_verifier_error(
> + struct xfs_inode *ip,
> + int error,
> + const char *name,
> + void *buf,
> + size_t bufsz,
> + xfs_failaddr_t failaddr)
> +{
> + struct xfs_mount *mp = ip->i_mount;
> + xfs_failaddr_t fa;
> + int sz;
> +
> + fa = failaddr ? failaddr : __return_address;
> +
> + xfs_alert(mp, "Metadata %s detected at %pS, inode 0x%llx %s",
> + error == -EFSBADCRC ? "CRC error" : "corruption",
> + fa, ip->i_ino, name);
> +
> + xfs_alert(mp, "Unmount and run xfs_repair");
> +
> + if (buf && 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:",
> + sz);
> + xfs_hex_dump(buf, sz);
> + }
> +
> + if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
> + xfs_stack_trace();
> +}
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index a3ba05b..7e728c5 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -28,6 +28,9 @@ extern void xfs_corruption_error(const char *tag, int level,
> int linenum, 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,
> + const char *name, void *buf, size_t bufsz,
> + xfs_failaddr_t failaddr);
>
> #define XFS_ERROR_REPORT(e, lvl, mp) \
> xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index fc118dd..c60efec 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3502,21 +3502,23 @@ bool
> xfs_inode_verify_forks(
> struct xfs_inode *ip)
> {
> + struct xfs_ifork *ifp;
> xfs_failaddr_t fa;
>
> fa = xfs_ifork_verify_data(ip, &xfs_default_ifork_ops);
> if (fa) {
> - xfs_alert(ip->i_mount,
> - "%s: bad inode %llu inline data fork at %pS",
> - __func__, ip->i_ino, fa);
> + ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> + xfs_inode_verifier_error(ip, -EFSCORRUPTED, "data fork",
> + ifp->if_u1.if_data, ifp->if_bytes, fa);
> return false;
> }
>
> fa = xfs_ifork_verify_attr(ip, &xfs_default_ifork_ops);
> if (fa) {
> - xfs_alert(ip->i_mount,
> - "%s: bad inode %llu inline attr fork at %pS",
> - __func__, ip->i_ino, fa);
> + ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
> + xfs_inode_verifier_error(ip, -EFSCORRUPTED, "attr fork",
> + ifp ? ifp->if_u1.if_data : NULL,
> + ifp ? ifp->if_bytes : 0, fa);
> return false;
> }
> return true;
>
> --
> 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
next prev parent reply other threads:[~2018-01-25 17:31 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 2:17 [PATCH 00/11] xfs: reflink/scrub/quota fixes Darrick J. Wong
2018-01-24 2:18 ` [PATCH 01/11] xfs: reflink should break pnfs leases before sharing blocks Darrick J. Wong
2018-01-24 14:16 ` Brian Foster
2018-01-26 9:06 ` Christoph Hellwig
2018-01-26 18:26 ` Darrick J. Wong
2018-01-24 2:18 ` [PATCH 02/11] xfs: only grab shared inode locks for source file during reflink Darrick J. Wong
2018-01-24 14:18 ` Brian Foster
2018-01-24 18:40 ` Darrick J. Wong
2018-01-26 12:07 ` Christoph Hellwig
2018-01-26 18:48 ` Darrick J. Wong
2018-01-27 3:32 ` Dave Chinner
2018-01-24 2:18 ` [PATCH 03/11] xfs: call xfs_qm_dqattach before performing reflink operations Darrick J. Wong
2018-01-24 14:18 ` Brian Foster
2018-01-26 9:07 ` Christoph Hellwig
2018-01-24 2:18 ` [PATCH 04/11] xfs: CoW fork operations should only update quota reservations Darrick J. Wong
2018-01-24 14:22 ` Brian Foster
2018-01-24 19:14 ` Darrick J. Wong
2018-01-25 13:01 ` Brian Foster
2018-01-25 17:52 ` Darrick J. Wong
2018-01-25 1:20 ` [PATCH v2 " Darrick J. Wong
2018-01-25 13:03 ` Brian Foster
2018-01-25 18:20 ` Darrick J. Wong
2018-01-26 13:02 ` Brian Foster
2018-01-26 18:40 ` Darrick J. Wong
2018-01-26 12:12 ` Christoph Hellwig
2018-01-24 2:18 ` [PATCH 05/11] xfs: track CoW blocks separately in the inode Darrick J. Wong
2018-01-25 13:06 ` Brian Foster
2018-01-25 19:21 ` Darrick J. Wong
2018-01-26 13:04 ` Brian Foster
2018-01-26 19:08 ` Darrick J. Wong
2018-01-26 12:15 ` Christoph Hellwig
2018-01-26 19:00 ` Darrick J. Wong
2018-01-26 23:51 ` Darrick J. Wong
2018-01-24 2:18 ` [PATCH 06/11] xfs: fix up cowextsz allocation shortfalls Darrick J. Wong
2018-01-25 17:31 ` Brian Foster
2018-01-25 20:20 ` Darrick J. Wong
2018-01-26 13:06 ` Brian Foster
2018-01-26 19:12 ` Darrick J. Wong
2018-01-26 9:11 ` Christoph Hellwig
2018-01-24 2:18 ` [PATCH 07/11] xfs: always zero di_flags2 when we free the inode Darrick J. Wong
2018-01-25 17:31 ` Brian Foster
2018-01-25 18:36 ` Darrick J. Wong
2018-01-26 9:08 ` Christoph Hellwig
2018-01-24 2:18 ` [PATCH 08/11] xfs: fix tracepoint %p formats Darrick J. Wong
2018-01-25 17:31 ` Brian Foster
2018-01-25 18:47 ` Darrick J. Wong
2018-01-26 0:19 ` Darrick J. Wong
2018-01-26 9:09 ` Christoph Hellwig
2018-01-24 2:18 ` [PATCH 09/11] xfs: make tracepoint inode number format consistent Darrick J. Wong
2018-01-25 17:31 ` Brian Foster
2018-01-26 9:09 ` Christoph Hellwig
2018-01-24 2:19 ` [PATCH 10/11] xfs: refactor inode verifier corruption error printing Darrick J. Wong
2018-01-25 17:31 ` Brian Foster [this message]
2018-01-25 18:23 ` Darrick J. Wong
2018-01-26 9:10 ` Christoph Hellwig
2018-01-24 2:19 ` [PATCH 11/11] xfs: don't clobber inobt/finobt cursors when xref with rmap Darrick J. Wong
2018-01-26 9:10 ` Christoph Hellwig
2018-01-25 5:26 ` [PATCH 12/11] xfs: refactor quota code in xfs_bmap_btalloc Darrick J. Wong
2018-01-26 12:17 ` Christoph Hellwig
2018-01-26 21:46 ` 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=20180125173139.GE44175@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).