btrfs.h 39.1 KB
Newer Older
1 2 3 4 5 6 7 8
#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>
9
#include <trace/events/mmflags.h>
10 11 12 13 14 15 16 17 18 19

struct btrfs_root;
struct btrfs_fs_info;
struct btrfs_inode;
struct extent_map;
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 已提交
20 21
struct btrfs_block_group_cache;
struct btrfs_free_cluster;
22 23
struct map_lookup;
struct extent_buffer;
24
struct btrfs_work;
25
struct __btrfs_workqueue;
M
Mark Fasheh 已提交
26
struct btrfs_qgroup_extent_record;
27 28 29 30 31 32 33 34 35 36

#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)						\
37
	__print_symbolic_u64(obj,					\
38 39 40 41 42 43 44 45
		{ 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 已提交
46
		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
47
		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
48 49
		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
50 51 52 53
		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })

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

J
Josef Bacik 已提交
57
#define BTRFS_GROUP_FLAGS	\
L
Liu Bo 已提交
58 59 60 61 62 63 64 65 66
	{ 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 已提交
67

J
Josef Bacik 已提交
68
#define BTRFS_UUID_SIZE 16
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE)

#define TP_fast_assign_fsid(fs_info)					\
	memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE)

#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 已提交
84

85 86 87 88 89 90
TRACE_EVENT(btrfs_transaction_commit,

	TP_PROTO(struct btrfs_root *root),

	TP_ARGS(root),

91
	TP_STRUCT__entry_btrfs(
92 93 94 95
		__field(	u64,  generation		)
		__field(	u64,  root_objectid		)
	),

96
	TP_fast_assign_btrfs(root->fs_info,
97 98 99 100
		__entry->generation	= root->fs_info->generation;
		__entry->root_objectid	= root->root_key.objectid;
	),

101
	TP_printk_btrfs("root = %llu(%s), gen = %llu",
102 103 104 105 106 107 108 109 110 111
		  show_root_type(__entry->root_objectid),
		  (unsigned long long)__entry->generation)
);

DECLARE_EVENT_CLASS(btrfs__inode,

	TP_PROTO(struct inode *inode),

	TP_ARGS(inode),

112
	TP_STRUCT__entry_btrfs(
113 114 115 116 117 118 119 120 121
		__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		)
	),

122
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
123 124 125 126 127 128 129 130 131 132
		__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;
	),

133
	TP_printk_btrfs("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
		  "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
		  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,

	TP_PROTO(struct inode *inode),

	TP_ARGS(inode)
);

DEFINE_EVENT(btrfs__inode, btrfs_inode_request,

	TP_PROTO(struct inode *inode),

	TP_ARGS(inode)
);

DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,

	TP_PROTO(struct inode *inode),

	TP_ARGS(inode)
);

#define __show_map_type(type)						\
166
	__print_symbolic_u64(type,					\
167 168 169 170 171 172 173 174 175 176
		{ 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, "|",					\
177 178 179 180 181 182 183
		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
		{ (1 << EXTENT_FLAG_VACANCY), 		"VACANCY" 	},\
		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
184

185
TRACE_EVENT_CONDITION(btrfs_get_extent,
186

187 188
	TP_PROTO(struct btrfs_root *root, struct inode *inode,
		 struct extent_map *map),
189

190
	TP_ARGS(root, inode, map),
191

192 193
	TP_CONDITION(map),

194
	TP_STRUCT__entry_btrfs(
195
		__field(	u64,  root_objectid	)
196
		__field(	u64,  ino		)
197 198 199 200 201 202 203 204 205 206
		__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	)
	),

207
	TP_fast_assign_btrfs(root->fs_info,
208
		__entry->root_objectid	= root->root_key.objectid;
209 210
		__entry->ino		= btrfs_ino(inode);
		__entry->start		= map->start;
211 212 213 214 215 216 217 218 219
		__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;
		__entry->refs		= atomic_read(&map->refs);
		__entry->compress_type	= map->compress_type;
	),

220
	TP_printk_btrfs("root = %llu(%s), ino = %llu start = %llu, len = %llu, "
221 222 223 224
		  "orig_start = %llu, block_start = %llu(%s), "
		  "block_len = %llu, flags = %s, refs = %u, "
		  "compress_type = %u",
		  show_root_type(__entry->root_objectid),
225
		  (unsigned long long)__entry->ino,
226 227 228 229 230 231 232 233 234
		  (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)
);

235 236 237 238 239 240 241 242 243 244
#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"	}, \
245 246
		{ (1 << BTRFS_ORDERED_LOGGED_CSUM), 	"LOGGED_CSUM"	}, \
		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
L
Liu Bo 已提交
247

248 249 250 251 252 253 254

DECLARE_EVENT_CLASS(btrfs__ordered_extent,

	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),

	TP_ARGS(inode, ordered),

255
	TP_STRUCT__entry_btrfs(
256 257 258 259 260 261 262 263 264 265
		__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	)
266
		__field(	u64,  truncated_len	)
267 268
	),

269
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
270 271 272 273 274 275 276 277 278 279 280
		__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;
		__entry->refs		= atomic_read(&ordered->refs);
		__entry->root_objectid	=
				BTRFS_I(inode)->root->root_key.objectid;
281
		__entry->truncated_len	= ordered->truncated_len;
282 283
	),

284
	TP_printk_btrfs("root = %llu(%s), ino = %llu, file_offset = %llu, "
285
		  "start = %llu, len = %llu, disk_len = %llu, "
286
		  "truncated_len = %llu, "
287 288 289 290 291 292 293 294
		  "bytes_left = %llu, flags = %s, compress_type = %d, "
		  "refs = %d",
		  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,
295
		  (unsigned long long)__entry->truncated_len,
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
		  (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,

	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,

	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,

	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),

	TP_ARGS(inode, ordered)
);

DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,

	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),

	TP_ARGS(inode, ordered)
);

DECLARE_EVENT_CLASS(btrfs__writepage,

	TP_PROTO(struct page *page, struct inode *inode,
		 struct writeback_control *wbc),

	TP_ARGS(page, inode, wbc),

336
	TP_STRUCT__entry_btrfs(
337 338 339 340 341 342 343 344 345 346 347 348 349
		__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		)
	),

350
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
351 352 353 354 355 356 357 358 359 360 361 362 363 364
		__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;
	),

365
	TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, "
366
		  "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
367
		  "range_end = %llu, for_kupdate = %d, "
368 369 370 371 372
		  "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
		  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,
373
		  __entry->for_kupdate,
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
		  __entry->for_reclaim, __entry->range_cyclic,
		  (unsigned long)__entry->writeback_index)
);

DEFINE_EVENT(btrfs__writepage, __extent_writepage,

	TP_PROTO(struct page *page, struct inode *inode,
		 struct writeback_control *wbc),

	TP_ARGS(page, inode, wbc)
);

TRACE_EVENT(btrfs_writepage_end_io_hook,

	TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),

	TP_ARGS(page, start, end, uptodate),

392
	TP_STRUCT__entry_btrfs(
393 394 395 396 397 398 399 400
		__field(	ino_t,	 ino		)
		__field(	pgoff_t, index		)
		__field(	u64,	 start		)
		__field(	u64,	 end		)
		__field(	int,	 uptodate	)
		__field(	u64,    root_objectid	)
	),

401
	TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
402 403 404 405 406 407 408 409 410
		__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;
	),

411
	TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
412 413 414 415 416 417 418 419 420 421 422 423 424
		  "end = %llu, uptodate = %d",
		  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,

	TP_PROTO(struct file *file, int datasync),

	TP_ARGS(file, datasync),

425
	TP_STRUCT__entry_btrfs(
426 427 428 429 430 431 432 433
		__field(	ino_t,  ino		)
		__field(	ino_t,  parent		)
		__field(	int,    datasync	)
		__field(	u64,    root_objectid	)
	),

	TP_fast_assign(
		struct dentry *dentry = file->f_path.dentry;
434
		struct inode *inode = d_inode(dentry);
435

436
		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
437
		__entry->ino		= inode->i_ino;
438
		__entry->parent		= d_inode(dentry->d_parent)->i_ino;
439 440 441 442 443
		__entry->datasync	= datasync;
		__entry->root_objectid	=
				 BTRFS_I(inode)->root->root_key.objectid;
	),

444
	TP_printk_btrfs("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
445 446 447 448 449 450 451
		  show_root_type(__entry->root_objectid),
		  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
		  __entry->datasync)
);

TRACE_EVENT(btrfs_sync_fs,

452
	TP_PROTO(struct btrfs_fs_info *fs_info, int wait),
453

454
	TP_ARGS(fs_info, wait),
455

456
	TP_STRUCT__entry_btrfs(
457 458 459
		__field(	int,  wait		)
	),

460
	TP_fast_assign_btrfs(fs_info,
461 462 463
		__entry->wait	= wait;
	),

464
	TP_printk_btrfs("wait = %d", __entry->wait)
465 466
);

467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
TRACE_EVENT(btrfs_add_block_group,

	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_block_group_cache *block_group, int create),

	TP_ARGS(fs_info, block_group, create),

	TP_STRUCT__entry(
		__array(	u8,	fsid,	BTRFS_UUID_SIZE	)
		__field(	u64,	offset			)
		__field(	u64,	size			)
		__field(	u64,	flags			)
		__field(	u64,	bytes_used		)
		__field(	u64,	bytes_super		)
		__field(	int,	create			)
	),

	TP_fast_assign(
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
		__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;
	),

	TP_printk("%pU: block_group offset = %llu, size = %llu, "
		  "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, "
		  "create = %d", __entry->fsid,
		  (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)
);

507 508 509 510 511 512 513 514
#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" })
			

515
DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
516

517 518
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
519 520 521
		 struct btrfs_delayed_tree_ref *full_ref,
		 int action),

522
	TP_ARGS(fs_info, ref, full_ref, action),
523

524
	TP_STRUCT__entry_btrfs(
525 526 527 528 529 530 531
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
		__field(	int,  action		) 
		__field(	u64,  parent		)
		__field(	u64,  ref_root		)
		__field(	int,  level		)
		__field(	int,  type		)
532
		__field(	u64,  seq		)
533 534
	),

535
	TP_fast_assign_btrfs(fs_info,
536 537 538 539 540 541 542
		__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;
543
		__entry->seq		= ref->seq;
544 545
	),

546
	TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
547
		  "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
548
		  "type = %s, seq = %llu",
549 550 551 552 553
		  (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),
554 555
		  __entry->level, show_ref_type(__entry->type),
		  (unsigned long long)__entry->seq)
556 557
);

558 559
DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,

560 561
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
562 563 564
		 struct btrfs_delayed_tree_ref *full_ref,
		 int action),

565
	TP_ARGS(fs_info, ref, full_ref, action)
566 567 568 569
);

DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,

570 571
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
572 573 574
		 struct btrfs_delayed_tree_ref *full_ref,
		 int action),

575
	TP_ARGS(fs_info, ref, full_ref, action)
576 577 578
);

DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
579

580 581
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
582 583 584
		 struct btrfs_delayed_data_ref *full_ref,
		 int action),

585
	TP_ARGS(fs_info, ref, full_ref, action),
586

587
	TP_STRUCT__entry_btrfs(
588 589 590 591 592 593 594 595
		__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		)
596
		__field(	u64,  seq		)
597 598
	),

599
	TP_fast_assign_btrfs(fs_info,
600 601 602 603 604 605 606 607
		__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;
608
		__entry->seq		= ref->seq;
609 610
	),

611
	TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
612
		  "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
613
		  "offset = %llu, type = %s, seq = %llu",
614 615 616 617 618 619 620
		  (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,
621 622
		  show_ref_type(__entry->type),
		  (unsigned long long)__entry->seq)
623 624
);

625 626
DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,

627 628
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
629 630 631
		 struct btrfs_delayed_data_ref *full_ref,
		 int action),

632
	TP_ARGS(fs_info, ref, full_ref, action)
633 634 635 636
);

DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,

637 638
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
639 640 641
		 struct btrfs_delayed_data_ref *full_ref,
		 int action),

642
	TP_ARGS(fs_info, ref, full_ref, action)
643 644 645
);

DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
646

647 648
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
649 650 651
		 struct btrfs_delayed_ref_head *head_ref,
		 int action),

652
	TP_ARGS(fs_info, ref, head_ref, action),
653

654
	TP_STRUCT__entry_btrfs(
655 656 657 658 659 660
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
		__field(	int,  action		) 
		__field(	int,  is_data		)
	),

661
	TP_fast_assign_btrfs(fs_info,
662 663 664 665 666 667
		__entry->bytenr		= ref->bytenr;
		__entry->num_bytes	= ref->num_bytes;
		__entry->action		= action;
		__entry->is_data	= head_ref->is_data;
	),

668
	TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
669 670 671 672 673 674
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes,
		  show_ref_action(__entry->action),
		  __entry->is_data)
);

675 676
DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,

677 678
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
679 680 681
		 struct btrfs_delayed_ref_head *head_ref,
		 int action),

682
	TP_ARGS(fs_info, ref, head_ref, action)
683 684 685 686
);

DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,

687 688
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_delayed_ref_node *ref,
689 690 691
		 struct btrfs_delayed_ref_head *head_ref,
		 int action),

692
	TP_ARGS(fs_info, ref, head_ref, action)
693 694
);

695 696 697 698 699 700 701 702
#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 已提交
703 704 705
		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
706 707 708

DECLARE_EVENT_CLASS(btrfs__chunk,

709
	TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
710 711
		 u64 offset, u64 size),

712
	TP_ARGS(fs_info, map, offset, size),
713

714
	TP_STRUCT__entry_btrfs(
715 716 717 718 719 720 721 722
		__field(	int,  num_stripes		)
		__field(	u64,  type			)
		__field(	int,  sub_stripes		)
		__field(	u64,  offset			)
		__field(	u64,  size			)
		__field(	u64,  root_objectid		)
	),

723
	TP_fast_assign_btrfs(fs_info,
724 725 726 727 728
		__entry->num_stripes	= map->num_stripes;
		__entry->type		= map->type;
		__entry->sub_stripes	= map->sub_stripes;
		__entry->offset		= offset;
		__entry->size		= size;
729
		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
730 731
	),

732
	TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, "
733 734 735 736 737 738 739 740 741 742
		  "num_stripes = %d, sub_stripes = %d, type = %s",
		  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,

743
	TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
744 745
		 u64 offset, u64 size),

746
	TP_ARGS(fs_info, map, offset, size)
747 748 749 750
);

DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,

751
	TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
752 753
		 u64 offset, u64 size),

754
	TP_ARGS(fs_info, map, offset, size)
755 756 757 758 759 760 761 762 763
);

TRACE_EVENT(btrfs_cow_block,

	TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
		 struct extent_buffer *cow),

	TP_ARGS(root, buf, cow),

764
	TP_STRUCT__entry_btrfs(
765 766 767 768 769 770 771 772
		__field(	u64,  root_objectid		)
		__field(	u64,  buf_start			)
		__field(	int,  refs			)
		__field(	u64,  cow_start			)
		__field(	int,  buf_level			)
		__field(	int,  cow_level			)
	),

773
	TP_fast_assign_btrfs(root->fs_info,
774 775 776 777 778 779 780 781
		__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);
	),

782
	TP_printk_btrfs("root = %llu(%s), refs = %d, orig_buf = %llu "
783 784 785 786 787 788 789 790 791
		  "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
		  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 已提交
792 793 794 795 796 797 798
TRACE_EVENT(btrfs_space_reservation,

	TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
		 u64 bytes, int reserve),

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

799
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
800 801 802 803 804 805
		__string(	type,	type			)
		__field(	u64,	val			)
		__field(	u64,	bytes			)
		__field(	int,	reserve			)
	),

806
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
807 808 809 810 811 812
		__assign_str(type, type);
		__entry->val		= val;
		__entry->bytes		= bytes;
		__entry->reserve	= reserve;
	),

813 814 815
	TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
			__entry->reserve ? "reserve" : "release",
			__entry->bytes)
J
Josef Bacik 已提交
816 817
);

818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
#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,

	TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
		 int flush, char *reason),

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

	TP_STRUCT__entry(
		__array(	u8,	fsid,	BTRFS_UUID_SIZE	)
		__field(	u64,	flags			)
		__field(	u64,	bytes			)
		__field(	int,	flush			)
		__string(	reason,	reason			)
	),

	TP_fast_assign(
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
		__entry->flags	= flags;
		__entry->bytes	= bytes;
		__entry->flush	= flush;
		__assign_str(reason, reason)
	),

	TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu",
		  __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,

	TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
		 u64 orig_bytes, int state, int ret),

	TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),

	TP_STRUCT__entry(
		__array(	u8,	fsid,	BTRFS_UUID_SIZE	)
		__field(	u64,	flags			)
		__field(	u64,	num_bytes		)
		__field(	u64,	orig_bytes		)
		__field(	int,	state			)
		__field(	int,	ret			)
	),

	TP_fast_assign(
		memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
		__entry->flags		=	flags;
		__entry->num_bytes	=	num_bytes;
		__entry->orig_bytes	=	orig_bytes;
		__entry->state		=	state;
		__entry->ret		=	ret;
	),

	TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, "
		  "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state,
		  show_flush_state(__entry->state),
		  (unsigned long long)__entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS),
		  (unsigned long long)__entry->num_bytes,
		  (unsigned long long)__entry->orig_bytes, __entry->ret)
);

900 901
DECLARE_EVENT_CLASS(btrfs__reserved_extent,

902
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
903

904
	TP_ARGS(fs_info, start, len),
905

906 907 908
	TP_STRUCT__entry_btrfs(
		__field(	u64,  start			)
		__field(	u64,  len			)
909 910
	),

911
	TP_fast_assign_btrfs(fs_info,
912 913 914 915
		__entry->start		= start;
		__entry->len		= len;
	),

916
	TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu",
917
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
918 919 920 921 922 923
		  (unsigned long long)__entry->start,
		  (unsigned long long)__entry->len)
);

DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,

924
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
925

926
	TP_ARGS(fs_info, start, len)
927 928 929 930
);

DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,

931
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
932

933
	TP_ARGS(fs_info, start, len)
934 935
);

J
Josef Bacik 已提交
936 937
TRACE_EVENT(find_free_extent,

938
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size,
J
Josef Bacik 已提交
939 940
		 u64 data),

941
	TP_ARGS(fs_info, num_bytes, empty_size, data),
J
Josef Bacik 已提交
942

943
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
944 945 946 947 948
		__field(	u64,	num_bytes		)
		__field(	u64,	empty_size		)
		__field(	u64,	data			)
	),

949
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
950 951 952 953 954
		__entry->num_bytes	= num_bytes;
		__entry->empty_size	= empty_size;
		__entry->data		= data;
	),

955 956
	TP_printk_btrfs("root = %Lu(%s), len = %Lu, empty_size = %Lu, flags = %Lu(%s)",
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
J
Josef Bacik 已提交
957 958 959 960 961 962 963
		  __entry->num_bytes, __entry->empty_size, __entry->data,
		  __print_flags((unsigned long)__entry->data, "|",
				 BTRFS_GROUP_FLAGS))
);

DECLARE_EVENT_CLASS(btrfs__reserve_extent,

964
	TP_PROTO(struct btrfs_fs_info *fs_info,
J
Josef Bacik 已提交
965 966 967
		 struct btrfs_block_group_cache *block_group, u64 start,
		 u64 len),

968
	TP_ARGS(fs_info, block_group, start, len),
J
Josef Bacik 已提交
969

970
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
971 972 973 974 975 976
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	len			)
	),

977
	TP_fast_assign_btrfs(fs_info,
J
Josef Bacik 已提交
978 979 980 981 982 983
		__entry->bg_objectid	= block_group->key.objectid;
		__entry->flags		= block_group->flags;
		__entry->start		= start;
		__entry->len		= len;
	),

984 985
	TP_printk_btrfs("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
		  "start = %Lu, len = %Lu",
986 987
		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
		  __entry->bg_objectid,
J
Josef Bacik 已提交
988 989 990 991 992 993 994
		  __entry->flags, __print_flags((unsigned long)__entry->flags,
						"|", BTRFS_GROUP_FLAGS),
		  __entry->start, __entry->len)
);

DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,

995
	TP_PROTO(struct btrfs_fs_info *fs_info,
J
Josef Bacik 已提交
996 997 998
		 struct btrfs_block_group_cache *block_group, u64 start,
		 u64 len),

999
	TP_ARGS(fs_info, block_group, start, len)
J
Josef Bacik 已提交
1000 1001 1002 1003
);

DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,

1004
	TP_PROTO(struct btrfs_fs_info *fs_info,
J
Josef Bacik 已提交
1005 1006 1007
		 struct btrfs_block_group_cache *block_group, u64 start,
		 u64 len),

1008
	TP_ARGS(fs_info, block_group, start, len)
J
Josef Bacik 已提交
1009 1010 1011 1012 1013 1014 1015 1016 1017
);

TRACE_EVENT(btrfs_find_cluster,

	TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
		 u64 bytes, u64 empty_size, u64 min_bytes),

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

1018
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1019 1020 1021 1022 1023 1024 1025 1026
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	bytes			)
		__field(	u64,	empty_size		)
		__field(	u64,	min_bytes		)
	),

1027
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1028 1029 1030 1031 1032 1033 1034 1035
		__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;
	),

1036
	TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
J
Josef Bacik 已提交
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
		  " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
		  __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,

	TP_PROTO(struct btrfs_block_group_cache *block_group),

	TP_ARGS(block_group),

1050
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1051 1052 1053
		__field(	u64,	bg_objectid		)
	),

1054
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1055 1056 1057
		__entry->bg_objectid	= block_group->key.objectid;
	),

1058
	TP_printk_btrfs("block_group = %Lu", __entry->bg_objectid)
J
Josef Bacik 已提交
1059 1060 1061 1062 1063 1064 1065 1066 1067
);

TRACE_EVENT(btrfs_setup_cluster,

	TP_PROTO(struct btrfs_block_group_cache *block_group,
		 struct btrfs_free_cluster *cluster, u64 size, int bitmap),

	TP_ARGS(block_group, cluster, size, bitmap),

1068
	TP_STRUCT__entry_btrfs(
J
Josef Bacik 已提交
1069 1070 1071 1072 1073 1074 1075 1076
		__field(	u64,	bg_objectid		)
		__field(	u64,	flags			)
		__field(	u64,	start			)
		__field(	u64,	max_size		)
		__field(	u64,	size			)
		__field(	int,	bitmap			)
	),

1077
	TP_fast_assign_btrfs(block_group->fs_info,
J
Josef Bacik 已提交
1078 1079 1080 1081 1082 1083 1084 1085
		__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;
	),

1086
	TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
J
Josef Bacik 已提交
1087 1088 1089 1090 1091 1092 1093 1094
		  "size = %Lu, max_size = %Lu, bitmap = %d",
		  __entry->bg_objectid,
		  __entry->flags,
		  __print_flags((unsigned long)__entry->flags, "|",
				BTRFS_GROUP_FLAGS), __entry->start,
		  __entry->size, __entry->max_size, __entry->bitmap)
);

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
struct extent_state;
TRACE_EVENT(alloc_extent_state,

	TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),

	TP_ARGS(state, mask, IP),

	TP_STRUCT__entry(
		__field(struct extent_state *, state)
		__field(gfp_t, mask)
		__field(unsigned long, ip)
	),

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

1114
	TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
		  show_gfp_flags(__entry->mask), (void *)__entry->ip)
);

TRACE_EVENT(free_extent_state,

	TP_PROTO(struct extent_state *state, unsigned long IP),

	TP_ARGS(state, IP),

	TP_STRUCT__entry(
		__field(struct extent_state *, state)
		__field(unsigned long, ip)
	),

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

1134
	TP_printk(" state=%p; caller = %pS", __entry->state,
1135 1136 1137
		  (void *)__entry->ip)
);

1138 1139 1140 1141 1142 1143
DECLARE_EVENT_CLASS(btrfs__work,

	TP_PROTO(struct btrfs_work *work),

	TP_ARGS(work),

1144
	TP_STRUCT__entry_btrfs(
1145 1146 1147 1148 1149
		__field(	void *,	work			)
		__field(	void *, wq			)
		__field(	void *,	func			)
		__field(	void *,	ordered_func		)
		__field(	void *,	ordered_free		)
1150
		__field(	void *,	normal_work		)
1151 1152
	),

1153
	TP_fast_assign_btrfs(btrfs_work_owner(work),
1154 1155 1156 1157 1158
		__entry->work		= work;
		__entry->wq		= work->wq;
		__entry->func		= work->func;
		__entry->ordered_func	= work->ordered_func;
		__entry->ordered_free	= work->ordered_free;
1159
		__entry->normal_work	= &work->normal_work;
1160 1161
	),

1162
	TP_printk_btrfs("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
1163 1164 1165
		  " ordered_free=%p",
		  __entry->work, __entry->normal_work, __entry->wq,
		   __entry->func, __entry->ordered_func, __entry->ordered_free)
1166 1167
);

1168 1169 1170 1171 1172
/*
 * 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.
 */
1173 1174
DECLARE_EVENT_CLASS(btrfs__work__done,

1175
	TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1176

1177
	TP_ARGS(fs_info, wtag),
1178

1179
	TP_STRUCT__entry_btrfs(
1180
		__field(	void *,	wtag			)
1181 1182
	),

1183 1184
	TP_fast_assign_btrfs(fs_info,
		__entry->wtag		= wtag;
1185 1186
	),

1187
	TP_printk_btrfs("work->%p", __entry->wtag)
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205
);

DEFINE_EVENT(btrfs__work, btrfs_work_queued,

	TP_PROTO(struct btrfs_work *work),

	TP_ARGS(work)
);

DEFINE_EVENT(btrfs__work, btrfs_work_sched,

	TP_PROTO(struct btrfs_work *work),

	TP_ARGS(work)
);

DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,

1206
	TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1207

1208
	TP_ARGS(fs_info, wtag)
1209 1210 1211 1212 1213 1214 1215 1216 1217
);

DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,

	TP_PROTO(struct btrfs_work *work),

	TP_ARGS(work)
);

1218 1219 1220 1221 1222 1223
DECLARE_EVENT_CLASS(btrfs__workqueue,

	TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),

	TP_ARGS(wq, name, high),

1224
	TP_STRUCT__entry_btrfs(
1225 1226 1227 1228 1229
		__field(	void *,	wq			)
		__string(	name,	name			)
		__field(	int ,	high			)
	),

1230
	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1231 1232 1233 1234 1235
		__entry->wq		= wq;
		__assign_str(name, name);
		__entry->high		= high;
	),

1236
	TP_printk_btrfs("name=%s%s, wq=%p", __get_str(name),
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
		  __print_flags(__entry->high, "",
				{(WQ_HIGHPRI),	"-high"}),
		  __entry->wq)
);

DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,

	TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),

	TP_ARGS(wq, name, high)
);

DECLARE_EVENT_CLASS(btrfs__workqueue_done,

	TP_PROTO(struct __btrfs_workqueue *wq),

	TP_ARGS(wq),

1255
	TP_STRUCT__entry_btrfs(
1256 1257 1258
		__field(	void *,	wq			)
	),

1259
	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1260 1261 1262
		__entry->wq		= wq;
	),

1263
	TP_printk_btrfs("wq=%p", __entry->wq)
1264 1265 1266 1267 1268 1269 1270 1271
);

DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,

	TP_PROTO(struct __btrfs_workqueue *wq),

	TP_ARGS(wq)
);
1272

1273 1274 1275 1276 1277 1278
DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,

	TP_PROTO(struct inode *inode, u64 free_reserved),

	TP_ARGS(inode, free_reserved),

1279
	TP_STRUCT__entry_btrfs(
1280 1281 1282 1283 1284
		__field(	u64,		rootid		)
		__field(	unsigned long,	ino		)
		__field(	u64,		free_reserved	)
	),

1285
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
1286 1287 1288 1289 1290
		__entry->rootid		=	BTRFS_I(inode)->root->objectid;
		__entry->ino		=	inode->i_ino;
		__entry->free_reserved	=	free_reserved;
	),

1291
	TP_printk_btrfs("rootid=%llu, ino=%lu, free_reserved=%llu",
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
		  __entry->rootid, __entry->ino, __entry->free_reserved)
);

DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,

	TP_PROTO(struct inode *inode, u64 free_reserved),

	TP_ARGS(inode, free_reserved)
);

DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,

	TP_PROTO(struct inode *inode, u64 free_reserved),

	TP_ARGS(inode, free_reserved)
);

#define BTRFS_QGROUP_OPERATIONS				\
	{ QGROUP_RESERVE,	"reserve"	},	\
	{ QGROUP_RELEASE,	"release"	},	\
	{ QGROUP_FREE,		"free"		}

DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,

	TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),

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

1320
	TP_STRUCT__entry_btrfs(
1321 1322 1323 1324 1325 1326 1327 1328
		__field(	u64,		rootid		)
		__field(	unsigned long,	ino		)
		__field(	u64,		start		)
		__field(	u64,		len		)
		__field(	u64,		reserved	)
		__field(	int,		op		)
	),

1329
	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
1330 1331 1332 1333 1334 1335 1336 1337
		__entry->rootid		= BTRFS_I(inode)->root->objectid;
		__entry->ino		= inode->i_ino;
		__entry->start		= start;
		__entry->len		= len;
		__entry->reserved	= reserved;
		__entry->op		= op;
	),

1338
	TP_printk_btrfs("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361
		  __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,

	TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),

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

DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,

	TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),

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

DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,

1362
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
1363

1364
	TP_ARGS(fs_info, ref_root, reserved),
1365

1366
	TP_STRUCT__entry_btrfs(
1367 1368 1369 1370
		__field(	u64,		ref_root	)
		__field(	u64,		reserved	)
	),

1371
	TP_fast_assign_btrfs(fs_info,
1372 1373 1374 1375
		__entry->ref_root	= ref_root;
		__entry->reserved	= reserved;
	),

1376
	TP_printk_btrfs("root=%llu, reserved=%llu, op=free",
1377 1378 1379 1380 1381
		  __entry->ref_root, __entry->reserved)
);

DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,

1382
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
1383

1384
	TP_ARGS(fs_info, ref_root, reserved)
1385
);
M
Mark Fasheh 已提交
1386 1387

DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1388 1389
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1390

1391
	TP_ARGS(fs_info, rec),
M
Mark Fasheh 已提交
1392

1393
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1394 1395 1396 1397
		__field(	u64,  bytenr		)
		__field(	u64,  num_bytes		)
	),

1398
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1399 1400 1401 1402
		__entry->bytenr		= rec->bytenr,
		__entry->num_bytes	= rec->num_bytes;
	),

1403
	TP_printk_btrfs("bytenr = %llu, num_bytes = %llu",
M
Mark Fasheh 已提交
1404 1405 1406 1407 1408 1409
		  (unsigned long long)__entry->bytenr,
		  (unsigned long long)__entry->num_bytes)
);

DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,

1410 1411
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1412

1413
	TP_ARGS(fs_info, rec)
M
Mark Fasheh 已提交
1414 1415
);

1416
DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
M
Mark Fasheh 已提交
1417

1418 1419
	TP_PROTO(struct btrfs_fs_info *fs_info,
		 struct btrfs_qgroup_extent_record *rec),
M
Mark Fasheh 已提交
1420

1421
	TP_ARGS(fs_info, rec)
M
Mark Fasheh 已提交
1422 1423 1424 1425
);

TRACE_EVENT(btrfs_qgroup_account_extent,

1426 1427
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr,
		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
M
Mark Fasheh 已提交
1428

1429
	TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
M
Mark Fasheh 已提交
1430

1431
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1432 1433 1434 1435 1436 1437
		__field(	u64,  bytenr			)
		__field(	u64,  num_bytes			)
		__field(	u64,  nr_old_roots		)
		__field(	u64,  nr_new_roots		)
	),

1438
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1439 1440 1441 1442 1443 1444
		__entry->bytenr		= bytenr;
		__entry->num_bytes	= num_bytes;
		__entry->nr_old_roots	= nr_old_roots;
		__entry->nr_new_roots	= nr_new_roots;
	),

1445
	TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
M
Mark Fasheh 已提交
1446 1447 1448 1449 1450 1451 1452 1453 1454
		  "nr_new_roots = %llu",
		  __entry->bytenr,
		  __entry->num_bytes,
		  __entry->nr_old_roots,
		  __entry->nr_new_roots)
);

TRACE_EVENT(qgroup_update_counters,

1455 1456
	TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid,
		 u64 cur_old_count, u64 cur_new_count),
M
Mark Fasheh 已提交
1457

1458
	TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
M
Mark Fasheh 已提交
1459

1460
	TP_STRUCT__entry_btrfs(
M
Mark Fasheh 已提交
1461 1462 1463 1464 1465
		__field(	u64,  qgid			)
		__field(	u64,  cur_old_count		)
		__field(	u64,  cur_new_count		)
	),

1466
	TP_fast_assign_btrfs(fs_info,
M
Mark Fasheh 已提交
1467 1468 1469 1470 1471
		__entry->qgid		= qgid;
		__entry->cur_old_count	= cur_old_count;
		__entry->cur_new_count	= cur_new_count;
	),

1472
	TP_printk_btrfs("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
M
Mark Fasheh 已提交
1473 1474 1475 1476 1477
		  __entry->qgid,
		  __entry->cur_old_count,
		  __entry->cur_new_count)
);

1478 1479 1480 1481
#endif /* _TRACE_BTRFS_H */

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