btrfs.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478
  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/mmflags.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_extent_record;
  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_TREE" }, \
  44. { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
  45. { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
  46. #define show_root_type(obj) \
  47. obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
  48. (obj >= BTRFS_ROOT_TREE_OBJECTID && \
  49. obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
  50. #define BTRFS_GROUP_FLAGS \
  51. { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
  52. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  53. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  54. { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
  55. { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
  56. { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
  57. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  58. { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
  59. { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
  60. #define BTRFS_UUID_SIZE 16
  61. #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE)
  62. #define TP_fast_assign_fsid(fs_info) \
  63. memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE)
  64. #define TP_STRUCT__entry_btrfs(args...) \
  65. TP_STRUCT__entry( \
  66. TP_STRUCT__entry_fsid \
  67. args)
  68. #define TP_fast_assign_btrfs(fs_info, args...) \
  69. TP_fast_assign( \
  70. TP_fast_assign_fsid(fs_info); \
  71. args)
  72. #define TP_printk_btrfs(fmt, args...) \
  73. TP_printk("%pU: " fmt, __entry->fsid, args)
  74. TRACE_EVENT(btrfs_transaction_commit,
  75. TP_PROTO(struct btrfs_root *root),
  76. TP_ARGS(root),
  77. TP_STRUCT__entry_btrfs(
  78. __field( u64, generation )
  79. __field( u64, root_objectid )
  80. ),
  81. TP_fast_assign_btrfs(root->fs_info,
  82. __entry->generation = root->fs_info->generation;
  83. __entry->root_objectid = root->root_key.objectid;
  84. ),
  85. TP_printk_btrfs("root = %llu(%s), gen = %llu",
  86. show_root_type(__entry->root_objectid),
  87. (unsigned long long)__entry->generation)
  88. );
  89. DECLARE_EVENT_CLASS(btrfs__inode,
  90. TP_PROTO(struct inode *inode),
  91. TP_ARGS(inode),
  92. TP_STRUCT__entry_btrfs(
  93. __field( ino_t, ino )
  94. __field( blkcnt_t, blocks )
  95. __field( u64, disk_i_size )
  96. __field( u64, generation )
  97. __field( u64, last_trans )
  98. __field( u64, logged_trans )
  99. __field( u64, root_objectid )
  100. ),
  101. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  102. __entry->ino = inode->i_ino;
  103. __entry->blocks = inode->i_blocks;
  104. __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
  105. __entry->generation = BTRFS_I(inode)->generation;
  106. __entry->last_trans = BTRFS_I(inode)->last_trans;
  107. __entry->logged_trans = BTRFS_I(inode)->logged_trans;
  108. __entry->root_objectid =
  109. BTRFS_I(inode)->root->root_key.objectid;
  110. ),
  111. TP_printk_btrfs("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
  112. "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
  113. show_root_type(__entry->root_objectid),
  114. (unsigned long long)__entry->generation,
  115. (unsigned long)__entry->ino,
  116. (unsigned long long)__entry->blocks,
  117. (unsigned long long)__entry->disk_i_size,
  118. (unsigned long long)__entry->last_trans,
  119. (unsigned long long)__entry->logged_trans)
  120. );
  121. DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
  122. TP_PROTO(struct inode *inode),
  123. TP_ARGS(inode)
  124. );
  125. DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
  126. TP_PROTO(struct inode *inode),
  127. TP_ARGS(inode)
  128. );
  129. DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
  130. TP_PROTO(struct inode *inode),
  131. TP_ARGS(inode)
  132. );
  133. #define __show_map_type(type) \
  134. __print_symbolic_u64(type, \
  135. { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
  136. { EXTENT_MAP_HOLE, "HOLE" }, \
  137. { EXTENT_MAP_INLINE, "INLINE" }, \
  138. { EXTENT_MAP_DELALLOC, "DELALLOC" })
  139. #define show_map_type(type) \
  140. type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
  141. #define show_map_flags(flag) \
  142. __print_flags(flag, "|", \
  143. { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
  144. { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
  145. { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
  146. { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
  147. { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
  148. { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
  149. { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
  150. TRACE_EVENT_CONDITION(btrfs_get_extent,
  151. TP_PROTO(struct btrfs_root *root, struct extent_map *map),
  152. TP_ARGS(root, map),
  153. TP_CONDITION(map),
  154. TP_STRUCT__entry_btrfs(
  155. __field( u64, root_objectid )
  156. __field( u64, start )
  157. __field( u64, len )
  158. __field( u64, orig_start )
  159. __field( u64, block_start )
  160. __field( u64, block_len )
  161. __field( unsigned long, flags )
  162. __field( int, refs )
  163. __field( unsigned int, compress_type )
  164. ),
  165. TP_fast_assign_btrfs(root->fs_info,
  166. __entry->root_objectid = root->root_key.objectid;
  167. __entry->start = map->start;
  168. __entry->len = map->len;
  169. __entry->orig_start = map->orig_start;
  170. __entry->block_start = map->block_start;
  171. __entry->block_len = map->block_len;
  172. __entry->flags = map->flags;
  173. __entry->refs = atomic_read(&map->refs);
  174. __entry->compress_type = map->compress_type;
  175. ),
  176. TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu, "
  177. "orig_start = %llu, block_start = %llu(%s), "
  178. "block_len = %llu, flags = %s, refs = %u, "
  179. "compress_type = %u",
  180. show_root_type(__entry->root_objectid),
  181. (unsigned long long)__entry->start,
  182. (unsigned long long)__entry->len,
  183. (unsigned long long)__entry->orig_start,
  184. show_map_type(__entry->block_start),
  185. (unsigned long long)__entry->block_len,
  186. show_map_flags(__entry->flags),
  187. __entry->refs, __entry->compress_type)
  188. );
  189. #define show_ordered_flags(flags) \
  190. __print_flags(flags, "|", \
  191. { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
  192. { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
  193. { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
  194. { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
  195. { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
  196. { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
  197. { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
  198. { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
  199. { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
  200. { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
  201. DECLARE_EVENT_CLASS(btrfs__ordered_extent,
  202. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  203. TP_ARGS(inode, ordered),
  204. TP_STRUCT__entry_btrfs(
  205. __field( ino_t, ino )
  206. __field( u64, file_offset )
  207. __field( u64, start )
  208. __field( u64, len )
  209. __field( u64, disk_len )
  210. __field( u64, bytes_left )
  211. __field( unsigned long, flags )
  212. __field( int, compress_type )
  213. __field( int, refs )
  214. __field( u64, root_objectid )
  215. ),
  216. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  217. __entry->ino = inode->i_ino;
  218. __entry->file_offset = ordered->file_offset;
  219. __entry->start = ordered->start;
  220. __entry->len = ordered->len;
  221. __entry->disk_len = ordered->disk_len;
  222. __entry->bytes_left = ordered->bytes_left;
  223. __entry->flags = ordered->flags;
  224. __entry->compress_type = ordered->compress_type;
  225. __entry->refs = atomic_read(&ordered->refs);
  226. __entry->root_objectid =
  227. BTRFS_I(inode)->root->root_key.objectid;
  228. ),
  229. TP_printk_btrfs("root = %llu(%s), ino = %llu, file_offset = %llu, "
  230. "start = %llu, len = %llu, disk_len = %llu, "
  231. "bytes_left = %llu, flags = %s, compress_type = %d, "
  232. "refs = %d",
  233. show_root_type(__entry->root_objectid),
  234. (unsigned long long)__entry->ino,
  235. (unsigned long long)__entry->file_offset,
  236. (unsigned long long)__entry->start,
  237. (unsigned long long)__entry->len,
  238. (unsigned long long)__entry->disk_len,
  239. (unsigned long long)__entry->bytes_left,
  240. show_ordered_flags(__entry->flags),
  241. __entry->compress_type, __entry->refs)
  242. );
  243. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
  244. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  245. TP_ARGS(inode, ordered)
  246. );
  247. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
  248. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  249. TP_ARGS(inode, ordered)
  250. );
  251. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
  252. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  253. TP_ARGS(inode, ordered)
  254. );
  255. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
  256. TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
  257. TP_ARGS(inode, ordered)
  258. );
  259. DECLARE_EVENT_CLASS(btrfs__writepage,
  260. TP_PROTO(struct page *page, struct inode *inode,
  261. struct writeback_control *wbc),
  262. TP_ARGS(page, inode, wbc),
  263. TP_STRUCT__entry_btrfs(
  264. __field( ino_t, ino )
  265. __field( pgoff_t, index )
  266. __field( long, nr_to_write )
  267. __field( long, pages_skipped )
  268. __field( loff_t, range_start )
  269. __field( loff_t, range_end )
  270. __field( char, for_kupdate )
  271. __field( char, for_reclaim )
  272. __field( char, range_cyclic )
  273. __field( pgoff_t, writeback_index )
  274. __field( u64, root_objectid )
  275. ),
  276. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  277. __entry->ino = inode->i_ino;
  278. __entry->index = page->index;
  279. __entry->nr_to_write = wbc->nr_to_write;
  280. __entry->pages_skipped = wbc->pages_skipped;
  281. __entry->range_start = wbc->range_start;
  282. __entry->range_end = wbc->range_end;
  283. __entry->for_kupdate = wbc->for_kupdate;
  284. __entry->for_reclaim = wbc->for_reclaim;
  285. __entry->range_cyclic = wbc->range_cyclic;
  286. __entry->writeback_index = inode->i_mapping->writeback_index;
  287. __entry->root_objectid =
  288. BTRFS_I(inode)->root->root_key.objectid;
  289. ),
  290. TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, "
  291. "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
  292. "range_end = %llu, for_kupdate = %d, "
  293. "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
  294. show_root_type(__entry->root_objectid),
  295. (unsigned long)__entry->ino, __entry->index,
  296. __entry->nr_to_write, __entry->pages_skipped,
  297. __entry->range_start, __entry->range_end,
  298. __entry->for_kupdate,
  299. __entry->for_reclaim, __entry->range_cyclic,
  300. (unsigned long)__entry->writeback_index)
  301. );
  302. DEFINE_EVENT(btrfs__writepage, __extent_writepage,
  303. TP_PROTO(struct page *page, struct inode *inode,
  304. struct writeback_control *wbc),
  305. TP_ARGS(page, inode, wbc)
  306. );
  307. TRACE_EVENT(btrfs_writepage_end_io_hook,
  308. TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
  309. TP_ARGS(page, start, end, uptodate),
  310. TP_STRUCT__entry_btrfs(
  311. __field( ino_t, ino )
  312. __field( pgoff_t, index )
  313. __field( u64, start )
  314. __field( u64, end )
  315. __field( int, uptodate )
  316. __field( u64, root_objectid )
  317. ),
  318. TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
  319. __entry->ino = page->mapping->host->i_ino;
  320. __entry->index = page->index;
  321. __entry->start = start;
  322. __entry->end = end;
  323. __entry->uptodate = uptodate;
  324. __entry->root_objectid =
  325. BTRFS_I(page->mapping->host)->root->root_key.objectid;
  326. ),
  327. TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
  328. "end = %llu, uptodate = %d",
  329. show_root_type(__entry->root_objectid),
  330. (unsigned long)__entry->ino, (unsigned long)__entry->index,
  331. (unsigned long long)__entry->start,
  332. (unsigned long long)__entry->end, __entry->uptodate)
  333. );
  334. TRACE_EVENT(btrfs_sync_file,
  335. TP_PROTO(struct file *file, int datasync),
  336. TP_ARGS(file, datasync),
  337. TP_STRUCT__entry_btrfs(
  338. __field( ino_t, ino )
  339. __field( ino_t, parent )
  340. __field( int, datasync )
  341. __field( u64, root_objectid )
  342. ),
  343. TP_fast_assign(
  344. struct dentry *dentry = file->f_path.dentry;
  345. struct inode *inode = d_inode(dentry);
  346. TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
  347. __entry->ino = inode->i_ino;
  348. __entry->parent = d_inode(dentry->d_parent)->i_ino;
  349. __entry->datasync = datasync;
  350. __entry->root_objectid =
  351. BTRFS_I(inode)->root->root_key.objectid;
  352. ),
  353. TP_printk_btrfs("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
  354. show_root_type(__entry->root_objectid),
  355. (unsigned long)__entry->ino, (unsigned long)__entry->parent,
  356. __entry->datasync)
  357. );
  358. TRACE_EVENT(btrfs_sync_fs,
  359. TP_PROTO(struct btrfs_fs_info *fs_info, int wait),
  360. TP_ARGS(fs_info, wait),
  361. TP_STRUCT__entry_btrfs(
  362. __field( int, wait )
  363. ),
  364. TP_fast_assign_btrfs(fs_info,
  365. __entry->wait = wait;
  366. ),
  367. TP_printk_btrfs("wait = %d", __entry->wait)
  368. );
  369. TRACE_EVENT(btrfs_add_block_group,
  370. TP_PROTO(struct btrfs_fs_info *fs_info,
  371. struct btrfs_block_group_cache *block_group, int create),
  372. TP_ARGS(fs_info, block_group, create),
  373. TP_STRUCT__entry(
  374. __array( u8, fsid, BTRFS_UUID_SIZE )
  375. __field( u64, offset )
  376. __field( u64, size )
  377. __field( u64, flags )
  378. __field( u64, bytes_used )
  379. __field( u64, bytes_super )
  380. __field( int, create )
  381. ),
  382. TP_fast_assign(
  383. memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
  384. __entry->offset = block_group->key.objectid;
  385. __entry->size = block_group->key.offset;
  386. __entry->flags = block_group->flags;
  387. __entry->bytes_used =
  388. btrfs_block_group_used(&block_group->item);
  389. __entry->bytes_super = block_group->bytes_super;
  390. __entry->create = create;
  391. ),
  392. TP_printk("%pU: block_group offset = %llu, size = %llu, "
  393. "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, "
  394. "create = %d", __entry->fsid,
  395. (unsigned long long)__entry->offset,
  396. (unsigned long long)__entry->size,
  397. (unsigned long long)__entry->flags,
  398. __print_flags((unsigned long)__entry->flags, "|",
  399. BTRFS_GROUP_FLAGS),
  400. (unsigned long long)__entry->bytes_used,
  401. (unsigned long long)__entry->bytes_super, __entry->create)
  402. );
  403. #define show_ref_action(action) \
  404. __print_symbolic(action, \
  405. { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
  406. { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
  407. { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
  408. { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
  409. DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
  410. TP_PROTO(struct btrfs_fs_info *fs_info,
  411. struct btrfs_delayed_ref_node *ref,
  412. struct btrfs_delayed_tree_ref *full_ref,
  413. int action),
  414. TP_ARGS(fs_info, ref, full_ref, action),
  415. TP_STRUCT__entry_btrfs(
  416. __field( u64, bytenr )
  417. __field( u64, num_bytes )
  418. __field( int, action )
  419. __field( u64, parent )
  420. __field( u64, ref_root )
  421. __field( int, level )
  422. __field( int, type )
  423. __field( u64, seq )
  424. ),
  425. TP_fast_assign_btrfs(fs_info,
  426. __entry->bytenr = ref->bytenr;
  427. __entry->num_bytes = ref->num_bytes;
  428. __entry->action = action;
  429. __entry->parent = full_ref->parent;
  430. __entry->ref_root = full_ref->root;
  431. __entry->level = full_ref->level;
  432. __entry->type = ref->type;
  433. __entry->seq = ref->seq;
  434. ),
  435. TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
  436. "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
  437. "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. __entry->level, show_ref_type(__entry->type),
  444. (unsigned long long)__entry->seq)
  445. );
  446. DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
  447. TP_PROTO(struct btrfs_fs_info *fs_info,
  448. struct btrfs_delayed_ref_node *ref,
  449. struct btrfs_delayed_tree_ref *full_ref,
  450. int action),
  451. TP_ARGS(fs_info, ref, full_ref, action)
  452. );
  453. DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
  454. TP_PROTO(struct btrfs_fs_info *fs_info,
  455. struct btrfs_delayed_ref_node *ref,
  456. struct btrfs_delayed_tree_ref *full_ref,
  457. int action),
  458. TP_ARGS(fs_info, ref, full_ref, action)
  459. );
  460. DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
  461. TP_PROTO(struct btrfs_fs_info *fs_info,
  462. struct btrfs_delayed_ref_node *ref,
  463. struct btrfs_delayed_data_ref *full_ref,
  464. int action),
  465. TP_ARGS(fs_info, ref, full_ref, action),
  466. TP_STRUCT__entry_btrfs(
  467. __field( u64, bytenr )
  468. __field( u64, num_bytes )
  469. __field( int, action )
  470. __field( u64, parent )
  471. __field( u64, ref_root )
  472. __field( u64, owner )
  473. __field( u64, offset )
  474. __field( int, type )
  475. __field( u64, seq )
  476. ),
  477. TP_fast_assign_btrfs(fs_info,
  478. __entry->bytenr = ref->bytenr;
  479. __entry->num_bytes = ref->num_bytes;
  480. __entry->action = action;
  481. __entry->parent = full_ref->parent;
  482. __entry->ref_root = full_ref->root;
  483. __entry->owner = full_ref->objectid;
  484. __entry->offset = full_ref->offset;
  485. __entry->type = ref->type;
  486. __entry->seq = ref->seq;
  487. ),
  488. TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
  489. "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
  490. "offset = %llu, type = %s, seq = %llu",
  491. (unsigned long long)__entry->bytenr,
  492. (unsigned long long)__entry->num_bytes,
  493. show_ref_action(__entry->action),
  494. show_root_type(__entry->parent),
  495. show_root_type(__entry->ref_root),
  496. (unsigned long long)__entry->owner,
  497. (unsigned long long)__entry->offset,
  498. show_ref_type(__entry->type),
  499. (unsigned long long)__entry->seq)
  500. );
  501. DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
  502. TP_PROTO(struct btrfs_fs_info *fs_info,
  503. struct btrfs_delayed_ref_node *ref,
  504. struct btrfs_delayed_data_ref *full_ref,
  505. int action),
  506. TP_ARGS(fs_info, ref, full_ref, action)
  507. );
  508. DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
  509. TP_PROTO(struct btrfs_fs_info *fs_info,
  510. struct btrfs_delayed_ref_node *ref,
  511. struct btrfs_delayed_data_ref *full_ref,
  512. int action),
  513. TP_ARGS(fs_info, ref, full_ref, action)
  514. );
  515. DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
  516. TP_PROTO(struct btrfs_fs_info *fs_info,
  517. struct btrfs_delayed_ref_node *ref,
  518. struct btrfs_delayed_ref_head *head_ref,
  519. int action),
  520. TP_ARGS(fs_info, ref, head_ref, action),
  521. TP_STRUCT__entry_btrfs(
  522. __field( u64, bytenr )
  523. __field( u64, num_bytes )
  524. __field( int, action )
  525. __field( int, is_data )
  526. ),
  527. TP_fast_assign_btrfs(fs_info,
  528. __entry->bytenr = ref->bytenr;
  529. __entry->num_bytes = ref->num_bytes;
  530. __entry->action = action;
  531. __entry->is_data = head_ref->is_data;
  532. ),
  533. TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
  534. (unsigned long long)__entry->bytenr,
  535. (unsigned long long)__entry->num_bytes,
  536. show_ref_action(__entry->action),
  537. __entry->is_data)
  538. );
  539. DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
  540. TP_PROTO(struct btrfs_fs_info *fs_info,
  541. struct btrfs_delayed_ref_node *ref,
  542. struct btrfs_delayed_ref_head *head_ref,
  543. int action),
  544. TP_ARGS(fs_info, ref, head_ref, action)
  545. );
  546. DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
  547. TP_PROTO(struct btrfs_fs_info *fs_info,
  548. struct btrfs_delayed_ref_node *ref,
  549. struct btrfs_delayed_ref_head *head_ref,
  550. int action),
  551. TP_ARGS(fs_info, ref, head_ref, action)
  552. );
  553. #define show_chunk_type(type) \
  554. __print_flags(type, "|", \
  555. { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
  556. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  557. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  558. { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
  559. { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
  560. { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
  561. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  562. { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
  563. { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
  564. DECLARE_EVENT_CLASS(btrfs__chunk,
  565. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  566. u64 offset, u64 size),
  567. TP_ARGS(root, map, offset, size),
  568. TP_STRUCT__entry_btrfs(
  569. __field( int, num_stripes )
  570. __field( u64, type )
  571. __field( int, sub_stripes )
  572. __field( u64, offset )
  573. __field( u64, size )
  574. __field( u64, root_objectid )
  575. ),
  576. TP_fast_assign_btrfs(root->fs_info,
  577. __entry->num_stripes = map->num_stripes;
  578. __entry->type = map->type;
  579. __entry->sub_stripes = map->sub_stripes;
  580. __entry->offset = offset;
  581. __entry->size = size;
  582. __entry->root_objectid = root->root_key.objectid;
  583. ),
  584. TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, "
  585. "num_stripes = %d, sub_stripes = %d, type = %s",
  586. show_root_type(__entry->root_objectid),
  587. (unsigned long long)__entry->offset,
  588. (unsigned long long)__entry->size,
  589. __entry->num_stripes, __entry->sub_stripes,
  590. show_chunk_type(__entry->type))
  591. );
  592. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
  593. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  594. u64 offset, u64 size),
  595. TP_ARGS(root, map, offset, size)
  596. );
  597. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
  598. TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
  599. u64 offset, u64 size),
  600. TP_ARGS(root, map, offset, size)
  601. );
  602. TRACE_EVENT(btrfs_cow_block,
  603. TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
  604. struct extent_buffer *cow),
  605. TP_ARGS(root, buf, cow),
  606. TP_STRUCT__entry_btrfs(
  607. __field( u64, root_objectid )
  608. __field( u64, buf_start )
  609. __field( int, refs )
  610. __field( u64, cow_start )
  611. __field( int, buf_level )
  612. __field( int, cow_level )
  613. ),
  614. TP_fast_assign_btrfs(root->fs_info,
  615. __entry->root_objectid = root->root_key.objectid;
  616. __entry->buf_start = buf->start;
  617. __entry->refs = atomic_read(&buf->refs);
  618. __entry->cow_start = cow->start;
  619. __entry->buf_level = btrfs_header_level(buf);
  620. __entry->cow_level = btrfs_header_level(cow);
  621. ),
  622. TP_printk_btrfs("root = %llu(%s), refs = %d, orig_buf = %llu "
  623. "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
  624. show_root_type(__entry->root_objectid),
  625. __entry->refs,
  626. (unsigned long long)__entry->buf_start,
  627. __entry->buf_level,
  628. (unsigned long long)__entry->cow_start,
  629. __entry->cow_level)
  630. );
  631. TRACE_EVENT(btrfs_space_reservation,
  632. TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
  633. u64 bytes, int reserve),
  634. TP_ARGS(fs_info, type, val, bytes, reserve),
  635. TP_STRUCT__entry_btrfs(
  636. __string( type, type )
  637. __field( u64, val )
  638. __field( u64, bytes )
  639. __field( int, reserve )
  640. ),
  641. TP_fast_assign_btrfs(fs_info,
  642. __assign_str(type, type);
  643. __entry->val = val;
  644. __entry->bytes = bytes;
  645. __entry->reserve = reserve;
  646. ),
  647. TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
  648. __entry->reserve ? "reserve" : "release",
  649. __entry->bytes)
  650. );
  651. #define show_flush_action(action) \
  652. __print_symbolic(action, \
  653. { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
  654. { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
  655. { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
  656. TRACE_EVENT(btrfs_trigger_flush,
  657. TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
  658. int flush, char *reason),
  659. TP_ARGS(fs_info, flags, bytes, flush, reason),
  660. TP_STRUCT__entry(
  661. __array( u8, fsid, BTRFS_UUID_SIZE )
  662. __field( u64, flags )
  663. __field( u64, bytes )
  664. __field( int, flush )
  665. __string( reason, reason )
  666. ),
  667. TP_fast_assign(
  668. memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
  669. __entry->flags = flags;
  670. __entry->bytes = bytes;
  671. __entry->flush = flush;
  672. __assign_str(reason, reason)
  673. ),
  674. TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu",
  675. __entry->fsid, __get_str(reason), __entry->flush,
  676. show_flush_action(__entry->flush),
  677. (unsigned long long)__entry->flags,
  678. __print_flags((unsigned long)__entry->flags, "|",
  679. BTRFS_GROUP_FLAGS),
  680. (unsigned long long)__entry->bytes)
  681. );
  682. #define show_flush_state(state) \
  683. __print_symbolic(state, \
  684. { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
  685. { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
  686. { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
  687. { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
  688. { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
  689. { COMMIT_TRANS, "COMMIT_TRANS"})
  690. TRACE_EVENT(btrfs_flush_space,
  691. TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
  692. u64 orig_bytes, int state, int ret),
  693. TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
  694. TP_STRUCT__entry(
  695. __array( u8, fsid, BTRFS_UUID_SIZE )
  696. __field( u64, flags )
  697. __field( u64, num_bytes )
  698. __field( u64, orig_bytes )
  699. __field( int, state )
  700. __field( int, ret )
  701. ),
  702. TP_fast_assign(
  703. memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
  704. __entry->flags = flags;
  705. __entry->num_bytes = num_bytes;
  706. __entry->orig_bytes = orig_bytes;
  707. __entry->state = state;
  708. __entry->ret = ret;
  709. ),
  710. TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, "
  711. "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state,
  712. show_flush_state(__entry->state),
  713. (unsigned long long)__entry->flags,
  714. __print_flags((unsigned long)__entry->flags, "|",
  715. BTRFS_GROUP_FLAGS),
  716. (unsigned long long)__entry->num_bytes,
  717. (unsigned long long)__entry->orig_bytes, __entry->ret)
  718. );
  719. DECLARE_EVENT_CLASS(btrfs__reserved_extent,
  720. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  721. TP_ARGS(root, start, len),
  722. TP_STRUCT__entry_btrfs(
  723. __field( u64, root_objectid )
  724. __field( u64, start )
  725. __field( u64, len )
  726. ),
  727. TP_fast_assign_btrfs(root->fs_info,
  728. __entry->root_objectid = root->root_key.objectid;
  729. __entry->start = start;
  730. __entry->len = len;
  731. ),
  732. TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu",
  733. show_root_type(__entry->root_objectid),
  734. (unsigned long long)__entry->start,
  735. (unsigned long long)__entry->len)
  736. );
  737. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
  738. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  739. TP_ARGS(root, start, len)
  740. );
  741. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
  742. TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
  743. TP_ARGS(root, start, len)
  744. );
  745. TRACE_EVENT(find_free_extent,
  746. TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
  747. u64 data),
  748. TP_ARGS(root, num_bytes, empty_size, data),
  749. TP_STRUCT__entry_btrfs(
  750. __field( u64, root_objectid )
  751. __field( u64, num_bytes )
  752. __field( u64, empty_size )
  753. __field( u64, data )
  754. ),
  755. TP_fast_assign_btrfs(root->fs_info,
  756. __entry->root_objectid = root->root_key.objectid;
  757. __entry->num_bytes = num_bytes;
  758. __entry->empty_size = empty_size;
  759. __entry->data = data;
  760. ),
  761. TP_printk_btrfs("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
  762. "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
  763. __entry->num_bytes, __entry->empty_size, __entry->data,
  764. __print_flags((unsigned long)__entry->data, "|",
  765. BTRFS_GROUP_FLAGS))
  766. );
  767. DECLARE_EVENT_CLASS(btrfs__reserve_extent,
  768. TP_PROTO(struct btrfs_root *root,
  769. struct btrfs_block_group_cache *block_group, u64 start,
  770. u64 len),
  771. TP_ARGS(root, block_group, start, len),
  772. TP_STRUCT__entry_btrfs(
  773. __field( u64, root_objectid )
  774. __field( u64, bg_objectid )
  775. __field( u64, flags )
  776. __field( u64, start )
  777. __field( u64, len )
  778. ),
  779. TP_fast_assign_btrfs(root->fs_info,
  780. __entry->root_objectid = root->root_key.objectid;
  781. __entry->bg_objectid = block_group->key.objectid;
  782. __entry->flags = block_group->flags;
  783. __entry->start = start;
  784. __entry->len = len;
  785. ),
  786. TP_printk_btrfs("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
  787. "start = %Lu, len = %Lu",
  788. show_root_type(__entry->root_objectid), __entry->bg_objectid,
  789. __entry->flags, __print_flags((unsigned long)__entry->flags,
  790. "|", BTRFS_GROUP_FLAGS),
  791. __entry->start, __entry->len)
  792. );
  793. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
  794. TP_PROTO(struct btrfs_root *root,
  795. struct btrfs_block_group_cache *block_group, u64 start,
  796. u64 len),
  797. TP_ARGS(root, block_group, start, len)
  798. );
  799. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
  800. TP_PROTO(struct btrfs_root *root,
  801. struct btrfs_block_group_cache *block_group, u64 start,
  802. u64 len),
  803. TP_ARGS(root, block_group, start, len)
  804. );
  805. TRACE_EVENT(btrfs_find_cluster,
  806. TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
  807. u64 bytes, u64 empty_size, u64 min_bytes),
  808. TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
  809. TP_STRUCT__entry_btrfs(
  810. __field( u64, bg_objectid )
  811. __field( u64, flags )
  812. __field( u64, start )
  813. __field( u64, bytes )
  814. __field( u64, empty_size )
  815. __field( u64, min_bytes )
  816. ),
  817. TP_fast_assign_btrfs(block_group->fs_info,
  818. __entry->bg_objectid = block_group->key.objectid;
  819. __entry->flags = block_group->flags;
  820. __entry->start = start;
  821. __entry->bytes = bytes;
  822. __entry->empty_size = empty_size;
  823. __entry->min_bytes = min_bytes;
  824. ),
  825. TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
  826. " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
  827. __entry->flags,
  828. __print_flags((unsigned long)__entry->flags, "|",
  829. BTRFS_GROUP_FLAGS), __entry->start,
  830. __entry->bytes, __entry->empty_size, __entry->min_bytes)
  831. );
  832. TRACE_EVENT(btrfs_failed_cluster_setup,
  833. TP_PROTO(struct btrfs_block_group_cache *block_group),
  834. TP_ARGS(block_group),
  835. TP_STRUCT__entry_btrfs(
  836. __field( u64, bg_objectid )
  837. ),
  838. TP_fast_assign_btrfs(block_group->fs_info,
  839. __entry->bg_objectid = block_group->key.objectid;
  840. ),
  841. TP_printk_btrfs("block_group = %Lu", __entry->bg_objectid)
  842. );
  843. TRACE_EVENT(btrfs_setup_cluster,
  844. TP_PROTO(struct btrfs_block_group_cache *block_group,
  845. struct btrfs_free_cluster *cluster, u64 size, int bitmap),
  846. TP_ARGS(block_group, cluster, size, bitmap),
  847. TP_STRUCT__entry_btrfs(
  848. __field( u64, bg_objectid )
  849. __field( u64, flags )
  850. __field( u64, start )
  851. __field( u64, max_size )
  852. __field( u64, size )
  853. __field( int, bitmap )
  854. ),
  855. TP_fast_assign_btrfs(block_group->fs_info,
  856. __entry->bg_objectid = block_group->key.objectid;
  857. __entry->flags = block_group->flags;
  858. __entry->start = cluster->window_start;
  859. __entry->max_size = cluster->max_size;
  860. __entry->size = size;
  861. __entry->bitmap = bitmap;
  862. ),
  863. TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
  864. "size = %Lu, max_size = %Lu, bitmap = %d",
  865. __entry->bg_objectid,
  866. __entry->flags,
  867. __print_flags((unsigned long)__entry->flags, "|",
  868. BTRFS_GROUP_FLAGS), __entry->start,
  869. __entry->size, __entry->max_size, __entry->bitmap)
  870. );
  871. struct extent_state;
  872. TRACE_EVENT(alloc_extent_state,
  873. TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
  874. TP_ARGS(state, mask, IP),
  875. TP_STRUCT__entry(
  876. __field(struct extent_state *, state)
  877. __field(gfp_t, mask)
  878. __field(unsigned long, ip)
  879. ),
  880. TP_fast_assign(
  881. __entry->state = state,
  882. __entry->mask = mask,
  883. __entry->ip = IP
  884. ),
  885. TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
  886. show_gfp_flags(__entry->mask), (void *)__entry->ip)
  887. );
  888. TRACE_EVENT(free_extent_state,
  889. TP_PROTO(struct extent_state *state, unsigned long IP),
  890. TP_ARGS(state, IP),
  891. TP_STRUCT__entry(
  892. __field(struct extent_state *, state)
  893. __field(unsigned long, ip)
  894. ),
  895. TP_fast_assign(
  896. __entry->state = state,
  897. __entry->ip = IP
  898. ),
  899. TP_printk(" state=%p; caller = %pS", __entry->state,
  900. (void *)__entry->ip)
  901. );
  902. DECLARE_EVENT_CLASS(btrfs__work,
  903. TP_PROTO(struct btrfs_work *work),
  904. TP_ARGS(work),
  905. TP_STRUCT__entry_btrfs(
  906. __field( void *, work )
  907. __field( void *, wq )
  908. __field( void *, func )
  909. __field( void *, ordered_func )
  910. __field( void *, ordered_free )
  911. __field( void *, normal_work )
  912. ),
  913. TP_fast_assign_btrfs(btrfs_work_owner(work),
  914. __entry->work = work;
  915. __entry->wq = work->wq;
  916. __entry->func = work->func;
  917. __entry->ordered_func = work->ordered_func;
  918. __entry->ordered_free = work->ordered_free;
  919. __entry->normal_work = &work->normal_work;
  920. ),
  921. TP_printk_btrfs("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
  922. " ordered_free=%p",
  923. __entry->work, __entry->normal_work, __entry->wq,
  924. __entry->func, __entry->ordered_func, __entry->ordered_free)
  925. );
  926. /*
  927. * For situiations when the work is freed, we pass fs_info and a tag that that
  928. * matches address of the work structure so it can be paired with the
  929. * scheduling event.
  930. */
  931. DECLARE_EVENT_CLASS(btrfs__work__done,
  932. TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
  933. TP_ARGS(fs_info, wtag),
  934. TP_STRUCT__entry_btrfs(
  935. __field( void *, wtag )
  936. ),
  937. TP_fast_assign_btrfs(fs_info,
  938. __entry->wtag = wtag;
  939. ),
  940. TP_printk_btrfs("work->%p", __entry->wtag)
  941. );
  942. DEFINE_EVENT(btrfs__work, btrfs_work_queued,
  943. TP_PROTO(struct btrfs_work *work),
  944. TP_ARGS(work)
  945. );
  946. DEFINE_EVENT(btrfs__work, btrfs_work_sched,
  947. TP_PROTO(struct btrfs_work *work),
  948. TP_ARGS(work)
  949. );
  950. DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
  951. TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
  952. TP_ARGS(fs_info, wtag)
  953. );
  954. DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
  955. TP_PROTO(struct btrfs_work *work),
  956. TP_ARGS(work)
  957. );
  958. DECLARE_EVENT_CLASS(btrfs__workqueue,
  959. TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
  960. TP_ARGS(wq, name, high),
  961. TP_STRUCT__entry_btrfs(
  962. __field( void *, wq )
  963. __string( name, name )
  964. __field( int , high )
  965. ),
  966. TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
  967. __entry->wq = wq;
  968. __assign_str(name, name);
  969. __entry->high = high;
  970. ),
  971. TP_printk_btrfs("name=%s%s, wq=%p", __get_str(name),
  972. __print_flags(__entry->high, "",
  973. {(WQ_HIGHPRI), "-high"}),
  974. __entry->wq)
  975. );
  976. DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
  977. TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
  978. TP_ARGS(wq, name, high)
  979. );
  980. DECLARE_EVENT_CLASS(btrfs__workqueue_done,
  981. TP_PROTO(struct __btrfs_workqueue *wq),
  982. TP_ARGS(wq),
  983. TP_STRUCT__entry_btrfs(
  984. __field( void *, wq )
  985. ),
  986. TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
  987. __entry->wq = wq;
  988. ),
  989. TP_printk_btrfs("wq=%p", __entry->wq)
  990. );
  991. DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
  992. TP_PROTO(struct __btrfs_workqueue *wq),
  993. TP_ARGS(wq)
  994. );
  995. DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
  996. TP_PROTO(struct inode *inode, u64 free_reserved),
  997. TP_ARGS(inode, free_reserved),
  998. TP_STRUCT__entry_btrfs(
  999. __field( u64, rootid )
  1000. __field( unsigned long, ino )
  1001. __field( u64, free_reserved )
  1002. ),
  1003. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  1004. __entry->rootid = BTRFS_I(inode)->root->objectid;
  1005. __entry->ino = inode->i_ino;
  1006. __entry->free_reserved = free_reserved;
  1007. ),
  1008. TP_printk_btrfs("rootid=%llu, ino=%lu, free_reserved=%llu",
  1009. __entry->rootid, __entry->ino, __entry->free_reserved)
  1010. );
  1011. DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
  1012. TP_PROTO(struct inode *inode, u64 free_reserved),
  1013. TP_ARGS(inode, free_reserved)
  1014. );
  1015. DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
  1016. TP_PROTO(struct inode *inode, u64 free_reserved),
  1017. TP_ARGS(inode, free_reserved)
  1018. );
  1019. #define BTRFS_QGROUP_OPERATIONS \
  1020. { QGROUP_RESERVE, "reserve" }, \
  1021. { QGROUP_RELEASE, "release" }, \
  1022. { QGROUP_FREE, "free" }
  1023. DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
  1024. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  1025. TP_ARGS(inode, start, len, reserved, op),
  1026. TP_STRUCT__entry_btrfs(
  1027. __field( u64, rootid )
  1028. __field( unsigned long, ino )
  1029. __field( u64, start )
  1030. __field( u64, len )
  1031. __field( u64, reserved )
  1032. __field( int, op )
  1033. ),
  1034. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  1035. __entry->rootid = BTRFS_I(inode)->root->objectid;
  1036. __entry->ino = inode->i_ino;
  1037. __entry->start = start;
  1038. __entry->len = len;
  1039. __entry->reserved = reserved;
  1040. __entry->op = op;
  1041. ),
  1042. TP_printk_btrfs("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
  1043. __entry->rootid, __entry->ino, __entry->start, __entry->len,
  1044. __entry->reserved,
  1045. __print_flags((unsigned long)__entry->op, "",
  1046. BTRFS_QGROUP_OPERATIONS)
  1047. )
  1048. );
  1049. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
  1050. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  1051. TP_ARGS(inode, start, len, reserved, op)
  1052. );
  1053. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
  1054. TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
  1055. TP_ARGS(inode, start, len, reserved, op)
  1056. );
  1057. DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
  1058. TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
  1059. TP_ARGS(fs_info, ref_root, reserved),
  1060. TP_STRUCT__entry_btrfs(
  1061. __field( u64, ref_root )
  1062. __field( u64, reserved )
  1063. ),
  1064. TP_fast_assign_btrfs(fs_info,
  1065. __entry->ref_root = ref_root;
  1066. __entry->reserved = reserved;
  1067. ),
  1068. TP_printk_btrfs("root=%llu, reserved=%llu, op=free",
  1069. __entry->ref_root, __entry->reserved)
  1070. );
  1071. DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
  1072. TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
  1073. TP_ARGS(fs_info, ref_root, reserved)
  1074. );
  1075. DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
  1076. TP_PROTO(struct btrfs_fs_info *fs_info,
  1077. struct btrfs_qgroup_extent_record *rec),
  1078. TP_ARGS(fs_info, rec),
  1079. TP_STRUCT__entry_btrfs(
  1080. __field( u64, bytenr )
  1081. __field( u64, num_bytes )
  1082. ),
  1083. TP_fast_assign_btrfs(fs_info,
  1084. __entry->bytenr = rec->bytenr,
  1085. __entry->num_bytes = rec->num_bytes;
  1086. ),
  1087. TP_printk_btrfs("bytenr = %llu, num_bytes = %llu",
  1088. (unsigned long long)__entry->bytenr,
  1089. (unsigned long long)__entry->num_bytes)
  1090. );
  1091. DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
  1092. TP_PROTO(struct btrfs_fs_info *fs_info,
  1093. struct btrfs_qgroup_extent_record *rec),
  1094. TP_ARGS(fs_info, rec)
  1095. );
  1096. DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_insert_dirty_extent,
  1097. TP_PROTO(struct btrfs_fs_info *fs_info,
  1098. struct btrfs_qgroup_extent_record *rec),
  1099. TP_ARGS(fs_info, rec)
  1100. );
  1101. TRACE_EVENT(btrfs_qgroup_account_extent,
  1102. TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr,
  1103. u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
  1104. TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
  1105. TP_STRUCT__entry_btrfs(
  1106. __field( u64, bytenr )
  1107. __field( u64, num_bytes )
  1108. __field( u64, nr_old_roots )
  1109. __field( u64, nr_new_roots )
  1110. ),
  1111. TP_fast_assign_btrfs(fs_info,
  1112. __entry->bytenr = bytenr;
  1113. __entry->num_bytes = num_bytes;
  1114. __entry->nr_old_roots = nr_old_roots;
  1115. __entry->nr_new_roots = nr_new_roots;
  1116. ),
  1117. TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
  1118. "nr_new_roots = %llu",
  1119. __entry->bytenr,
  1120. __entry->num_bytes,
  1121. __entry->nr_old_roots,
  1122. __entry->nr_new_roots)
  1123. );
  1124. TRACE_EVENT(qgroup_update_counters,
  1125. TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid,
  1126. u64 cur_old_count, u64 cur_new_count),
  1127. TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
  1128. TP_STRUCT__entry_btrfs(
  1129. __field( u64, qgid )
  1130. __field( u64, cur_old_count )
  1131. __field( u64, cur_new_count )
  1132. ),
  1133. TP_fast_assign_btrfs(fs_info,
  1134. __entry->qgid = qgid;
  1135. __entry->cur_old_count = cur_old_count;
  1136. __entry->cur_new_count = cur_new_count;
  1137. ),
  1138. TP_printk_btrfs("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
  1139. __entry->qgid,
  1140. __entry->cur_old_count,
  1141. __entry->cur_new_count)
  1142. );
  1143. #endif /* _TRACE_BTRFS_H */
  1144. /* This part must be outside protection */
  1145. #include <trace/define_trace.h>