提交 5dc41107 编写于 作者: D Dave Chinner 提交者: Zheng Zengkai

xfs: add iclog state trace events

mainline-inclusion
from mainline-v5.13-rc4
commit 956f6daa
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=956f6daa84bf50dd5bd13a64b57cae446bca3899

-------------------------------------------------

For the DEBUGS!
Signed-off-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 678e6eea
...@@ -480,6 +480,7 @@ xlog_state_release_iclog( ...@@ -480,6 +480,7 @@ xlog_state_release_iclog(
xfs_lsn_t tail_lsn; xfs_lsn_t tail_lsn;
lockdep_assert_held(&log->l_icloglock); lockdep_assert_held(&log->l_icloglock);
trace_xlog_iclog_release(iclog, _RET_IP_);
if (iclog->ic_state == XLOG_STATE_IOERROR) if (iclog->ic_state == XLOG_STATE_IOERROR)
return -EIO; return -EIO;
...@@ -507,6 +508,7 @@ xlog_state_release_iclog( ...@@ -507,6 +508,7 @@ xlog_state_release_iclog(
iclog->ic_state = XLOG_STATE_SYNCING; iclog->ic_state = XLOG_STATE_SYNCING;
iclog->ic_header.h_tail_lsn = cpu_to_be64(tail_lsn); iclog->ic_header.h_tail_lsn = cpu_to_be64(tail_lsn);
xlog_verify_tail_lsn(log, iclog, tail_lsn); xlog_verify_tail_lsn(log, iclog, tail_lsn);
trace_xlog_iclog_syncing(iclog, _RET_IP_);
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
xlog_sync(log, iclog); xlog_sync(log, iclog);
...@@ -780,6 +782,7 @@ xlog_wait_on_iclog( ...@@ -780,6 +782,7 @@ xlog_wait_on_iclog(
{ {
struct xlog *log = iclog->ic_log; struct xlog *log = iclog->ic_log;
trace_xlog_iclog_wait_on(iclog, _RET_IP_);
if (!XLOG_FORCED_SHUTDOWN(log) && if (!XLOG_FORCED_SHUTDOWN(log) &&
iclog->ic_state != XLOG_STATE_ACTIVE && iclog->ic_state != XLOG_STATE_ACTIVE &&
iclog->ic_state != XLOG_STATE_DIRTY) { iclog->ic_state != XLOG_STATE_DIRTY) {
...@@ -1679,6 +1682,7 @@ xlog_write_iclog( ...@@ -1679,6 +1682,7 @@ xlog_write_iclog(
unsigned int count) unsigned int count)
{ {
ASSERT(bno < log->l_logBBsize); ASSERT(bno < log->l_logBBsize);
trace_xlog_iclog_write(iclog, _RET_IP_);
/* /*
* We lock the iclogbufs here so that we can serialise against I/O * We lock the iclogbufs here so that we can serialise against I/O
...@@ -1834,6 +1838,7 @@ xlog_sync( ...@@ -1834,6 +1838,7 @@ xlog_sync(
unsigned int size; unsigned int size;
ASSERT(atomic_read(&iclog->ic_refcnt) == 0); ASSERT(atomic_read(&iclog->ic_refcnt) == 0);
trace_xlog_iclog_sync(iclog, _RET_IP_);
count = xlog_calc_iclog_size(log, iclog, &roundoff); count = xlog_calc_iclog_size(log, iclog, &roundoff);
...@@ -2471,6 +2476,7 @@ xlog_state_activate_iclog( ...@@ -2471,6 +2476,7 @@ xlog_state_activate_iclog(
int *iclogs_changed) int *iclogs_changed)
{ {
ASSERT(list_empty_careful(&iclog->ic_callbacks)); ASSERT(list_empty_careful(&iclog->ic_callbacks));
trace_xlog_iclog_activate(iclog, _RET_IP_);
/* /*
* If the number of ops in this iclog indicate it just contains the * If the number of ops in this iclog indicate it just contains the
...@@ -2561,6 +2567,8 @@ xlog_state_clean_iclog( ...@@ -2561,6 +2567,8 @@ xlog_state_clean_iclog(
{ {
int iclogs_changed = 0; int iclogs_changed = 0;
trace_xlog_iclog_clean(dirty_iclog, _RET_IP_);
dirty_iclog->ic_state = XLOG_STATE_DIRTY; dirty_iclog->ic_state = XLOG_STATE_DIRTY;
xlog_state_activate_iclogs(log, &iclogs_changed); xlog_state_activate_iclogs(log, &iclogs_changed);
...@@ -2620,6 +2628,7 @@ xlog_state_set_callback( ...@@ -2620,6 +2628,7 @@ xlog_state_set_callback(
struct xlog_in_core *iclog, struct xlog_in_core *iclog,
xfs_lsn_t header_lsn) xfs_lsn_t header_lsn)
{ {
trace_xlog_iclog_callback(iclog, _RET_IP_);
iclog->ic_state = XLOG_STATE_CALLBACK; iclog->ic_state = XLOG_STATE_CALLBACK;
ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn),
...@@ -2727,7 +2736,9 @@ xlog_state_do_callback( ...@@ -2727,7 +2736,9 @@ xlog_state_do_callback(
list_splice_init(&iclog->ic_callbacks, &cb_list); list_splice_init(&iclog->ic_callbacks, &cb_list);
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
trace_xlog_iclog_callbacks_start(iclog, _RET_IP_);
xlog_cil_process_committed(&cb_list); xlog_cil_process_committed(&cb_list);
trace_xlog_iclog_callbacks_done(iclog, _RET_IP_);
cycled_icloglock = true; cycled_icloglock = true;
spin_lock(&log->l_icloglock); spin_lock(&log->l_icloglock);
...@@ -2776,6 +2787,7 @@ xlog_state_done_syncing( ...@@ -2776,6 +2787,7 @@ xlog_state_done_syncing(
spin_lock(&log->l_icloglock); spin_lock(&log->l_icloglock);
ASSERT(atomic_read(&iclog->ic_refcnt) == 0); ASSERT(atomic_read(&iclog->ic_refcnt) == 0);
trace_xlog_iclog_sync_done(iclog, _RET_IP_);
/* /*
* If we got an error, either on the first buffer, or in the case of * If we got an error, either on the first buffer, or in the case of
...@@ -2849,6 +2861,8 @@ xlog_state_get_iclog_space( ...@@ -2849,6 +2861,8 @@ xlog_state_get_iclog_space(
atomic_inc(&iclog->ic_refcnt); /* prevents sync */ atomic_inc(&iclog->ic_refcnt); /* prevents sync */
log_offset = iclog->ic_offset; log_offset = iclog->ic_offset;
trace_xlog_iclog_get_space(iclog, _RET_IP_);
/* On the 1st write to an iclog, figure out lsn. This works /* On the 1st write to an iclog, figure out lsn. This works
* if iclogs marked XLOG_STATE_WANT_SYNC always write out what they are * if iclogs marked XLOG_STATE_WANT_SYNC always write out what they are
* committing to. If the offset is set, that's how many blocks * committing to. If the offset is set, that's how many blocks
...@@ -3014,6 +3028,7 @@ xlog_state_switch_iclogs( ...@@ -3014,6 +3028,7 @@ xlog_state_switch_iclogs(
{ {
ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE);
assert_spin_locked(&log->l_icloglock); assert_spin_locked(&log->l_icloglock);
trace_xlog_iclog_switch(iclog, _RET_IP_);
if (!eventual_size) if (!eventual_size)
eventual_size = iclog->ic_offset; eventual_size = iclog->ic_offset;
...@@ -3124,6 +3139,8 @@ xfs_log_force( ...@@ -3124,6 +3139,8 @@ xfs_log_force(
if (iclog->ic_state == XLOG_STATE_IOERROR) if (iclog->ic_state == XLOG_STATE_IOERROR)
goto out_error; goto out_error;
trace_xlog_iclog_force(iclog, _RET_IP_);
if (iclog->ic_state == XLOG_STATE_DIRTY || if (iclog->ic_state == XLOG_STATE_DIRTY ||
(iclog->ic_state == XLOG_STATE_ACTIVE && (iclog->ic_state == XLOG_STATE_ACTIVE &&
atomic_read(&iclog->ic_refcnt) == 0 && iclog->ic_offset == 0)) { atomic_read(&iclog->ic_refcnt) == 0 && iclog->ic_offset == 0)) {
...@@ -3192,6 +3209,7 @@ xlog_force_lsn( ...@@ -3192,6 +3209,7 @@ xlog_force_lsn(
goto out_error; goto out_error;
while (be64_to_cpu(iclog->ic_header.h_lsn) != lsn) { while (be64_to_cpu(iclog->ic_header.h_lsn) != lsn) {
trace_xlog_iclog_force_lsn(iclog, _RET_IP_);
iclog = iclog->ic_next; iclog = iclog->ic_next;
if (iclog == log->l_iclog) if (iclog == log->l_iclog)
goto out_unlock; goto out_unlock;
......
...@@ -50,6 +50,16 @@ enum xlog_iclog_state { ...@@ -50,6 +50,16 @@ enum xlog_iclog_state {
XLOG_STATE_IOERROR, /* IO error happened in sync'ing log */ XLOG_STATE_IOERROR, /* IO error happened in sync'ing log */
}; };
#define XLOG_STATE_STRINGS \
{ XLOG_STATE_ACTIVE, "XLOG_STATE_ACTIVE" }, \
{ XLOG_STATE_WANT_SYNC, "XLOG_STATE_WANT_SYNC" }, \
{ XLOG_STATE_SYNCING, "XLOG_STATE_SYNCING" }, \
{ XLOG_STATE_DONE_SYNC, "XLOG_STATE_DONE_SYNC" }, \
{ XLOG_STATE_CALLBACK, "XLOG_STATE_CALLBACK" }, \
{ XLOG_STATE_DIRTY, "XLOG_STATE_DIRTY" }, \
{ XLOG_STATE_IOERROR, "XLOG_STATE_IOERROR" }
/* /*
* Log ticket flags * Log ticket flags
*/ */
......
...@@ -24,6 +24,7 @@ struct xlog_ticket; ...@@ -24,6 +24,7 @@ struct xlog_ticket;
struct xlog_recover; struct xlog_recover;
struct xlog_recover_item; struct xlog_recover_item;
struct xlog_rec_header; struct xlog_rec_header;
struct xlog_in_core;
struct xfs_buf_log_format; struct xfs_buf_log_format;
struct xfs_inode_log_format; struct xfs_inode_log_format;
struct xfs_bmbt_irec; struct xfs_bmbt_irec;
...@@ -3909,6 +3910,65 @@ DEFINE_EVENT(xfs_icwalk_class, name, \ ...@@ -3909,6 +3910,65 @@ DEFINE_EVENT(xfs_icwalk_class, name, \
DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks); DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks);
DEFINE_ICWALK_EVENT(xfs_blockgc_free_space); DEFINE_ICWALK_EVENT(xfs_blockgc_free_space);
TRACE_DEFINE_ENUM(XLOG_STATE_ACTIVE);
TRACE_DEFINE_ENUM(XLOG_STATE_WANT_SYNC);
TRACE_DEFINE_ENUM(XLOG_STATE_SYNCING);
TRACE_DEFINE_ENUM(XLOG_STATE_DONE_SYNC);
TRACE_DEFINE_ENUM(XLOG_STATE_CALLBACK);
TRACE_DEFINE_ENUM(XLOG_STATE_DIRTY);
TRACE_DEFINE_ENUM(XLOG_STATE_IOERROR);
DECLARE_EVENT_CLASS(xlog_iclog_class,
TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip),
TP_ARGS(iclog, caller_ip),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(uint32_t, state)
__field(int32_t, refcount)
__field(uint32_t, offset)
__field(unsigned long long, lsn)
__field(unsigned long, caller_ip)
),
TP_fast_assign(
__entry->dev = iclog->ic_log->l_mp->m_super->s_dev;
__entry->state = iclog->ic_state;
__entry->refcount = atomic_read(&iclog->ic_refcnt);
__entry->offset = iclog->ic_offset;
__entry->lsn = be64_to_cpu(iclog->ic_header.h_lsn);
__entry->caller_ip = caller_ip;
),
TP_printk("dev %d:%d state %s refcnt %d offset %u lsn 0x%llx caller %pS",
MAJOR(__entry->dev), MINOR(__entry->dev),
__print_symbolic(__entry->state, XLOG_STATE_STRINGS),
__entry->refcount,
__entry->offset,
__entry->lsn,
(char *)__entry->caller_ip)
);
#define DEFINE_ICLOG_EVENT(name) \
DEFINE_EVENT(xlog_iclog_class, name, \
TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip), \
TP_ARGS(iclog, caller_ip))
DEFINE_ICLOG_EVENT(xlog_iclog_activate);
DEFINE_ICLOG_EVENT(xlog_iclog_clean);
DEFINE_ICLOG_EVENT(xlog_iclog_callback);
DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_start);
DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_done);
DEFINE_ICLOG_EVENT(xlog_iclog_force);
DEFINE_ICLOG_EVENT(xlog_iclog_force_lsn);
DEFINE_ICLOG_EVENT(xlog_iclog_get_space);
DEFINE_ICLOG_EVENT(xlog_iclog_release);
DEFINE_ICLOG_EVENT(xlog_iclog_switch);
DEFINE_ICLOG_EVENT(xlog_iclog_sync);
DEFINE_ICLOG_EVENT(xlog_iclog_syncing);
DEFINE_ICLOG_EVENT(xlog_iclog_sync_done);
DEFINE_ICLOG_EVENT(xlog_iclog_want_sync);
DEFINE_ICLOG_EVENT(xlog_iclog_wait_on);
DEFINE_ICLOG_EVENT(xlog_iclog_write);
#endif /* _TRACE_XFS_H */ #endif /* _TRACE_XFS_H */
#undef TRACE_INCLUDE_PATH #undef TRACE_INCLUDE_PATH
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册