]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: add trace point for fs shutdown
authorDarrick J. Wong <djwong@kernel.org>
Wed, 11 Aug 2021 00:00:54 +0000 (17:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 19 Aug 2021 01:46:00 +0000 (18:46 -0700)
Add a tracepoint for fs shutdowns so we can capture that in ftrace
output.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_error.h
fs/xfs/xfs_fsops.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_trace.c
fs/xfs/xfs_trace.h

index 1717b7508356443d62ed3f70e0a1116f6a1b28ef..5735d5ea87ee2a1ff4c5615563639baa2b90af26 100644 (file)
@@ -75,4 +75,16 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
 #define                XFS_PTAG_FSBLOCK_ZERO           0x00000080
 #define                XFS_PTAG_VERIFIER_ERROR         0x00000100
 
+#define XFS_PTAG_STRINGS \
+       { XFS_NO_PTAG,                  "none" }, \
+       { XFS_PTAG_IFLUSH,              "iflush" }, \
+       { XFS_PTAG_LOGRES,              "logres" }, \
+       { XFS_PTAG_AILDELETE,           "aildelete" }, \
+       { XFS_PTAG_ERROR_REPORT ,       "error_report" }, \
+       { XFS_PTAG_SHUTDOWN_CORRUPT,    "corrupt" }, \
+       { XFS_PTAG_SHUTDOWN_IOERROR,    "ioerror" }, \
+       { XFS_PTAG_SHUTDOWN_LOGERROR,   "logerror" }, \
+       { XFS_PTAG_FSBLOCK_ZERO,        "fsb_zero" }, \
+       { XFS_PTAG_VERIFIER_ERROR,      "verifier" }
+
 #endif /* __XFS_ERROR_H__ */
index 7a2f4feacc35333978987fad114bd9c1857427ec..0ef0aad7ddc9da3a4a8389b370adfd2a906e3916 100644 (file)
@@ -19,6 +19,7 @@
 #include "xfs_log.h"
 #include "xfs_ag.h"
 #include "xfs_ag_resv.h"
+#include "xfs_trace.h"
 
 /*
  * Write new AG headers to disk. Non-transactional, but need to be
@@ -551,6 +552,8 @@ xfs_do_force_shutdown(
                why = "Metadata I/O Error";
        }
 
+       trace_xfs_force_shutdown(mp, tag, flags, fname, lnnum);
+
        xfs_alert_tag(mp, tag,
 "%s (0x%x) detected at %pS (%s:%d).  Shutting down filesystem.",
                        why, flags, __return_address, fname, lnnum);
index 2266c6a668cf7e7b093d184b4e59639593030ba1..57f2ea398832d033c673595f628a01aace6cad6f 100644 (file)
@@ -331,6 +331,12 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
 #define SHUTDOWN_FORCE_UMOUNT  0x0004  /* shutdown from a forced unmount */
 #define SHUTDOWN_CORRUPT_INCORE        0x0008  /* corrupt in-memory data structures */
 
+#define XFS_SHUTDOWN_STRINGS \
+       { SHUTDOWN_META_IO_ERROR,       "metadata_io" }, \
+       { SHUTDOWN_LOG_IO_ERROR,        "log_io" }, \
+       { SHUTDOWN_FORCE_UMOUNT,        "force_umount" }, \
+       { SHUTDOWN_CORRUPT_INCORE,      "corruption" }
+
 /*
  * Flags for xfs_mountfs
  */
index 4c86afad1617b8cb08645bfeca227c969d55af56..d269ef57ff0166c0ef17d0c9b58b06e59932c673 100644 (file)
@@ -33,6 +33,7 @@
 #include "xfs_icache.h"
 #include "xfs_ag.h"
 #include "xfs_ag_resv.h"
+#include "xfs_error.h"
 
 /*
  * We include this last to have the helpers above available for the trace
index 70c142f6aeb24cad724e96ad66deeeb538a1edf6..84199e29845ddbc2ae30d85568ab5e60485f33a6 100644 (file)
@@ -4096,6 +4096,33 @@ DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
+
+TRACE_EVENT(xfs_force_shutdown,
+       TP_PROTO(struct xfs_mount *mp, int ptag, int flags, const char *fname,
+                int line_num),
+       TP_ARGS(mp, ptag, flags, fname, line_num),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(int, ptag)
+               __field(int, flags)
+               __string(fname, fname)
+               __field(int, line_num)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->ptag = ptag;
+               __entry->flags = flags;
+               __assign_str(fname, fname);
+               __entry->line_num = line_num;
+       ),
+       TP_printk("dev %d:%d tag %s flags %s file %s line_num %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+               __print_flags(__entry->ptag, "|", XFS_PTAG_STRINGS),
+               __print_flags(__entry->flags, "|", XFS_SHUTDOWN_STRINGS),
+               __get_str(fname),
+               __entry->line_num)
+);
+
 #endif /* _TRACE_XFS_H */
 
 #undef TRACE_INCLUDE_PATH