summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-01-05 17:46:09 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-03-25 17:08:54 -0700
commitea5a9dbd8c77595e374f67958f359a2b61ac9718 (patch)
tree060b8d6d6d51660648a877d527a47a3656b36e05
parent077f94200f28630fc14e2347cf89d47135f878ef (diff)
xfs: whine to dmesg when we encounter errorsdjwong-wtf_2021-03-25
Forward everything scrub whines about to dmesg. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/scrub/btree.c68
-rw-r--r--fs/xfs/scrub/common.c90
-rw-r--r--fs/xfs/scrub/common.h1
-rw-r--r--fs/xfs/scrub/dabtree.c15
-rw-r--r--fs/xfs/scrub/scrub.c6
-rw-r--r--fs/xfs/xfs_error.c2
6 files changed, 182 insertions, 0 deletions
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index 352d5a4368ce..034d3c3c8b18 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -10,6 +10,8 @@
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_btree.h"
+#include "xfs_log_format.h"
+#include "xfs_inode.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/btree.h"
@@ -17,6 +19,22 @@
/* btree scrubbing */
+/* Figure out which block the btree cursor was pointing to. */
+static inline xfs_fsblock_t
+xchk_btree_cur_fsbno(
+ struct xfs_btree_cur *cur,
+ int level)
+{
+ if (level < cur->bc_nlevels && cur->bc_levels[level].bp)
+ return XFS_DADDR_TO_FSB(cur->bc_mp, cur->bc_levels[level].bp->b_bn);
+ else if (level == cur->bc_nlevels - 1 &&
+ (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE))
+ return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_ino.ip->i_ino);
+ else if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS))
+ return XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_ag.agno, 0);
+ return NULLFSBLOCK;
+}
+
/*
* Check for btree operation errors. See the section about handling
* operational errors in common.c.
@@ -46,11 +64,37 @@ __xchk_btree_process_error(
/* fall through */
default:
if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
+ {
+ xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
+ xchk_whine(sc->mp, "ino %llu fork %d type %d btnum %d level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
+ cur->bc_ino.ip->i_ino,
+ cur->bc_ino.whichfork,
+ sc->sm->sm_type,
+ cur->bc_btnum,
+ level,
+ cur->bc_levels[level].ptr,
+ XFS_FSB_TO_AGNO(cur->bc_mp, fsbno),
+ XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno),
+ *error,
+ ret_ip);
trace_xchk_ifork_btree_op_error(sc, cur, level,
*error, ret_ip);
+ }
else
+ {
+ xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
+ xchk_whine(sc->mp, "type %d btnum %d level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
+ sc->sm->sm_type,
+ cur->bc_btnum,
+ level,
+ cur->bc_levels[level].ptr,
+ XFS_FSB_TO_AGNO(cur->bc_mp, fsbno),
+ XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno),
+ *error,
+ ret_ip);
trace_xchk_btree_op_error(sc, cur, level,
*error, ret_ip);
+ }
break;
}
return false;
@@ -90,11 +134,35 @@ __xchk_btree_set_corrupt(
sc->sm->sm_flags |= errflag;
if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
+ {
+ xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
+ xchk_whine(sc->mp, "ino %llu fork %d type %d btnum %d level %d ptr %d agno %u agbno %u ret_ip %pS",
+ cur->bc_ino.ip->i_ino,
+ cur->bc_ino.whichfork,
+ sc->sm->sm_type,
+ cur->bc_btnum,
+ level,
+ cur->bc_levels[level].ptr,
+ XFS_FSB_TO_AGNO(cur->bc_mp, fsbno),
+ XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno),
+ ret_ip);
trace_xchk_ifork_btree_error(sc, cur, level,
ret_ip);
+ }
else
+ {
+ xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
+ xchk_whine(sc->mp, "type %d btnum %d level %d ptr %d agno %u agbno %u ret_ip %pS",
+ sc->sm->sm_type,
+ cur->bc_btnum,
+ level,
+ cur->bc_levels[level].ptr,
+ XFS_FSB_TO_AGNO(cur->bc_mp, fsbno),
+ XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno),
+ ret_ip);
trace_xchk_btree_error(sc, cur, level,
ret_ip);
+ }
}
void
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index fa3606d9b332..6113b6c3d5c4 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -30,6 +30,7 @@
#include "xfs_rtalloc.h"
#include "xfs_rtrmap_btree.h"
#include "xfs_rtrefcount_btree.h"
+#include "xfs_error.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/trace.h"
@@ -96,6 +97,12 @@ __xchk_process_error(
*error = 0;
/* fall through */
default:
+ xchk_whine(sc->mp, "type %d agno %u agbno %u error %d ret_ip %pS",
+ sc->sm->sm_type,
+ agno,
+ bno,
+ *error,
+ ret_ip);
trace_xchk_op_error(sc, agno, bno, *error, ret_ip);
break;
}
@@ -158,6 +165,13 @@ __xchk_fblock_process_error(
*error = 0;
/* fall through */
default:
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu error %d ret_ip %pS",
+ sc->ip->i_ino,
+ whichfork,
+ sc->sm->sm_type,
+ offset,
+ *error,
+ ret_ip);
trace_xchk_file_op_error(sc, whichfork, offset, *error,
ret_ip);
break;
@@ -229,6 +243,8 @@ xchk_set_corrupt(
struct xfs_scrub *sc)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "type %d ret_ip %pS", sc->sm->sm_type,
+ __return_address);
trace_xchk_fs_error(sc, 0, __return_address);
}
@@ -239,6 +255,11 @@ xchk_block_set_corrupt(
struct xfs_buf *bp)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "type %d agno %u agbno %u ret_ip %pS",
+ sc->sm->sm_type,
+ XFS_FSB_TO_AGNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ XFS_FSB_TO_AGBNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ __return_address);
trace_xchk_block_error(sc, bp->b_bn, __return_address);
}
@@ -250,6 +271,8 @@ xchk_qcheck_set_corrupt(
xfs_dqid_t id)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "type %d dqtype %u id %u ret_ip %pS",
+ sc->sm->sm_type, dqtype, id, __return_address);
trace_xchk_qcheck_error(sc, dqtype, id, __return_address);
}
@@ -260,6 +283,11 @@ xchk_block_xref_set_corrupt(
struct xfs_buf *bp)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
+ xchk_whine(sc->mp, "type %d agno %u agbno %u ret_ip %pS",
+ sc->sm->sm_type,
+ XFS_FSB_TO_AGNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ XFS_FSB_TO_AGBNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ __return_address);
trace_xchk_block_error(sc, bp->b_bn, __return_address);
}
@@ -274,6 +302,8 @@ xchk_ino_set_corrupt(
xfs_ino_t ino)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "ino %llu type %d ret_ip %pS",
+ ino, sc->sm->sm_type, __return_address);
trace_xchk_ino_error(sc, ino, __return_address);
}
@@ -284,6 +314,8 @@ xchk_ino_xref_set_corrupt(
xfs_ino_t ino)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
+ xchk_whine(sc->mp, "ino %llu type %d ret_ip %pS",
+ ino, sc->sm->sm_type, __return_address);
trace_xchk_ino_error(sc, ino, __return_address);
}
@@ -295,6 +327,12 @@ xchk_fblock_set_corrupt(
xfs_fileoff_t offset)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu ret_ip %pS",
+ sc->ip->i_ino,
+ whichfork,
+ sc->sm->sm_type,
+ offset,
+ __return_address);
trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
}
@@ -306,6 +344,12 @@ xchk_fblock_xref_set_corrupt(
xfs_fileoff_t offset)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu ret_ip %pS",
+ sc->ip->i_ino,
+ whichfork,
+ sc->sm->sm_type,
+ offset,
+ __return_address);
trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
}
@@ -319,6 +363,8 @@ xchk_ino_set_warning(
xfs_ino_t ino)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
+ xchk_whine(sc->mp, "ino %llu type %d agno %u agbno %u ret_ip %pS",
+ ino, sc->sm->sm_type, __return_address);
trace_xchk_ino_warning(sc, ino, __return_address);
}
@@ -330,6 +376,12 @@ xchk_fblock_set_warning(
xfs_fileoff_t offset)
{
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu ret_ip %pS",
+ sc->ip->i_ino,
+ whichfork,
+ sc->sm->sm_type,
+ offset,
+ __return_address);
trace_xchk_fblock_warning(sc, whichfork, offset, __return_address);
}
@@ -826,6 +878,12 @@ xchk_get_inode(
error = -EFSCORRUPTED;
/* fall through */
default:
+ xchk_whine(mp, "type %d agno %u agbno %u error %d ret_ip %pS",
+ sc->sm->sm_type,
+ XFS_INO_TO_AGNO(mp, sc->sm->sm_ino),
+ XFS_INO_TO_AGBNO(mp, sc->sm->sm_ino),
+ error,
+ __return_address);
trace_xchk_op_error(sc,
XFS_INO_TO_AGNO(mp, sc->sm->sm_ino),
XFS_INO_TO_AGBNO(mp, sc->sm->sm_ino),
@@ -902,6 +960,10 @@ xchk_should_check_xref(
}
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XFAIL;
+ xchk_whine(sc->mp, "type %d xref error %d ret_ip %pS",
+ sc->sm->sm_type,
+ *error,
+ __return_address);
trace_xchk_xref_error(sc, *error, __return_address);
/*
@@ -932,6 +994,11 @@ xchk_buffer_recheck(
if (!fa)
return;
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "type %d agno %u agbno %u ret_ip %pS",
+ sc->sm->sm_type,
+ XFS_FSB_TO_AGNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ XFS_FSB_TO_AGBNO(sc->mp, XFS_DADDR_TO_FSB(sc->mp, bp->b_bn)),
+ fa);
trace_xchk_block_error(sc, bp->b_bn, fa);
}
@@ -1118,3 +1185,26 @@ xchk_fs_thaw(
mutex_unlock(&sc->mp->m_scrub_freeze);
return error;
}
+
+/* Complain about failures... */
+void
+xchk_whine(
+ const struct xfs_mount *mp,
+ const char *fmt,
+ ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ va_start(args, fmt);
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ printk(KERN_INFO "XFS (%s) %pS: %pV\n", mp->m_super->s_id,
+ __return_address, &vaf);
+ va_end(args);
+
+ if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
+ xfs_stack_trace();
+}
diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
index 193705567965..4e92bb89ef5d 100644
--- a/fs/xfs/scrub/common.h
+++ b/fs/xfs/scrub/common.h
@@ -150,6 +150,7 @@ int xchk_get_inode(struct xfs_scrub *sc);
int xchk_setup_inode_contents(struct xfs_scrub *sc, unsigned int resblks);
int xchk_install_inode(struct xfs_scrub *sc, struct xfs_inode *ip);
void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp);
+void xchk_whine(const struct xfs_mount *mp, const char *fmt, ...);
/*
* Don't bother cross-referencing if we already found corruption or cross
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 851a9eb54a5a..ae9e9debd9e5 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -49,6 +49,14 @@ xchk_da_process_error(
*error = 0;
/* fall through */
default:
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu error %d ret_ip %pS",
+ sc->ip->i_ino,
+ ds->dargs.whichfork,
+ sc->sm->sm_type,
+ xfs_dir2_da_to_db(ds->dargs.geo,
+ ds->state->path.blk[level].blkno),
+ *error,
+ __return_address);
trace_xchk_file_op_error(sc, ds->dargs.whichfork,
xfs_dir2_da_to_db(ds->dargs.geo,
ds->state->path.blk[level].blkno),
@@ -71,6 +79,13 @@ xchk_da_set_corrupt(
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+ xchk_whine(sc->mp, "ino %llu fork %d type %d offset %llu ret_ip %pS",
+ sc->ip->i_ino,
+ ds->dargs.whichfork,
+ sc->sm->sm_type,
+ xfs_dir2_da_to_db(ds->dargs.geo,
+ ds->state->path.blk[level].blkno),
+ __return_address);
trace_xchk_fblock_error(sc, ds->dargs.whichfork,
xfs_dir2_da_to_db(ds->dargs.geo,
ds->state->path.blk[level].blkno),
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index 5f8ef9861460..d0d06c93f373 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -619,6 +619,12 @@ retry_op:
* already tried to fix it, then attempt a repair.
*/
error = xrep_attempt(sc);
+ if (error != -EOPNOTSUPP && error != -ENOENT)
+ xchk_whine(mp, "REPAIRED? ino 0x%llx type %u agno %u inum %llu gen %u flags 0x%x error %d",
+ XFS_I(file_inode(filp))->i_ino,
+ sm->sm_type, sm->sm_agno,
+ sm->sm_ino, sm->sm_gen, sm->sm_flags,
+ (sc->flags & XREP_ALREADY_FIXED) ? 0 : error);
if (error == -EAGAIN) {
/*
* Either the repair function succeeded or it couldn't
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 9b6c38d0671b..0afcd14825a0 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -267,9 +267,11 @@ xfs_errortag_test(
if (!randfactor || prandom_u32() % randfactor)
return false;
+#if 0
xfs_warn_ratelimited(mp,
"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",
expression, file, line, mp->m_super->s_id);
+#endif
return true;
}