btrfs.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM btrfs
  3. #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_BTRFS_H
  5. #include <linux/writeback.h>
  6. #include <linux/tracepoint.h>
  7. #include <trace/events/gfpflags.h>
  8. struct btrfs_root;
  9. struct btrfs_fs_info;
  10. struct btrfs_inode;
  11. struct extent_map;
  12. struct btrfs_ordered_extent;
  13. struct btrfs_delayed_ref_node;
  14. struct btrfs_delayed_tree_ref;
  15. struct btrfs_delayed_data_ref;
  16. struct btrfs_delayed_ref_head;
  17. struct btrfs_block_group_cache;
  18. struct btrfs_free_cluster;
  19. struct map_lookup;
  20. struct extent_buffer;
  21. struct btrfs_work;
  22. struct __btrfs_workqueue;
  23. struct btrfs_qgroup_operation;
  24. #define show_ref_type(type) \
  25. __print_symbolic(type, \
  26. { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
  27. { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
  28. { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
  29. { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
  30. { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
  31. #define __show_root_type(obj) \
  32. __print_symbolic_u64(obj, \
  33. { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
  34. { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
  35. { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
  36. { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
  37. { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
  38. { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
  39. { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
  40. { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
  41. { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
  42. { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
  43. { BTRFS_UUID_TREE_OBJECTID, "UUID_RELOC" }, \
  44. { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
  45. #define show_root_type(obj) \
  46. obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
  47. (obj >= BTRFS_ROOT_TREE_OBJECTID && \
  48. obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
  49. #define BTRFS_GROUP_FLAGS \
  50. { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
  51. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  52. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  53. { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
  54. { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
  55. { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
  56. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  57. { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
  58. { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
  59. #define BTRFS_UUID_SIZE 16
  60. TRACE_EVENT(btrfs_transaction_commit,
  61. TP_PROTO(struct btrfs_root *root),
  62. TP_ARGS(root),
  63. TP_STRUCT__entry(
  64. __field( u64, generation )
  65. __field( u64, root_objectid )
  66. ),
  67. TP_fast_assign(
  68. __entry->generation = root->fs_info->generation;
  69. __entry->root_objectid = root->root_key.objectid;
  70. ),
  71. TP_printk("root = %llu(%s), gen = %llu",
  72. show_root_type(__entry->root_objectid),
  73. (unsigned long long)__entry->generation)
  74. );
  75. DECLARE_EVENT_CLASS(btrfs__inode,
  76. TP_PROTO(struct inode *inode),
  77. TP_ARGS(inode),
  78. TP_STRUCT__entry(
  79. __field( ino_t, ino )
  80. __field( blkcnt_t, blocks )
  81. __field( u64, disk_i_size )
  82. __field( u64, generation )
  83. __field( u64, last_trans )
  84. __field( u64, logged_trans )
  85. __field( u64, root_objectid )
  86. ),
  87. TP_fast_assign(
  88. __entry->ino = inode->i_ino;
  89. __entry->blocks = inode->i_blocks;
  90. __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
  91. __entry->generation = BTRFS_I(inode)->generation;
  92. __entry->last_trans = BTRFS_I(inode)->last_trans;
  93. __entry->logged_trans = BTRFS_I(inode)->logged_trans;
  94. __entry->root_objectid =
  95. BTRFS_I(inode)->root->root_key.objectid;
  96. ),
  97. TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
  98. "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
  99. show_root_type(__entry->root_objectid),
  100. (unsigned long long)__entry->generation,
  101. (unsigned long)__entry->ino,
  102. (unsigned long long)__entry->blocks,
  103. (unsigned long long)__entry->disk_i_size,
  104. (unsigned long long)__entry->last_trans,
  105. (unsigned long long)__entry->logged_trans)
  106. );
  107. DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
  108. TP_PROTO(struct inode *inode),
  109. TP_ARGS(inode)
  110. );
  111. DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
  112. TP_PROTO(struct inode *inode),
  113. TP_ARGS(inode)
  114. );
  115. DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
  116. TP_PROTO(struct inode *inode),
  117. TP_ARGS(inode)
  118. );
  119. #define __show_map_type(type) \
  120. __print_symbolic_u64(type, \
  121. { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
  122. { EXTENT_MAP_HOLE, "HOLE" }, \
  123. { EXTENT_MAP_INLINE, "INLINE" }, \
  124. { EXTENT_MAP_DELALLOC, "DELALLOC" })
  125. #define show_map_type(type) \
  126. type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
  127. #define show_map_flags(flag) \
  128. __print_flags(flag, "|", \
  129. { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
  130. { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
  131. { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
  132. { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
  133. { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
  134. { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
  135. { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
  136. TRACE_EVENT_CONDITION(btrfs_get_extent,
  137. TP_PROTO(struct btrfs_root *root, struct extent_map *map),
  138. TP_ARGS(root, map),
  139. TP_CONDITION(map),
  140. TP_STRUCT__entry(
  141. __field( u64, root_objectid )
  142. __field( u64, start )
  143. __field( u64, len )
  144. __field( u64, orig_start )
  145. __field( u64, block_start )
  146. __field( u64, block_len )
  147. __field( unsigned long, flags )
  148. __field( int, refs )
  149. __field( unsigned int, compress_type )
  150. ),
  151. TP_fast_assign(
  152. __entry->root_objectid = root->root_key.objectid;
  153. __entry->start = map->start;
  154. __entry->len = map->len;
  155. __entry->orig_start = map->orig_start;
  156. __entry->block_start = map->block_start;
  157. __entry->block_len = map->block_len;
  158. __entry->flags = map->flags;
  159. __entry->refs = atomic_read(&map->refs);
  160. __entry->compress_type = map->compress_type;
  161. ),
  162. TP_printk("root = %llu(%s), start = %llu, len = %llu, "
  163. "orig_start = %llu, block_start = %llu(%s), "
  164. "block_len = %llu, flags = %s, refs = %u, "
  165. "compress_type = %u",
  166. show_root_type(__entry->root_objectid),
  167. (unsigned long long)__entry->start,
  168. (unsigned long long)__entry->len,
  169. (unsigned long long)__entry->orig_start,
  170. show_map_type(__entry->block_start),
  171. (unsigned long long)__entry->block_len,
  172. show_map_flags(__entry->flags),
  173. __entry->refs, __entry->compress_type)
  174. );
  175. #define show_ordered_flags(flags) \
  176. __print_flags(flags, "|", \
  177. { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
  178. { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
  179. { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
  180. { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
  181. { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
  182. { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
  183. { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
  184. { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
  185. { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
  186. { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
  187. DECLARE_EVENT_CLASS(btrfs__ordered_extent,
  188. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  189. TP_ARGS(inode, ordered),
  190. TP_STRUCT__entry(
  191. __field( ino_t, ino )
  192. __field( u64, file_offset )
  193. __field( u64, start )
  194. __field( u64, len )
  195. __field( u64, disk_len )
  196. __field( u64, bytes_left )
  197. __field( unsigned long, flags )
  198. __field( int, compress_type )
  199. __field( int, refs )
  200. __field( u64, root_objectid )
  201. ),
  202. TP_fast_assign(
  203. __entry->ino = inode->i_ino;
  204. __entry->file_offset = ordered->file_offset;
  205. __entry->start = ordered->start;
  206. __entry->len = ordered->len;
  207. __entry->disk_len = ordered->disk_len;
  208. __entry->bytes_left = ordered->bytes_left;
  209. __entry->flags = ordered->flags;
  210. __entry->compress_type = ordered->compress_type;
  211. __entry->refs = atomic_read(&ordered->refs);
  212. __entry->root_objectid =
  213. BTRFS_I(inode)->root->root_key.objectid;
  214. ),
  215. TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
  216. "start = %llu, len = %llu, disk_len = %llu, "
  217. "bytes_left = %llu, flags = %s, compress_type = %d, "
  218. "refs = %d",
  219. show_root_type(__entry->root_objectid),
  220. (unsigned long long)__entry->ino,
  221. (unsigned long long)__entry->file_offset,
  222. (unsigned long long)__entry->start,
  223. (unsigned long long)__entry->len,
  224. (unsigned long long)__entry->disk_len,
  225. (unsigned long long)__entry->bytes_left,
  226. show_ordered_flags(__entry->flags),
  227. __entry->compress_type, __entry->refs)
  228. );
  229. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
  230. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  231. TP_ARGS(inode, ordered)
  232. );
  233. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
  234. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  235. TP_ARGS(inode, ordered)
  236. );
  237. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
  238. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  239. TP_ARGS(inode, ordered)
  240. );
  241. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
  242. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  243. TP_ARGS(inode, ordered)
  244. );
  245. DECLARE_EVENT_CLASS(btrfs__writepage,
  246. TP_PROTO(struct page *page, struct inode *inode,
  247. struct writeback_control *wbc),
  248. TP_ARGS(page, inode, wbc),
  249. TP_STRUCT__entry(
  250. __field( ino_t, ino )
  251. __field( pgoff_t, index )
  252. __field( long, nr_to_write )
  253. __field( long, pages_skipped )
  254. __field( loff_t, range_start )
  255. __field( loff_t, range_end )
  256. __field( char, for_kupdate )
  257. __field( char, for_reclaim )
  258. __field( char, range_cyclic )
  259. __field( pgoff_t, writeback_index )
  260. __field( u64, root_objectid )
  261. ),
  262. TP_fast_assign(
  263. __entry->ino = inode->i_ino;
  264. __entry->index = page->index;
  265. __entry->nr_to_write = wbc->nr_to_write;
  266. __entry->pages_skipped = wbc->pages_skipped;
  267. __entry->range_start = wbc->range_start;
  268. __entry->range_end = wbc->range_end;
  269. __entry->for_kupdate = wbc->for_kupdate;
  270. __entry->for_reclaim = wbc->for_reclaim;
  271. __entry->range_cyclic = wbc->range_cyclic;
  272. __entry->writeback_index = inode->i_mapping->writeback_index;
  273. __entry->root_objectid =
  274. BTRFS_I(inode)->root->root_key.objectid;
  275. ),
  276. TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
  277. "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
  278. "range_end = %llu, for_kupdate = %d, "
  279. "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
  280. show_root_type(__entry->root_objectid),
  281. (unsigned long)__entry->ino, __entry->index,
  282. __entry->nr_to_write, __entry->pages_skipped,
  283. __entry->range_start, __entry->range_end,
  284. __entry->for_kupdate,
  285. __entry->for_reclaim, __entry->range_cyclic,
  286. (unsigned long)__entry->writeback_index)
  287. );
  288. DEFINE_EVENT(btrfs__writepage, __extent_writepage,
  289. TP_PROTO(struct page *page, struct inode *inode,
  290. struct writeback_control *wbc),
  291. TP_ARGS(page, inode, wbc)
  292. );
  293. TRACE_EVENT(btrfs_writepage_end_io_hook,
  294. TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
  295. TP_ARGS(page, start, end, uptodate),
  296. TP_STRUCT__entry(
  297. __field( ino_t, ino )
  298. __field( pgoff_t, index )
  299. __field( u64, start )
  300. __field( u64, end )
  301. __field( int, uptodate )
  302. __field( u64, root_objectid )
  303. ),
  304. TP_fast_assign(
  305. __entry->ino = page->mapping->host->i_ino;
  306. __entry->index = page->index;
  307. __entry->start = start;
  308. __entry->end = end;
  309. __entry->uptodate = uptodate;
  310. __entry->root_objectid =
  311. BTRFS_I(page->mapping->host)->root->root_key.objectid;
  312. ),
  313. TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
  314. "end = %llu, uptodate = %d",
  315. show_root_type(__entry->root_objectid),
  316. (unsigned long)__entry->ino, (unsigned long)__entry->index,
  317. (unsigned long long)__entry->start,
  318. (unsigned long long)__entry->end, __entry->uptodate)
  319. );
  320. TRACE_EVENT(btrfs_sync_file,
  321. TP_PROTO(struct file *file, int datasync),
  322. TP_ARGS(file, datasync),
  323. TP_STRUCT__entry(
  324. __field( ino_t, ino )
  325. __field( ino_t, parent )
  326. __field( int, datasync )
  327. __field( u64, root_objectid )
  328. ),
  329. TP_fast_assign(
  330. struct dentry *dentry = file->f_path.dentry;
  331. struct inode *inode = d_inode(dentry);
  332. __entry->ino = inode->i_ino;
  333. __entry->parent = d_inode(dentry->d_parent)->i_ino;
  334. __entry->datasync = datasync;
  335. __entry->root_objectid =
  336. BTRFS_I(inode)->root->root_key.objectid;
  337. ),
  338. TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
  339. show_root_type(__entry->root_objectid),
  340. (unsigned long)__entry->ino, (unsigned long)__entry->parent,
  341. __entry->datasync)
  342. );
  343. TRACE_EVENT(btrfs_sync_fs,
  344. TP_PROTO(int wait),
  345. TP_ARGS(wait),
  346. TP_STRUCT__entry(
  347. __field( int, wait )
  348. ),
  349. TP_fast_assign(
  350. __entry->wait = wait;
  351. ),
  352. TP_printk("wait = %d", __entry->wait)
  353. );
  354. #define show_ref_action(action) \
  355. __print_symbolic(action, \
  356. { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
  357. { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
  358. { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
  359. { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
  360. DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
  361. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  362. struct btrfs_delayed_tree_ref *full_ref,
  363. int action),
  364. TP_ARGS(ref, full_ref, action),
  365. TP_STRUCT__entry(
  366. __field( u64, bytenr )
  367. __field( u64, num_bytes )
  368. __field( int, action )
  369. __field( u64, parent )
  370. __field( u64, ref_root )
  371. __field( int, level )
  372. __field( int, type )
  373. __field( u64, seq )
  374. ),
  375. TP_fast_assign(
  376. __entry->bytenr = ref->bytenr;
  377. __entry->num_bytes = ref->num_bytes;
  378. __entry->action = action;
  379. __entry->parent = full_ref->parent;
  380. __entry->ref_root = full_ref->root;
  381. __entry->level = full_ref->level;
  382. __entry->type = ref->type;
  383. __entry->seq = ref->seq;
  384. ),
  385. TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
  386. "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
  387. "type = %s, seq = %llu",
  388. (unsigned long long)__entry->bytenr,
  389. (unsigned long long)__entry->num_bytes,
  390. show_ref_action(__entry->action),
  391. show_root_type(__entry->parent),
  392. show_root_type(__entry->ref_root),
  393. __entry->level, show_ref_type(__entry->type),
  394. (unsigned long long)__entry->seq)
  395. );
  396. DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
  397. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  398. struct btrfs_delayed_tree_ref *full_ref,
  399. int action),
  400. TP_ARGS(ref, full_ref, action)
  401. );
  402. DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
  403. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  404. struct btrfs_delayed_tree_ref *full_ref,
  405. int action),
  406. TP_ARGS(ref, full_ref, action)
  407. );
  408. DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
  409. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  410. struct btrfs_delayed_data_ref *full_ref,
  411. int action),
  412. TP_ARGS(ref, full_ref, action),
  413. TP_STRUCT__entry(
  414. __field( u64, bytenr )
  415. __field( u64, num_bytes )
  416. __field( int, action )
  417. __field( u64, parent )
  418. __field( u64, ref_root )
  419. __field( u64, owner )
  420. __field( u64, offset )
  421. __field( int, type )
  422. __field( u64, seq )
  423. ),
  424. TP_fast_assign(
  425. __entry->bytenr = ref->bytenr;
  426. __entry->num_bytes = ref->num_bytes;
  427. __entry->action = action;
  428. __entry->parent = full_ref->parent;
  429. __entry->ref_root = full_ref->root;
  430. __entry->owner = full_ref->objectid;
  431. __entry->offset = full_ref->offset;
  432. __entry->type = ref->type;
  433. __entry->seq = ref->seq;
  434. ),
  435. TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
  436. "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
  437. "offset = %llu, type = %s, seq = %llu",
  438. (unsigned long long)__entry->bytenr,
  439. (unsigned long long)__entry->num_bytes,
  440. show_ref_action(__entry->action),
  441. show_root_type(__entry->parent),
  442. show_root_type(__entry->ref_root),
  443. (unsigned long long)__entry->owner,
  444. (unsigned long long)__entry->offset,
  445. show_ref_type(__entry->type),
  446. (unsigned long long)__entry->seq)
  447. );
  448. DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
  449. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  450. struct btrfs_delayed_data_ref *full_ref,
  451. int action),
  452. TP_ARGS(ref, full_ref, action)
  453. );
  454. DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
  455. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  456. struct btrfs_delayed_data_ref *full_ref,
  457. int action),
  458. TP_ARGS(ref, full_ref, action)
  459. );
  460. DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
  461. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  462. struct btrfs_delayed_ref_head *head_ref,
  463. int action),
  464. TP_ARGS(ref, head_ref, action),
  465. TP_STRUCT__entry(
  466. __field( u64, bytenr )
  467. __field( u64, num_bytes )
  468. __field( int, action )
  469. __field( int, is_data )
  470. ),
  471. TP_fast_assign(
  472. __entry->bytenr = ref->bytenr;
  473. __entry->num_bytes = ref->num_bytes;
  474. __entry->action = action;
  475. __entry->is_data = head_ref->is_data;
  476. ),
  477. TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
  478. (unsigned long long)__entry->bytenr,
  479. (unsigned long long)__entry->num_bytes,
  480. show_ref_action(__entry->action),
  481. __entry->is_data)
  482. );
  483. DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
  484. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  485. struct btrfs_delayed_ref_head *head_ref,
  486. int action),
  487. TP_ARGS(ref, head_ref, action)
  488. );
  489. DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
  490. TP_PROTO(struct btrfs_delayed_ref_node *ref,
  491. struct btrfs_delayed_ref_head *head_ref,
  492. int action),
  493. TP_ARGS(ref, head_ref, action)
  494. );
  495. #define show_chunk_type(type) \
  496. __print_flags(type, "|", \
  497. { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
  498. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  499. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  500. { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
  501. { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
  502. { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
  503. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  504. { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
  505. { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
  506. DECLARE_EVENT_CLASS(btrfs__chunk,
  507. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  508. u64 offset, u64 size),
  509. TP_ARGS(root, map, offset, size),
  510. TP_STRUCT__entry(
  511. __field( int, num_stripes )
  512. __field( u64, type )
  513. __field( int, sub_stripes )
  514. __field( u64, offset )
  515. __field( u64, size )
  516. __field( u64, root_objectid )
  517. ),
  518. TP_fast_assign(
  519. __entry->num_stripes = map->num_stripes;
  520. __entry->type = map->type;
  521. __entry->sub_stripes = map->sub_stripes;
  522. __entry->offset = offset;
  523. __entry->size = size;
  524. __entry->root_objectid = root->root_key.objectid;
  525. ),
  526. TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
  527. "num_stripes = %d, sub_stripes = %d, type = %s",
  528. show_root_type(__entry->root_objectid),
  529. (unsigned long long)__entry->offset,
  530. (unsigned long long)__entry->size,
  531. __entry->num_stripes, __entry->sub_stripes,
  532. show_chunk_type(__entry->type))
  533. );
  534. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
  535. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  536. u64 offset, u64 size),
  537. TP_ARGS(root, map, offset, size)
  538. );
  539. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
  540. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  541. u64 offset, u64 size),
  542. TP_ARGS(root, map, offset, size)
  543. );
  544. TRACE_EVENT(btrfs_cow_block,
  545. TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
  546. struct extent_buffer *cow),
  547. TP_ARGS(root, buf, cow),
  548. TP_STRUCT__entry(
  549. __field( u64, root_objectid )
  550. __field( u64, buf_start )
  551. __field( int, refs )
  552. __field( u64, cow_start )
  553. __field( int, buf_level )
  554. __field( int, cow_level )
  555. ),
  556. TP_fast_assign(
  557. __entry->root_objectid = root->root_key.objectid;
  558. __entry->buf_start = buf->start;
  559. __entry->refs = atomic_read(&buf->refs);
  560. __entry->cow_start = cow->start;
  561. __entry->buf_level = btrfs_header_level(buf);
  562. __entry->cow_level = btrfs_header_level(cow);
  563. ),
  564. TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
  565. "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
  566. show_root_type(__entry->root_objectid),
  567. __entry->refs,
  568. (unsigned long long)__entry->buf_start,
  569. __entry->buf_level,
  570. (unsigned long long)__entry->cow_start,
  571. __entry->cow_level)
  572. );
  573. TRACE_EVENT(btrfs_space_reservation,
  574. TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
  575. u64 bytes, int reserve),
  576. TP_ARGS(fs_info, type, val, bytes, reserve),
  577. TP_STRUCT__entry(
  578. __array( u8, fsid, BTRFS_UUID_SIZE )
  579. __string( type, type )
  580. __field( u64, val )
  581. __field( u64, bytes )
  582. __field( int, reserve )
  583. ),
  584. TP_fast_assign(
  585. memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
  586. __assign_str(type, type);
  587. __entry->val = val;
  588. __entry->bytes = bytes;
  589. __entry->reserve = reserve;
  590. ),
  591. TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
  592. __entry->val, __entry->reserve ? "reserve" : "release",
  593. __entry->bytes)
  594. );
  595. DECLARE_EVENT_CLASS(btrfs__reserved_extent,
  596. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  597. TP_ARGS(root, start, len),
  598. TP_STRUCT__entry(
  599. __field( u64, root_objectid )
  600. __field( u64, start )
  601. __field( u64, len )
  602. ),
  603. TP_fast_assign(
  604. __entry->root_objectid = root->root_key.objectid;
  605. __entry->start = start;
  606. __entry->len = len;
  607. ),
  608. TP_printk("root = %llu(%s), start = %llu, len = %llu",
  609. show_root_type(__entry->root_objectid),
  610. (unsigned long long)__entry->start,
  611. (unsigned long long)__entry->len)
  612. );
  613. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
  614. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  615. TP_ARGS(root, start, len)
  616. );
  617. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
  618. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  619. TP_ARGS(root, start, len)
  620. );
  621. TRACE_EVENT(find_free_extent,
  622. TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
  623. u64 data),
  624. TP_ARGS(root, num_bytes, empty_size, data),
  625. TP_STRUCT__entry(
  626. __field( u64, root_objectid )
  627. __field( u64, num_bytes )
  628. __field( u64, empty_size )
  629. __field( u64, data )
  630. ),
  631. TP_fast_assign(
  632. __entry->root_objectid = root->root_key.objectid;
  633. __entry->num_bytes = num_bytes;
  634. __entry->empty_size = empty_size;
  635. __entry->data = data;
  636. ),
  637. TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
  638. "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
  639. __entry->num_bytes, __entry->empty_size, __entry->data,
  640. __print_flags((unsigned long)__entry->data, "|",
  641. BTRFS_GROUP_FLAGS))
  642. );
  643. DECLARE_EVENT_CLASS(btrfs__reserve_extent,
  644. TP_PROTO(struct btrfs_root *root,
  645. struct btrfs_block_group_cache *block_group, u64 start,
  646. u64 len),
  647. TP_ARGS(root, block_group, start, len),
  648. TP_STRUCT__entry(
  649. __field( u64, root_objectid )
  650. __field( u64, bg_objectid )
  651. __field( u64, flags )
  652. __field( u64, start )
  653. __field( u64, len )
  654. ),
  655. TP_fast_assign(
  656. __entry->root_objectid = root->root_key.objectid;
  657. __entry->bg_objectid = block_group->key.objectid;
  658. __entry->flags = block_group->flags;
  659. __entry->start = start;
  660. __entry->len = len;
  661. ),
  662. TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
  663. "start = %Lu, len = %Lu",
  664. show_root_type(__entry->root_objectid), __entry->bg_objectid,
  665. __entry->flags, __print_flags((unsigned long)__entry->flags,
  666. "|", BTRFS_GROUP_FLAGS),
  667. __entry->start, __entry->len)
  668. );
  669. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
  670. TP_PROTO(struct btrfs_root *root,
  671. struct btrfs_block_group_cache *block_group, u64 start,
  672. u64 len),
  673. TP_ARGS(root, block_group, start, len)
  674. );
  675. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
  676. TP_PROTO(struct btrfs_root *root,
  677. struct btrfs_block_group_cache *block_group, u64 start,
  678. u64 len),
  679. TP_ARGS(root, block_group, start, len)
  680. );
  681. TRACE_EVENT(btrfs_find_cluster,
  682. TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
  683. u64 bytes, u64 empty_size, u64 min_bytes),
  684. TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
  685. TP_STRUCT__entry(
  686. __field( u64, bg_objectid )
  687. __field( u64, flags )
  688. __field( u64, start )
  689. __field( u64, bytes )
  690. __field( u64, empty_size )
  691. __field( u64, min_bytes )
  692. ),
  693. TP_fast_assign(
  694. __entry->bg_objectid = block_group->key.objectid;
  695. __entry->flags = block_group->flags;
  696. __entry->start = start;
  697. __entry->bytes = bytes;
  698. __entry->empty_size = empty_size;
  699. __entry->min_bytes = min_bytes;
  700. ),
  701. TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
  702. " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
  703. __entry->flags,
  704. __print_flags((unsigned long)__entry->flags, "|",
  705. BTRFS_GROUP_FLAGS), __entry->start,
  706. __entry->bytes, __entry->empty_size, __entry->min_bytes)
  707. );
  708. TRACE_EVENT(btrfs_failed_cluster_setup,
  709. TP_PROTO(struct btrfs_block_group_cache *block_group),
  710. TP_ARGS(block_group),
  711. TP_STRUCT__entry(
  712. __field( u64, bg_objectid )
  713. ),
  714. TP_fast_assign(
  715. __entry->bg_objectid = block_group->key.objectid;
  716. ),
  717. TP_printk("block_group = %Lu", __entry->bg_objectid)
  718. );
  719. TRACE_EVENT(btrfs_setup_cluster,
  720. TP_PROTO(struct btrfs_block_group_cache *block_group,
  721. struct btrfs_free_cluster *cluster, u64 size, int bitmap),
  722. TP_ARGS(block_group, cluster, size, bitmap),
  723. TP_STRUCT__entry(
  724. __field( u64, bg_objectid )
  725. __field( u64, flags )
  726. __field( u64, start )
  727. __field( u64, max_size )
  728. __field( u64, size )
  729. __field( int, bitmap )
  730. ),
  731. TP_fast_assign(
  732. __entry->bg_objectid = block_group->key.objectid;
  733. __entry->flags = block_group->flags;
  734. __entry->start = cluster->window_start;
  735. __entry->max_size = cluster->max_size;
  736. __entry->size = size;
  737. __entry->bitmap = bitmap;
  738. ),
  739. TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
  740. "size = %Lu, max_size = %Lu, bitmap = %d",
  741. __entry->bg_objectid,
  742. __entry->flags,
  743. __print_flags((unsigned long)__entry->flags, "|",
  744. BTRFS_GROUP_FLAGS), __entry->start,
  745. __entry->size, __entry->max_size, __entry->bitmap)
  746. );
  747. struct extent_state;
  748. TRACE_EVENT(alloc_extent_state,
  749. TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
  750. TP_ARGS(state, mask, IP),
  751. TP_STRUCT__entry(
  752. __field(struct extent_state *, state)
  753. __field(gfp_t, mask)
  754. __field(unsigned long, ip)
  755. ),
  756. TP_fast_assign(
  757. __entry->state = state,
  758. __entry->mask = mask,
  759. __entry->ip = IP
  760. ),
  761. TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
  762. show_gfp_flags(__entry->mask), (void *)__entry->ip)
  763. );
  764. TRACE_EVENT(free_extent_state,
  765. TP_PROTO(struct extent_state *state, unsigned long IP),
  766. TP_ARGS(state, IP),
  767. TP_STRUCT__entry(
  768. __field(struct extent_state *, state)
  769. __field(unsigned long, ip)
  770. ),
  771. TP_fast_assign(
  772. __entry->state = state,
  773. __entry->ip = IP
  774. ),
  775. TP_printk(" state=%p; caller = %pS", __entry->state,
  776. (void *)__entry->ip)
  777. );
  778. DECLARE_EVENT_CLASS(btrfs__work,
  779. TP_PROTO(struct btrfs_work *work),
  780. TP_ARGS(work),
  781. TP_STRUCT__entry(
  782. __field( void *, work )
  783. __field( void *, wq )
  784. __field( void *, func )
  785. __field( void *, ordered_func )
  786. __field( void *, ordered_free )
  787. __field( void *, normal_work )
  788. ),
  789. TP_fast_assign(
  790. __entry->work = work;
  791. __entry->wq = work->wq;
  792. __entry->func = work->func;
  793. __entry->ordered_func = work->ordered_func;
  794. __entry->ordered_free = work->ordered_free;
  795. __entry->normal_work = &work->normal_work;
  796. ),
  797. TP_printk("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
  798. " ordered_free=%p",
  799. __entry->work, __entry->normal_work, __entry->wq,
  800. __entry->func, __entry->ordered_func, __entry->ordered_free)
  801. );
  802. /* For situiations that the work is freed */
  803. DECLARE_EVENT_CLASS(btrfs__work__done,
  804. TP_PROTO(struct btrfs_work *work),
  805. TP_ARGS(work),
  806. TP_STRUCT__entry(
  807. __field( void *, work )
  808. ),
  809. TP_fast_assign(
  810. __entry->work = work;
  811. ),
  812. TP_printk("work->%p", __entry->work)
  813. );
  814. DEFINE_EVENT(btrfs__work, btrfs_work_queued,
  815. TP_PROTO(struct btrfs_work *work),
  816. TP_ARGS(work)
  817. );
  818. DEFINE_EVENT(btrfs__work, btrfs_work_sched,
  819. TP_PROTO(struct btrfs_work *work),
  820. TP_ARGS(work)
  821. );
  822. DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
  823. TP_PROTO(struct btrfs_work *work),
  824. TP_ARGS(work)
  825. );
  826. DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
  827. TP_PROTO(struct btrfs_work *work),
  828. TP_ARGS(work)
  829. );
  830. DECLARE_EVENT_CLASS(btrfs__workqueue,
  831. TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
  832. TP_ARGS(wq, name, high),
  833. TP_STRUCT__entry(
  834. __field( void *, wq )
  835. __string( name, name )
  836. __field( int , high )
  837. ),
  838. TP_fast_assign(
  839. __entry->wq = wq;
  840. __assign_str(name, name);
  841. __entry->high = high;
  842. ),
  843. TP_printk("name=%s%s, wq=%p", __get_str(name),
  844. __print_flags(__entry->high, "",
  845. {(WQ_HIGHPRI), "-high"}),
  846. __entry->wq)
  847. );
  848. DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
  849. TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
  850. TP_ARGS(wq, name, high)
  851. );
  852. DECLARE_EVENT_CLASS(btrfs__workqueue_done,
  853. TP_PROTO(struct __btrfs_workqueue *wq),
  854. TP_ARGS(wq),
  855. TP_STRUCT__entry(
  856. __field( void *, wq )
  857. ),
  858. TP_fast_assign(
  859. __entry->wq = wq;
  860. ),
  861. TP_printk("wq=%p", __entry->wq)
  862. );
  863. DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
  864. TP_PROTO(struct __btrfs_workqueue *wq),
  865. TP_ARGS(wq)
  866. );
  867. DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
  868. TP_PROTO(struct inode *inode, u64 free_reserved),
  869. TP_ARGS(inode, free_reserved),
  870. TP_STRUCT__entry(
  871. __field( u64, rootid )
  872. __field( unsigned long, ino )
  873. __field( u64, free_reserved )
  874. ),
  875. TP_fast_assign(
  876. __entry->rootid = BTRFS_I(inode)->root->objectid;
  877. __entry->ino = inode->i_ino;
  878. __entry->free_reserved = free_reserved;
  879. ),
  880. TP_printk("rootid=%llu, ino=%lu, free_reserved=%llu",
  881. __entry->rootid, __entry->ino, __entry->free_reserved)
  882. );
  883. DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
  884. TP_PROTO(struct inode *inode, u64 free_reserved),
  885. TP_ARGS(inode, free_reserved)
  886. );
  887. DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
  888. TP_PROTO(struct inode *inode, u64 free_reserved),
  889. TP_ARGS(inode, free_reserved)
  890. );
  891. #define BTRFS_QGROUP_OPERATIONS \
  892. { QGROUP_RESERVE, "reserve" }, \
  893. { QGROUP_RELEASE, "release" }, \
  894. { QGROUP_FREE, "free" }
  895. DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
  896. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  897. TP_ARGS(inode, start, len, reserved, op),
  898. TP_STRUCT__entry(
  899. __field( u64, rootid )
  900. __field( unsigned long, ino )
  901. __field( u64, start )
  902. __field( u64, len )
  903. __field( u64, reserved )
  904. __field( int, op )
  905. ),
  906. TP_fast_assign(
  907. __entry->rootid = BTRFS_I(inode)->root->objectid;
  908. __entry->ino = inode->i_ino;
  909. __entry->start = start;
  910. __entry->len = len;
  911. __entry->reserved = reserved;
  912. __entry->op = op;
  913. ),
  914. TP_printk("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
  915. __entry->rootid, __entry->ino, __entry->start, __entry->len,
  916. __entry->reserved,
  917. __print_flags((unsigned long)__entry->op, "",
  918. BTRFS_QGROUP_OPERATIONS)
  919. )
  920. );
  921. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
  922. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  923. TP_ARGS(inode, start, len, reserved, op)
  924. );
  925. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
  926. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  927. TP_ARGS(inode, start, len, reserved, op)
  928. );
  929. DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
  930. TP_PROTO(u64 ref_root, u64 reserved),
  931. TP_ARGS(ref_root, reserved),
  932. TP_STRUCT__entry(
  933. __field( u64, ref_root )
  934. __field( u64, reserved )
  935. ),
  936. TP_fast_assign(
  937. __entry->ref_root = ref_root;
  938. __entry->reserved = reserved;
  939. ),
  940. TP_printk("root=%llu, reserved=%llu, op=free",
  941. __entry->ref_root, __entry->reserved)
  942. );
  943. DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
  944. TP_PROTO(u64 ref_root, u64 reserved),
  945. TP_ARGS(ref_root, reserved)
  946. );
  947. #endif /* _TRACE_BTRFS_H */
  948. /* This part must be outside protection */
  949. #include <trace/define_trace.h>