linux/fs/xfs/xfs_trace.h

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2009, Christoph Hellwig
 * All Rights Reserved.
 *
 * NOTE: none of these tracepoints shall be considered a stable kernel ABI
 * as they can change at any time.
 *
 * Current conventions for printing numbers measuring specific units:
 *
 * agno: allocation group number
 *
 * agino: per-AG inode number
 * ino: filesystem inode number
 *
 * agbno: per-AG block number in fs blocks
 * startblock: physical block number for file mappings.  This is either a
 *             segmented fsblock for data device mappings, or a rfsblock
 *             for realtime device mappings
 * fsbcount: number of blocks in an extent, in fs blocks
 *
 * daddr: physical block number in 512b blocks
 * bbcount: number of blocks in a physical extent, in 512b blocks
 *
 * rtx: physical rt extent number for extent mappings
 * rtxcount: number of rt extents in an extent mapping
 *
 * owner: reverse-mapping owner, usually inodes
 *
 * fileoff: file offset, in fs blocks
 * pos: file offset, in bytes
 * bytecount: number of bytes
 *
 * dablk: directory or xattr block offset, in filesystem blocks
 *
 * disize: ondisk file size, in bytes
 * isize: incore file size, in bytes
 *
 * forkoff: inode fork offset, in bytes
 *
 * ireccount: number of inode records
 *
 * Numbers describing space allocations (blocks, extents, inodes) should be
 * formatted in hexadecimal.
 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM

#if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_XFS_H

#include <linux/tracepoint.h>

struct xfs_agf;
struct xfs_alloc_arg;
struct xfs_attr_list_context;
struct xfs_buf_log_item;
struct xfs_da_args;
struct xfs_da_node_entry;
struct xfs_dquot;
struct xfs_log_item;
struct xlog;
struct xlog_ticket;
struct xlog_recover;
struct xlog_recover_item;
struct xlog_rec_header;
struct xlog_in_core;
struct xfs_buf_log_format;
struct xfs_inode_log_format;
struct xfs_bmbt_irec;
struct xfs_btree_cur;
struct xfs_defer_op_type;
struct xfs_refcount_irec;
struct xfs_fsmap;
struct xfs_rmap_irec;
struct xfs_icreate_log;
struct xfs_owner_info;
struct xfs_trans_res;
struct xfs_inobt_rec_incore;
xfs_btree_ptr;
struct xfs_dqtrx;
struct xfs_icwalk;
struct xfs_perag;
struct xfbtree;
struct xfs_btree_ops;
struct xfs_bmap_intent;
struct xfs_exchmaps_intent;
struct xfs_exchmaps_req;
struct xfs_exchrange;
struct xfs_getparents;
struct xfs_parent_irec;
struct xfs_attrlist_cursor_kern;
struct xfs_extent_free_item;
struct xfs_rmap_intent;
struct xfs_refcount_intent;

#define XFS_ATTR_FILTER_FLAGS

DECLARE_EVENT_CLASS()

#define DEFINE_ATTR_LIST_EVENT(name)
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk);
DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound);
DEFINE_ATTR_LIST_EVENT(xfs_attr_leaf_list);
DEFINE_ATTR_LIST_EVENT(xfs_attr_node_list);

TRACE_EVENT(xlog_intent_recovery_failed,
	TP_PROTO(struct xfs_mount *mp, const struct xfs_defer_op_type *ops,
		 int error),
	TP_ARGS(mp, ops, error),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__string(name, ops->name)
		__field(int, error)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__assign_str(name);
		__entry->error = error;
	),
	TP_printk("dev %d:%d optype %s error %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __get_str(name),
		  __entry->error)
);

DECLARE_EVENT_CLASS(xfs_perag_class,
	TP_PROTO(struct xfs_perag *pag, unsigned long caller_ip),
	TP_ARGS(pag, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(int, refcount)
		__field(int, active_refcount)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = pag->pag_mount->m_super->s_dev;
		__entry->agno = pag->pag_agno;
		__entry->refcount = atomic_read(&pag->pag_ref);
		__entry->active_refcount = atomic_read(&pag->pag_active_ref);
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x passive refs %d active refs %d caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->refcount,
		  __entry->active_refcount,
		  (char *)__entry->caller_ip)
);

#define DEFINE_PERAG_REF_EVENT(name)
DEFINE_PERAG_REF_EVENT(xfs_perag_get);
DEFINE_PERAG_REF_EVENT(xfs_perag_get_tag);
DEFINE_PERAG_REF_EVENT(xfs_perag_hold);
DEFINE_PERAG_REF_EVENT(xfs_perag_put);
DEFINE_PERAG_REF_EVENT(xfs_perag_grab);
DEFINE_PERAG_REF_EVENT(xfs_perag_grab_tag);
DEFINE_PERAG_REF_EVENT(xfs_perag_rele);
DEFINE_PERAG_REF_EVENT(xfs_perag_set_inode_tag);
DEFINE_PERAG_REF_EVENT(xfs_perag_clear_inode_tag);

TRACE_EVENT(xfs_inodegc_worker,
	TP_PROTO(struct xfs_mount *mp, unsigned int shrinker_hits),
	TP_ARGS(mp, shrinker_hits),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned int, shrinker_hits)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->shrinker_hits = shrinker_hits;
	),
	TP_printk("dev %d:%d shrinker_hits %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->shrinker_hits)
);

DECLARE_EVENT_CLASS(xfs_fs_class,
	TP_PROTO(struct xfs_mount *mp, void *caller_ip),
	TP_ARGS(mp, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long long, mflags)
		__field(unsigned long, opstate)
		__field(unsigned long, sbflags)
		__field(void *, caller_ip)
	),
	TP_fast_assign(
		if (mp) {
			__entry->dev = mp->m_super->s_dev;
			__entry->mflags = mp->m_features;
			__entry->opstate = mp->m_opstate;
			__entry->sbflags = mp->m_super->s_flags;
		}
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d m_features 0x%llx opstate (%s) s_flags 0x%lx caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->mflags,
		  __print_flags(__entry->opstate, "|", XFS_OPSTATE_STRINGS),
		  __entry->sbflags,
		  __entry->caller_ip)
);

#define DEFINE_FS_EVENT(name)
DEFINE_FS_EVENT(xfs_inodegc_flush);
DEFINE_FS_EVENT(xfs_inodegc_push);
DEFINE_FS_EVENT(xfs_inodegc_start);
DEFINE_FS_EVENT(xfs_inodegc_stop);
DEFINE_FS_EVENT(xfs_inodegc_queue);
DEFINE_FS_EVENT(xfs_inodegc_throttle);
DEFINE_FS_EVENT(xfs_fs_sync_fs);
DEFINE_FS_EVENT(xfs_blockgc_start);
DEFINE_FS_EVENT(xfs_blockgc_stop);
DEFINE_FS_EVENT(xfs_blockgc_worker);
DEFINE_FS_EVENT(xfs_blockgc_flush_all);

TRACE_EVENT(xfs_inodegc_shrinker_scan,
	TP_PROTO(struct xfs_mount *mp, struct shrink_control *sc,
		 void *caller_ip),
	TP_ARGS(mp, sc, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long, nr_to_scan)
		__field(void *, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->nr_to_scan = sc->nr_to_scan;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d nr_to_scan %lu caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->nr_to_scan,
		  __entry->caller_ip)
);

DECLARE_EVENT_CLASS(xfs_ag_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno),
	TP_ARGS(mp, agno),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
	),
	TP_printk("dev %d:%d agno 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno)
);
#define DEFINE_AG_EVENT(name)

DEFINE_AG_EVENT(xfs_read_agf);
DEFINE_AG_EVENT(xfs_alloc_read_agf);
DEFINE_AG_EVENT(xfs_read_agi);
DEFINE_AG_EVENT(xfs_ialloc_read_agi);

TRACE_EVENT(xfs_attr_list_node_descend,
	TP_PROTO(struct xfs_attr_list_context *ctx,
		 struct xfs_da_node_entry *btree),
	TP_ARGS(ctx, btree),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(u32, hashval)
		__field(u32, blkno)
		__field(u32, offset)
		__field(void *, buffer)
		__field(int, bufsize)
		__field(int, count)
		__field(int, firstu)
		__field(int, dupcnt)
		__field(unsigned int, attr_filter)
		__field(u32, bt_hashval)
		__field(u32, bt_before)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
		__entry->ino = ctx->dp->i_ino;
		__entry->hashval = ctx->cursor.hashval;
		__entry->blkno = ctx->cursor.blkno;
		__entry->offset = ctx->cursor.offset;
		__entry->buffer = ctx->buffer;
		__entry->bufsize = ctx->bufsize;
		__entry->count = ctx->count;
		__entry->firstu = ctx->firstu;
		__entry->attr_filter = ctx->attr_filter;
		__entry->bt_hashval = be32_to_cpu(btree->hashval);
		__entry->bt_before = be32_to_cpu(btree->before);
	),
	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
		  "buffer %p size %u count %u firstu %u filter %s "
		  "node hashval %u, node before %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		   __entry->ino,
		   __entry->hashval,
		   __entry->blkno,
		   __entry->offset,
		   __entry->dupcnt,
		   __entry->buffer,
		   __entry->bufsize,
		   __entry->count,
		   __entry->firstu,
		   __print_flags(__entry->attr_filter, "|",
				 XFS_ATTR_FILTER_FLAGS),
		   __entry->bt_hashval,
		   __entry->bt_before)
);

DECLARE_EVENT_CLASS()

#define DEFINE_BMAP_EVENT(name)
DEFINE_BMAP_EVENT(xfs_iext_insert);
DEFINE_BMAP_EVENT(xfs_iext_remove);
DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
DEFINE_BMAP_EVENT(xfs_bmap_post_update);
DEFINE_BMAP_EVENT(xfs_read_extent);
DEFINE_BMAP_EVENT(xfs_write_extent);

DECLARE_EVENT_CLASS()

#define DEFINE_BUF_EVENT(name)
DEFINE_BUF_EVENT(xfs_buf_init);
DEFINE_BUF_EVENT(xfs_buf_free);
DEFINE_BUF_EVENT(xfs_buf_hold);
DEFINE_BUF_EVENT(xfs_buf_rele);
DEFINE_BUF_EVENT(xfs_buf_iodone);
DEFINE_BUF_EVENT(xfs_buf_submit);
DEFINE_BUF_EVENT(xfs_buf_lock);
DEFINE_BUF_EVENT(xfs_buf_lock_done);
DEFINE_BUF_EVENT(xfs_buf_trylock_fail);
DEFINE_BUF_EVENT(xfs_buf_trylock);
DEFINE_BUF_EVENT(xfs_buf_unlock);
DEFINE_BUF_EVENT(xfs_buf_iowait);
DEFINE_BUF_EVENT(xfs_buf_iowait_done);
DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
DEFINE_BUF_EVENT(xfs_buf_delwri_queued);
DEFINE_BUF_EVENT(xfs_buf_delwri_split);
DEFINE_BUF_EVENT(xfs_buf_delwri_pushbuf);
DEFINE_BUF_EVENT(xfs_buf_get_uncached);
DEFINE_BUF_EVENT(xfs_buf_item_relse);
DEFINE_BUF_EVENT(xfs_buf_iodone_async);
DEFINE_BUF_EVENT(xfs_buf_error_relse);
DEFINE_BUF_EVENT(xfs_buf_drain_buftarg);
DEFINE_BUF_EVENT(xfs_trans_read_buf_shut);

/* not really buffer traces, but the buf provides useful information */
DEFINE_BUF_EVENT(xfs_btree_corrupt);
DEFINE_BUF_EVENT(xfs_reset_dqcounts);

/* pass flags explicitly */
DECLARE_EVENT_CLASS()

#define DEFINE_BUF_FLAGS_EVENT(name)
DEFINE_BUF_FLAGS_EVENT(xfs_buf_find);
DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);

TRACE_EVENT(xfs_buf_ioerror,
	TP_PROTO(struct xfs_buf *bp, int error, xfs_failaddr_t caller_ip),
	TP_ARGS(bp, error, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_daddr_t, bno)
		__field(unsigned int, length)
		__field(unsigned, flags)
		__field(int, hold)
		__field(int, pincount)
		__field(unsigned, lockval)
		__field(int, error)
		__field(xfs_failaddr_t, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = bp->b_target->bt_dev;
		__entry->bno = xfs_buf_daddr(bp);
		__entry->length = bp->b_length;
		__entry->hold = atomic_read(&bp->b_hold);
		__entry->pincount = atomic_read(&bp->b_pin_count);
		__entry->lockval = bp->b_sema.count;
		__entry->error = error;
		__entry->flags = bp->b_flags;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
		  "lock %d error %d flags %s caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  (unsigned long long)__entry->bno,
		  __entry->length,
		  __entry->hold,
		  __entry->pincount,
		  __entry->lockval,
		  __entry->error,
		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
		  (void *)__entry->caller_ip)
);

DECLARE_EVENT_CLASS()

#define DEFINE_BUF_ITEM_EVENT(name)
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_ordered);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_release);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur);
DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb);
DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur);
DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf);
DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur);
DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf);
DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse);
DEFINE_BUF_ITEM_EVENT(xfs_trans_bdetach);
DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin);
DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold);
DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);

DECLARE_EVENT_CLASS()
#define DEFINE_FILESTREAM_EVENT(name)
DEFINE_FILESTREAM_EVENT(xfs_filestream_free);
DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup);
DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);

TRACE_EVENT(xfs_filestream_pick,
	TP_PROTO(struct xfs_perag *pag, xfs_ino_t ino, xfs_extlen_t free),
	TP_ARGS(pag, ino, free),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(xfs_agnumber_t, agno)
		__field(int, streams)
		__field(xfs_extlen_t, free)
	),
	TP_fast_assign(
		__entry->dev = pag->pag_mount->m_super->s_dev;
		__entry->ino = ino;
		if (pag) {
			__entry->agno = pag->pag_agno;
			__entry->streams = atomic_read(&pag->pagf_fstrms);
		} else {
			__entry->agno = NULLAGNUMBER;
			__entry->streams = 0;
		}
		__entry->free = free;
	),
	TP_printk("dev %d:%d ino 0x%llx agno 0x%x streams %d free %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->agno,
		  __entry->streams,
		  __entry->free)
);

DECLARE_EVENT_CLASS()

#define DEFINE_LOCK_EVENT(name)
DEFINE_LOCK_EVENT(xfs_ilock);
DEFINE_LOCK_EVENT(xfs_ilock_nowait);
DEFINE_LOCK_EVENT(xfs_ilock_demote);
DEFINE_LOCK_EVENT(xfs_iunlock);

DECLARE_EVENT_CLASS()

#define DEFINE_INODE_EVENT(name)
DEFINE_INODE_EVENT(xfs_iget_skip);
DEFINE_INODE_EVENT(xfs_iget_recycle);
DEFINE_INODE_EVENT(xfs_iget_recycle_fail);
DEFINE_INODE_EVENT(xfs_iget_hit);
DEFINE_INODE_EVENT(xfs_iget_miss);

DEFINE_INODE_EVENT(xfs_getattr);
DEFINE_INODE_EVENT(xfs_setattr);
DEFINE_INODE_EVENT(xfs_readlink);
DEFINE_INODE_EVENT(xfs_inactive_symlink);
DEFINE_INODE_EVENT(xfs_alloc_file_space);
DEFINE_INODE_EVENT(xfs_free_file_space);
DEFINE_INODE_EVENT(xfs_zero_file_space);
DEFINE_INODE_EVENT(xfs_collapse_file_space);
DEFINE_INODE_EVENT(xfs_insert_file_space);
DEFINE_INODE_EVENT(xfs_readdir);
#ifdef CONFIG_XFS_POSIX_ACL
DEFINE_INODE_EVENT(xfs_get_acl);
#endif
DEFINE_INODE_EVENT(xfs_vm_bmap);
DEFINE_INODE_EVENT(xfs_file_ioctl);
DEFINE_INODE_EVENT(xfs_file_compat_ioctl);
DEFINE_INODE_EVENT(xfs_ioctl_setattr);
DEFINE_INODE_EVENT(xfs_dir_fsync);
DEFINE_INODE_EVENT(xfs_file_fsync);
DEFINE_INODE_EVENT(xfs_destroy_inode);
DEFINE_INODE_EVENT(xfs_update_time);

DEFINE_INODE_EVENT(xfs_dquot_dqalloc);
DEFINE_INODE_EVENT(xfs_dquot_dqdetach);

DEFINE_INODE_EVENT(xfs_inode_set_eofblocks_tag);
DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
DEFINE_INODE_EVENT(xfs_inode_set_cowblocks_tag);
DEFINE_INODE_EVENT(xfs_inode_clear_cowblocks_tag);
DEFINE_INODE_EVENT(xfs_inode_free_cowblocks_invalid);
DEFINE_INODE_EVENT(xfs_inode_set_reclaimable);
DEFINE_INODE_EVENT(xfs_inode_reclaiming);
DEFINE_INODE_EVENT(xfs_inode_set_need_inactive);
DEFINE_INODE_EVENT(xfs_inode_inactivating);

/*
 * ftrace's __print_symbolic requires that all enum values be wrapped in the
 * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
 * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
 * code.
 */
TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_SHARED);
TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW);

TRACE_EVENT()

DECLARE_EVENT_CLASS()

TRACE_EVENT()

TRACE_EVENT()

TRACE_EVENT()

#define DEFINE_IREF_EVENT(name)
DEFINE_IREF_EVENT(xfs_irele);
DEFINE_IREF_EVENT(xfs_inode_pin);
DEFINE_IREF_EVENT(xfs_inode_unpin);
DEFINE_IREF_EVENT(xfs_inode_unpin_nowait);

DECLARE_EVENT_CLASS()

#define DEFINE_NAMESPACE_EVENT(name)
DEFINE_NAMESPACE_EVENT(xfs_remove);
DEFINE_NAMESPACE_EVENT(xfs_link);
DEFINE_NAMESPACE_EVENT(xfs_lookup);
DEFINE_NAMESPACE_EVENT(xfs_create);
DEFINE_NAMESPACE_EVENT(xfs_symlink);

TRACE_EVENT()

DECLARE_EVENT_CLASS()

#define DEFINE_DQUOT_EVENT(name)
DEFINE_DQUOT_EVENT(xfs_dqadjust);
DEFINE_DQUOT_EVENT(xfs_dqreclaim_want);
DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty);
DEFINE_DQUOT_EVENT(xfs_dqreclaim_busy);
DEFINE_DQUOT_EVENT(xfs_dqreclaim_done);
DEFINE_DQUOT_EVENT(xfs_dqattach_found);
DEFINE_DQUOT_EVENT(xfs_dqattach_get);
DEFINE_DQUOT_EVENT(xfs_dqalloc);
DEFINE_DQUOT_EVENT(xfs_dqtobp_read);
DEFINE_DQUOT_EVENT(xfs_dqread);
DEFINE_DQUOT_EVENT(xfs_dqread_fail);
DEFINE_DQUOT_EVENT(xfs_dqget_hit);
DEFINE_DQUOT_EVENT(xfs_dqget_miss);
DEFINE_DQUOT_EVENT(xfs_dqget_freeing);
DEFINE_DQUOT_EVENT(xfs_dqget_dup);
DEFINE_DQUOT_EVENT(xfs_dqput);
DEFINE_DQUOT_EVENT(xfs_dqput_free);
DEFINE_DQUOT_EVENT(xfs_dqrele);
DEFINE_DQUOT_EVENT(xfs_dqflush);
DEFINE_DQUOT_EVENT(xfs_dqflush_force);
DEFINE_DQUOT_EVENT(xfs_dqflush_done);
DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_before);
DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_after);

TRACE_EVENT(xfs_trans_mod_dquot,
	TP_PROTO(struct xfs_trans *tp, struct xfs_dquot *dqp,
		 unsigned int field, int64_t delta),
	TP_ARGS(tp, dqp, field, delta),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_dqtype_t, type)
		__field(unsigned int, flags)
		__field(unsigned int, dqid)
		__field(unsigned int, field)
		__field(int64_t, delta)
	),
	TP_fast_assign(
		__entry->dev = tp->t_mountp->m_super->s_dev;
		__entry->type = dqp->q_type;
		__entry->flags = dqp->q_flags;
		__entry->dqid = dqp->q_id;
		__entry->field = field;
		__entry->delta = delta;
	),
	TP_printk("dev %d:%d dquot id 0x%x type %s flags %s field %s delta %lld",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->dqid,
		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
		  __print_flags(__entry->flags, "|", XFS_DQFLAG_STRINGS),
		  __print_flags(__entry->field, "|", XFS_QMOPT_FLAGS),
		  __entry->delta)
);

DECLARE_EVENT_CLASS()

#define DEFINE_DQTRX_EVENT(name)
DEFINE_DQTRX_EVENT(xfs_trans_apply_dquot_deltas);
DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_before);
DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_after);

DECLARE_EVENT_CLASS()

#define DEFINE_LOGGRANT_EVENT(name)
DEFINE_LOGGRANT_EVENT(xfs_log_umount_write);
DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep);
DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake);
DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake_up);
DEFINE_LOGGRANT_EVENT(xfs_log_reserve);
DEFINE_LOGGRANT_EVENT(xfs_log_reserve_exit);
DEFINE_LOGGRANT_EVENT(xfs_log_regrant);
DEFINE_LOGGRANT_EVENT(xfs_log_regrant_exit);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant_exit);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant_sub);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant_sub);
DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant_exit);
DEFINE_LOGGRANT_EVENT(xfs_log_cil_wait);
DEFINE_LOGGRANT_EVENT(xfs_log_cil_return);

DECLARE_EVENT_CLASS()

TRACE_EVENT()

#define DEFINE_LOG_ITEM_EVENT(name)
DEFINE_LOG_ITEM_EVENT(xfs_ail_push);
DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned);
DEFINE_LOG_ITEM_EVENT(xfs_ail_locked);
DEFINE_LOG_ITEM_EVENT(xfs_ail_flushing);
DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_mark);
DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_skip);
DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_unpin);

DECLARE_EVENT_CLASS()

#define DEFINE_AIL_EVENT(name)
DEFINE_AIL_EVENT(xfs_ail_insert);
DEFINE_AIL_EVENT(xfs_ail_move);
DEFINE_AIL_EVENT(xfs_ail_delete);

TRACE_EVENT()

DECLARE_EVENT_CLASS()

#define DEFINE_RW_EVENT(name)
DEFINE_RW_EVENT(xfs_file_buffered_read);
DEFINE_RW_EVENT(xfs_file_direct_read);
DEFINE_RW_EVENT(xfs_file_dax_read);
DEFINE_RW_EVENT(xfs_file_buffered_write);
DEFINE_RW_EVENT(xfs_file_direct_write);
DEFINE_RW_EVENT(xfs_file_dax_write);
DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write);

DECLARE_EVENT_CLASS()

#define DEFINE_IMAP_EVENT(name)
DEFINE_IMAP_EVENT(xfs_map_blocks_found);
DEFINE_IMAP_EVENT(xfs_map_blocks_alloc);
DEFINE_IMAP_EVENT(xfs_iomap_alloc);
DEFINE_IMAP_EVENT(xfs_iomap_found);

DECLARE_EVENT_CLASS(xfs_simple_io_class,
	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
	TP_ARGS(ip, offset, count),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(loff_t, isize)
		__field(loff_t, disize)
		__field(loff_t, offset)
		__field(size_t, count)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->isize = VFS_I(ip)->i_size;
		__entry->disize = ip->i_disk_size;
		__entry->offset = offset;
		__entry->count = count;
	),
	TP_printk("dev %d:%d ino 0x%llx isize 0x%llx disize 0x%llx "
		  "pos 0x%llx bytecount 0x%zx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->isize,
		  __entry->disize,
		  __entry->offset,
		  __entry->count)
);

#define DEFINE_SIMPLE_IO_EVENT(name)
DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc);
DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
DEFINE_SIMPLE_IO_EVENT(xfs_setfilesize);
DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof);
DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write);
DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten);
DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append);
DEFINE_SIMPLE_IO_EVENT(xfs_file_splice_read);

DECLARE_EVENT_CLASS()

#define DEFINE_ITRUNC_EVENT(name)
DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_start);
DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_end);

TRACE_EVENT(xfs_pagecache_inval,
	TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
	TP_ARGS(ip, start, finish),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(xfs_fsize_t, size)
		__field(xfs_off_t, start)
		__field(xfs_off_t, finish)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->size = ip->i_disk_size;
		__entry->start = start;
		__entry->finish = finish;
	),
	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx start 0x%llx finish 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->size,
		  __entry->start,
		  __entry->finish)
);

TRACE_EVENT(xfs_bunmap,
	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t fileoff, xfs_filblks_t len,
		 int flags, unsigned long caller_ip),
	TP_ARGS(ip, fileoff, len, flags, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(xfs_fsize_t, size)
		__field(xfs_fileoff_t, fileoff)
		__field(xfs_filblks_t, len)
		__field(unsigned long, caller_ip)
		__field(int, flags)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->size = ip->i_disk_size;
		__entry->fileoff = fileoff;
		__entry->len = len;
		__entry->caller_ip = caller_ip;
		__entry->flags = flags;
	),
	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx fileoff 0x%llx fsbcount 0x%llx "
		  "flags %s caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->size,
		  __entry->fileoff,
		  __entry->len,
		  __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS),
		  (void *)__entry->caller_ip)

);

DECLARE_EVENT_CLASS(xfs_extent_busy_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
		 xfs_agblock_t agbno, xfs_extlen_t len),
	TP_ARGS(mp, agno, agbno, len),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->agbno = agbno;
		__entry->len = len;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len)
);
#define DEFINE_BUSY_EVENT(name)
DEFINE_BUSY_EVENT(xfs_extent_busy);
DEFINE_BUSY_EVENT(xfs_extent_busy_force);
DEFINE_BUSY_EVENT(xfs_extent_busy_reuse);
DEFINE_BUSY_EVENT(xfs_extent_busy_clear);

TRACE_EVENT(xfs_extent_busy_trim,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
		 xfs_agblock_t agbno, xfs_extlen_t len,
		 xfs_agblock_t tbno, xfs_extlen_t tlen),
	TP_ARGS(mp, agno, agbno, len, tbno, tlen),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
		__field(xfs_agblock_t, tbno)
		__field(xfs_extlen_t, tlen)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->agbno = agbno;
		__entry->len = len;
		__entry->tbno = tbno;
		__entry->tlen = tlen;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x found_agbno 0x%x found_fsbcount 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len,
		  __entry->tbno,
		  __entry->tlen)
);

DECLARE_EVENT_CLASS(xfs_agf_class,
	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
		 unsigned long caller_ip),
	TP_ARGS(mp, agf, flags, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(int, flags)
		__field(__u32, length)
		__field(__u32, bno_root)
		__field(__u32, cnt_root)
		__field(__u32, bno_level)
		__field(__u32, cnt_level)
		__field(__u32, flfirst)
		__field(__u32, fllast)
		__field(__u32, flcount)
		__field(__u32, freeblks)
		__field(__u32, longest)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = be32_to_cpu(agf->agf_seqno),
		__entry->flags = flags;
		__entry->length = be32_to_cpu(agf->agf_length),
		__entry->bno_root = be32_to_cpu(agf->agf_bno_root),
		__entry->cnt_root = be32_to_cpu(agf->agf_cnt_root),
		__entry->bno_level = be32_to_cpu(agf->agf_bno_level),
		__entry->cnt_level = be32_to_cpu(agf->agf_cnt_level),
		__entry->flfirst = be32_to_cpu(agf->agf_flfirst),
		__entry->fllast = be32_to_cpu(agf->agf_fllast),
		__entry->flcount = be32_to_cpu(agf->agf_flcount),
		__entry->freeblks = be32_to_cpu(agf->agf_freeblks),
		__entry->longest = be32_to_cpu(agf->agf_longest);
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x flags %s length %u roots b %u c %u "
		  "levels b %u c %u flfirst %u fllast %u flcount %u "
		  "freeblks %u longest %u caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __print_flags(__entry->flags, "|", XFS_AGF_FLAGS),
		  __entry->length,
		  __entry->bno_root,
		  __entry->cnt_root,
		  __entry->bno_level,
		  __entry->cnt_level,
		  __entry->flfirst,
		  __entry->fllast,
		  __entry->flcount,
		  __entry->freeblks,
		  __entry->longest,
		  (void *)__entry->caller_ip)
);
#define DEFINE_AGF_EVENT(name)
DEFINE_AGF_EVENT(xfs_agf);
DEFINE_AGF_EVENT(xfs_agfl_reset);

TRACE_EVENT(xfs_free_extent,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
		 xfs_extlen_t len, enum xfs_ag_resv_type resv, int haveleft,
		 int haveright),
	TP_ARGS(mp, agno, agbno, len, resv, haveleft, haveright),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
		__field(int, resv)
		__field(int, haveleft)
		__field(int, haveright)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->agbno = agbno;
		__entry->len = len;
		__entry->resv = resv;
		__entry->haveleft = haveleft;
		__entry->haveright = haveright;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x resv %d %s",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len,
		  __entry->resv,
		  __entry->haveleft ?
			(__entry->haveright ? "both" : "left") :
			(__entry->haveright ? "right" : "none"))

);

DECLARE_EVENT_CLASS()

#define DEFINE_ALLOC_EVENT(name)
DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
DEFINE_ALLOC_EVENT(xfs_alloc_cur);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_right);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_left);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup_done);
DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
DEFINE_ALLOC_EVENT(xfs_alloc_near_noentry);
DEFINE_ALLOC_EVENT(xfs_alloc_near_busy);
DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry);
DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft);
DEFINE_ALLOC_EVENT(xfs_alloc_size_done);
DEFINE_ALLOC_EVENT(xfs_alloc_size_error);
DEFINE_ALLOC_EVENT(xfs_alloc_size_busy);
DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist);
DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough);
DEFINE_ALLOC_EVENT(xfs_alloc_small_done);
DEFINE_ALLOC_EVENT(xfs_alloc_small_error);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_skip_deadlock);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);

DEFINE_ALLOC_EVENT(xfs_alloc_vextent_this_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_start_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_first_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_exact_bno);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_near_bno);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_finish);

TRACE_EVENT()

DECLARE_EVENT_CLASS()

#define DEFINE_DIR2_EVENT(name)
DEFINE_DIR2_EVENT(xfs_dir2_sf_addname);
DEFINE_DIR2_EVENT(xfs_dir2_sf_create);
DEFINE_DIR2_EVENT(xfs_dir2_sf_lookup);
DEFINE_DIR2_EVENT(xfs_dir2_sf_replace);
DEFINE_DIR2_EVENT(xfs_dir2_sf_removename);
DEFINE_DIR2_EVENT(xfs_dir2_sf_toino4);
DEFINE_DIR2_EVENT(xfs_dir2_sf_toino8);
DEFINE_DIR2_EVENT(xfs_dir2_sf_to_block);
DEFINE_DIR2_EVENT(xfs_dir2_block_addname);
DEFINE_DIR2_EVENT(xfs_dir2_block_lookup);
DEFINE_DIR2_EVENT(xfs_dir2_block_replace);
DEFINE_DIR2_EVENT(xfs_dir2_block_removename);
DEFINE_DIR2_EVENT(xfs_dir2_block_to_sf);
DEFINE_DIR2_EVENT(xfs_dir2_block_to_leaf);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_addname);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_lookup);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_replace);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_removename);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_block);
DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_node);
DEFINE_DIR2_EVENT(xfs_dir2_node_addname);
DEFINE_DIR2_EVENT(xfs_dir2_node_lookup);
DEFINE_DIR2_EVENT(xfs_dir2_node_replace);
DEFINE_DIR2_EVENT(xfs_dir2_node_removename);
DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf);

DECLARE_EVENT_CLASS()

#define DEFINE_ATTR_EVENT(name)
DEFINE_ATTR_EVENT(xfs_attr_sf_add);
DEFINE_ATTR_EVENT(xfs_attr_sf_addname);
DEFINE_ATTR_EVENT(xfs_attr_sf_create);
DEFINE_ATTR_EVENT(xfs_attr_sf_lookup);
DEFINE_ATTR_EVENT(xfs_attr_sf_remove);
DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf);

DEFINE_ATTR_EVENT(xfs_attr_leaf_add);
DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old);
DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new);
DEFINE_ATTR_EVENT(xfs_attr_leaf_add_work);
DEFINE_ATTR_EVENT(xfs_attr_leaf_create);
DEFINE_ATTR_EVENT(xfs_attr_leaf_compact);
DEFINE_ATTR_EVENT(xfs_attr_leaf_get);
DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup);
DEFINE_ATTR_EVENT(xfs_attr_leaf_replace);
DEFINE_ATTR_EVENT(xfs_attr_leaf_remove);
DEFINE_ATTR_EVENT(xfs_attr_leaf_removename);
DEFINE_ATTR_EVENT(xfs_attr_leaf_split);
DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before);
DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after);
DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag);
DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag);
DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags);
DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf);
DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node);
DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance);
DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance);
DEFINE_ATTR_EVENT(xfs_attr_leaf_toosmall);

DEFINE_ATTR_EVENT(xfs_attr_node_addname);
DEFINE_ATTR_EVENT(xfs_attr_node_get);
DEFINE_ATTR_EVENT(xfs_attr_node_replace);
DEFINE_ATTR_EVENT(xfs_attr_node_removename);

DEFINE_ATTR_EVENT(xfs_attr_fillstate);
DEFINE_ATTR_EVENT(xfs_attr_refillstate);

DEFINE_ATTR_EVENT(xfs_attr_rmtval_get);
DEFINE_ATTR_EVENT(xfs_attr_rmtval_set);

#define DEFINE_DA_EVENT(name)
DEFINE_DA_EVENT(xfs_da_split);
DEFINE_DA_EVENT(xfs_da_join);
DEFINE_DA_EVENT(xfs_da_link_before);
DEFINE_DA_EVENT(xfs_da_link_after);
DEFINE_DA_EVENT(xfs_da_unlink_back);
DEFINE_DA_EVENT(xfs_da_unlink_forward);
DEFINE_DA_EVENT(xfs_da_root_split);
DEFINE_DA_EVENT(xfs_da_root_join);
DEFINE_DA_EVENT(xfs_da_node_add);
DEFINE_DA_EVENT(xfs_da_node_create);
DEFINE_DA_EVENT(xfs_da_node_split);
DEFINE_DA_EVENT(xfs_da_node_remove);
DEFINE_DA_EVENT(xfs_da_node_rebalance);
DEFINE_DA_EVENT(xfs_da_node_unbalance);
DEFINE_DA_EVENT(xfs_da_node_toosmall);
DEFINE_DA_EVENT(xfs_da_swap_lastblock);
DEFINE_DA_EVENT(xfs_da_grow_inode);
DEFINE_DA_EVENT(xfs_da_shrink_inode);
DEFINE_DA_EVENT(xfs_da_fixhashpath);
DEFINE_DA_EVENT(xfs_da_path_shift);

DECLARE_EVENT_CLASS()

#define DEFINE_DIR2_SPACE_EVENT(name)
DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_add);
DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_remove);
DEFINE_DIR2_SPACE_EVENT(xfs_dir2_grow_inode);
DEFINE_DIR2_SPACE_EVENT(xfs_dir2_shrink_inode);

TRACE_EVENT(xfs_dir2_leafn_moveents,
	TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count),
	TP_ARGS(args, src_idx, dst_idx, count),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(uint32_t, op_flags)
		__field(int, src_idx)
		__field(int, dst_idx)
		__field(int, count)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
		__entry->ino = args->dp->i_ino;
		__entry->op_flags = args->op_flags;
		__entry->src_idx = src_idx;
		__entry->dst_idx = dst_idx;
		__entry->count = count;
	),
	TP_printk("dev %d:%d ino 0x%llx op_flags %s "
		  "src_idx %d dst_idx %d count %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
		  __entry->src_idx,
		  __entry->dst_idx,
		  __entry->count)
);

#define XFS_SWAPEXT_INODES

TRACE_DEFINE_ENUM(XFS_DINODE_FMT_DEV);
TRACE_DEFINE_ENUM(XFS_DINODE_FMT_LOCAL);
TRACE_DEFINE_ENUM(XFS_DINODE_FMT_EXTENTS);
TRACE_DEFINE_ENUM(XFS_DINODE_FMT_BTREE);
TRACE_DEFINE_ENUM(XFS_DINODE_FMT_UUID);

DECLARE_EVENT_CLASS()

#define DEFINE_SWAPEXT_EVENT(name)

DEFINE_SWAPEXT_EVENT(xfs_swap_extent_before);
DEFINE_SWAPEXT_EVENT(xfs_swap_extent_after);

TRACE_EVENT()

TRACE_EVENT()

DECLARE_EVENT_CLASS()

#define DEFINE_LOG_RECOVER_ITEM(name)

DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add);
DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add_cont);
DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_head);
DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_tail);
DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_recover);

DECLARE_EVENT_CLASS()

#define DEFINE_LOG_RECOVER_BUF_ITEM(name)

DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_not_cancel);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_add);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_ref_inc);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_recover);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_skip);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_inode_buf);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_reg_buf);
DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_dquot_buf);

DECLARE_EVENT_CLASS()
#define DEFINE_LOG_RECOVER_INO_ITEM(name)

DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_recover);
DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_cancel);
DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_skip);

DECLARE_EVENT_CLASS()
#define DEFINE_LOG_RECOVER_ICREATE_ITEM(name)

DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_cancel);
DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_recover);

DECLARE_EVENT_CLASS()

#define DEFINE_DISCARD_EVENT(name)
DEFINE_DISCARD_EVENT(xfs_discard_extent);
DEFINE_DISCARD_EVENT(xfs_discard_toosmall);
DEFINE_DISCARD_EVENT(xfs_discard_exclude);
DEFINE_DISCARD_EVENT(xfs_discard_busy);

DECLARE_EVENT_CLASS()

#define DEFINE_RTDISCARD_EVENT(name)
DEFINE_RTDISCARD_EVENT(xfs_discard_rtextent);
DEFINE_RTDISCARD_EVENT(xfs_discard_rttoosmall);
DEFINE_RTDISCARD_EVENT(xfs_discard_rtrelax);

DECLARE_EVENT_CLASS()

#define DEFINE_BTREE_CUR_EVENT(name)
DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys);
DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range);

TRACE_EVENT(xfs_btree_alloc_block,
	TP_PROTO(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, int stat,
		 int error),
	TP_ARGS(cur, ptr, stat, error),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_ino_t, ino)
		__string(name, cur->bc_ops->name)
		__field(int, error)
		__field(xfs_agblock_t, agbno)
	),
	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;
		}
		__assign_str(name);
		__entry->error = error;
		if (!error && stat) {
			if (cur->bc_ops->ptr_len == XFS_BTREE_LONG_PTR_LEN) {
				xfs_fsblock_t	fsb = be64_to_cpu(ptr->l);

				__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp,
								fsb);
				__entry->agbno = XFS_FSB_TO_AGBNO(cur->bc_mp,
								fsb);
			} else {
				__entry->agbno = be32_to_cpu(ptr->s);
			}
		} else {
			__entry->agbno = NULLAGBLOCK;
		}
	),
	TP_printk("dev %d:%d %sbt agno 0x%x ino 0x%llx agbno 0x%x error %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __get_str(name),
		  __entry->agno,
		  __entry->ino,
		  __entry->agbno,
		  __entry->error)
);

TRACE_EVENT(xfs_btree_free_block,
	TP_PROTO(struct xfs_btree_cur *cur, struct xfs_buf *bp),
	TP_ARGS(cur, bp),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_ino_t, ino)
		__string(name, cur->bc_ops->name)
		__field(xfs_agblock_t, agbno)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__entry->agno = xfs_daddr_to_agno(cur->bc_mp,
							xfs_buf_daddr(bp));
		if (cur->bc_ops->type == XFS_BTREE_TYPE_INODE)
			__entry->ino = cur->bc_ino.ip->i_ino;
		else
			__entry->ino = 0;
		__assign_str(name);
		__entry->agbno = xfs_daddr_to_agbno(cur->bc_mp,
							xfs_buf_daddr(bp));
	),
	TP_printk("dev %d:%d %sbt agno 0x%x ino 0x%llx agbno 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __get_str(name),
		  __entry->agno,
		  __entry->ino,
		  __entry->agbno)
);

/* deferred ops */
struct xfs_defer_pending;

DECLARE_EVENT_CLASS()
#define DEFINE_DEFER_EVENT(name)

DECLARE_EVENT_CLASS()
#define DEFINE_DEFER_ERROR_EVENT(name)

DECLARE_EVENT_CLASS()
#define DEFINE_DEFER_PENDING_EVENT(name)

DEFINE_DEFER_EVENT(xfs_defer_cancel);
DEFINE_DEFER_EVENT(xfs_defer_trans_roll);
DEFINE_DEFER_EVENT(xfs_defer_trans_abort);
DEFINE_DEFER_EVENT(xfs_defer_finish);
DEFINE_DEFER_EVENT(xfs_defer_finish_done);

DEFINE_DEFER_ERROR_EVENT(xfs_defer_trans_roll_error);
DEFINE_DEFER_ERROR_EVENT(xfs_defer_finish_error);

DEFINE_DEFER_PENDING_EVENT(xfs_defer_create_intent);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_cancel_list);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_relog_intent);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_isolate_paused);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_item_pause);
DEFINE_DEFER_PENDING_EVENT(xfs_defer_item_unpause);

DECLARE_EVENT_CLASS(xfs_free_extent_deferred_class,
	TP_PROTO(struct xfs_mount *mp, struct xfs_extent_free_item *free),
	TP_ARGS(mp, free),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
		__field(unsigned int, flags)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
		__entry->agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
		__entry->len = free->xefi_blockcount;
		__entry->flags = free->xefi_flags;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x flags 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len,
		  __entry->flags)
);
#define DEFINE_FREE_EXTENT_DEFERRED_EVENT(name)
DEFINE_FREE_EXTENT_DEFERRED_EVENT(xfs_agfl_free_defer);
DEFINE_FREE_EXTENT_DEFERRED_EVENT(xfs_agfl_free_deferred);
DEFINE_FREE_EXTENT_DEFERRED_EVENT(xfs_extent_free_defer);
DEFINE_FREE_EXTENT_DEFERRED_EVENT(xfs_extent_free_deferred);

DECLARE_EVENT_CLASS()
#define DEFINE_DEFER_PENDING_ITEM_EVENT(name)

DEFINE_DEFER_PENDING_ITEM_EVENT(xfs_defer_add_item);
DEFINE_DEFER_PENDING_ITEM_EVENT(xfs_defer_cancel_item);
DEFINE_DEFER_PENDING_ITEM_EVENT(xfs_defer_finish_item);

/* rmap tracepoints */
DECLARE_EVENT_CLASS(xfs_rmap_class,
	TP_PROTO(struct xfs_btree_cur *cur,
		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten,
		 const struct xfs_owner_info *oinfo),
	TP_ARGS(cur, agbno, len, unwritten, oinfo),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
		__field(uint64_t, owner)
		__field(uint64_t, offset)
		__field(unsigned long, flags)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__entry->agno = cur->bc_ag.pag->pag_agno;
		__entry->agbno = agbno;
		__entry->len = len;
		__entry->owner = oinfo->oi_owner;
		__entry->offset = oinfo->oi_offset;
		__entry->flags = oinfo->oi_flags;
		if (unwritten)
			__entry->flags |= XFS_RMAP_UNWRITTEN;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%lx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len,
		  __entry->owner,
		  __entry->offset,
		  __entry->flags)
);
#define DEFINE_RMAP_EVENT(name)

/* 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(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 = 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 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_BTREE_ERROR_EVENT(name)

DEFINE_RMAP_EVENT(xfs_rmap_unmap);
DEFINE_RMAP_EVENT(xfs_rmap_unmap_done);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_unmap_error);
DEFINE_RMAP_EVENT(xfs_rmap_map);
DEFINE_RMAP_EVENT(xfs_rmap_map_done);
DEFINE_BTREE_ERROR_EVENT(xfs_rmap_map_error);
DEFINE_RMAP_EVENT(xfs_rmap_convert);
DEFINE_RMAP_EVENT(xfs_rmap_convert_done);
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_btree_cur *cur,
		 xfs_agblock_t agbno, xfs_extlen_t len,
		 uint64_t owner, uint64_t offset, unsigned int flags),
	TP_ARGS(cur, agbno, len, owner, offset, flags),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
		__field(uint64_t, owner)
		__field(uint64_t, offset)
		__field(unsigned int, flags)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__entry->agno = cur->bc_ag.pag->pag_agno;
		__entry->agbno = agbno;
		__entry->len = len;
		__entry->owner = owner;
		__entry->offset = offset;
		__entry->flags = flags;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len,
		  __entry->owner,
		  __entry->offset,
		  __entry->flags)
);
#define DEFINE_RMAPBT_EVENT(name)

TRACE_DEFINE_ENUM(XFS_RMAP_MAP);
TRACE_DEFINE_ENUM(XFS_RMAP_MAP_SHARED);
TRACE_DEFINE_ENUM(XFS_RMAP_UNMAP);
TRACE_DEFINE_ENUM(XFS_RMAP_UNMAP_SHARED);
TRACE_DEFINE_ENUM(XFS_RMAP_CONVERT);
TRACE_DEFINE_ENUM(XFS_RMAP_CONVERT_SHARED);
TRACE_DEFINE_ENUM(XFS_RMAP_ALLOC);
TRACE_DEFINE_ENUM(XFS_RMAP_FREE);

DECLARE_EVENT_CLASS(xfs_rmap_deferred_class,
	TP_PROTO(struct xfs_mount *mp, struct xfs_rmap_intent *ri),
	TP_ARGS(mp, ri),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long long, owner)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(int, whichfork)
		__field(xfs_fileoff_t, l_loff)
		__field(xfs_filblks_t, l_len)
		__field(xfs_exntst_t, l_state)
		__field(int, op)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = XFS_FSB_TO_AGNO(mp, ri->ri_bmap.br_startblock);
		__entry->agbno = XFS_FSB_TO_AGBNO(mp,
					ri->ri_bmap.br_startblock);
		__entry->owner = ri->ri_owner;
		__entry->whichfork = ri->ri_whichfork;
		__entry->l_loff = ri->ri_bmap.br_startoff;
		__entry->l_len = ri->ri_bmap.br_blockcount;
		__entry->l_state = ri->ri_bmap.br_state;
		__entry->op = ri->ri_type;
	),
	TP_printk("dev %d:%d op %s agno 0x%x agbno 0x%x owner 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __print_symbolic(__entry->op, XFS_RMAP_INTENT_STRINGS),
		  __entry->agno,
		  __entry->agbno,
		  __entry->owner,
		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
		  __entry->l_loff,
		  __entry->l_len,
		  __entry->l_state)
);
#define DEFINE_RMAP_DEFERRED_EVENT(name)
DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_defer);
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_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);
DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_candidate);
DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range);
DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_result);
DEFINE_RMAPBT_EVENT(xfs_rmap_find_right_neighbor_result);
DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_result);

/* deferred bmbt updates */
TRACE_DEFINE_ENUM(XFS_BMAP_MAP);
TRACE_DEFINE_ENUM(XFS_BMAP_UNMAP);

DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
	TP_PROTO(struct xfs_bmap_intent *bi),
	TP_ARGS(bi),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(dev_t, opdev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_ino_t, ino)
		__field(xfs_agblock_t, agbno)
		__field(xfs_fsblock_t, rtbno)
		__field(int, whichfork)
		__field(xfs_fileoff_t, l_loff)
		__field(xfs_filblks_t, l_len)
		__field(xfs_exntst_t, l_state)
		__field(int, op)
	),
	TP_fast_assign(
		struct xfs_inode	*ip = bi->bi_owner;

		__entry->dev = ip->i_mount->m_super->s_dev;
		if (xfs_ifork_is_realtime(ip, bi->bi_whichfork)) {
			__entry->agno = 0;
			__entry->agbno = 0;
			__entry->rtbno = bi->bi_bmap.br_startblock;
			__entry->opdev = ip->i_mount->m_rtdev_targp->bt_dev;
		} else {
			__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
						bi->bi_bmap.br_startblock);
			__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
						bi->bi_bmap.br_startblock);
			__entry->rtbno = 0;
			__entry->opdev = __entry->dev;
		}
		__entry->ino = ip->i_ino;
		__entry->whichfork = bi->bi_whichfork;
		__entry->l_loff = bi->bi_bmap.br_startoff;
		__entry->l_len = bi->bi_bmap.br_blockcount;
		__entry->l_state = bi->bi_bmap.br_state;
		__entry->op = bi->bi_type;
	),
	TP_printk("dev %d:%d op %s opdev %d:%d ino 0x%llx agno 0x%x agbno 0x%x rtbno 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __print_symbolic(__entry->op, XFS_BMAP_INTENT_STRINGS),
		  MAJOR(__entry->opdev), MINOR(__entry->opdev),
		  __entry->ino,
		  __entry->agno,
		  __entry->agbno,
		  __entry->rtbno,
		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
		  __entry->l_loff,
		  __entry->l_len,
		  __entry->l_state)
);
#define DEFINE_BMAP_DEFERRED_EVENT(name)
DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_defer);
DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_deferred);

/* per-AG reservation */
DECLARE_EVENT_CLASS()
#define DEFINE_AG_RESV_EVENT(name)

/* per-AG reservation tracepoints */
DEFINE_AG_RESV_EVENT(xfs_ag_resv_init);
DEFINE_AG_RESV_EVENT(xfs_ag_resv_free);
DEFINE_AG_RESV_EVENT(xfs_ag_resv_alloc_extent);
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_AG_ERROR_EVENT(xfs_ag_resv_init_error);

/* refcount tracepoint classes */

DECLARE_EVENT_CLASS(xfs_refcount_class,
	TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno,
		xfs_extlen_t len),
	TP_ARGS(cur, agbno, len),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__entry->agno = cur->bc_ag.pag->pag_agno;
		__entry->agbno = agbno;
		__entry->len = len;
	),
	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len)
);
#define DEFINE_REFCOUNT_EVENT(name)

TRACE_DEFINE_ENUM(XFS_LOOKUP_EQi);
TRACE_DEFINE_ENUM(XFS_LOOKUP_LEi);
TRACE_DEFINE_ENUM(XFS_LOOKUP_GEi);
TRACE_EVENT()

/* single-rcext tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_REFCOUNT_EXTENT_EVENT(name)

/* single-rcext and an agbno tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_REFCOUNT_EXTENT_AT_EVENT(name)

/* double-rcext tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(name)

/* double-rcext and an agbno tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(name)

/* triple-rcext tracepoint class */
DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class,
	TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1,
		struct xfs_refcount_irec *i2, struct xfs_refcount_irec *i3),
	TP_ARGS(cur, i1, i2, i3),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(enum xfs_refc_domain, i1_domain)
		__field(xfs_agblock_t, i1_startblock)
		__field(xfs_extlen_t, i1_blockcount)
		__field(xfs_nlink_t, i1_refcount)
		__field(enum xfs_refc_domain, i2_domain)
		__field(xfs_agblock_t, i2_startblock)
		__field(xfs_extlen_t, i2_blockcount)
		__field(xfs_nlink_t, i2_refcount)
		__field(enum xfs_refc_domain, i3_domain)
		__field(xfs_agblock_t, i3_startblock)
		__field(xfs_extlen_t, i3_blockcount)
		__field(xfs_nlink_t, i3_refcount)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__entry->agno = cur->bc_ag.pag->pag_agno;
		__entry->i1_domain = i1->rc_domain;
		__entry->i1_startblock = i1->rc_startblock;
		__entry->i1_blockcount = i1->rc_blockcount;
		__entry->i1_refcount = i1->rc_refcount;
		__entry->i2_domain = i2->rc_domain;
		__entry->i2_startblock = i2->rc_startblock;
		__entry->i2_blockcount = i2->rc_blockcount;
		__entry->i2_refcount = i2->rc_refcount;
		__entry->i3_domain = i3->rc_domain;
		__entry->i3_startblock = i3->rc_startblock;
		__entry->i3_blockcount = i3->rc_blockcount;
		__entry->i3_refcount = i3->rc_refcount;
	),
	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u -- "
		  "dom %s agbno 0x%x fsbcount 0x%x refcount %u -- "
		  "dom %s agbno 0x%x fsbcount 0x%x refcount %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __print_symbolic(__entry->i1_domain, XFS_REFC_DOMAIN_STRINGS),
		  __entry->i1_startblock,
		  __entry->i1_blockcount,
		  __entry->i1_refcount,
		  __print_symbolic(__entry->i2_domain, XFS_REFC_DOMAIN_STRINGS),
		  __entry->i2_startblock,
		  __entry->i2_blockcount,
		  __entry->i2_refcount,
		  __print_symbolic(__entry->i3_domain, XFS_REFC_DOMAIN_STRINGS),
		  __entry->i3_startblock,
		  __entry->i3_blockcount,
		  __entry->i3_refcount)
);

#define DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(name)

/* refcount btree tracepoints */
DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get);
DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update);
DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert);
DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_delete);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_insert_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_delete_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_update_error);

/* refcount adjustment tracepoints */
DEFINE_REFCOUNT_EVENT(xfs_refcount_increase);
DEFINE_REFCOUNT_EVENT(xfs_refcount_decrease);
DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_increase);
DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_decrease);
DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents);
DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent);
DEFINE_REFCOUNT_EXTENT_AT_EVENT(xfs_refcount_split_extent);
DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent);
DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent);
DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_left_extent);
DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_right_extent);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_adjust_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_adjust_cow_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_center_extents_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_modify_extent_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_split_extent_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_left_extent_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_right_extent_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_left_extent_error);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_right_extent_error);

/* reflink helpers */
DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared);
DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared_result);
DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error);

TRACE_DEFINE_ENUM(XFS_REFCOUNT_INCREASE);
TRACE_DEFINE_ENUM(XFS_REFCOUNT_DECREASE);
TRACE_DEFINE_ENUM(XFS_REFCOUNT_ALLOC_COW);
TRACE_DEFINE_ENUM(XFS_REFCOUNT_FREE_COW);

DECLARE_EVENT_CLASS(xfs_refcount_deferred_class,
	TP_PROTO(struct xfs_mount *mp, struct xfs_refcount_intent *refc),
	TP_ARGS(mp, refc),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(int, op)
		__field(xfs_agblock_t, agbno)
		__field(xfs_extlen_t, len)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = XFS_FSB_TO_AGNO(mp, refc->ri_startblock);
		__entry->op = refc->ri_type;
		__entry->agbno = XFS_FSB_TO_AGBNO(mp, refc->ri_startblock);
		__entry->len = refc->ri_blockcount;
	),
	TP_printk("dev %d:%d op %s agno 0x%x agbno 0x%x fsbcount 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __print_symbolic(__entry->op, XFS_REFCOUNT_INTENT_STRINGS),
		  __entry->agno,
		  __entry->agbno,
		  __entry->len)
);
#define DEFINE_REFCOUNT_DEFERRED_EVENT(name)
DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer);
DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred);
DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_finish_one_leftover);

/* simple inode-based error/%ip tracepoint class */
DECLARE_EVENT_CLASS(xfs_inode_error_class,
	TP_PROTO(struct xfs_inode *ip, int error, unsigned long caller_ip),
	TP_ARGS(ip, error, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(int, error)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->error = error;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d ino 0x%llx error %d caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->error,
		  (char *)__entry->caller_ip)
);

#define DEFINE_INODE_ERROR_EVENT(name)

/* reflink tracepoint classes */

/* two-file io tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_DOUBLE_IO_EVENT(name)

/* inode/irec events */
DECLARE_EVENT_CLASS(xfs_inode_irec_class,
	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec),
	TP_ARGS(ip, irec),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(xfs_fileoff_t, lblk)
		__field(xfs_extlen_t, len)
		__field(xfs_fsblock_t, pblk)
		__field(int, state)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->lblk = irec->br_startoff;
		__entry->len = irec->br_blockcount;
		__entry->pblk = irec->br_startblock;
		__entry->state = irec->br_state;
	),
	TP_printk("dev %d:%d ino 0x%llx fileoff 0x%llx fsbcount 0x%x startblock 0x%llx st %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->lblk,
		  __entry->len,
		  __entry->pblk,
		  __entry->state)
);
#define DEFINE_INODE_IREC_EVENT(name)

/* inode iomap invalidation events */
DECLARE_EVENT_CLASS(xfs_wb_invalid_class,
	TP_PROTO(struct xfs_inode *ip, const struct iomap *iomap, unsigned int wpcseq, int whichfork),
	TP_ARGS(ip, iomap, wpcseq, whichfork),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(u64, addr)
		__field(loff_t, pos)
		__field(u64, len)
		__field(u16, type)
		__field(u16, flags)
		__field(u32, wpcseq)
		__field(u32, forkseq)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->addr = iomap->addr;
		__entry->pos = iomap->offset;
		__entry->len = iomap->length;
		__entry->type = iomap->type;
		__entry->flags = iomap->flags;
		__entry->wpcseq = wpcseq;
		__entry->forkseq = READ_ONCE(xfs_ifork_ptr(ip, whichfork)->if_seq);
	),
	TP_printk("dev %d:%d ino 0x%llx pos 0x%llx addr 0x%llx bytecount 0x%llx type 0x%x flags 0x%x wpcseq 0x%x forkseq 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->pos,
		  __entry->addr,
		  __entry->len,
		  __entry->type,
		  __entry->flags,
		  __entry->wpcseq,
		  __entry->forkseq)
);
#define DEFINE_WB_INVALID_EVENT(name)
DEFINE_WB_INVALID_EVENT(xfs_wb_cow_iomap_invalid);
DEFINE_WB_INVALID_EVENT(xfs_wb_data_iomap_invalid);

DECLARE_EVENT_CLASS(xfs_iomap_invalid_class,
	TP_PROTO(struct xfs_inode *ip, const struct iomap *iomap),
	TP_ARGS(ip, iomap),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(u64, addr)
		__field(loff_t, pos)
		__field(u64, len)
		__field(u64, validity_cookie)
		__field(u64, inodeseq)
		__field(u16, type)
		__field(u16, flags)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(ip)->i_sb->s_dev;
		__entry->ino = ip->i_ino;
		__entry->addr = iomap->addr;
		__entry->pos = iomap->offset;
		__entry->len = iomap->length;
		__entry->validity_cookie = iomap->validity_cookie;
		__entry->type = iomap->type;
		__entry->flags = iomap->flags;
		__entry->inodeseq = xfs_iomap_inode_sequence(ip, iomap->flags);
	),
	TP_printk("dev %d:%d ino 0x%llx pos 0x%llx addr 0x%llx bytecount 0x%llx type 0x%x flags 0x%x validity_cookie 0x%llx inodeseq 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->pos,
		  __entry->addr,
		  __entry->len,
		  __entry->type,
		  __entry->flags,
		  __entry->validity_cookie,
		  __entry->inodeseq)
);
#define DEFINE_IOMAP_INVALID_EVENT(name)
DEFINE_IOMAP_INVALID_EVENT(xfs_iomap_invalid);

/* refcount/reflink tracepoint definitions */

/* reflink tracepoints */
DEFINE_INODE_EVENT(xfs_reflink_set_inode_flag);
DEFINE_INODE_EVENT(xfs_reflink_unset_inode_flag);
DEFINE_ITRUNC_EVENT(xfs_reflink_update_inode_size);
TRACE_EVENT(xfs_reflink_remap_blocks,
	TP_PROTO(struct xfs_inode *src, xfs_fileoff_t soffset,
		 xfs_filblks_t len, struct xfs_inode *dest,
		 xfs_fileoff_t doffset),
	TP_ARGS(src, soffset, len, dest, doffset),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, src_ino)
		__field(xfs_fileoff_t, src_lblk)
		__field(xfs_filblks_t, len)
		__field(xfs_ino_t, dest_ino)
		__field(xfs_fileoff_t, dest_lblk)
	),
	TP_fast_assign(
		__entry->dev = VFS_I(src)->i_sb->s_dev;
		__entry->src_ino = src->i_ino;
		__entry->src_lblk = soffset;
		__entry->len = len;
		__entry->dest_ino = dest->i_ino;
		__entry->dest_lblk = doffset;
	),
	TP_printk("dev %d:%d fsbcount 0x%llx "
		  "ino 0x%llx fileoff 0x%llx -> ino 0x%llx fileoff 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->len,
		  __entry->src_ino,
		  __entry->src_lblk,
		  __entry->dest_ino,
		  __entry->dest_lblk)
);
DEFINE_DOUBLE_IO_EVENT(xfs_reflink_remap_range);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_range_error);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_set_inode_flag_error);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_update_inode_size_error);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_blocks_error);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_extent_error);
DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_src);
DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_dest);

/* dedupe tracepoints */
DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);

/* ioctl tracepoints */
TRACE_EVENT(xfs_ioctl_clone,
	TP_PROTO(struct inode *src, struct inode *dest),
	TP_ARGS(src, dest),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long, src_ino)
		__field(loff_t, src_isize)
		__field(unsigned long, dest_ino)
		__field(loff_t, dest_isize)
	),
	TP_fast_assign(
		__entry->dev = src->i_sb->s_dev;
		__entry->src_ino = src->i_ino;
		__entry->src_isize = i_size_read(src);
		__entry->dest_ino = dest->i_ino;
		__entry->dest_isize = i_size_read(dest);
	),
	TP_printk("dev %d:%d ino 0x%lx isize 0x%llx -> ino 0x%lx isize 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->src_ino,
		  __entry->src_isize,
		  __entry->dest_ino,
		  __entry->dest_isize)
);

/* unshare tracepoints */
DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);

/* copy on write */
DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);

DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range);
DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow);
DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap_from);
DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap_to);

DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error);
DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error);


DEFINE_INODE_IREC_EVENT(xfs_reflink_cancel_cow);

/* rmap swapext tracepoints */
DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap);
DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap_piece);
DEFINE_INODE_ERROR_EVENT(xfs_swap_extent_rmap_error);

/* fsmap traces */
DECLARE_EVENT_CLASS()
#define DEFINE_FSMAP_EVENT(name)
DEFINE_FSMAP_EVENT(xfs_fsmap_low_key);
DEFINE_FSMAP_EVENT(xfs_fsmap_high_key);
DEFINE_FSMAP_EVENT(xfs_fsmap_mapping);

DECLARE_EVENT_CLASS()
#define DEFINE_FSMAP_LINEAR_EVENT(name)
DEFINE_FSMAP_LINEAR_EVENT(xfs_fsmap_low_key_linear);
DEFINE_FSMAP_LINEAR_EVENT(xfs_fsmap_high_key_linear);

DECLARE_EVENT_CLASS()
#define DEFINE_GETFSMAP_EVENT(name)
DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);

DECLARE_EVENT_CLASS()

#define DEFINE_TRANS_RESV_EVENT(name)
DEFINE_TRANS_RESV_EVENT(xfs_trans_resv_calc);
DEFINE_TRANS_RESV_EVENT(xfs_trans_resv_calc_minlogsize);

TRACE_EVENT(xfs_log_get_max_trans_res,
	TP_PROTO(struct xfs_mount *mp, const struct xfs_trans_res *res),
	TP_ARGS(mp, res),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(uint, logres)
		__field(int, logcount)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->logres = res->tr_logres;
		__entry->logcount = res->tr_logcount;
	),
	TP_printk("dev %d:%d logres %u logcount %d",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->logres,
		  __entry->logcount)
);

DECLARE_EVENT_CLASS()

#define DEFINE_TRANS_EVENT(name)
DEFINE_TRANS_EVENT(xfs_trans_alloc);
DEFINE_TRANS_EVENT(xfs_trans_cancel);
DEFINE_TRANS_EVENT(xfs_trans_commit);
DEFINE_TRANS_EVENT(xfs_trans_dup);
DEFINE_TRANS_EVENT(xfs_trans_free);
DEFINE_TRANS_EVENT(xfs_trans_roll);
DEFINE_TRANS_EVENT(xfs_trans_add_item);
DEFINE_TRANS_EVENT(xfs_trans_commit_items);
DEFINE_TRANS_EVENT(xfs_trans_free_items);

TRACE_EVENT(xfs_iunlink_update_bucket,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int bucket,
		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
	TP_ARGS(mp, agno, bucket, old_ptr, new_ptr),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(unsigned int, bucket)
		__field(xfs_agino_t, old_ptr)
		__field(xfs_agino_t, new_ptr)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->bucket = bucket;
		__entry->old_ptr = old_ptr;
		__entry->new_ptr = new_ptr;
	),
	TP_printk("dev %d:%d agno 0x%x bucket %u old 0x%x new 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->bucket,
		  __entry->old_ptr,
		  __entry->new_ptr)
);

TRACE_EVENT(xfs_iunlink_update_dinode,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
	TP_ARGS(mp, agno, agino, old_ptr, new_ptr),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agino_t, agino)
		__field(xfs_agino_t, old_ptr)
		__field(xfs_agino_t, new_ptr)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->agino = agino;
		__entry->old_ptr = old_ptr;
		__entry->new_ptr = new_ptr;
	),
	TP_printk("dev %d:%d agno 0x%x agino 0x%x old 0x%x new 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agino,
		  __entry->old_ptr,
		  __entry->new_ptr)
);

TRACE_EVENT(xfs_iunlink_reload_next,
	TP_PROTO(struct xfs_inode *ip),
	TP_ARGS(ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agino_t, agino)
		__field(xfs_agino_t, prev_agino)
		__field(xfs_agino_t, next_agino)
	),
	TP_fast_assign(
		__entry->dev = ip->i_mount->m_super->s_dev;
		__entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino);
		__entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino);
		__entry->prev_agino = ip->i_prev_unlinked;
		__entry->next_agino = ip->i_next_unlinked;
	),
	TP_printk("dev %d:%d agno 0x%x agino 0x%x prev_unlinked 0x%x next_unlinked 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agino,
		  __entry->prev_agino,
		  __entry->next_agino)
);

TRACE_EVENT(xfs_inode_reload_unlinked_bucket,
	TP_PROTO(struct xfs_inode *ip),
	TP_ARGS(ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agino_t, agino)
	),
	TP_fast_assign(
		__entry->dev = ip->i_mount->m_super->s_dev;
		__entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino);
		__entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino);
	),
	TP_printk("dev %d:%d agno 0x%x agino 0x%x bucket %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->agino,
		  __entry->agino % XFS_AGI_UNLINKED_BUCKETS)
);

DECLARE_EVENT_CLASS()

#define DEFINE_AGINODE_EVENT(name)
DEFINE_AGINODE_EVENT(xfs_iunlink);
DEFINE_AGINODE_EVENT(xfs_iunlink_remove);

DECLARE_EVENT_CLASS(xfs_fs_corrupt_class,
	TP_PROTO(struct xfs_mount *mp, unsigned int flags),
	TP_ARGS(mp, flags),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned int, flags)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->flags = flags;
	),
	TP_printk("dev %d:%d flags 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->flags)
);
#define DEFINE_FS_CORRUPT_EVENT(name)
DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_sick);
DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_corrupt);
DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_healthy);
DEFINE_FS_CORRUPT_EVENT(xfs_fs_unfixed_corruption);
DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_sick);
DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_corrupt);
DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_healthy);
DEFINE_FS_CORRUPT_EVENT(xfs_rt_unfixed_corruption);

DECLARE_EVENT_CLASS(xfs_ag_corrupt_class,
	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int flags),
	TP_ARGS(mp, agno, flags),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(unsigned int, flags)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->agno = agno;
		__entry->flags = flags;
	),
	TP_printk("dev %d:%d agno 0x%x flags 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno, __entry->flags)
);
#define DEFINE_AG_CORRUPT_EVENT(name)
DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_sick);
DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_corrupt);
DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_healthy);
DEFINE_AG_CORRUPT_EVENT(xfs_ag_unfixed_corruption);

DECLARE_EVENT_CLASS(xfs_inode_corrupt_class,
	TP_PROTO(struct xfs_inode *ip, unsigned int flags),
	TP_ARGS(ip, flags),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino)
		__field(unsigned int, flags)
	),
	TP_fast_assign(
		__entry->dev = ip->i_mount->m_super->s_dev;
		__entry->ino = ip->i_ino;
		__entry->flags = flags;
	),
	TP_printk("dev %d:%d ino 0x%llx flags 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino, __entry->flags)
);
#define DEFINE_INODE_CORRUPT_EVENT(name)
DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_sick);
DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_corrupt);
DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_healthy);
DEFINE_INODE_CORRUPT_EVENT(xfs_inode_unfixed_corruption);

TRACE_EVENT()

TRACE_EVENT()

TRACE_EVENT()

TRACE_EVENT()

TRACE_EVENT(xfs_btree_commit_afakeroot,
	TP_PROTO(struct xfs_btree_cur *cur),
	TP_ARGS(cur),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__string(name, cur->bc_ops->name)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agblock_t, agbno)
		__field(unsigned int, levels)
		__field(unsigned int, blocks)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__assign_str(name);
		__entry->agno = cur->bc_ag.pag->pag_agno;
		__entry->agbno = cur->bc_ag.afake->af_root;
		__entry->levels = cur->bc_ag.afake->af_levels;
		__entry->blocks = cur->bc_ag.afake->af_blocks;
	),
	TP_printk("dev %d:%d %sbt agno 0x%x levels %u blocks %u root %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __get_str(name),
		  __entry->agno,
		  __entry->levels,
		  __entry->blocks,
		  __entry->agbno)
)

TRACE_EVENT(xfs_btree_commit_ifakeroot,
	TP_PROTO(struct xfs_btree_cur *cur),
	TP_ARGS(cur),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__string(name, cur->bc_ops->name)
		__field(xfs_agnumber_t, agno)
		__field(xfs_agino_t, agino)
		__field(unsigned int, levels)
		__field(unsigned int, blocks)
		__field(int, whichfork)
	),
	TP_fast_assign(
		__entry->dev = cur->bc_mp->m_super->s_dev;
		__assign_str(name);
		__entry->agno = XFS_INO_TO_AGNO(cur->bc_mp,
					cur->bc_ino.ip->i_ino);
		__entry->agino = XFS_INO_TO_AGINO(cur->bc_mp,
					cur->bc_ino.ip->i_ino);
		__entry->levels = cur->bc_ino.ifake->if_levels;
		__entry->blocks = cur->bc_ino.ifake->if_blocks;
		__entry->whichfork = cur->bc_ino.whichfork;
	),
	TP_printk("dev %d:%d %sbt agno 0x%x agino 0x%x whichfork %s levels %u blocks %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __get_str(name),
		  __entry->agno,
		  __entry->agino,
		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
		  __entry->levels,
		  __entry->blocks)
)

TRACE_EVENT()

TRACE_EVENT()

DECLARE_EVENT_CLASS()

#define DEFINE_TIMESTAMP_RANGE_EVENT(name)
DEFINE_TIMESTAMP_RANGE_EVENT(xfs_inode_timestamp_range);
DEFINE_TIMESTAMP_RANGE_EVENT(xfs_quota_expiry_range);

DECLARE_EVENT_CLASS(xfs_icwalk_class,
	TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw,
		 unsigned long caller_ip),
	TP_ARGS(mp, icw, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(__u32, flags)
		__field(uint32_t, uid)
		__field(uint32_t, gid)
		__field(prid_t, prid)
		__field(__u64, min_file_size)
		__field(long, scan_limit)
		__field(unsigned long, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->flags = icw ? icw->icw_flags : 0;
		__entry->uid = icw ? from_kuid(mp->m_super->s_user_ns,
						icw->icw_uid) : 0;
		__entry->gid = icw ? from_kgid(mp->m_super->s_user_ns,
						icw->icw_gid) : 0;
		__entry->prid = icw ? icw->icw_prid : 0;
		__entry->min_file_size = icw ? icw->icw_min_file_size : 0;
		__entry->scan_limit = icw ? icw->icw_scan_limit : 0;
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %ld caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->flags,
		  __entry->uid,
		  __entry->gid,
		  __entry->prid,
		  __entry->min_file_size,
		  __entry->scan_limit,
		  (char *)__entry->caller_ip)
);
#define DEFINE_ICWALK_EVENT(name)
DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks);
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);

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(uint32_t, flags)
		__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->flags = iclog->ic_flags;
		__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 flags %s caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __print_symbolic(__entry->state, XLOG_STATE_STRINGS),
		  __entry->refcount,
		  __entry->offset,
		  __entry->lsn,
		  __print_flags(__entry->flags, "|", XLOG_ICL_STRINGS),
		  (char *)__entry->caller_ip)

);

#define DEFINE_ICLOG_EVENT(name)

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);

TRACE_DEFINE_ENUM(XFS_DAS_UNINIT);
TRACE_DEFINE_ENUM(XFS_DAS_SF_ADD);
TRACE_DEFINE_ENUM(XFS_DAS_SF_REMOVE);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_ADD);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_ADD);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_SET_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_ALLOC_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REPLACE);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE_OLD);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE_ATTR);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_SET_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_ALLOC_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REPLACE);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE_OLD);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE_RMT);
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE_ATTR);
TRACE_DEFINE_ENUM(XFS_DAS_DONE);

DECLARE_EVENT_CLASS()

#define DEFINE_DAS_STATE_EVENT(name)
DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return);
DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
DEFINE_DAS_STATE_EVENT(xfs_attr_leaf_addname_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_alloc);
DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
DEFINE_DAS_STATE_EVENT(xfs_attr_defer_add);


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);
		__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)
);

#ifdef CONFIG_XFS_DRAIN_INTENTS
DECLARE_EVENT_CLASS(xfs_perag_intents_class,
	TP_PROTO(struct xfs_perag *pag, void *caller_ip),
	TP_ARGS(pag, caller_ip),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_agnumber_t, agno)
		__field(long, nr_intents)
		__field(void *, caller_ip)
	),
	TP_fast_assign(
		__entry->dev = pag->pag_mount->m_super->s_dev;
		__entry->agno = pag->pag_agno;
		__entry->nr_intents = atomic_read(&pag->pag_intents_drain.dr_count);
		__entry->caller_ip = caller_ip;
	),
	TP_printk("dev %d:%d agno 0x%x intents %ld caller %pS",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->agno,
		  __entry->nr_intents,
		  __entry->caller_ip)
);

#define DEFINE_PERAG_INTENTS_EVENT(name)
DEFINE_PERAG_INTENTS_EVENT(xfs_perag_intent_hold);
DEFINE_PERAG_INTENTS_EVENT(xfs_perag_intent_rele);
DEFINE_PERAG_INTENTS_EVENT(xfs_perag_wait_intents);

#endif /* CONFIG_XFS_DRAIN_INTENTS */

#ifdef CONFIG_XFS_MEMORY_BUFS
TRACE_EVENT(xmbuf_create,
	TP_PROTO(struct xfs_buftarg *btp),
	TP_ARGS(btp),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long, ino)
		__array(char, pathname, MAXNAMELEN)
	),
	TP_fast_assign(
		char		*path;
		struct file	*file = btp->bt_file;

		__entry->dev = btp->bt_mount->m_super->s_dev;
		__entry->ino = file_inode(file)->i_ino;
		path = file_path(file, __entry->pathname, MAXNAMELEN);
		if (IS_ERR(path))
			strncpy(__entry->pathname, "(unknown)",
					sizeof(__entry->pathname));
	),
	TP_printk("dev %d:%d xmino 0x%lx path '%s'",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->pathname)
);

TRACE_EVENT(xmbuf_free,
	TP_PROTO(struct xfs_buftarg *btp),
	TP_ARGS(btp),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long, ino)
		__field(unsigned long long, bytes)
		__field(loff_t, size)
	),
	TP_fast_assign(
		struct file	*file = btp->bt_file;
		struct inode	*inode = file_inode(file);

		__entry->dev = btp->bt_mount->m_super->s_dev;
		__entry->size = i_size_read(inode);
		__entry->bytes = (inode->i_blocks << SECTOR_SHIFT) + inode->i_bytes;
		__entry->ino = inode->i_ino;
	),
	TP_printk("dev %d:%d xmino 0x%lx mem_bytes 0x%llx isize 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino,
		  __entry->bytes,
		  __entry->size)
);
#endif /* CONFIG_XFS_MEMORY_BUFS */

#ifdef CONFIG_XFS_BTREE_IN_MEM
TRACE_EVENT(xfbtree_init,
	TP_PROTO(struct xfs_mount *mp, struct xfbtree *xfbt,
		 const struct xfs_btree_ops *ops),
	TP_ARGS(mp, xfbt, ops),
	TP_STRUCT__entry(
		__field(const void *, btree_ops)
		__field(unsigned long, xfino)
		__field(unsigned int, leaf_mxr)
		__field(unsigned int, leaf_mnr)
		__field(unsigned int, node_mxr)
		__field(unsigned int, node_mnr)
		__field(unsigned long long, owner)
	),
	TP_fast_assign(
		__entry->btree_ops = ops;
		__entry->xfino = file_inode(xfbt->target->bt_file)->i_ino;
		__entry->leaf_mxr = xfbt->maxrecs[0];
		__entry->node_mxr = xfbt->maxrecs[1];
		__entry->leaf_mnr = xfbt->minrecs[0];
		__entry->node_mnr = xfbt->minrecs[1];
		__entry->owner = xfbt->owner;
	),
	TP_printk("xfino 0x%lx btree_ops %pS owner 0x%llx leaf_mxr %u leaf_mnr %u node_mxr %u node_mnr %u",
		  __entry->xfino,
		  __entry->btree_ops,
		  __entry->owner,
		  __entry->leaf_mxr,
		  __entry->leaf_mnr,
		  __entry->node_mxr,
		  __entry->node_mnr)
);

DECLARE_EVENT_CLASS()

#define DEFINE_XFBTREE_BUF_EVENT(name)
DEFINE_XFBTREE_BUF_EVENT(xfbtree_create_root_buf);
DEFINE_XFBTREE_BUF_EVENT(xfbtree_trans_commit_buf);
DEFINE_XFBTREE_BUF_EVENT(xfbtree_trans_cancel_buf);

DECLARE_EVENT_CLASS()

#define DEFINE_XFBTREE_FREESP_EVENT(name)
DEFINE_XFBTREE_FREESP_EVENT(xfbtree_alloc_block);
DEFINE_XFBTREE_FREESP_EVENT(xfbtree_free_block);
#endif /* CONFIG_XFS_BTREE_IN_MEM */

/* exchmaps tracepoints */
#define XFS_EXCHMAPS_STRINGS

DEFINE_INODE_IREC_EVENT(xfs_exchmaps_mapping1_skip);
DEFINE_INODE_IREC_EVENT(xfs_exchmaps_mapping1);
DEFINE_INODE_IREC_EVENT(xfs_exchmaps_mapping2);
DEFINE_ITRUNC_EVENT(xfs_exchmaps_update_inode_size);

#define XFS_EXCHRANGE_INODES

DECLARE_EVENT_CLASS()

#define DEFINE_EXCHRANGE_INODE_EVENT(name)

DEFINE_EXCHRANGE_INODE_EVENT(xfs_exchrange_before);
DEFINE_EXCHRANGE_INODE_EVENT(xfs_exchrange_after);
DEFINE_INODE_ERROR_EVENT(xfs_exchrange_error);

#define XFS_EXCHANGE_RANGE_FLAGS_STRS

/* file exchange-range tracepoint class */
DECLARE_EVENT_CLASS()

#define DEFINE_EXCHRANGE_EVENT(name)
DEFINE_EXCHRANGE_EVENT(xfs_exchrange_prep);
DEFINE_EXCHRANGE_EVENT(xfs_exchrange_flush);
DEFINE_EXCHRANGE_EVENT(xfs_exchrange_mappings);

TRACE_EVENT(xfs_exchmaps_overhead,
	TP_PROTO(struct xfs_mount *mp, unsigned long long bmbt_blocks,
		 unsigned long long rmapbt_blocks),
	TP_ARGS(mp, bmbt_blocks, rmapbt_blocks),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(unsigned long long, bmbt_blocks)
		__field(unsigned long long, rmapbt_blocks)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->bmbt_blocks = bmbt_blocks;
		__entry->rmapbt_blocks = rmapbt_blocks;
	),
	TP_printk("dev %d:%d bmbt_blocks 0x%llx rmapbt_blocks 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->bmbt_blocks,
		  __entry->rmapbt_blocks)
);

DECLARE_EVENT_CLASS(xfs_exchmaps_estimate_class,
	TP_PROTO(const struct xfs_exchmaps_req *req),
	TP_ARGS(req),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino1)
		__field(xfs_ino_t, ino2)
		__field(xfs_fileoff_t, startoff1)
		__field(xfs_fileoff_t, startoff2)
		__field(xfs_filblks_t, blockcount)
		__field(uint64_t, flags)
		__field(xfs_filblks_t, ip1_bcount)
		__field(xfs_filblks_t, ip2_bcount)
		__field(xfs_filblks_t, ip1_rtbcount)
		__field(xfs_filblks_t, ip2_rtbcount)
		__field(unsigned long long, resblks)
		__field(unsigned long long, nr_exchanges)
	),
	TP_fast_assign(
		__entry->dev = req->ip1->i_mount->m_super->s_dev;
		__entry->ino1 = req->ip1->i_ino;
		__entry->ino2 = req->ip2->i_ino;
		__entry->startoff1 = req->startoff1;
		__entry->startoff2 = req->startoff2;
		__entry->blockcount = req->blockcount;
		__entry->flags = req->flags;
		__entry->ip1_bcount = req->ip1_bcount;
		__entry->ip2_bcount = req->ip2_bcount;
		__entry->ip1_rtbcount = req->ip1_rtbcount;
		__entry->ip2_rtbcount = req->ip2_rtbcount;
		__entry->resblks = req->resblks;
		__entry->nr_exchanges = req->nr_exchanges;
	),
	TP_printk("dev %d:%d ino1 0x%llx fileoff1 0x%llx ino2 0x%llx fileoff2 0x%llx fsbcount 0x%llx flags (%s) bcount1 0x%llx rtbcount1 0x%llx bcount2 0x%llx rtbcount2 0x%llx resblks 0x%llx nr_exchanges %llu",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino1, __entry->startoff1,
		  __entry->ino2, __entry->startoff2,
		  __entry->blockcount,
		  __print_flags_u64(__entry->flags, "|", XFS_EXCHMAPS_STRINGS),
		  __entry->ip1_bcount,
		  __entry->ip1_rtbcount,
		  __entry->ip2_bcount,
		  __entry->ip2_rtbcount,
		  __entry->resblks,
		  __entry->nr_exchanges)
);

#define DEFINE_EXCHMAPS_ESTIMATE_EVENT(name)
DEFINE_EXCHMAPS_ESTIMATE_EVENT(xfs_exchmaps_initial_estimate);
DEFINE_EXCHMAPS_ESTIMATE_EVENT(xfs_exchmaps_final_estimate);

DECLARE_EVENT_CLASS(xfs_exchmaps_intent_class,
	TP_PROTO(struct xfs_mount *mp, const struct xfs_exchmaps_intent *xmi),
	TP_ARGS(mp, xmi),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino1)
		__field(xfs_ino_t, ino2)
		__field(uint64_t, flags)
		__field(xfs_fileoff_t, startoff1)
		__field(xfs_fileoff_t, startoff2)
		__field(xfs_filblks_t, blockcount)
		__field(xfs_fsize_t, isize1)
		__field(xfs_fsize_t, isize2)
		__field(xfs_fsize_t, new_isize1)
		__field(xfs_fsize_t, new_isize2)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->ino1 = xmi->xmi_ip1->i_ino;
		__entry->ino2 = xmi->xmi_ip2->i_ino;
		__entry->flags = xmi->xmi_flags;
		__entry->startoff1 = xmi->xmi_startoff1;
		__entry->startoff2 = xmi->xmi_startoff2;
		__entry->blockcount = xmi->xmi_blockcount;
		__entry->isize1 = xmi->xmi_ip1->i_disk_size;
		__entry->isize2 = xmi->xmi_ip2->i_disk_size;
		__entry->new_isize1 = xmi->xmi_isize1;
		__entry->new_isize2 = xmi->xmi_isize2;
	),
	TP_printk("dev %d:%d ino1 0x%llx fileoff1 0x%llx ino2 0x%llx fileoff2 0x%llx fsbcount 0x%llx flags (%s) isize1 0x%llx newisize1 0x%llx isize2 0x%llx newisize2 0x%llx",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino1, __entry->startoff1,
		  __entry->ino2, __entry->startoff2,
		  __entry->blockcount,
		  __print_flags_u64(__entry->flags, "|", XFS_EXCHMAPS_STRINGS),
		  __entry->isize1, __entry->new_isize1,
		  __entry->isize2, __entry->new_isize2)
);

#define DEFINE_EXCHMAPS_INTENT_EVENT(name)
DEFINE_EXCHMAPS_INTENT_EVENT(xfs_exchmaps_defer);
DEFINE_EXCHMAPS_INTENT_EVENT(xfs_exchmaps_recover);

TRACE_EVENT(xfs_exchmaps_delta_nextents_step,
	TP_PROTO(struct xfs_mount *mp,
		 const struct xfs_bmbt_irec *left,
		 const struct xfs_bmbt_irec *curr,
		 const struct xfs_bmbt_irec *new,
		 const struct xfs_bmbt_irec *right,
		 int delta, unsigned int state),
	TP_ARGS(mp, left, curr, new, right, delta, state),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_fileoff_t, loff)
		__field(xfs_fsblock_t, lstart)
		__field(xfs_filblks_t, lcount)
		__field(xfs_fileoff_t, coff)
		__field(xfs_fsblock_t, cstart)
		__field(xfs_filblks_t, ccount)
		__field(xfs_fileoff_t, noff)
		__field(xfs_fsblock_t, nstart)
		__field(xfs_filblks_t, ncount)
		__field(xfs_fileoff_t, roff)
		__field(xfs_fsblock_t, rstart)
		__field(xfs_filblks_t, rcount)
		__field(int, delta)
		__field(unsigned int, state)
	),
	TP_fast_assign(
		__entry->dev = mp->m_super->s_dev;
		__entry->loff = left->br_startoff;
		__entry->lstart = left->br_startblock;
		__entry->lcount = left->br_blockcount;
		__entry->coff = curr->br_startoff;
		__entry->cstart = curr->br_startblock;
		__entry->ccount = curr->br_blockcount;
		__entry->noff = new->br_startoff;
		__entry->nstart = new->br_startblock;
		__entry->ncount = new->br_blockcount;
		__entry->roff = right->br_startoff;
		__entry->rstart = right->br_startblock;
		__entry->rcount = right->br_blockcount;
		__entry->delta = delta;
		__entry->state = state;
	),
	TP_printk("dev %d:%d left 0x%llx:0x%llx:0x%llx; curr 0x%llx:0x%llx:0x%llx <- new 0x%llx:0x%llx:0x%llx; right 0x%llx:0x%llx:0x%llx delta %d state 0x%x",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		__entry->loff, __entry->lstart, __entry->lcount,
		__entry->coff, __entry->cstart, __entry->ccount,
		__entry->noff, __entry->nstart, __entry->ncount,
		__entry->roff, __entry->rstart, __entry->rcount,
		__entry->delta, __entry->state)
);

TRACE_EVENT(xfs_exchmaps_delta_nextents,
	TP_PROTO(const struct xfs_exchmaps_req *req, int64_t d_nexts1,
		 int64_t d_nexts2),
	TP_ARGS(req, d_nexts1, d_nexts2),
	TP_STRUCT__entry(
		__field(dev_t, dev)
		__field(xfs_ino_t, ino1)
		__field(xfs_ino_t, ino2)
		__field(xfs_extnum_t, nexts1)
		__field(xfs_extnum_t, nexts2)
		__field(int64_t, d_nexts1)
		__field(int64_t, d_nexts2)
	),
	TP_fast_assign(
		int whichfork = xfs_exchmaps_reqfork(req);

		__entry->dev = req->ip1->i_mount->m_super->s_dev;
		__entry->ino1 = req->ip1->i_ino;
		__entry->ino2 = req->ip2->i_ino;
		__entry->nexts1 = xfs_ifork_ptr(req->ip1, whichfork)->if_nextents;
		__entry->nexts2 = xfs_ifork_ptr(req->ip2, whichfork)->if_nextents;
		__entry->d_nexts1 = d_nexts1;
		__entry->d_nexts2 = d_nexts2;
	),
	TP_printk("dev %d:%d ino1 0x%llx nexts %llu ino2 0x%llx nexts %llu delta1 %lld delta2 %lld",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		  __entry->ino1, __entry->nexts1,
		  __entry->ino2, __entry->nexts2,
		  __entry->d_nexts1, __entry->d_nexts2)
);

DECLARE_EVENT_CLASS()
#define DEFINE_XFS_GETPARENTS_REC_EVENT(name)
DEFINE_XFS_GETPARENTS_REC_EVENT(xfs_getparents_put_listent);
DEFINE_XFS_GETPARENTS_REC_EVENT(xfs_getparents_expand_lastrec);

DECLARE_EVENT_CLASS()
#define DEFINE_XFS_GETPARENTS_EVENT(name)
DEFINE_XFS_GETPARENTS_EVENT(xfs_getparents_begin);
DEFINE_XFS_GETPARENTS_EVENT(xfs_getparents_end);

#endif /* _TRACE_XFS_H */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_FILE
#include <trace/define_trace.h>