btrfs.h 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM btrfs
  4. #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_BTRFS_H
  6. #include <linux/writeback.h>
  7. #include <linux/tracepoint.h>
  8. #include <trace/events/mmflags.h>
  9. struct btrfs_root;
  10. struct btrfs_fs_info;
  11. struct btrfs_inode;
  12. struct extent_map;
  13. struct btrfs_file_extent_item;
  14. struct btrfs_ordered_extent;
  15. struct btrfs_delayed_ref_node;
  16. struct btrfs_delayed_tree_ref;
  17. struct btrfs_delayed_data_ref;
  18. struct btrfs_delayed_ref_head;
  19. struct btrfs_block_group_cache;
  20. struct btrfs_free_cluster;
  21. struct map_lookup;
  22. struct extent_buffer;
  23. struct btrfs_work;
  24. struct __btrfs_workqueue;
  25. struct btrfs_qgroup_extent_record;
  26. struct btrfs_qgroup;
  27. struct prelim_ref;
  28. TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
  29. TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
  30. TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
  31. TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
  32. TRACE_DEFINE_ENUM(ALLOC_CHUNK);
  33. TRACE_DEFINE_ENUM(COMMIT_TRANS);
  34. #define show_ref_type(type) \
  35. __print_symbolic(type, \
  36. { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
  37. { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
  38. { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
  39. { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
  40. { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
  41. #define __show_root_type(obj) \
  42. __print_symbolic_u64(obj, \
  43. { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
  44. { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
  45. { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
  46. { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
  47. { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
  48. { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
  49. { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
  50. { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
  51. { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
  52. { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
  53. { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
  54. { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
  55. { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
  56. #define show_root_type(obj) \
  57. obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
  58. (obj >= BTRFS_ROOT_TREE_OBJECTID && \
  59. obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
  60. #define show_fi_type(type) \
  61. __print_symbolic(type, \
  62. { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
  63. { BTRFS_FILE_EXTENT_REG, "REG" }, \
  64. { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
  65. #define show_qgroup_rsv_type(type) \
  66. __print_symbolic(type, \
  67. { BTRFS_QGROUP_RSV_DATA, "DATA" }, \
  68. { BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" }, \
  69. { BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" })
  70. #define BTRFS_GROUP_FLAGS \
  71. { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
  72. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  73. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  74. { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
  75. { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
  76. { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
  77. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  78. { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
  79. { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
  80. #define BTRFS_FSID_SIZE 16
  81. #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
  82. #define TP_fast_assign_fsid(fs_info) \
  83. memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE)
  84. #define TP_STRUCT__entry_btrfs(args...) \
  85. TP_STRUCT__entry( \
  86. TP_STRUCT__entry_fsid \
  87. args)
  88. #define TP_fast_assign_btrfs(fs_info, args...) \
  89. TP_fast_assign( \
  90. TP_fast_assign_fsid(fs_info); \
  91. args)
  92. #define TP_printk_btrfs(fmt, args...) \
  93. TP_printk("%pU: " fmt, __entry->fsid, args)
  94. TRACE_EVENT(btrfs_transaction_commit,
  95. TP_PROTO(const struct btrfs_root *root),
  96. TP_ARGS(root),
  97. TP_STRUCT__entry_btrfs(
  98. __field( u64, generation )
  99. __field( u64, root_objectid )
  100. ),
  101. TP_fast_assign_btrfs(root->fs_info,
  102. __entry->generation = root->fs_info->generation;
  103. __entry->root_objectid = root->root_key.objectid;
  104. ),
  105. TP_printk_btrfs("root=%llu(%s) gen=%llu",
  106. show_root_type(__entry->root_objectid),
  107. __entry->generation)
  108. );
  109. DECLARE_EVENT_CLASS(btrfs__inode,
  110. TP_PROTO(const struct inode *inode),
  111. TP_ARGS(inode),
  112. TP_STRUCT__entry_btrfs(
  113. __field( u64, ino )
  114. __field( blkcnt_t, blocks )
  115. __field( u64, disk_i_size )
  116. __field( u64, generation )
  117. __field( u64, last_trans )
  118. __field( u64, logged_trans )
  119. __field( u64, root_objectid )
  120. ),
  121. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  122. __entry->ino = btrfs_ino(BTRFS_I(inode));
  123. __entry->blocks = inode->i_blocks;
  124. __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
  125. __entry->generation = BTRFS_I(inode)->generation;
  126. __entry->last_trans = BTRFS_I(inode)->last_trans;
  127. __entry->logged_trans = BTRFS_I(inode)->logged_trans;
  128. __entry->root_objectid =
  129. BTRFS_I(inode)->root->root_key.objectid;
  130. ),
  131. TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
  132. "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
  133. show_root_type(__entry->root_objectid),
  134. __entry->generation,
  135. __entry->ino,
  136. (unsigned long long)__entry->blocks,
  137. __entry->disk_i_size,
  138. __entry->last_trans,
  139. __entry->logged_trans)
  140. );
  141. DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
  142. TP_PROTO(const struct inode *inode),
  143. TP_ARGS(inode)
  144. );
  145. DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
  146. TP_PROTO(const struct inode *inode),
  147. TP_ARGS(inode)
  148. );
  149. DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
  150. TP_PROTO(const struct inode *inode),
  151. TP_ARGS(inode)
  152. );
  153. #define __show_map_type(type) \
  154. __print_symbolic_u64(type, \
  155. { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
  156. { EXTENT_MAP_HOLE, "HOLE" }, \
  157. { EXTENT_MAP_INLINE, "INLINE" }, \
  158. { EXTENT_MAP_DELALLOC, "DELALLOC" })
  159. #define show_map_type(type) \
  160. type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
  161. #define show_map_flags(flag) \
  162. __print_flags(flag, "|", \
  163. { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
  164. { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
  165. { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
  166. { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
  167. { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
  168. { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
  169. TRACE_EVENT_CONDITION(btrfs_get_extent,
  170. TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
  171. const struct extent_map *map),
  172. TP_ARGS(root, inode, map),
  173. TP_CONDITION(map),
  174. TP_STRUCT__entry_btrfs(
  175. __field( u64, root_objectid )
  176. __field( u64, ino )
  177. __field( u64, start )
  178. __field( u64, len )
  179. __field( u64, orig_start )
  180. __field( u64, block_start )
  181. __field( u64, block_len )
  182. __field( unsigned long, flags )
  183. __field( int, refs )
  184. __field( unsigned int, compress_type )
  185. ),
  186. TP_fast_assign_btrfs(root->fs_info,
  187. __entry->root_objectid = root->root_key.objectid;
  188. __entry->ino = btrfs_ino(inode);
  189. __entry->start = map->start;
  190. __entry->len = map->len;
  191. __entry->orig_start = map->orig_start;
  192. __entry->block_start = map->block_start;
  193. __entry->block_len = map->block_len;
  194. __entry->flags = map->flags;
  195. __entry->refs = refcount_read(&map->refs);
  196. __entry->compress_type = map->compress_type;
  197. ),
  198. TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
  199. "orig_start=%llu block_start=%llu(%s) "
  200. "block_len=%llu flags=%s refs=%u "
  201. "compress_type=%u",
  202. show_root_type(__entry->root_objectid),
  203. __entry->ino,
  204. __entry->start,
  205. __entry->len,
  206. __entry->orig_start,
  207. show_map_type(__entry->block_start),
  208. __entry->block_len,
  209. show_map_flags(__entry->flags),
  210. __entry->refs, __entry->compress_type)
  211. );
  212. TRACE_EVENT(btrfs_handle_em_exist,
  213. TP_PROTO(struct btrfs_fs_info *fs_info,
  214. const struct extent_map *existing, const struct extent_map *map,
  215. u64 start, u64 len),
  216. TP_ARGS(fs_info, existing, map, start, len),
  217. TP_STRUCT__entry_btrfs(
  218. __field( u64, e_start )
  219. __field( u64, e_len )
  220. __field( u64, map_start )
  221. __field( u64, map_len )
  222. __field( u64, start )
  223. __field( u64, len )
  224. ),
  225. TP_fast_assign_btrfs(fs_info,
  226. __entry->e_start = existing->start;
  227. __entry->e_len = existing->len;
  228. __entry->map_start = map->start;
  229. __entry->map_len = map->len;
  230. __entry->start = start;
  231. __entry->len = len;
  232. ),
  233. TP_printk_btrfs("start=%llu len=%llu "
  234. "existing(start=%llu len=%llu) "
  235. "em(start=%llu len=%llu)",
  236. __entry->start,
  237. __entry->len,
  238. __entry->e_start,
  239. __entry->e_len,
  240. __entry->map_start,
  241. __entry->map_len)
  242. );
  243. /* file extent item */
  244. DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
  245. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  246. struct btrfs_file_extent_item *fi, u64 start),
  247. TP_ARGS(bi, l, fi, start),
  248. TP_STRUCT__entry_btrfs(
  249. __field( u64, root_obj )
  250. __field( u64, ino )
  251. __field( loff_t, isize )
  252. __field( u64, disk_isize )
  253. __field( u64, num_bytes )
  254. __field( u64, ram_bytes )
  255. __field( u64, disk_bytenr )
  256. __field( u64, disk_num_bytes )
  257. __field( u64, extent_offset )
  258. __field( u8, extent_type )
  259. __field( u8, compression )
  260. __field( u64, extent_start )
  261. __field( u64, extent_end )
  262. ),
  263. TP_fast_assign_btrfs(bi->root->fs_info,
  264. __entry->root_obj = bi->root->objectid;
  265. __entry->ino = btrfs_ino(bi);
  266. __entry->isize = bi->vfs_inode.i_size;
  267. __entry->disk_isize = bi->disk_i_size;
  268. __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
  269. __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
  270. __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
  271. __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
  272. __entry->extent_offset = btrfs_file_extent_offset(l, fi);
  273. __entry->extent_type = btrfs_file_extent_type(l, fi);
  274. __entry->compression = btrfs_file_extent_compression(l, fi);
  275. __entry->extent_start = start;
  276. __entry->extent_end = (start + __entry->num_bytes);
  277. ),
  278. TP_printk_btrfs(
  279. "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
  280. "file extent range=[%llu %llu] "
  281. "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
  282. "disk_num_bytes=%llu extent_offset=%llu type=%s "
  283. "compression=%u",
  284. show_root_type(__entry->root_obj), __entry->ino,
  285. __entry->isize,
  286. __entry->disk_isize, __entry->extent_start,
  287. __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
  288. __entry->disk_bytenr, __entry->disk_num_bytes,
  289. __entry->extent_offset, show_fi_type(__entry->extent_type),
  290. __entry->compression)
  291. );
  292. DECLARE_EVENT_CLASS(
  293. btrfs__file_extent_item_inline,
  294. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  295. struct btrfs_file_extent_item *fi, int slot, u64 start),
  296. TP_ARGS(bi, l, fi, slot, start),
  297. TP_STRUCT__entry_btrfs(
  298. __field( u64, root_obj )
  299. __field( u64, ino )
  300. __field( loff_t, isize )
  301. __field( u64, disk_isize )
  302. __field( u8, extent_type )
  303. __field( u8, compression )
  304. __field( u64, extent_start )
  305. __field( u64, extent_end )
  306. ),
  307. TP_fast_assign_btrfs(
  308. bi->root->fs_info,
  309. __entry->root_obj = bi->root->objectid;
  310. __entry->ino = btrfs_ino(bi);
  311. __entry->isize = bi->vfs_inode.i_size;
  312. __entry->disk_isize = bi->disk_i_size;
  313. __entry->extent_type = btrfs_file_extent_type(l, fi);
  314. __entry->compression = btrfs_file_extent_compression(l, fi);
  315. __entry->extent_start = start;
  316. __entry->extent_end = (start + btrfs_file_extent_ram_bytes(l, fi));
  317. ),
  318. TP_printk_btrfs(
  319. "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
  320. "file extent range=[%llu %llu] "
  321. "extent_type=%s compression=%u",
  322. show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
  323. __entry->disk_isize, __entry->extent_start,
  324. __entry->extent_end, show_fi_type(__entry->extent_type),
  325. __entry->compression)
  326. );
  327. DEFINE_EVENT(
  328. btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
  329. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  330. struct btrfs_file_extent_item *fi, u64 start),
  331. TP_ARGS(bi, l, fi, start)
  332. );
  333. DEFINE_EVENT(
  334. btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
  335. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  336. struct btrfs_file_extent_item *fi, u64 start),
  337. TP_ARGS(bi, l, fi, start)
  338. );
  339. DEFINE_EVENT(
  340. btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
  341. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  342. struct btrfs_file_extent_item *fi, int slot, u64 start),
  343. TP_ARGS(bi, l, fi, slot, start)
  344. );
  345. DEFINE_EVENT(
  346. btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
  347. TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
  348. struct btrfs_file_extent_item *fi, int slot, u64 start),
  349. TP_ARGS(bi, l, fi, slot, start)
  350. );
  351. #define show_ordered_flags(flags) \
  352. __print_flags(flags, "|", \
  353. { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
  354. { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
  355. { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
  356. { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
  357. { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
  358. { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
  359. { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
  360. { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
  361. { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
  362. DECLARE_EVENT_CLASS(btrfs__ordered_extent,
  363. TP_PROTO(const struct inode *inode,
  364. const struct btrfs_ordered_extent *ordered),
  365. TP_ARGS(inode, ordered),
  366. TP_STRUCT__entry_btrfs(
  367. __field( u64, ino )
  368. __field( u64, file_offset )
  369. __field( u64, start )
  370. __field( u64, len )
  371. __field( u64, disk_len )
  372. __field( u64, bytes_left )
  373. __field( unsigned long, flags )
  374. __field( int, compress_type )
  375. __field( int, refs )
  376. __field( u64, root_objectid )
  377. __field( u64, truncated_len )
  378. ),
  379. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  380. __entry->ino = btrfs_ino(BTRFS_I(inode));
  381. __entry->file_offset = ordered->file_offset;
  382. __entry->start = ordered->start;
  383. __entry->len = ordered->len;
  384. __entry->disk_len = ordered->disk_len;
  385. __entry->bytes_left = ordered->bytes_left;
  386. __entry->flags = ordered->flags;
  387. __entry->compress_type = ordered->compress_type;
  388. __entry->refs = refcount_read(&ordered->refs);
  389. __entry->root_objectid =
  390. BTRFS_I(inode)->root->root_key.objectid;
  391. __entry->truncated_len = ordered->truncated_len;
  392. ),
  393. TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
  394. "start=%llu len=%llu disk_len=%llu "
  395. "truncated_len=%llu "
  396. "bytes_left=%llu flags=%s compress_type=%d "
  397. "refs=%d",
  398. show_root_type(__entry->root_objectid),
  399. __entry->ino,
  400. __entry->file_offset,
  401. __entry->start,
  402. __entry->len,
  403. __entry->disk_len,
  404. __entry->truncated_len,
  405. __entry->bytes_left,
  406. show_ordered_flags(__entry->flags),
  407. __entry->compress_type, __entry->refs)
  408. );
  409. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
  410. TP_PROTO(const struct inode *inode,
  411. const struct btrfs_ordered_extent *ordered),
  412. TP_ARGS(inode, ordered)
  413. );
  414. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
  415. TP_PROTO(const struct inode *inode,
  416. const struct btrfs_ordered_extent *ordered),
  417. TP_ARGS(inode, ordered)
  418. );
  419. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
  420. TP_PROTO(const struct inode *inode,
  421. const struct btrfs_ordered_extent *ordered),
  422. TP_ARGS(inode, ordered)
  423. );
  424. DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
  425. TP_PROTO(const struct inode *inode,
  426. const struct btrfs_ordered_extent *ordered),
  427. TP_ARGS(inode, ordered)
  428. );
  429. DECLARE_EVENT_CLASS(btrfs__writepage,
  430. TP_PROTO(const struct page *page, const struct inode *inode,
  431. const struct writeback_control *wbc),
  432. TP_ARGS(page, inode, wbc),
  433. TP_STRUCT__entry_btrfs(
  434. __field( u64, ino )
  435. __field( pgoff_t, index )
  436. __field( long, nr_to_write )
  437. __field( long, pages_skipped )
  438. __field( loff_t, range_start )
  439. __field( loff_t, range_end )
  440. __field( char, for_kupdate )
  441. __field( char, for_reclaim )
  442. __field( char, range_cyclic )
  443. __field( pgoff_t, writeback_index )
  444. __field( u64, root_objectid )
  445. ),
  446. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  447. __entry->ino = btrfs_ino(BTRFS_I(inode));
  448. __entry->index = page->index;
  449. __entry->nr_to_write = wbc->nr_to_write;
  450. __entry->pages_skipped = wbc->pages_skipped;
  451. __entry->range_start = wbc->range_start;
  452. __entry->range_end = wbc->range_end;
  453. __entry->for_kupdate = wbc->for_kupdate;
  454. __entry->for_reclaim = wbc->for_reclaim;
  455. __entry->range_cyclic = wbc->range_cyclic;
  456. __entry->writeback_index = inode->i_mapping->writeback_index;
  457. __entry->root_objectid =
  458. BTRFS_I(inode)->root->root_key.objectid;
  459. ),
  460. TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
  461. "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
  462. "range_end=%llu for_kupdate=%d "
  463. "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
  464. show_root_type(__entry->root_objectid),
  465. __entry->ino, __entry->index,
  466. __entry->nr_to_write, __entry->pages_skipped,
  467. __entry->range_start, __entry->range_end,
  468. __entry->for_kupdate,
  469. __entry->for_reclaim, __entry->range_cyclic,
  470. (unsigned long)__entry->writeback_index)
  471. );
  472. DEFINE_EVENT(btrfs__writepage, __extent_writepage,
  473. TP_PROTO(const struct page *page, const struct inode *inode,
  474. const struct writeback_control *wbc),
  475. TP_ARGS(page, inode, wbc)
  476. );
  477. TRACE_EVENT(btrfs_writepage_end_io_hook,
  478. TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
  479. TP_ARGS(page, start, end, uptodate),
  480. TP_STRUCT__entry_btrfs(
  481. __field( u64, ino )
  482. __field( pgoff_t, index )
  483. __field( u64, start )
  484. __field( u64, end )
  485. __field( int, uptodate )
  486. __field( u64, root_objectid )
  487. ),
  488. TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
  489. __entry->ino = btrfs_ino(BTRFS_I(page->mapping->host));
  490. __entry->index = page->index;
  491. __entry->start = start;
  492. __entry->end = end;
  493. __entry->uptodate = uptodate;
  494. __entry->root_objectid =
  495. BTRFS_I(page->mapping->host)->root->root_key.objectid;
  496. ),
  497. TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu "
  498. "end=%llu uptodate=%d",
  499. show_root_type(__entry->root_objectid),
  500. __entry->ino, (unsigned long)__entry->index,
  501. __entry->start,
  502. __entry->end, __entry->uptodate)
  503. );
  504. TRACE_EVENT(btrfs_sync_file,
  505. TP_PROTO(const struct file *file, int datasync),
  506. TP_ARGS(file, datasync),
  507. TP_STRUCT__entry_btrfs(
  508. __field( u64, ino )
  509. __field( u64, parent )
  510. __field( int, datasync )
  511. __field( u64, root_objectid )
  512. ),
  513. TP_fast_assign(
  514. const struct dentry *dentry = file->f_path.dentry;
  515. const struct inode *inode = d_inode(dentry);
  516. TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
  517. __entry->ino = btrfs_ino(BTRFS_I(inode));
  518. __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
  519. __entry->datasync = datasync;
  520. __entry->root_objectid =
  521. BTRFS_I(inode)->root->root_key.objectid;
  522. ),
  523. TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
  524. show_root_type(__entry->root_objectid),
  525. __entry->ino,
  526. __entry->parent,
  527. __entry->datasync)
  528. );
  529. TRACE_EVENT(btrfs_sync_fs,
  530. TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
  531. TP_ARGS(fs_info, wait),
  532. TP_STRUCT__entry_btrfs(
  533. __field( int, wait )
  534. ),
  535. TP_fast_assign_btrfs(fs_info,
  536. __entry->wait = wait;
  537. ),
  538. TP_printk_btrfs("wait=%d", __entry->wait)
  539. );
  540. TRACE_EVENT(btrfs_add_block_group,
  541. TP_PROTO(const struct btrfs_fs_info *fs_info,
  542. const struct btrfs_block_group_cache *block_group, int create),
  543. TP_ARGS(fs_info, block_group, create),
  544. TP_STRUCT__entry_btrfs(
  545. __field( u64, offset )
  546. __field( u64, size )
  547. __field( u64, flags )
  548. __field( u64, bytes_used )
  549. __field( u64, bytes_super )
  550. __field( int, create )
  551. ),
  552. TP_fast_assign_btrfs(fs_info,
  553. __entry->offset = block_group->key.objectid;
  554. __entry->size = block_group->key.offset;
  555. __entry->flags = block_group->flags;
  556. __entry->bytes_used =
  557. btrfs_block_group_used(&block_group->item);
  558. __entry->bytes_super = block_group->bytes_super;
  559. __entry->create = create;
  560. ),
  561. TP_printk_btrfs("block_group offset=%llu size=%llu "
  562. "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
  563. "create=%d",
  564. __entry->offset,
  565. __entry->size,
  566. __entry->flags,
  567. __print_flags((unsigned long)__entry->flags, "|",
  568. BTRFS_GROUP_FLAGS),
  569. __entry->bytes_used,
  570. __entry->bytes_super, __entry->create)
  571. );
  572. #define show_ref_action(action) \
  573. __print_symbolic(action, \
  574. { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
  575. { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
  576. { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
  577. { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
  578. DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
  579. TP_PROTO(const struct btrfs_fs_info *fs_info,
  580. const struct btrfs_delayed_ref_node *ref,
  581. const struct btrfs_delayed_tree_ref *full_ref,
  582. int action),
  583. TP_ARGS(fs_info, ref, full_ref, action),
  584. TP_STRUCT__entry_btrfs(
  585. __field( u64, bytenr )
  586. __field( u64, num_bytes )
  587. __field( int, action )
  588. __field( u64, parent )
  589. __field( u64, ref_root )
  590. __field( int, level )
  591. __field( int, type )
  592. __field( u64, seq )
  593. ),
  594. TP_fast_assign_btrfs(fs_info,
  595. __entry->bytenr = ref->bytenr;
  596. __entry->num_bytes = ref->num_bytes;
  597. __entry->action = action;
  598. __entry->parent = full_ref->parent;
  599. __entry->ref_root = full_ref->root;
  600. __entry->level = full_ref->level;
  601. __entry->type = ref->type;
  602. __entry->seq = ref->seq;
  603. ),
  604. TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
  605. "parent=%llu(%s) ref_root=%llu(%s) level=%d "
  606. "type=%s seq=%llu",
  607. __entry->bytenr,
  608. __entry->num_bytes,
  609. show_ref_action(__entry->action),
  610. show_root_type(__entry->parent),
  611. show_root_type(__entry->ref_root),
  612. __entry->level, show_ref_type(__entry->type),
  613. __entry->seq)
  614. );
  615. DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
  616. TP_PROTO(const struct btrfs_fs_info *fs_info,
  617. const struct btrfs_delayed_ref_node *ref,
  618. const struct btrfs_delayed_tree_ref *full_ref,
  619. int action),
  620. TP_ARGS(fs_info, ref, full_ref, action)
  621. );
  622. DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
  623. TP_PROTO(const struct btrfs_fs_info *fs_info,
  624. const struct btrfs_delayed_ref_node *ref,
  625. const struct btrfs_delayed_tree_ref *full_ref,
  626. int action),
  627. TP_ARGS(fs_info, ref, full_ref, action)
  628. );
  629. DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
  630. TP_PROTO(const struct btrfs_fs_info *fs_info,
  631. const struct btrfs_delayed_ref_node *ref,
  632. const struct btrfs_delayed_data_ref *full_ref,
  633. int action),
  634. TP_ARGS(fs_info, ref, full_ref, action),
  635. TP_STRUCT__entry_btrfs(
  636. __field( u64, bytenr )
  637. __field( u64, num_bytes )
  638. __field( int, action )
  639. __field( u64, parent )
  640. __field( u64, ref_root )
  641. __field( u64, owner )
  642. __field( u64, offset )
  643. __field( int, type )
  644. __field( u64, seq )
  645. ),
  646. TP_fast_assign_btrfs(fs_info,
  647. __entry->bytenr = ref->bytenr;
  648. __entry->num_bytes = ref->num_bytes;
  649. __entry->action = action;
  650. __entry->parent = full_ref->parent;
  651. __entry->ref_root = full_ref->root;
  652. __entry->owner = full_ref->objectid;
  653. __entry->offset = full_ref->offset;
  654. __entry->type = ref->type;
  655. __entry->seq = ref->seq;
  656. ),
  657. TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
  658. "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
  659. "offset=%llu type=%s seq=%llu",
  660. __entry->bytenr,
  661. __entry->num_bytes,
  662. show_ref_action(__entry->action),
  663. show_root_type(__entry->parent),
  664. show_root_type(__entry->ref_root),
  665. __entry->owner,
  666. __entry->offset,
  667. show_ref_type(__entry->type),
  668. __entry->seq)
  669. );
  670. DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
  671. TP_PROTO(const struct btrfs_fs_info *fs_info,
  672. const struct btrfs_delayed_ref_node *ref,
  673. const struct btrfs_delayed_data_ref *full_ref,
  674. int action),
  675. TP_ARGS(fs_info, ref, full_ref, action)
  676. );
  677. DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
  678. TP_PROTO(const struct btrfs_fs_info *fs_info,
  679. const struct btrfs_delayed_ref_node *ref,
  680. const struct btrfs_delayed_data_ref *full_ref,
  681. int action),
  682. TP_ARGS(fs_info, ref, full_ref, action)
  683. );
  684. DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
  685. TP_PROTO(const struct btrfs_fs_info *fs_info,
  686. const struct btrfs_delayed_ref_head *head_ref,
  687. int action),
  688. TP_ARGS(fs_info, head_ref, action),
  689. TP_STRUCT__entry_btrfs(
  690. __field( u64, bytenr )
  691. __field( u64, num_bytes )
  692. __field( int, action )
  693. __field( int, is_data )
  694. ),
  695. TP_fast_assign_btrfs(fs_info,
  696. __entry->bytenr = head_ref->bytenr;
  697. __entry->num_bytes = head_ref->num_bytes;
  698. __entry->action = action;
  699. __entry->is_data = head_ref->is_data;
  700. ),
  701. TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
  702. __entry->bytenr,
  703. __entry->num_bytes,
  704. show_ref_action(__entry->action),
  705. __entry->is_data)
  706. );
  707. DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
  708. TP_PROTO(const struct btrfs_fs_info *fs_info,
  709. const struct btrfs_delayed_ref_head *head_ref,
  710. int action),
  711. TP_ARGS(fs_info, head_ref, action)
  712. );
  713. DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
  714. TP_PROTO(const struct btrfs_fs_info *fs_info,
  715. const struct btrfs_delayed_ref_head *head_ref,
  716. int action),
  717. TP_ARGS(fs_info, head_ref, action)
  718. );
  719. #define show_chunk_type(type) \
  720. __print_flags(type, "|", \
  721. { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
  722. { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
  723. { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
  724. { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
  725. { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
  726. { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
  727. { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
  728. { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
  729. { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
  730. DECLARE_EVENT_CLASS(btrfs__chunk,
  731. TP_PROTO(const struct btrfs_fs_info *fs_info,
  732. const struct map_lookup *map, u64 offset, u64 size),
  733. TP_ARGS(fs_info, map, offset, size),
  734. TP_STRUCT__entry_btrfs(
  735. __field( int, num_stripes )
  736. __field( u64, type )
  737. __field( int, sub_stripes )
  738. __field( u64, offset )
  739. __field( u64, size )
  740. __field( u64, root_objectid )
  741. ),
  742. TP_fast_assign_btrfs(fs_info,
  743. __entry->num_stripes = map->num_stripes;
  744. __entry->type = map->type;
  745. __entry->sub_stripes = map->sub_stripes;
  746. __entry->offset = offset;
  747. __entry->size = size;
  748. __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
  749. ),
  750. TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
  751. "num_stripes=%d sub_stripes=%d type=%s",
  752. show_root_type(__entry->root_objectid),
  753. __entry->offset,
  754. __entry->size,
  755. __entry->num_stripes, __entry->sub_stripes,
  756. show_chunk_type(__entry->type))
  757. );
  758. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
  759. TP_PROTO(const struct btrfs_fs_info *fs_info,
  760. const struct map_lookup *map, u64 offset, u64 size),
  761. TP_ARGS(fs_info, map, offset, size)
  762. );
  763. DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
  764. TP_PROTO(const struct btrfs_fs_info *fs_info,
  765. const struct map_lookup *map, u64 offset, u64 size),
  766. TP_ARGS(fs_info, map, offset, size)
  767. );
  768. TRACE_EVENT(btrfs_cow_block,
  769. TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
  770. const struct extent_buffer *cow),
  771. TP_ARGS(root, buf, cow),
  772. TP_STRUCT__entry_btrfs(
  773. __field( u64, root_objectid )
  774. __field( u64, buf_start )
  775. __field( int, refs )
  776. __field( u64, cow_start )
  777. __field( int, buf_level )
  778. __field( int, cow_level )
  779. ),
  780. TP_fast_assign_btrfs(root->fs_info,
  781. __entry->root_objectid = root->root_key.objectid;
  782. __entry->buf_start = buf->start;
  783. __entry->refs = atomic_read(&buf->refs);
  784. __entry->cow_start = cow->start;
  785. __entry->buf_level = btrfs_header_level(buf);
  786. __entry->cow_level = btrfs_header_level(cow);
  787. ),
  788. TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
  789. "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
  790. show_root_type(__entry->root_objectid),
  791. __entry->refs,
  792. __entry->buf_start,
  793. __entry->buf_level,
  794. __entry->cow_start,
  795. __entry->cow_level)
  796. );
  797. TRACE_EVENT(btrfs_space_reservation,
  798. TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
  799. u64 bytes, int reserve),
  800. TP_ARGS(fs_info, type, val, bytes, reserve),
  801. TP_STRUCT__entry_btrfs(
  802. __string( type, type )
  803. __field( u64, val )
  804. __field( u64, bytes )
  805. __field( int, reserve )
  806. ),
  807. TP_fast_assign_btrfs(fs_info,
  808. __assign_str(type, type);
  809. __entry->val = val;
  810. __entry->bytes = bytes;
  811. __entry->reserve = reserve;
  812. ),
  813. TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
  814. __entry->reserve ? "reserve" : "release",
  815. __entry->bytes)
  816. );
  817. #define show_flush_action(action) \
  818. __print_symbolic(action, \
  819. { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
  820. { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
  821. { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
  822. TRACE_EVENT(btrfs_trigger_flush,
  823. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
  824. int flush, char *reason),
  825. TP_ARGS(fs_info, flags, bytes, flush, reason),
  826. TP_STRUCT__entry_btrfs(
  827. __field( u64, flags )
  828. __field( u64, bytes )
  829. __field( int, flush )
  830. __string( reason, reason )
  831. ),
  832. TP_fast_assign_btrfs(fs_info,
  833. __entry->flags = flags;
  834. __entry->bytes = bytes;
  835. __entry->flush = flush;
  836. __assign_str(reason, reason)
  837. ),
  838. TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
  839. __get_str(reason), __entry->flush,
  840. show_flush_action(__entry->flush),
  841. __entry->flags,
  842. __print_flags((unsigned long)__entry->flags, "|",
  843. BTRFS_GROUP_FLAGS),
  844. __entry->bytes)
  845. );
  846. #define show_flush_state(state) \
  847. __print_symbolic(state, \
  848. { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
  849. { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
  850. { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
  851. { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
  852. { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
  853. { COMMIT_TRANS, "COMMIT_TRANS"})
  854. TRACE_EVENT(btrfs_flush_space,
  855. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
  856. int state, int ret),
  857. TP_ARGS(fs_info, flags, num_bytes, state, ret),
  858. TP_STRUCT__entry_btrfs(
  859. __field( u64, flags )
  860. __field( u64, num_bytes )
  861. __field( int, state )
  862. __field( int, ret )
  863. ),
  864. TP_fast_assign_btrfs(fs_info,
  865. __entry->flags = flags;
  866. __entry->num_bytes = num_bytes;
  867. __entry->state = state;
  868. __entry->ret = ret;
  869. ),
  870. TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
  871. __entry->state,
  872. show_flush_state(__entry->state),
  873. __entry->flags,
  874. __print_flags((unsigned long)__entry->flags, "|",
  875. BTRFS_GROUP_FLAGS),
  876. __entry->num_bytes, __entry->ret)
  877. );
  878. DECLARE_EVENT_CLASS(btrfs__reserved_extent,
  879. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
  880. TP_ARGS(fs_info, start, len),
  881. TP_STRUCT__entry_btrfs(
  882. __field( u64, start )
  883. __field( u64, len )
  884. ),
  885. TP_fast_assign_btrfs(fs_info,
  886. __entry->start = start;
  887. __entry->len = len;
  888. ),
  889. TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
  890. show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
  891. __entry->start,
  892. __entry->len)
  893. );
  894. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
  895. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
  896. TP_ARGS(fs_info, start, len)
  897. );
  898. DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
  899. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
  900. TP_ARGS(fs_info, start, len)
  901. );
  902. TRACE_EVENT(find_free_extent,
  903. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
  904. u64 empty_size, u64 data),
  905. TP_ARGS(fs_info, num_bytes, empty_size, data),
  906. TP_STRUCT__entry_btrfs(
  907. __field( u64, num_bytes )
  908. __field( u64, empty_size )
  909. __field( u64, data )
  910. ),
  911. TP_fast_assign_btrfs(fs_info,
  912. __entry->num_bytes = num_bytes;
  913. __entry->empty_size = empty_size;
  914. __entry->data = data;
  915. ),
  916. TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
  917. show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
  918. __entry->num_bytes, __entry->empty_size, __entry->data,
  919. __print_flags((unsigned long)__entry->data, "|",
  920. BTRFS_GROUP_FLAGS))
  921. );
  922. DECLARE_EVENT_CLASS(btrfs__reserve_extent,
  923. TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
  924. u64 len),
  925. TP_ARGS(block_group, start, len),
  926. TP_STRUCT__entry_btrfs(
  927. __field( u64, bg_objectid )
  928. __field( u64, flags )
  929. __field( u64, start )
  930. __field( u64, len )
  931. ),
  932. TP_fast_assign_btrfs(block_group->fs_info,
  933. __entry->bg_objectid = block_group->key.objectid;
  934. __entry->flags = block_group->flags;
  935. __entry->start = start;
  936. __entry->len = len;
  937. ),
  938. TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
  939. "start=%llu len=%llu",
  940. show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
  941. __entry->bg_objectid,
  942. __entry->flags, __print_flags((unsigned long)__entry->flags,
  943. "|", BTRFS_GROUP_FLAGS),
  944. __entry->start, __entry->len)
  945. );
  946. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
  947. TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
  948. u64 len),
  949. TP_ARGS(block_group, start, len)
  950. );
  951. DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
  952. TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
  953. u64 len),
  954. TP_ARGS(block_group, start, len)
  955. );
  956. TRACE_EVENT(btrfs_find_cluster,
  957. TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
  958. u64 bytes, u64 empty_size, u64 min_bytes),
  959. TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
  960. TP_STRUCT__entry_btrfs(
  961. __field( u64, bg_objectid )
  962. __field( u64, flags )
  963. __field( u64, start )
  964. __field( u64, bytes )
  965. __field( u64, empty_size )
  966. __field( u64, min_bytes )
  967. ),
  968. TP_fast_assign_btrfs(block_group->fs_info,
  969. __entry->bg_objectid = block_group->key.objectid;
  970. __entry->flags = block_group->flags;
  971. __entry->start = start;
  972. __entry->bytes = bytes;
  973. __entry->empty_size = empty_size;
  974. __entry->min_bytes = min_bytes;
  975. ),
  976. TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
  977. "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
  978. __entry->flags,
  979. __print_flags((unsigned long)__entry->flags, "|",
  980. BTRFS_GROUP_FLAGS), __entry->start,
  981. __entry->bytes, __entry->empty_size, __entry->min_bytes)
  982. );
  983. TRACE_EVENT(btrfs_failed_cluster_setup,
  984. TP_PROTO(const struct btrfs_block_group_cache *block_group),
  985. TP_ARGS(block_group),
  986. TP_STRUCT__entry_btrfs(
  987. __field( u64, bg_objectid )
  988. ),
  989. TP_fast_assign_btrfs(block_group->fs_info,
  990. __entry->bg_objectid = block_group->key.objectid;
  991. ),
  992. TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
  993. );
  994. TRACE_EVENT(btrfs_setup_cluster,
  995. TP_PROTO(const struct btrfs_block_group_cache *block_group,
  996. const struct btrfs_free_cluster *cluster,
  997. u64 size, int bitmap),
  998. TP_ARGS(block_group, cluster, size, bitmap),
  999. TP_STRUCT__entry_btrfs(
  1000. __field( u64, bg_objectid )
  1001. __field( u64, flags )
  1002. __field( u64, start )
  1003. __field( u64, max_size )
  1004. __field( u64, size )
  1005. __field( int, bitmap )
  1006. ),
  1007. TP_fast_assign_btrfs(block_group->fs_info,
  1008. __entry->bg_objectid = block_group->key.objectid;
  1009. __entry->flags = block_group->flags;
  1010. __entry->start = cluster->window_start;
  1011. __entry->max_size = cluster->max_size;
  1012. __entry->size = size;
  1013. __entry->bitmap = bitmap;
  1014. ),
  1015. TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
  1016. "size=%llu max_size=%llu bitmap=%d",
  1017. __entry->bg_objectid,
  1018. __entry->flags,
  1019. __print_flags((unsigned long)__entry->flags, "|",
  1020. BTRFS_GROUP_FLAGS), __entry->start,
  1021. __entry->size, __entry->max_size, __entry->bitmap)
  1022. );
  1023. struct extent_state;
  1024. TRACE_EVENT(alloc_extent_state,
  1025. TP_PROTO(const struct extent_state *state,
  1026. gfp_t mask, unsigned long IP),
  1027. TP_ARGS(state, mask, IP),
  1028. TP_STRUCT__entry(
  1029. __field(const struct extent_state *, state)
  1030. __field(gfp_t, mask)
  1031. __field(unsigned long, ip)
  1032. ),
  1033. TP_fast_assign(
  1034. __entry->state = state,
  1035. __entry->mask = mask,
  1036. __entry->ip = IP
  1037. ),
  1038. TP_printk("state=%p mask=%s caller=%pS", __entry->state,
  1039. show_gfp_flags(__entry->mask), (const void *)__entry->ip)
  1040. );
  1041. TRACE_EVENT(free_extent_state,
  1042. TP_PROTO(const struct extent_state *state, unsigned long IP),
  1043. TP_ARGS(state, IP),
  1044. TP_STRUCT__entry(
  1045. __field(const struct extent_state *, state)
  1046. __field(unsigned long, ip)
  1047. ),
  1048. TP_fast_assign(
  1049. __entry->state = state,
  1050. __entry->ip = IP
  1051. ),
  1052. TP_printk("state=%p caller=%pS", __entry->state,
  1053. (const void *)__entry->ip)
  1054. );
  1055. DECLARE_EVENT_CLASS(btrfs__work,
  1056. TP_PROTO(const struct btrfs_work *work),
  1057. TP_ARGS(work),
  1058. TP_STRUCT__entry_btrfs(
  1059. __field( const void *, work )
  1060. __field( const void *, wq )
  1061. __field( const void *, func )
  1062. __field( const void *, ordered_func )
  1063. __field( const void *, ordered_free )
  1064. __field( const void *, normal_work )
  1065. ),
  1066. TP_fast_assign_btrfs(btrfs_work_owner(work),
  1067. __entry->work = work;
  1068. __entry->wq = work->wq;
  1069. __entry->func = work->func;
  1070. __entry->ordered_func = work->ordered_func;
  1071. __entry->ordered_free = work->ordered_free;
  1072. __entry->normal_work = &work->normal_work;
  1073. ),
  1074. TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
  1075. "ordered_free=%p",
  1076. __entry->work, __entry->normal_work, __entry->wq,
  1077. __entry->func, __entry->ordered_func, __entry->ordered_free)
  1078. );
  1079. /*
  1080. * For situiations when the work is freed, we pass fs_info and a tag that that
  1081. * matches address of the work structure so it can be paired with the
  1082. * scheduling event.
  1083. */
  1084. DECLARE_EVENT_CLASS(btrfs__work__done,
  1085. TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
  1086. TP_ARGS(fs_info, wtag),
  1087. TP_STRUCT__entry_btrfs(
  1088. __field( const void *, wtag )
  1089. ),
  1090. TP_fast_assign_btrfs(fs_info,
  1091. __entry->wtag = wtag;
  1092. ),
  1093. TP_printk_btrfs("work->%p", __entry->wtag)
  1094. );
  1095. DEFINE_EVENT(btrfs__work, btrfs_work_queued,
  1096. TP_PROTO(const struct btrfs_work *work),
  1097. TP_ARGS(work)
  1098. );
  1099. DEFINE_EVENT(btrfs__work, btrfs_work_sched,
  1100. TP_PROTO(const struct btrfs_work *work),
  1101. TP_ARGS(work)
  1102. );
  1103. DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
  1104. TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
  1105. TP_ARGS(fs_info, wtag)
  1106. );
  1107. DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
  1108. TP_PROTO(const struct btrfs_work *work),
  1109. TP_ARGS(work)
  1110. );
  1111. DECLARE_EVENT_CLASS(btrfs__workqueue,
  1112. TP_PROTO(const struct __btrfs_workqueue *wq,
  1113. const char *name, int high),
  1114. TP_ARGS(wq, name, high),
  1115. TP_STRUCT__entry_btrfs(
  1116. __field( const void *, wq )
  1117. __string( name, name )
  1118. __field( int , high )
  1119. ),
  1120. TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
  1121. __entry->wq = wq;
  1122. __assign_str(name, name);
  1123. __entry->high = high;
  1124. ),
  1125. TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
  1126. __print_flags(__entry->high, "",
  1127. {(WQ_HIGHPRI), "-high"}),
  1128. __entry->wq)
  1129. );
  1130. DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
  1131. TP_PROTO(const struct __btrfs_workqueue *wq,
  1132. const char *name, int high),
  1133. TP_ARGS(wq, name, high)
  1134. );
  1135. DECLARE_EVENT_CLASS(btrfs__workqueue_done,
  1136. TP_PROTO(const struct __btrfs_workqueue *wq),
  1137. TP_ARGS(wq),
  1138. TP_STRUCT__entry_btrfs(
  1139. __field( const void *, wq )
  1140. ),
  1141. TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
  1142. __entry->wq = wq;
  1143. ),
  1144. TP_printk_btrfs("wq=%p", __entry->wq)
  1145. );
  1146. DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
  1147. TP_PROTO(const struct __btrfs_workqueue *wq),
  1148. TP_ARGS(wq)
  1149. );
  1150. #define BTRFS_QGROUP_OPERATIONS \
  1151. { QGROUP_RESERVE, "reserve" }, \
  1152. { QGROUP_RELEASE, "release" }, \
  1153. { QGROUP_FREE, "free" }
  1154. DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
  1155. TP_PROTO(const struct inode *inode, u64 start, u64 len,
  1156. u64 reserved, int op),
  1157. TP_ARGS(inode, start, len, reserved, op),
  1158. TP_STRUCT__entry_btrfs(
  1159. __field( u64, rootid )
  1160. __field( u64, ino )
  1161. __field( u64, start )
  1162. __field( u64, len )
  1163. __field( u64, reserved )
  1164. __field( int, op )
  1165. ),
  1166. TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
  1167. __entry->rootid = BTRFS_I(inode)->root->objectid;
  1168. __entry->ino = btrfs_ino(BTRFS_I(inode));
  1169. __entry->start = start;
  1170. __entry->len = len;
  1171. __entry->reserved = reserved;
  1172. __entry->op = op;
  1173. ),
  1174. TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
  1175. __entry->rootid, __entry->ino, __entry->start, __entry->len,
  1176. __entry->reserved,
  1177. __print_flags((unsigned long)__entry->op, "",
  1178. BTRFS_QGROUP_OPERATIONS)
  1179. )
  1180. );
  1181. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
  1182. TP_PROTO(const struct inode *inode, u64 start, u64 len,
  1183. u64 reserved, int op),
  1184. TP_ARGS(inode, start, len, reserved, op)
  1185. );
  1186. DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
  1187. TP_PROTO(const struct inode *inode, u64 start, u64 len,
  1188. u64 reserved, int op),
  1189. TP_ARGS(inode, start, len, reserved, op)
  1190. );
  1191. DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
  1192. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1193. u64 ref_root, u64 reserved),
  1194. TP_ARGS(fs_info, ref_root, reserved),
  1195. TP_STRUCT__entry_btrfs(
  1196. __field( u64, ref_root )
  1197. __field( u64, reserved )
  1198. ),
  1199. TP_fast_assign_btrfs(fs_info,
  1200. __entry->ref_root = ref_root;
  1201. __entry->reserved = reserved;
  1202. ),
  1203. TP_printk_btrfs("root=%llu reserved=%llu op=free",
  1204. __entry->ref_root, __entry->reserved)
  1205. );
  1206. DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
  1207. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1208. u64 ref_root, u64 reserved),
  1209. TP_ARGS(fs_info, ref_root, reserved)
  1210. );
  1211. DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
  1212. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1213. const struct btrfs_qgroup_extent_record *rec),
  1214. TP_ARGS(fs_info, rec),
  1215. TP_STRUCT__entry_btrfs(
  1216. __field( u64, bytenr )
  1217. __field( u64, num_bytes )
  1218. ),
  1219. TP_fast_assign_btrfs(fs_info,
  1220. __entry->bytenr = rec->bytenr,
  1221. __entry->num_bytes = rec->num_bytes;
  1222. ),
  1223. TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
  1224. (unsigned long long)__entry->bytenr,
  1225. (unsigned long long)__entry->num_bytes)
  1226. );
  1227. DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
  1228. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1229. const struct btrfs_qgroup_extent_record *rec),
  1230. TP_ARGS(fs_info, rec)
  1231. );
  1232. DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
  1233. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1234. const struct btrfs_qgroup_extent_record *rec),
  1235. TP_ARGS(fs_info, rec)
  1236. );
  1237. TRACE_EVENT(btrfs_qgroup_account_extent,
  1238. TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
  1239. u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
  1240. TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
  1241. nr_new_roots),
  1242. TP_STRUCT__entry_btrfs(
  1243. __field( u64, transid )
  1244. __field( u64, bytenr )
  1245. __field( u64, num_bytes )
  1246. __field( u64, nr_old_roots )
  1247. __field( u64, nr_new_roots )
  1248. ),
  1249. TP_fast_assign_btrfs(fs_info,
  1250. __entry->transid = transid;
  1251. __entry->bytenr = bytenr;
  1252. __entry->num_bytes = num_bytes;
  1253. __entry->nr_old_roots = nr_old_roots;
  1254. __entry->nr_new_roots = nr_new_roots;
  1255. ),
  1256. TP_printk_btrfs(
  1257. "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
  1258. __entry->transid,
  1259. __entry->bytenr,
  1260. __entry->num_bytes,
  1261. __entry->nr_old_roots,
  1262. __entry->nr_new_roots)
  1263. );
  1264. TRACE_EVENT(qgroup_update_counters,
  1265. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1266. struct btrfs_qgroup *qgroup,
  1267. u64 cur_old_count, u64 cur_new_count),
  1268. TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
  1269. TP_STRUCT__entry_btrfs(
  1270. __field( u64, qgid )
  1271. __field( u64, old_rfer )
  1272. __field( u64, old_excl )
  1273. __field( u64, cur_old_count )
  1274. __field( u64, cur_new_count )
  1275. ),
  1276. TP_fast_assign_btrfs(fs_info,
  1277. __entry->qgid = qgroup->qgroupid;
  1278. __entry->old_rfer = qgroup->rfer;
  1279. __entry->old_excl = qgroup->excl;
  1280. __entry->cur_old_count = cur_old_count;
  1281. __entry->cur_new_count = cur_new_count;
  1282. ),
  1283. TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
  1284. __entry->qgid, __entry->old_rfer, __entry->old_excl,
  1285. __entry->cur_old_count, __entry->cur_new_count)
  1286. );
  1287. TRACE_EVENT(qgroup_update_reserve,
  1288. TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
  1289. s64 diff, int type),
  1290. TP_ARGS(fs_info, qgroup, diff, type),
  1291. TP_STRUCT__entry_btrfs(
  1292. __field( u64, qgid )
  1293. __field( u64, cur_reserved )
  1294. __field( s64, diff )
  1295. __field( int, type )
  1296. ),
  1297. TP_fast_assign_btrfs(fs_info,
  1298. __entry->qgid = qgroup->qgroupid;
  1299. __entry->cur_reserved = qgroup->rsv.values[type];
  1300. __entry->diff = diff;
  1301. __entry->type = type;
  1302. ),
  1303. TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
  1304. __entry->qgid, show_qgroup_rsv_type(__entry->type),
  1305. __entry->cur_reserved, __entry->diff)
  1306. );
  1307. TRACE_EVENT(qgroup_meta_reserve,
  1308. TP_PROTO(struct btrfs_root *root, s64 diff, int type),
  1309. TP_ARGS(root, diff, type),
  1310. TP_STRUCT__entry_btrfs(
  1311. __field( u64, refroot )
  1312. __field( s64, diff )
  1313. __field( int, type )
  1314. ),
  1315. TP_fast_assign_btrfs(root->fs_info,
  1316. __entry->refroot = root->objectid;
  1317. __entry->diff = diff;
  1318. __entry->type = type;
  1319. ),
  1320. TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
  1321. show_root_type(__entry->refroot),
  1322. show_qgroup_rsv_type(__entry->type), __entry->diff)
  1323. );
  1324. TRACE_EVENT(qgroup_meta_convert,
  1325. TP_PROTO(struct btrfs_root *root, s64 diff),
  1326. TP_ARGS(root, diff),
  1327. TP_STRUCT__entry_btrfs(
  1328. __field( u64, refroot )
  1329. __field( s64, diff )
  1330. ),
  1331. TP_fast_assign_btrfs(root->fs_info,
  1332. __entry->refroot = root->objectid;
  1333. __entry->diff = diff;
  1334. ),
  1335. TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
  1336. show_root_type(__entry->refroot),
  1337. show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC),
  1338. show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS),
  1339. __entry->diff)
  1340. );
  1341. TRACE_EVENT(qgroup_meta_free_all_pertrans,
  1342. TP_PROTO(struct btrfs_root *root),
  1343. TP_ARGS(root),
  1344. TP_STRUCT__entry_btrfs(
  1345. __field( u64, refroot )
  1346. __field( s64, diff )
  1347. __field( int, type )
  1348. ),
  1349. TP_fast_assign_btrfs(root->fs_info,
  1350. __entry->refroot = root->objectid;
  1351. spin_lock(&root->qgroup_meta_rsv_lock);
  1352. __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans;
  1353. spin_unlock(&root->qgroup_meta_rsv_lock);
  1354. __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS;
  1355. ),
  1356. TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
  1357. show_root_type(__entry->refroot),
  1358. show_qgroup_rsv_type(__entry->type), __entry->diff)
  1359. );
  1360. DECLARE_EVENT_CLASS(btrfs__prelim_ref,
  1361. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1362. const struct prelim_ref *oldref,
  1363. const struct prelim_ref *newref, u64 tree_size),
  1364. TP_ARGS(fs_info, newref, oldref, tree_size),
  1365. TP_STRUCT__entry_btrfs(
  1366. __field( u64, root_id )
  1367. __field( u64, objectid )
  1368. __field( u8, type )
  1369. __field( u64, offset )
  1370. __field( int, level )
  1371. __field( int, old_count )
  1372. __field( u64, parent )
  1373. __field( u64, bytenr )
  1374. __field( int, mod_count )
  1375. __field( u64, tree_size )
  1376. ),
  1377. TP_fast_assign_btrfs(fs_info,
  1378. __entry->root_id = oldref->root_id;
  1379. __entry->objectid = oldref->key_for_search.objectid;
  1380. __entry->type = oldref->key_for_search.type;
  1381. __entry->offset = oldref->key_for_search.offset;
  1382. __entry->level = oldref->level;
  1383. __entry->old_count = oldref->count;
  1384. __entry->parent = oldref->parent;
  1385. __entry->bytenr = oldref->wanted_disk_byte;
  1386. __entry->mod_count = newref ? newref->count : 0;
  1387. __entry->tree_size = tree_size;
  1388. ),
  1389. TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
  1390. __entry->root_id,
  1391. __entry->objectid, __entry->type,
  1392. __entry->offset, __entry->level,
  1393. __entry->old_count, __entry->mod_count,
  1394. __entry->old_count + __entry->mod_count,
  1395. __entry->parent,
  1396. __entry->bytenr,
  1397. __entry->tree_size)
  1398. );
  1399. DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
  1400. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1401. const struct prelim_ref *oldref,
  1402. const struct prelim_ref *newref, u64 tree_size),
  1403. TP_ARGS(fs_info, oldref, newref, tree_size)
  1404. );
  1405. DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
  1406. TP_PROTO(const struct btrfs_fs_info *fs_info,
  1407. const struct prelim_ref *oldref,
  1408. const struct prelim_ref *newref, u64 tree_size),
  1409. TP_ARGS(fs_info, oldref, newref, tree_size)
  1410. );
  1411. TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
  1412. TP_PROTO(struct btrfs_root *root, u64 ino, int mod),
  1413. TP_ARGS(root, ino, mod),
  1414. TP_STRUCT__entry_btrfs(
  1415. __field( u64, root_objectid )
  1416. __field( u64, ino )
  1417. __field( int, mod )
  1418. ),
  1419. TP_fast_assign_btrfs(root->fs_info,
  1420. __entry->root_objectid = root->objectid;
  1421. __entry->ino = ino;
  1422. __entry->mod = mod;
  1423. ),
  1424. TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
  1425. show_root_type(__entry->root_objectid),
  1426. __entry->ino, __entry->mod)
  1427. );
  1428. DECLARE_EVENT_CLASS(btrfs__block_group,
  1429. TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
  1430. TP_ARGS(bg_cache),
  1431. TP_STRUCT__entry_btrfs(
  1432. __field( u64, bytenr )
  1433. __field( u64, len )
  1434. __field( u64, used )
  1435. __field( u64, flags )
  1436. ),
  1437. TP_fast_assign_btrfs(bg_cache->fs_info,
  1438. __entry->bytenr = bg_cache->key.objectid,
  1439. __entry->len = bg_cache->key.offset,
  1440. __entry->used = btrfs_block_group_used(&bg_cache->item);
  1441. __entry->flags = bg_cache->flags;
  1442. ),
  1443. TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
  1444. __entry->bytenr, __entry->len, __entry->used, __entry->flags,
  1445. __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
  1446. );
  1447. DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
  1448. TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
  1449. TP_ARGS(bg_cache)
  1450. );
  1451. DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
  1452. TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
  1453. TP_ARGS(bg_cache)
  1454. );
  1455. DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
  1456. TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
  1457. TP_ARGS(bg_cache)
  1458. );
  1459. #endif /* _TRACE_BTRFS_H */
  1460. /* This part must be outside protection */
  1461. #include <trace/define_trace.h>