]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: refactor inode verifier corruption error printing
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)
committerEric Sandeen <sandeen@redhat.com>
Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)
Source kernel commit: 22431bf3dfbf44d7356933776eb486a6a01dea6f

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>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_priv.h
libxfs/rdwr.c
libxfs/util.c
libxfs/xfs_inode_buf.c

index 82627668fb006a22db00b82876b68e062b149063..d35676e9c797d5303f5bbe81ead26ebf1266d715 100644 (file)
@@ -527,7 +527,11 @@ int  libxfs_mod_incore_sb(struct xfs_mount *, int, int64_t, int);
 #define xfs_reinit_percpu_counters(mp)
 
 void xfs_trans_mod_sb(struct xfs_trans *, uint, long);
-void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr);
+void xfs_verifier_error(struct xfs_buf *bp, int error,
+                       xfs_failaddr_t failaddr);
+void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
+                       const char *name, void *buf, size_t bufsz,
+                       xfs_failaddr_t failaddr);
 
 /* XXX: this is clearly a bug - a shared header needs to export this */
 /* xfs_rtalloc.c */
index 7b75648c22b4f32f1190c4667bd11c47f90d039f..3c5def2950292926368b20bbd35fd91253c64079 100644 (file)
@@ -1344,21 +1344,23 @@ bool
 libxfs_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 %Lu inline data fork at %pF",
-                               __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 %Lu inline attr fork at %pF",
-                               __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;
index 2d3b721777e33992158b1b55494665f8afe482da..aac558cf0cf43981d5f67f3fa07f88612b6a027c 100644 (file)
@@ -743,6 +743,25 @@ xfs_verifier_error(
                  bp->b_ops->name, bp->b_bn, BBTOB(bp->b_length));
 }
 
+/*
+ * 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)
+{
+       xfs_alert(NULL, "Metadata %s detected at %p, inode 0x%llx %s",
+                 error == -EFSBADCRC ? "CRC error" : "corruption",
+                 failaddr ? failaddr : __return_address,
+                 ip->i_ino, name);
+}
+
 /*
  * This is called from I/O verifiers on v5 superblock filesystems. In the
  * kernel, it validates the metadata LSN parameter against the current LSN of
index ecbd517854d2cfc56d89bd7c7247681022875033..2c805b342ea269816448011c66c1ba3261674c2d 100644 (file)
@@ -577,10 +577,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, "dinode", dip,
+                               sizeof(*dip), fa);
                error = -EFSCORRUPTED;
                goto out_brelse;
        }