btrfs.h 47.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4 5 6 7 8 9
#undef TRACE_SYSTEM
#define TRACE_SYSTEM btrfs

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

#include <linux/writeback.h>
#include <linux/tracepoint.h>
10
#include <trace/events/mmflags.h>
11 12 13 14 15

struct btrfs_root;
struct btrfs_fs_info;
struct btrfs_inode;
struct extent_map;
L
Liu Bo 已提交
16
struct btrfs_file_extent_item;
17 18 19 20 21
struct btrfs_ordered_extent;
struct btrfs_delayed_ref_node;
struct btrfs_delayed_tree_ref;
struct btrfs_delayed_data_ref;
struct btrfs_delayed_ref_head;
J
Josef Bacik 已提交
22 23
struct btrfs_block_group_cache;
struct btrfs_free_cluster;
24 25
struct map_lookup;
struct extent_buffer;
26
struct btrfs_work;
27
struct __btrfs_workqueue;
M
Mark Fasheh 已提交
28
struct btrfs_qgroup_extent_record;
29
struct btrfs_qgroup;
30
struct prelim_ref;
31

32 33 34 35 36 37 38
TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
TRACE_DEFINE_ENUM(ALLOC_CHUNK);
TRACE_DEFINE_ENUM(COMMIT_TRANS);

39 40 41 42 43 44 45 46 47
#define show_ref_type(type)						\
	__print_symbolic(type,						\
		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })

#define __show_root_type(obj)						\
48
	__print_symbolic_u64(obj,					\
49 50 51 52 53 54 55 56
		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
L
Liu Bo 已提交
57
		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
58
		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
59 60
		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
61 62 63 64
		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })

#define show_root_type(obj)						\
	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
65
	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
L
Liu Bo 已提交
66
	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
67

L
Liu Bo 已提交
68 69 70 71 72 73
#define show_fi_type(type)						\
	__print_symbolic(type,						\
		 { BTRFS_FILE_EXTENT_INLINE,	"INLINE" },		\
		 { BTRFS_FILE_EXTENT_REG,	"REG"	 },		\
		 { BTRFS_FILE_EXTENT_PREALLOC,	"PREALLOC"})

J
Josef Bacik 已提交
74
#define BTRFS_GROUP_FLAGS	\
L
Liu Bo 已提交
75 76 77 78 79 80 81 82 83
	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
J
Josef Bacik 已提交
84

A
Anand Jain 已提交
85 86
#define BTRFS_FSID_SIZE 16
#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
87 88

#define TP_fast_assign_fsid(fs_info)					\
A
Anand Jain 已提交
89
	memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE)
90 91 92 93 94 95 96 97 98 99 100

#define TP_STRUCT__entry_btrfs(args...)					\
	TP_STRUCT__entry(						\
		TP_STRUCT__entry_fsid					\
		args)
#define TP_fast_assign_btrfs(fs_info, args...)				\
	TP_fast_assign(							\
		TP_fast_assign_fsid(fs_info);				\
		args)
#define TP_printk_btrfs(fmt, args...) \
	TP_printk("%pU: " fmt, __entry->fsid, args)
J
Josef Bacik 已提交
101

102 103
TRACE_EVENT(btrfs_transaction_commit,

104
	TP_PROTO(const struct btrfs_root *root),
105 106 107

	TP_ARGS(root),

108
	TP_STRUCT__entry_btrfs(
109 110 111 112
		__field(	u64,  generation		)
		__field(	u64,  root_objectid		)
	),

113
	TP_fast_assign_btrfs(root->fs_info,
114 115 116 117
		__entry->generation	= root->fs_info->generation;
		__entry->root_objectid	= root->root_key.objectid;
	),

118
	TP_printk_btrfs("root = %llu(%s), gen = %llu",
119 120 121 122 123 124
		  show_root_type(__entry->root_objectid),
		  (unsigned long long)__entry->generation)
);

DECLARE_EVENT_CLASS(btrfs__inode,

125
	TP_PROTO(const struct inode *inode),
126 127 128

	TP_ARGS(inode),

129
	TP_STRUCT__entry_btrfs(
130 131 132 133 134 135 136 137 138
		__field(	ino_t,  ino			)
		__field(	blkcnt_t,  blocks		)
		__field(	u64,  disk_i_size		)
		__field(	u64,  generation		)
		__field(	u64,  last_trans		)
		__field(	u64,  logged_trans		)
		__field(	u64,  root_objectid		)
	),

139
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
140 141 142 143 144 145 146 147 148 149
		__entry->ino	= inode->i_ino;
		__entry->blocks	= inode->i_blocks;
		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
		__entry->generation = BTRFS_I(inode)->generation;
		__entry->last_trans = BTRFS_I(inode)->last_trans;
		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
		__entry->root_objectid =
				BTRFS_I(inode)->root->root_key.objectid;
	),

150 151
	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
152 153 154 155 156 157 158 159 160 161 162
		  show_root_type(__entry->root_objectid),
		  (unsigned long long)__entry->generation,
		  (unsigned long)__entry->ino,
		  (unsigned long long)__entry->blocks,
		  (unsigned long long)__entry->disk_i_size,
		  (unsigned long long)__entry->last_trans,
		  (unsigned long long)__entry->logged_trans)
);

DEFINE_EVENT(btrfs__inode, btrfs_inode_new,

163
	TP_PROTO(const struct inode *inode),
164 165 166 167 168 169

	TP_ARGS(inode)
);

DEFINE_EVENT(btrfs__inode, btrfs_inode_request,

170
	TP_PROTO(const struct inode *inode),
171 172 173 174 175 176

	TP_ARGS(inode)
);

DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,

177
	TP_PROTO(const struct inode *inode),
178 179 180 181 182

	TP_ARGS(inode)
);

#define __show_map_type(type)						\
183
	__print_symbolic_u64(type,					\
184 185 186 187 188 189 190 191 192 193
		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})

#define show_map_type(type)			\
	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)

#define show_map_flags(flag)						\
	__print_flags(flag, "|",					\
194 195 196 197 198 199
		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
200

201
TRACE_EVENT_CONDITION(btrfs_get_extent,
202

203 204
	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
		 const struct extent_map *map),
205

206
	TP_ARGS(root, inode, map),
207

208 209
	TP_CONDITION(map),

210
	TP_STRUCT__entry_btrfs(
211
		__field(	u64,  root_objectid	)
212
		__field(	u64,  ino		)
213 214 215 216 217 218 219 220 221 222
		__field(	u64,  start		)
		__field(	u64,  len		)
		__field(	u64,  orig_start	)
		__field(	u64,  block_start	)
		__field(	u64,  block_len		)
		__field(	unsigned long,  flags	)
		__field(	int,  refs		)
		__field(	unsigned int,  compress_type	)
	),

223
	TP_fast_assign_btrfs(root->fs_info,
224
		__entry->root_objectid	= root->root_key.objectid;
225 226
		__entry->ino		= btrfs_ino(inode);
		__entry->start		= map->start;
227 228 229 230 231
		__entry->len		= map->len;
		__entry->orig_start	= map->orig_start;
		__entry->block_start	= map->block_start;
		__entry->block_len	= map->block_len;
		__entry->flags		= map->flags;
232
		__entry->refs		= refcount_read(&map->refs);
233 234 235
		__entry->compress_type	= map->compress_type;
	),

236 237 238 239
	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
		  "orig_start=%llu block_start=%llu(%s) "
		  "block_len=%llu flags=%s refs=%u "
		  "compress_type=%u",
240
		  show_root_type(__entry->root_objectid),
241
		  (unsigned long long)__entry->ino,
242 243 244 245 246 247 248 249 250
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->len,
		  (unsigned long long)__entry->orig_start,
		  show_map_type(__entry->block_start),
		  (unsigned long long)__entry->block_len,
		  show_map_flags(__entry->flags),
		  __entry->refs, __entry->compress_type)
);

251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
TRACE_EVENT(btrfs_handle_em_exist,

	TP_PROTO(const struct extent_map *existing, const struct extent_map *map, u64 start, u64 len),

	TP_ARGS(existing, map, start, len),

	TP_STRUCT__entry(
		__field(	u64,  e_start		)
		__field(	u64,  e_len		)
		__field(	u64,  map_start		)
		__field(	u64,  map_len		)
		__field(	u64,  start		)
		__field(	u64,  len		)
	),

	TP_fast_assign(
		__entry->e_start	= existing->start;
		__entry->e_len		= existing->len;
		__entry->map_start	= map->start;
		__entry->map_len	= map->len;
		__entry->start		= start;
		__entry->len		= len;
	),

	TP_printk("start=%llu len=%llu "
		  "existing(start=%llu len=%llu) "
		  "em(start=%llu len=%llu)",
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->len,
		  (unsigned long long)__entry->e_start,
		  (unsigned long long)__entry->e_len,
		  (unsigned long long)__entry->map_start,
		  (unsigned long long)__entry->map_len)
);

L
Liu Bo 已提交
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
/* file extent item */
DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, u64 start),

	TP_ARGS(bi, l, fi, start),

	TP_STRUCT__entry_btrfs(
		__field(	u64,	root_obj	)
		__field(	u64,	ino		)
		__field(	loff_t,	isize		)
		__field(	u64,	disk_isize	)
		__field(	u64,	num_bytes	)
		__field(	u64,	ram_bytes	)
		__field(	u64,	disk_bytenr	)
		__field(	u64,	disk_num_bytes	)
		__field(	u64,	extent_offset	)
		__field(	u8,	extent_type	)
		__field(	u8,	compression	)
		__field(	u64,	extent_start	)
		__field(	u64,	extent_end	)
	),

	TP_fast_assign_btrfs(bi->root->fs_info,
		__entry->root_obj	= bi->root->objectid;
		__entry->ino		= btrfs_ino(bi);
		__entry->isize		= bi->vfs_inode.i_size;
		__entry->disk_isize	= bi->disk_i_size;
		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
		__entry->extent_type	= btrfs_file_extent_type(l, fi);
		__entry->compression	= btrfs_file_extent_compression(l, fi);
		__entry->extent_start	= start;
		__entry->extent_end	= (start + __entry->num_bytes);
	),

	TP_printk_btrfs(
		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
		"file extent range=[%llu %llu] "
		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
		"disk_num_bytes=%llu extent_offset=%llu type=%s "
		"compression=%u",
		show_root_type(__entry->root_obj), __entry->ino,
		__entry->isize,
		__entry->disk_isize, __entry->extent_start,
		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
		__entry->disk_bytenr, __entry->disk_num_bytes,
		__entry->extent_offset, show_fi_type(__entry->extent_type),
		__entry->compression)
);

DECLARE_EVENT_CLASS(
	btrfs__file_extent_item_inline,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, int slot, u64 start),

	TP_ARGS(bi, l, fi, slot,  start),

	TP_STRUCT__entry_btrfs(
		__field(	u64,	root_obj	)
		__field(	u64,	ino		)
		__field(	loff_t,	isize		)
		__field(	u64,	disk_isize	)
		__field(	u8,	extent_type	)
		__field(	u8,	compression	)
		__field(	u64,	extent_start	)
		__field(	u64,	extent_end	)
	),

	TP_fast_assign_btrfs(
		bi->root->fs_info,
		__entry->root_obj	= bi->root->objectid;
		__entry->ino		= btrfs_ino(bi);
		__entry->isize		= bi->vfs_inode.i_size;
		__entry->disk_isize	= bi->disk_i_size;
		__entry->extent_type	= btrfs_file_extent_type(l, fi);
		__entry->compression	= btrfs_file_extent_compression(l, fi);
		__entry->extent_start	= start;
		__entry->extent_end	= (start + btrfs_file_extent_inline_len(l, slot, fi));
	),

	TP_printk_btrfs(
		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
		"file extent range=[%llu %llu] "
		"extent_type=%s compression=%u",
		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
		__entry->disk_isize, __entry->extent_start,
		__entry->extent_end, show_fi_type(__entry->extent_type),
		__entry->compression)
);

DEFINE_EVENT(
	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, u64 start),

	TP_ARGS(bi, l, fi, start)
);

DEFINE_EVENT(
	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, u64 start),

	TP_ARGS(bi, l, fi, start)
);

DEFINE_EVENT(
	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, int slot, u64 start),

	TP_ARGS(bi, l, fi, slot, start)
);

DEFINE_EVENT(
	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,

	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
		 struct btrfs_file_extent_item *fi, int slot, u64 start),

	TP_ARGS(bi, l, fi, slot, start)
);

418 419 420 421 422 423 424 425 426 427
#define show_ordered_flags(flags)					   \
	__print_flags(flags, "|",					   \
		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
		{ (1 << BTRFS_ORDERED_UPDATED_ISIZE), 	"UPDATED_ISIZE"	}, \
428 429
		{ (1 << BTRFS_ORDERED_LOGGED_CSUM), 	"LOGGED_CSUM"	}, \
		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
L
Liu Bo 已提交
430

431 432 433

DECLARE_EVENT_CLASS(btrfs__ordered_extent,

434 435
	TP_PROTO(const struct inode *inode,
		 const struct btrfs_ordered_extent *ordered),
436 437 438

	TP_ARGS(inode, ordered),

439
	TP_STRUCT__entry_btrfs(
440 441 442 443 444 445 446 447 448 449
		__field(	ino_t,  ino		)
		__field(	u64,  file_offset	)
		__field(	u64,  start		)
		__field(	u64,  len		)
		__field(	u64,  disk_len		)
		__field(	u64,  bytes_left	)
		__field(	unsigned long,  flags	)
		__field(	int,  compress_type	)
		__field(	int,  refs		)
		__field(	u64,  root_objectid	)
450
		__field(	u64,  truncated_len	)
451 452
	),

453
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
454 455 456 457 458 459 460 461
		__entry->ino 		= inode->i_ino;
		__entry->file_offset	= ordered->file_offset;
		__entry->start		= ordered->start;
		__entry->len		= ordered->len;
		__entry->disk_len	= ordered->disk_len;
		__entry->bytes_left	= ordered->bytes_left;
		__entry->flags		= ordered->flags;
		__entry->compress_type	= ordered->compress_type;
462
		__entry->refs		= refcount_read(&ordered->refs);
463 464
		__entry->root_objectid	=
				BTRFS_I(inode)->root->root_key.objectid;
465
		__entry->truncated_len	= ordered->truncated_len;
466 467
	),

468 469 470 471 472
	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
		  "start=%llu len=%llu disk_len=%llu "
		  "truncated_len=%llu "
		  "bytes_left=%llu flags=%s compress_type=%d "
		  "refs=%d",
473 474 475 476 477 478
		  show_root_type(__entry->root_objectid),
		  (unsigned long long)__entry->ino,
		  (unsigned long long)__entry->file_offset,
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->len,
		  (unsigned long long)__entry->disk_len,
479
		  (unsigned long long)__entry->truncated_len,
480 481 482 483 484 485 486
		  (unsigned long long)__entry->bytes_left,
		  show_ordered_flags(__entry->flags),
		  __entry->compress_type, __entry->refs)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,

487 488
	TP_PROTO(const struct inode *inode,
		 const struct btrfs_ordered_extent *ordered),
489 490 491 492 493 494

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,

495 496
	TP_PROTO(const struct inode *inode,
		 const struct btrfs_ordered_extent *ordered),
497 498 499 500 501 502

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,

503 504
	TP_PROTO(const struct inode *inode,
		 const struct btrfs_ordered_extent *ordered),
505 506 507 508 509 510

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,

511 512
	TP_PROTO(const struct inode *inode,
		 const struct btrfs_ordered_extent *ordered),
513 514 515 516 517 518

	TP_ARGS(inode, ordered)
);

DECLARE_EVENT_CLASS(btrfs__writepage,

519 520
	TP_PROTO(const struct page *page, const struct inode *inode,
		 const struct writeback_control *wbc),
521 522 523

	TP_ARGS(page, inode, wbc),

524
	TP_STRUCT__entry_btrfs(
525 526 527 528 529 530 531 532 533 534 535 536 537
		__field(	ino_t,  ino			)
		__field(	pgoff_t,  index			)
		__field(	long,   nr_to_write		)
		__field(	long,   pages_skipped		)
		__field(	loff_t, range_start		)
		__field(	loff_t, range_end		)
		__field(	char,   for_kupdate		)
		__field(	char,   for_reclaim		)
		__field(	char,   range_cyclic		)
		__field(	pgoff_t,  writeback_index	)
		__field(	u64,    root_objectid		)
	),

538
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
539 540 541 542 543 544 545 546 547 548 549 550 551 552
		__entry->ino		= inode->i_ino;
		__entry->index		= page->index;
		__entry->nr_to_write	= wbc->nr_to_write;
		__entry->pages_skipped	= wbc->pages_skipped;
		__entry->range_start	= wbc->range_start;
		__entry->range_end	= wbc->range_end;
		__entry->for_kupdate	= wbc->for_kupdate;
		__entry->for_reclaim	= wbc->for_reclaim;
		__entry->range_cyclic	= wbc->range_cyclic;
		__entry->writeback_index = inode->i_mapping->writeback_index;
		__entry->root_objectid	=
				 BTRFS_I(inode)->root->root_key.objectid;
	),

553 554 555 556
	TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
		  "range_end=%llu for_kupdate=%d "
		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
557 558 559 560
		  show_root_type(__entry->root_objectid),
		  (unsigned long)__entry->ino, __entry->index,
		  __entry->nr_to_write, __entry->pages_skipped,
		  __entry->range_start, __entry->range_end,
561
		  __entry->for_kupdate,
562 563 564 565 566 567
		  __entry->for_reclaim, __entry->range_cyclic,
		  (unsigned long)__entry->writeback_index)
);

DEFINE_EVENT(btrfs__writepage, __extent_writepage,

568 569
	TP_PROTO(const struct page *page, const struct inode *inode,
		 const struct writeback_control *wbc),
570 571 572 573 574 575

	TP_ARGS(page, inode, wbc)
);

TRACE_EVENT(btrfs_writepage_end_io_hook,

576
	TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
577 578 579

	TP_ARGS(page, start, end, uptodate),

580
	TP_STRUCT__entry_btrfs(
581 582 583 584 585 586 587 588
		__field(	ino_t,	 ino		)
		__field(	pgoff_t, index		)
		__field(	u64,	 start		)
		__field(	u64,	 end		)
		__field(	int,	 uptodate	)
		__field(	u64,    root_objectid	)
	),

589
	TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
590 591 592 593 594 595 596 597 598
		__entry->ino	= page->mapping->host->i_ino;
		__entry->index	= page->index;
		__entry->start	= start;
		__entry->end	= end;
		__entry->uptodate = uptodate;
		__entry->root_objectid	=
			 BTRFS_I(page->mapping->host)->root->root_key.objectid;
	),

599 600
	TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
		  "end=%llu uptodate=%d",
601 602 603 604 605 606 607 608
		  show_root_type(__entry->root_objectid),
		  (unsigned long)__entry->ino, (unsigned long)__entry->index,
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->end, __entry->uptodate)
);

TRACE_EVENT(btrfs_sync_file,

609
	TP_PROTO(const struct file *file, int datasync),
610 611 612

	TP_ARGS(file, datasync),

613
	TP_STRUCT__entry_btrfs(
614 615 616 617 618 619 620
		__field(	ino_t,  ino		)
		__field(	ino_t,  parent		)
		__field(	int,    datasync	)
		__field(	u64,    root_objectid	)
	),

	TP_fast_assign(
621 622
		const struct dentry *dentry = file->f_path.dentry;
		const struct inode *inode = d_inode(dentry);
623

624
		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
625
		__entry->ino		= inode->i_ino;
626
		__entry->parent		= d_inode(dentry->d_parent)->i_ino;
627 628 629 630 631
		__entry->datasync	= datasync;
		__entry->root_objectid	=
				 BTRFS_I(inode)->root->root_key.objectid;
	),

632
	TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
633 634 635 636 637 638 639
		  show_root_type(__entry->root_objectid),
		  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
		  __entry->datasync)
);

TRACE_EVENT(btrfs_sync_fs,

640
	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
641

642
	TP_ARGS(fs_info, wait),
643

644
	TP_STRUCT__entry_btrfs(
645 646 647
		__field(	int,  wait		)
	),

648
	TP_fast_assign_btrfs(fs_info,
649 650 651
		__entry->wait	= wait;
	),

652
	TP_printk_btrfs("wait = %d", __entry->wait)
653 654
);

655 656
TRACE_EVENT(btrfs_add_block_group,

657 658
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_block_group_cache *block_group, int create),
659 660 661 662

	TP_ARGS(fs_info, block_group, create),

	TP_STRUCT__entry(
A
Anand Jain 已提交
663
		__array(	u8,	fsid,	BTRFS_FSID_SIZE	)
664 665 666 667 668 669 670 671 672
		__field(	u64,	offset			)
		__field(	u64,	size			)
		__field(	u64,	flags			)
		__field(	u64,	bytes_used		)
		__field(	u64,	bytes_super		)
		__field(	int,	create			)
	),

	TP_fast_assign(
A
Anand Jain 已提交
673
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
674 675 676 677 678 679 680 681 682
		__entry->offset		= block_group->key.objectid;
		__entry->size		= block_group->key.offset;
		__entry->flags		= block_group->flags;
		__entry->bytes_used	=
			btrfs_block_group_used(&block_group->item);
		__entry->bytes_super	= block_group->bytes_super;
		__entry->create		= create;
	),

683 684 685
	TP_printk("%pU: block_group offset=%llu size=%llu "
		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
		  "create=%d", __entry->fsid,
686 687 688 689 690 691 692 693 694
		  (unsigned long long)__entry->offset,
		  (unsigned long long)__entry->size,
		  (unsigned long long)__entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS),
		  (unsigned long long)__entry->bytes_used,
		  (unsigned long long)__entry->bytes_super, __entry->create)
);

695 696 697 698 699 700 701 702
#define show_ref_action(action)						\
	__print_symbolic(action,					\
		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
			

703
DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
704

705 706 707
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_tree_ref *full_ref,
708 709
		 int action),

710
	TP_ARGS(fs_info, ref, full_ref, action),
711

712
	TP_STRUCT__entry_btrfs(
713 714 715 716 717 718 719
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
		__field(	int,  action		) 
		__field(	u64,  parent		)
		__field(	u64,  ref_root		)
		__field(	int,  level		)
		__field(	int,  type		)
720
		__field(	u64,  seq		)
721 722
	),

723
	TP_fast_assign_btrfs(fs_info,
724 725 726 727 728 729 730
		__entry->bytenr		= ref->bytenr;
		__entry->num_bytes	= ref->num_bytes;
		__entry->action		= action;
		__entry->parent		= full_ref->parent;
		__entry->ref_root	= full_ref->root;
		__entry->level		= full_ref->level;
		__entry->type		= ref->type;
731
		__entry->seq		= ref->seq;
732 733
	),

734 735 736
	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
		  "type=%s seq=%llu",
737 738 739 740 741
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes,
		  show_ref_action(__entry->action),
		  show_root_type(__entry->parent),
		  show_root_type(__entry->ref_root),
742 743
		  __entry->level, show_ref_type(__entry->type),
		  (unsigned long long)__entry->seq)
744 745
);

746 747
DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,

748 749 750
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_tree_ref *full_ref,
751 752
		 int action),

753
	TP_ARGS(fs_info, ref, full_ref, action)
754 755 756 757
);

DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,

758 759 760
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_tree_ref *full_ref,
761 762
		 int action),

763
	TP_ARGS(fs_info, ref, full_ref, action)
764 765 766
);

DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
767

768 769 770
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_data_ref *full_ref,
771 772
		 int action),

773
	TP_ARGS(fs_info, ref, full_ref, action),
774

775
	TP_STRUCT__entry_btrfs(
776 777 778 779 780 781 782 783
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
		__field(	int,  action		) 
		__field(	u64,  parent		)
		__field(	u64,  ref_root		)
		__field(	u64,  owner		)
		__field(	u64,  offset		)
		__field(	int,  type		)
784
		__field(	u64,  seq		)
785 786
	),

787
	TP_fast_assign_btrfs(fs_info,
788 789 790 791 792 793 794 795
		__entry->bytenr		= ref->bytenr;
		__entry->num_bytes	= ref->num_bytes;
		__entry->action		= action;
		__entry->parent		= full_ref->parent;
		__entry->ref_root	= full_ref->root;
		__entry->owner		= full_ref->objectid;
		__entry->offset		= full_ref->offset;
		__entry->type		= ref->type;
796
		__entry->seq		= ref->seq;
797 798
	),

799 800 801
	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
		  "offset=%llu type=%s seq=%llu",
802 803 804 805 806 807 808
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes,
		  show_ref_action(__entry->action),
		  show_root_type(__entry->parent),
		  show_root_type(__entry->ref_root),
		  (unsigned long long)__entry->owner,
		  (unsigned long long)__entry->offset,
809 810
		  show_ref_type(__entry->type),
		  (unsigned long long)__entry->seq)
811 812
);

813 814
DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,

815 816 817
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_data_ref *full_ref,
818 819
		 int action),

820
	TP_ARGS(fs_info, ref, full_ref, action)
821 822 823 824
);

DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,

825 826 827
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_node *ref,
		 const struct btrfs_delayed_data_ref *full_ref,
828 829
		 int action),

830
	TP_ARGS(fs_info, ref, full_ref, action)
831 832 833
);

DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
834

835 836
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_head *head_ref,
837 838
		 int action),

839
	TP_ARGS(fs_info, head_ref, action),
840

841
	TP_STRUCT__entry_btrfs(
842 843 844 845 846 847
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
		__field(	int,  action		) 
		__field(	int,  is_data		)
	),

848
	TP_fast_assign_btrfs(fs_info,
849 850
		__entry->bytenr		= head_ref->bytenr;
		__entry->num_bytes	= head_ref->num_bytes;
851 852 853 854
		__entry->action		= action;
		__entry->is_data	= head_ref->is_data;
	),

855
	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
856 857 858 859 860 861
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes,
		  show_ref_action(__entry->action),
		  __entry->is_data)
);

862 863
DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,

864 865
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_head *head_ref,
866 867
		 int action),

868
	TP_ARGS(fs_info, head_ref, action)
869 870 871 872
);

DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,

873 874
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_delayed_ref_head *head_ref,
875 876
		 int action),

877
	TP_ARGS(fs_info, head_ref, action)
878 879
);

880 881 882 883 884 885 886 887
#define show_chunk_type(type)					\
	__print_flags(type, "|",				\
		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
L
Liu Bo 已提交
888 889 890
		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
891 892 893

DECLARE_EVENT_CLASS(btrfs__chunk,

894 895
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct map_lookup *map, u64 offset, u64 size),
896

897
	TP_ARGS(fs_info, map, offset, size),
898

899
	TP_STRUCT__entry_btrfs(
900 901 902 903 904 905 906 907
		__field(	int,  num_stripes		)
		__field(	u64,  type			)
		__field(	int,  sub_stripes		)
		__field(	u64,  offset			)
		__field(	u64,  size			)
		__field(	u64,  root_objectid		)
	),

908
	TP_fast_assign_btrfs(fs_info,
909 910 911 912 913
		__entry->num_stripes	= map->num_stripes;
		__entry->type		= map->type;
		__entry->sub_stripes	= map->sub_stripes;
		__entry->offset		= offset;
		__entry->size		= size;
914
		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
915 916
	),

917 918
	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
		  "num_stripes=%d sub_stripes=%d type=%s",
919 920 921 922 923 924 925 926 927
		  show_root_type(__entry->root_objectid),
		  (unsigned long long)__entry->offset,
		  (unsigned long long)__entry->size,
		  __entry->num_stripes, __entry->sub_stripes,
		  show_chunk_type(__entry->type))
);

DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,

928 929
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct map_lookup *map, u64 offset, u64 size),
930

931
	TP_ARGS(fs_info, map, offset, size)
932 933 934 935
);

DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,

936 937
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct map_lookup *map, u64 offset, u64 size),
938

939
	TP_ARGS(fs_info, map, offset, size)
940 941 942 943
);

TRACE_EVENT(btrfs_cow_block,

944 945
	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
		 const struct extent_buffer *cow),
946 947 948

	TP_ARGS(root, buf, cow),

949
	TP_STRUCT__entry_btrfs(
950 951 952 953 954 955 956 957
		__field(	u64,  root_objectid		)
		__field(	u64,  buf_start			)
		__field(	int,  refs			)
		__field(	u64,  cow_start			)
		__field(	int,  buf_level			)
		__field(	int,  cow_level			)
	),

958
	TP_fast_assign_btrfs(root->fs_info,
959 960 961 962 963 964 965 966
		__entry->root_objectid	= root->root_key.objectid;
		__entry->buf_start	= buf->start;
		__entry->refs		= atomic_read(&buf->refs);
		__entry->cow_start	= cow->start;
		__entry->buf_level	= btrfs_header_level(buf);
		__entry->cow_level	= btrfs_header_level(cow);
	),

967 968
	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
969 970 971 972 973 974 975 976
		  show_root_type(__entry->root_objectid),
		  __entry->refs,
		  (unsigned long long)__entry->buf_start,
		  __entry->buf_level,
		  (unsigned long long)__entry->cow_start,
		  __entry->cow_level)
);

J
Josef Bacik 已提交
977 978
TRACE_EVENT(btrfs_space_reservation,

979
	TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
J
Josef Bacik 已提交
980 981 982 983
		 u64 bytes, int reserve),

	TP_ARGS(fs_info, type, val, bytes, reserve),

984
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
985 986 987 988 989 990
		__string(	type,	type			)
		__field(	u64,	val			)
		__field(	u64,	bytes			)
		__field(	int,	reserve			)
	),

991
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
992 993 994 995 996 997
		__assign_str(type, type);
		__entry->val		= val;
		__entry->bytes		= bytes;
		__entry->reserve	= reserve;
	),

998 999 1000
	TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
			__entry->reserve ? "reserve" : "release",
			__entry->bytes)
J
Josef Bacik 已提交
1001 1002
);

1003 1004 1005 1006 1007 1008 1009 1010
#define show_flush_action(action)						\
	__print_symbolic(action,						\
		{ BTRFS_RESERVE_NO_FLUSH,	"BTRFS_RESERVE_NO_FLUSH"},	\
		{ BTRFS_RESERVE_FLUSH_LIMIT,	"BTRFS_RESERVE_FLUSH_LIMIT"},	\
		{ BTRFS_RESERVE_FLUSH_ALL,	"BTRFS_RESERVE_FLUSH_ALL"})

TRACE_EVENT(btrfs_trigger_flush,

1011
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
1012 1013 1014 1015 1016
		 int flush, char *reason),

	TP_ARGS(fs_info, flags, bytes, flush, reason),

	TP_STRUCT__entry(
A
Anand Jain 已提交
1017
		__array(	u8,	fsid,	BTRFS_FSID_SIZE	)
1018 1019 1020 1021 1022 1023 1024
		__field(	u64,	flags			)
		__field(	u64,	bytes			)
		__field(	int,	flush			)
		__string(	reason,	reason			)
	),

	TP_fast_assign(
A
Anand Jain 已提交
1025
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
1026 1027 1028 1029 1030 1031
		__entry->flags	= flags;
		__entry->bytes	= bytes;
		__entry->flush	= flush;
		__assign_str(reason, reason)
	),

1032
	TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
		  __entry->fsid, __get_str(reason), __entry->flush,
		  show_flush_action(__entry->flush),
		  (unsigned long long)__entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS),
		  (unsigned long long)__entry->bytes)
);

#define show_flush_state(state)							\
	__print_symbolic(state,							\
		{ FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR"},	\
		{ FLUSH_DELAYED_ITEMS,		"FLUSH_DELAYED_ITEMS"},		\
		{ FLUSH_DELALLOC,		"FLUSH_DELALLOC"},		\
		{ FLUSH_DELALLOC_WAIT,		"FLUSH_DELALLOC_WAIT"},		\
		{ ALLOC_CHUNK,			"ALLOC_CHUNK"},			\
		{ COMMIT_TRANS,			"COMMIT_TRANS"})

TRACE_EVENT(btrfs_flush_space,

1052
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
1053
		 int state, int ret),
1054

1055
	TP_ARGS(fs_info, flags, num_bytes, state, ret),
1056 1057

	TP_STRUCT__entry(
A
Anand Jain 已提交
1058
		__array(	u8,	fsid,	BTRFS_FSID_SIZE	)
1059 1060 1061 1062 1063 1064 1065
		__field(	u64,	flags			)
		__field(	u64,	num_bytes		)
		__field(	int,	state			)
		__field(	int,	ret			)
	),

	TP_fast_assign(
A
Anand Jain 已提交
1066
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
1067 1068 1069 1070 1071 1072
		__entry->flags		=	flags;
		__entry->num_bytes	=	num_bytes;
		__entry->state		=	state;
		__entry->ret		=	ret;
	),

1073 1074
	TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
		  __entry->fsid, __entry->state,
1075 1076 1077 1078
		  show_flush_state(__entry->state),
		  (unsigned long long)__entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS),
1079
		  (unsigned long long)__entry->num_bytes, __entry->ret)
1080 1081
);

1082 1083
DECLARE_EVENT_CLASS(btrfs__reserved_extent,

1084
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1085

1086
	TP_ARGS(fs_info, start, len),
1087

1088 1089 1090
	TP_STRUCT__entry_btrfs(
		__field(	u64,  start			)
		__field(	u64,  len			)
1091 1092
	),

1093
	TP_fast_assign_btrfs(fs_info,
1094 1095 1096 1097
		__entry->start		= start;
		__entry->len		= len;
	),

1098
	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
1099
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1100 1101 1102 1103 1104 1105
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->len)
);

DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,

1106
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1107

1108
	TP_ARGS(fs_info, start, len)
1109 1110 1111 1112
);

DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,

1113
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1114

1115
	TP_ARGS(fs_info, start, len)
1116 1117
);

J
Josef Bacik 已提交
1118 1119
TRACE_EVENT(find_free_extent,

1120 1121
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
		 u64 empty_size, u64 data),
J
Josef Bacik 已提交
1122

1123
	TP_ARGS(fs_info, num_bytes, empty_size, data),
J
Josef Bacik 已提交
1124

1125
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1126 1127 1128 1129 1130
		__field(	u64,	num_bytes		)
		__field(	u64,	empty_size		)
		__field(	u64,	data			)
	),

1131
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
1132 1133 1134 1135 1136
		__entry->num_bytes	= num_bytes;
		__entry->empty_size	= empty_size;
		__entry->data		= data;
	),

1137
	TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
1138
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
J
Josef Bacik 已提交
1139 1140 1141 1142 1143 1144 1145
		  __entry->num_bytes, __entry->empty_size, __entry->data,
		  __print_flags((unsigned long)__entry->data, "|",
				 BTRFS_GROUP_FLAGS))
);

DECLARE_EVENT_CLASS(btrfs__reserve_extent,

1146 1147
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_block_group_cache *block_group, u64 start,
J
Josef Bacik 已提交
1148 1149
		 u64 len),

1150
	TP_ARGS(fs_info, block_group, start, len),
J
Josef Bacik 已提交
1151

1152
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1153 1154 1155 1156 1157 1158
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	len			)
	),

1159
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
1160 1161 1162 1163 1164 1165
		__entry->bg_objectid	= block_group->key.objectid;
		__entry->flags		= block_group->flags;
		__entry->start		= start;
		__entry->len		= len;
	),

1166 1167
	TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
		  "start=%Lu len=%Lu",
1168 1169
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
		  __entry->bg_objectid,
J
Josef Bacik 已提交
1170 1171 1172 1173 1174 1175 1176
		  __entry->flags, __print_flags((unsigned long)__entry->flags,
						"|", BTRFS_GROUP_FLAGS),
		  __entry->start, __entry->len)
);

DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,

1177 1178
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_block_group_cache *block_group, u64 start,
J
Josef Bacik 已提交
1179 1180
		 u64 len),

1181
	TP_ARGS(fs_info, block_group, start, len)
J
Josef Bacik 已提交
1182 1183 1184 1185
);

DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,

1186 1187
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_block_group_cache *block_group, u64 start,
J
Josef Bacik 已提交
1188 1189
		 u64 len),

1190
	TP_ARGS(fs_info, block_group, start, len)
J
Josef Bacik 已提交
1191 1192 1193 1194
);

TRACE_EVENT(btrfs_find_cluster,

1195
	TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
J
Josef Bacik 已提交
1196 1197 1198 1199
		 u64 bytes, u64 empty_size, u64 min_bytes),

	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),

1200
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1201 1202 1203 1204 1205 1206 1207 1208
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	bytes			)
		__field(	u64,	empty_size		)
		__field(	u64,	min_bytes		)
	),

1209
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1210 1211 1212 1213 1214 1215 1216 1217
		__entry->bg_objectid	= block_group->key.objectid;
		__entry->flags		= block_group->flags;
		__entry->start		= start;
		__entry->bytes		= bytes;
		__entry->empty_size	= empty_size;
		__entry->min_bytes	= min_bytes;
	),

1218 1219
	TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
		  "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
J
Josef Bacik 已提交
1220 1221 1222 1223 1224 1225 1226 1227
		  __entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS), __entry->start,
		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
);

TRACE_EVENT(btrfs_failed_cluster_setup,

1228
	TP_PROTO(const struct btrfs_block_group_cache *block_group),
J
Josef Bacik 已提交
1229 1230 1231

	TP_ARGS(block_group),

1232
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1233 1234 1235
		__field(	u64,	bg_objectid		)
	),

1236
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1237 1238 1239
		__entry->bg_objectid	= block_group->key.objectid;
	),

1240
	TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
J
Josef Bacik 已提交
1241 1242 1243 1244
);

TRACE_EVENT(btrfs_setup_cluster,

1245 1246 1247
	TP_PROTO(const struct btrfs_block_group_cache *block_group,
		 const struct btrfs_free_cluster *cluster,
		 u64 size, int bitmap),
J
Josef Bacik 已提交
1248 1249 1250

	TP_ARGS(block_group, cluster, size, bitmap),

1251
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1252 1253 1254 1255 1256 1257 1258 1259
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	max_size		)
		__field(	u64,	size			)
		__field(	int,	bitmap			)
	),

1260
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1261 1262 1263 1264 1265 1266 1267 1268
		__entry->bg_objectid	= block_group->key.objectid;
		__entry->flags		= block_group->flags;
		__entry->start		= cluster->window_start;
		__entry->max_size	= cluster->max_size;
		__entry->size		= size;
		__entry->bitmap		= bitmap;
	),

1269 1270
	TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
		  "size=%Lu max_size=%Lu bitmap=%d",
J
Josef Bacik 已提交
1271 1272 1273 1274 1275 1276 1277
		  __entry->bg_objectid,
		  __entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS), __entry->start,
		  __entry->size, __entry->max_size, __entry->bitmap)
);

1278 1279 1280
struct extent_state;
TRACE_EVENT(alloc_extent_state,

1281 1282
	TP_PROTO(const struct extent_state *state,
		 gfp_t mask, unsigned long IP),
1283 1284 1285 1286

	TP_ARGS(state, mask, IP),

	TP_STRUCT__entry(
1287
		__field(const struct extent_state *, state)
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
		__field(gfp_t, mask)
		__field(unsigned long, ip)
	),

	TP_fast_assign(
		__entry->state	= state,
		__entry->mask	= mask,
		__entry->ip	= IP
	),

1298
	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
1299
		  show_gfp_flags(__entry->mask), (const void *)__entry->ip)
1300 1301 1302 1303
);

TRACE_EVENT(free_extent_state,

1304
	TP_PROTO(const struct extent_state *state, unsigned long IP),
1305 1306 1307 1308

	TP_ARGS(state, IP),

	TP_STRUCT__entry(
1309
		__field(const struct extent_state *, state)
1310 1311 1312 1313 1314 1315 1316 1317
		__field(unsigned long, ip)
	),

	TP_fast_assign(
		__entry->state	= state,
		__entry->ip = IP
	),

1318
	TP_printk("state=%p caller=%pS", __entry->state,
1319
		  (const void *)__entry->ip)
1320 1321
);

1322 1323
DECLARE_EVENT_CLASS(btrfs__work,

1324
	TP_PROTO(const struct btrfs_work *work),
1325 1326 1327

	TP_ARGS(work),

1328
	TP_STRUCT__entry_btrfs(
1329 1330 1331 1332 1333 1334
		__field(	const void *,	work			)
		__field(	const void *,	wq			)
		__field(	const void *,	func			)
		__field(	const void *,	ordered_func		)
		__field(	const void *,	ordered_free		)
		__field(	const void *,	normal_work		)
1335 1336
	),

1337
	TP_fast_assign_btrfs(btrfs_work_owner(work),
1338 1339 1340 1341 1342
		__entry->work		= work;
		__entry->wq		= work->wq;
		__entry->func		= work->func;
		__entry->ordered_func	= work->ordered_func;
		__entry->ordered_free	= work->ordered_free;
1343
		__entry->normal_work	= &work->normal_work;
1344 1345
	),

1346 1347
	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
		  "ordered_free=%p",
1348 1349
		  __entry->work, __entry->normal_work, __entry->wq,
		   __entry->func, __entry->ordered_func, __entry->ordered_free)
1350 1351
);

1352 1353 1354 1355 1356
/*
 * For situiations when the work is freed, we pass fs_info and a tag that that
 * matches address of the work structure so it can be paired with the
 * scheduling event.
 */
1357 1358
DECLARE_EVENT_CLASS(btrfs__work__done,

1359
	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1360

1361
	TP_ARGS(fs_info, wtag),
1362

1363
	TP_STRUCT__entry_btrfs(
1364
		__field(	const void *,	wtag			)
1365 1366
	),

1367 1368
	TP_fast_assign_btrfs(fs_info,
		__entry->wtag		= wtag;
1369 1370
	),

1371
	TP_printk_btrfs("work->%p", __entry->wtag)
1372 1373 1374 1375
);

DEFINE_EVENT(btrfs__work, btrfs_work_queued,

1376
	TP_PROTO(const struct btrfs_work *work),
1377 1378 1379 1380 1381 1382

	TP_ARGS(work)
);

DEFINE_EVENT(btrfs__work, btrfs_work_sched,

1383
	TP_PROTO(const struct btrfs_work *work),
1384 1385 1386 1387 1388 1389

	TP_ARGS(work)
);

DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,

1390
	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1391

1392
	TP_ARGS(fs_info, wtag)
1393 1394 1395 1396
);

DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,

1397
	TP_PROTO(const struct btrfs_work *work),
1398 1399 1400 1401

	TP_ARGS(work)
);

1402 1403
DECLARE_EVENT_CLASS(btrfs__workqueue,

1404 1405
	TP_PROTO(const struct __btrfs_workqueue *wq,
		 const char *name, int high),
1406 1407 1408

	TP_ARGS(wq, name, high),

1409
	TP_STRUCT__entry_btrfs(
1410
		__field(	const void *,	wq			)
1411 1412 1413 1414
		__string(	name,	name			)
		__field(	int ,	high			)
	),

1415
	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1416 1417 1418 1419 1420
		__entry->wq		= wq;
		__assign_str(name, name);
		__entry->high		= high;
	),

1421
	TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1422 1423 1424 1425 1426 1427 1428
		  __print_flags(__entry->high, "",
				{(WQ_HIGHPRI),	"-high"}),
		  __entry->wq)
);

DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,

1429 1430
	TP_PROTO(const struct __btrfs_workqueue *wq,
		 const char *name, int high),
1431 1432 1433 1434 1435 1436

	TP_ARGS(wq, name, high)
);

DECLARE_EVENT_CLASS(btrfs__workqueue_done,

1437
	TP_PROTO(const struct __btrfs_workqueue *wq),
1438 1439 1440

	TP_ARGS(wq),

1441
	TP_STRUCT__entry_btrfs(
1442
		__field(	const void *,	wq		)
1443 1444
	),

1445
	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1446 1447 1448
		__entry->wq		= wq;
	),

1449
	TP_printk_btrfs("wq=%p", __entry->wq)
1450 1451 1452 1453
);

DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,

1454
	TP_PROTO(const struct __btrfs_workqueue *wq),
1455 1456 1457

	TP_ARGS(wq)
);
1458

1459 1460 1461 1462 1463 1464 1465
#define BTRFS_QGROUP_OPERATIONS				\
	{ QGROUP_RESERVE,	"reserve"	},	\
	{ QGROUP_RELEASE,	"release"	},	\
	{ QGROUP_FREE,		"free"		}

DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,

1466 1467
	TP_PROTO(const struct inode *inode, u64 start, u64 len,
		 u64 reserved, int op),
1468 1469 1470

	TP_ARGS(inode, start, len, reserved, op),

1471
	TP_STRUCT__entry_btrfs(
1472 1473 1474 1475 1476 1477 1478 1479
		__field(	u64,		rootid		)
		__field(	unsigned long,	ino		)
		__field(	u64,		start		)
		__field(	u64,		len		)
		__field(	u64,		reserved	)
		__field(	int,		op		)
	),

1480
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
1481 1482 1483 1484 1485 1486 1487 1488
		__entry->rootid		= BTRFS_I(inode)->root->objectid;
		__entry->ino		= inode->i_ino;
		__entry->start		= start;
		__entry->len		= len;
		__entry->reserved	= reserved;
		__entry->op		= op;
	),

1489
	TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
1490 1491 1492 1493 1494 1495 1496 1497 1498
		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
		  __entry->reserved,
		  __print_flags((unsigned long)__entry->op, "",
				BTRFS_QGROUP_OPERATIONS)
	)
);

DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,

1499 1500
	TP_PROTO(const struct inode *inode, u64 start, u64 len,
		 u64 reserved, int op),
1501 1502 1503 1504 1505 1506

	TP_ARGS(inode, start, len, reserved, op)
);

DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,

1507 1508
	TP_PROTO(const struct inode *inode, u64 start, u64 len,
		 u64 reserved, int op),
1509 1510 1511 1512 1513 1514

	TP_ARGS(inode, start, len, reserved, op)
);

DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,

1515 1516
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 u64 ref_root, u64 reserved),
1517

1518
	TP_ARGS(fs_info, ref_root, reserved),
1519

1520
	TP_STRUCT__entry_btrfs(
1521 1522 1523 1524
		__field(	u64,		ref_root	)
		__field(	u64,		reserved	)
	),

1525
	TP_fast_assign_btrfs(fs_info,
1526 1527 1528 1529
		__entry->ref_root	= ref_root;
		__entry->reserved	= reserved;
	),

1530
	TP_printk_btrfs("root=%llu reserved=%llu op=free",
1531 1532 1533 1534 1535
		  __entry->ref_root, __entry->reserved)
);

DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,

1536 1537
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 u64 ref_root, u64 reserved),
1538

1539
	TP_ARGS(fs_info, ref_root, reserved)
1540
);
M
Mark Fasheh 已提交
1541 1542

DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1543 1544
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1545

1546
	TP_ARGS(fs_info, rec),
M
Mark Fasheh 已提交
1547

1548
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1549 1550 1551 1552
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
	),

1553
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1554 1555 1556 1557
		__entry->bytenr		= rec->bytenr,
		__entry->num_bytes	= rec->num_bytes;
	),

1558
	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
M
Mark Fasheh 已提交
1559 1560 1561 1562 1563 1564
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes)
);

DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,

1565 1566
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1567

1568
	TP_ARGS(fs_info, rec)
M
Mark Fasheh 已提交
1569 1570
);

1571
DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
M
Mark Fasheh 已提交
1572

1573 1574
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1575

1576
	TP_ARGS(fs_info, rec)
M
Mark Fasheh 已提交
1577 1578 1579 1580
);

TRACE_EVENT(btrfs_qgroup_account_extent,

1581
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
1582
		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
M
Mark Fasheh 已提交
1583

1584
	TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
M
Mark Fasheh 已提交
1585

1586
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1587 1588 1589 1590 1591 1592
		__field(	u64,  bytenr			)
		__field(	u64,  num_bytes			)
		__field(	u64,  nr_old_roots		)
		__field(	u64,  nr_new_roots		)
	),

1593
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1594 1595 1596 1597 1598 1599
		__entry->bytenr		= bytenr;
		__entry->num_bytes	= num_bytes;
		__entry->nr_old_roots	= nr_old_roots;
		__entry->nr_new_roots	= nr_new_roots;
	),

1600 1601
	TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
		  "nr_new_roots=%llu",
M
Mark Fasheh 已提交
1602 1603 1604 1605 1606 1607 1608 1609
		  __entry->bytenr,
		  __entry->num_bytes,
		  __entry->nr_old_roots,
		  __entry->nr_new_roots)
);

TRACE_EVENT(qgroup_update_counters,

1610
	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
1611
		 u64 cur_old_count, u64 cur_new_count),
M
Mark Fasheh 已提交
1612

1613
	TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
M
Mark Fasheh 已提交
1614

1615
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1616 1617 1618 1619 1620
		__field(	u64,  qgid			)
		__field(	u64,  cur_old_count		)
		__field(	u64,  cur_new_count		)
	),

1621
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1622 1623 1624 1625 1626
		__entry->qgid		= qgid;
		__entry->cur_old_count	= cur_old_count;
		__entry->cur_new_count	= cur_new_count;
	),

1627
	TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
M
Mark Fasheh 已提交
1628 1629 1630 1631 1632
		  __entry->qgid,
		  __entry->cur_old_count,
		  __entry->cur_new_count)
);

1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
TRACE_EVENT(qgroup_update_reserve,

	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
		 s64 diff),

	TP_ARGS(fs_info, qgroup, diff),

	TP_STRUCT__entry_btrfs(
		__field(	u64,	qgid			)
		__field(	u64,	cur_reserved		)
		__field(	s64,	diff			)
	),

	TP_fast_assign_btrfs(fs_info,
		__entry->qgid		= qgroup->qgroupid;
		__entry->cur_reserved	= qgroup->reserved;
		__entry->diff		= diff;
	),

	TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld",
		__entry->qgid, __entry->cur_reserved, __entry->diff)
);

TRACE_EVENT(qgroup_meta_reserve,

	TP_PROTO(struct btrfs_root *root, s64 diff),

	TP_ARGS(root, diff),

	TP_STRUCT__entry_btrfs(
		__field(	u64,	refroot			)
		__field(	s64,	diff			)
	),

	TP_fast_assign_btrfs(root->fs_info,
		__entry->refroot	= root->objectid;
		__entry->diff		= diff;
	),

	TP_printk_btrfs("refroot=%llu(%s) diff=%lld",
		show_root_type(__entry->refroot), __entry->diff)
);

1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732
DECLARE_EVENT_CLASS(btrfs__prelim_ref,
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct prelim_ref *oldref,
		 const struct prelim_ref *newref, u64 tree_size),
	TP_ARGS(fs_info, newref, oldref, tree_size),

	TP_STRUCT__entry_btrfs(
		__field(	u64,  root_id		)
		__field(	u64,  objectid		)
		__field(	 u8,  type		)
		__field(	u64,  offset		)
		__field(	int,  level		)
		__field(	int,  old_count		)
		__field(	u64,  parent		)
		__field(	u64,  bytenr		)
		__field(	int,  mod_count		)
		__field(	u64,  tree_size		)
	),

	TP_fast_assign_btrfs(fs_info,
		__entry->root_id	= oldref->root_id;
		__entry->objectid	= oldref->key_for_search.objectid;
		__entry->type		= oldref->key_for_search.type;
		__entry->offset		= oldref->key_for_search.offset;
		__entry->level		= oldref->level;
		__entry->old_count	= oldref->count;
		__entry->parent		= oldref->parent;
		__entry->bytenr		= oldref->wanted_disk_byte;
		__entry->mod_count	= newref ? newref->count : 0;
		__entry->tree_size	= tree_size;
	),

	TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
			(unsigned long long)__entry->root_id,
			(unsigned long long)__entry->objectid, __entry->type,
			(unsigned long long)__entry->offset, __entry->level,
			__entry->old_count, __entry->mod_count,
			__entry->old_count + __entry->mod_count,
			(unsigned long long)__entry->parent,
			(unsigned long long)__entry->bytenr,
			(unsigned long long)__entry->tree_size)
);

DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct prelim_ref *oldref,
		 const struct prelim_ref *newref, u64 tree_size),
	TP_ARGS(fs_info, oldref, newref, tree_size)
);

DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
	TP_PROTO(const struct btrfs_fs_info *fs_info,
		 const struct prelim_ref *oldref,
		 const struct prelim_ref *newref, u64 tree_size),
	TP_ARGS(fs_info, oldref, newref, tree_size)
);

1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753
TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
	TP_PROTO(struct btrfs_root *root, u64 ino, int mod),

	TP_ARGS(root, ino, mod),

	TP_STRUCT__entry_btrfs(
		__field(	u64, root_objectid	)
		__field(	u64, ino		)
		__field(	int, mod		)
	),

	TP_fast_assign_btrfs(root->fs_info,
		__entry->root_objectid	= root->objectid;
		__entry->ino		= ino;
		__entry->mod		= mod;
	),

	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
			show_root_type(__entry->root_objectid),
			(unsigned long long)__entry->ino, __entry->mod)
);
1754 1755 1756 1757
#endif /* _TRACE_BTRFS_H */

/* This part must be outside protection */
#include <trace/define_trace.h>