Commit 71f5a17e authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: give rmap btree cursor error tracepoints their own class



Create a new tracepoint class for btree-related errors, then convert all
the rmap tracepoints to use it.  Also fix the one tracepoint that was
abusing the old class by making it a separate tracepoint.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 84a3c157
Loading
Loading
Loading
Loading
+11 −22
Original line number Diff line number Diff line
@@ -111,8 +111,7 @@ xfs_rmap_update(
			xfs_rmap_irec_offset_pack(irec));
	error = xfs_btree_update(cur, &rec);
	if (error)
		trace_xfs_rmap_update_error(cur->bc_mp,
				cur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_update_error(cur, error, _RET_IP_);
	return error;
}

@@ -155,8 +154,7 @@ xfs_rmap_insert(
	}
done:
	if (error)
		trace_xfs_rmap_insert_error(rcur->bc_mp,
				rcur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_insert_error(rcur, error, _RET_IP_);
	return error;
}

@@ -194,8 +192,7 @@ xfs_rmap_delete(
	}
done:
	if (error)
		trace_xfs_rmap_delete_error(rcur->bc_mp,
				rcur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_delete_error(rcur, error, _RET_IP_);
	return error;
}

@@ -816,8 +813,7 @@ xfs_rmap_unmap(
			unwritten, oinfo);
out_error:
	if (error)
		trace_xfs_rmap_unmap_error(mp, cur->bc_ag.pag->pag_agno,
				error, _RET_IP_);
		trace_xfs_rmap_unmap_error(cur, error, _RET_IP_);
	return error;
}

@@ -1148,8 +1144,7 @@ xfs_rmap_map(
			unwritten, oinfo);
out_error:
	if (error)
		trace_xfs_rmap_map_error(mp, cur->bc_ag.pag->pag_agno,
				error, _RET_IP_);
		trace_xfs_rmap_map_error(cur, error, _RET_IP_);
	return error;
}

@@ -1344,8 +1339,7 @@ xfs_rmap_convert(
	     RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX)
		state &= ~RMAP_RIGHT_CONTIG;

	trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state,
			_RET_IP_);
	trace_xfs_rmap_convert_state(cur, state, _RET_IP_);

	/* reset the cursor back to PREV */
	error = xfs_rmap_lookup_le(cur, bno, owner, offset, oldext, NULL, &i);
@@ -1698,8 +1692,7 @@ xfs_rmap_convert(
			unwritten, oinfo);
done:
	if (error)
		trace_xfs_rmap_convert_error(cur->bc_mp,
				cur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_convert_error(cur, error, _RET_IP_);
	return error;
}

@@ -1822,8 +1815,7 @@ xfs_rmap_convert_shared(
	     RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX)
		state &= ~RMAP_RIGHT_CONTIG;

	trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state,
			_RET_IP_);
	trace_xfs_rmap_convert_state(cur, state, _RET_IP_);
	/*
	 * Switch out based on the FILLING and CONTIG state bits.
	 */
@@ -2125,8 +2117,7 @@ xfs_rmap_convert_shared(
			unwritten, oinfo);
done:
	if (error)
		trace_xfs_rmap_convert_error(cur->bc_mp,
				cur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_convert_error(cur, error, _RET_IP_);
	return error;
}

@@ -2325,8 +2316,7 @@ xfs_rmap_unmap_shared(
			unwritten, oinfo);
out_error:
	if (error)
		trace_xfs_rmap_unmap_error(cur->bc_mp,
				cur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_unmap_error(cur, error, _RET_IP_);
	return error;
}

@@ -2486,8 +2476,7 @@ xfs_rmap_map_shared(
			unwritten, oinfo);
out_error:
	if (error)
		trace_xfs_rmap_map_error(cur->bc_mp,
				cur->bc_ag.pag->pag_agno, error, _RET_IP_);
		trace_xfs_rmap_map_error(cur, error, _RET_IP_);
	return error;
}

+99 −18
Original line number Diff line number Diff line
@@ -2826,46 +2826,98 @@ DEFINE_EVENT(xfs_rmap_class, name, \
		 const struct xfs_owner_info *oinfo), \
	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo))

/* simple AG-based error/%ip tracepoint class */
DECLARE_EVENT_CLASS(xfs_ag_error_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error,
/* btree cursor error/%ip tracepoint class */
DECLARE_EVENT_CLASS(xfs_btree_error_class,
	TP_PROTO(struct xfs_btree_cur *cur, int error,
		 unsigned long caller_ip),
	TP_ARGS(mp, agno, error, caller_ip),
	TP_ARGS(cur, error, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_ino_t, ino)
		__field(int, error)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->dev = cur->bc_mp->m_super->s_dev;
		switch (cur->bc_ops->type) {
		case XFS_BTREE_TYPE_INODE:
			__entry->agno = 0;
			__entry->ino = cur->bc_ino.ip->i_ino;
			break;
		case XFS_BTREE_TYPE_AG:
			__entry->agno = cur->bc_ag.pag->pag_agno;
			__entry->ino = 0;
			break;
		case XFS_BTREE_TYPE_MEM:
			__entry->agno = 0;
			__entry->ino = 0;
			break;
		}
		__entry->error = error;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x error %d caller %pS",
	TP_printk("dev %d:%d agno 0x%x ino 0x%llx error %d caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->ino,
		  __entry->error,
		  (char *)__entry->caller_ip)
);

#define DEFINE_AG_ERROR_EVENT(name) \
DEFINE_EVENT(xfs_ag_error_class, name, \
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error, \
#define DEFINE_BTREE_ERROR_EVENT(name) \
DEFINE_EVENT(xfs_btree_error_class, name, \
	TP_PROTO(struct xfs_btree_cur *cur, int error, \
		 unsigned long caller_ip), \
	TP_ARGS(mp, agno, error, caller_ip))
	TP_ARGS(cur, error, caller_ip))

DEFINE_RMAP_EVENT(xfs_rmap_unmap);
DEFINE_RMAP_EVENT(xfs_rmap_unmap_done);
DEFINE_AG_ERROR_EVENT(xfs_rmap_unmap_error);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_unmap_error);
DEFINE_RMAP_EVENT(xfs_rmap_map);
DEFINE_RMAP_EVENT(xfs_rmap_map_done);
DEFINE_AG_ERROR_EVENT(xfs_rmap_map_error);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_map_error);
DEFINE_RMAP_EVENT(xfs_rmap_convert);
DEFINE_RMAP_EVENT(xfs_rmap_convert_done);
DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_error);
DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_state);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_convert_error);

TRACE_EVENT(xfs_rmap_convert_state,
	TP_PROTO(struct xfs_btree_cur *cur, int state,
		 unsigned long caller_ip),
	TP_ARGS(cur, state, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_ino_t, ino)
		__field(int, state)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		switch (cur->bc_ops->type) {
		case XFS_BTREE_TYPE_INODE:
			__entry->agno = 0;
			__entry->ino = cur->bc_ino.ip->i_ino;
			break;
		case XFS_BTREE_TYPE_AG:
			__entry->agno = cur->bc_ag.pag->pag_agno;
			__entry->ino = 0;
			break;
		case XFS_BTREE_TYPE_MEM:
			__entry->agno = 0;
			__entry->ino = 0;
			break;
		}
		__entry->state = state;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x ino 0x%llx state %d caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->ino,
		  __entry->state,
		  (char *)__entry->caller_ip)
);

DECLARE_EVENT_CLASS(xfs_rmapbt_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
@@ -2966,9 +3018,9 @@ DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_deferred);
DEFINE_RMAPBT_EVENT(xfs_rmap_update);
DEFINE_RMAPBT_EVENT(xfs_rmap_insert);
DEFINE_RMAPBT_EVENT(xfs_rmap_delete);
DEFINE_AG_ERROR_EVENT(xfs_rmap_insert_error);
DEFINE_AG_ERROR_EVENT(xfs_rmap_delete_error);
DEFINE_AG_ERROR_EVENT(xfs_rmap_update_error);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_insert_error);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_delete_error);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_update_error);

DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_candidate);
DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_query);
@@ -3094,6 +3146,35 @@ DEFINE_AG_RESV_EVENT(xfs_ag_resv_free_extent);
DEFINE_AG_RESV_EVENT(xfs_ag_resv_critical);
DEFINE_AG_RESV_EVENT(xfs_ag_resv_needed);

/* simple AG-based error/%ip tracepoint class */
DECLARE_EVENT_CLASS(xfs_ag_error_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error,
		 unsigned long caller_ip),
	TP_ARGS(mp, agno, error, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(int, error)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->error = error;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x error %d caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->error,
		  (char *)__entry->caller_ip)
);

#define DEFINE_AG_ERROR_EVENT(name) \
DEFINE_EVENT(xfs_ag_error_class, name, \
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error, \
		 unsigned long caller_ip), \
	TP_ARGS(mp, agno, error, caller_ip))
DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error);

/* refcount tracepoint classes */