trace_gfs2.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM gfs2
  3. #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_GFS2_H
  5. #include <linux/tracepoint.h>
  6. #include <linux/fs.h>
  7. #include <linux/buffer_head.h>
  8. #include <linux/dlmconstants.h>
  9. #include <linux/gfs2_ondisk.h>
  10. #include <linux/writeback.h>
  11. #include <linux/ktime.h>
  12. #include "incore.h"
  13. #include "glock.h"
  14. #include "rgrp.h"
  15. #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
  16. #define glock_trace_name(x) __print_symbolic(x, \
  17. dlm_state_name(IV), \
  18. dlm_state_name(NL), \
  19. dlm_state_name(CR), \
  20. dlm_state_name(CW), \
  21. dlm_state_name(PR), \
  22. dlm_state_name(PW), \
  23. dlm_state_name(EX))
  24. #define block_state_name(x) __print_symbolic(x, \
  25. { GFS2_BLKST_FREE, "free" }, \
  26. { GFS2_BLKST_USED, "used" }, \
  27. { GFS2_BLKST_DINODE, "dinode" }, \
  28. { GFS2_BLKST_UNLINKED, "unlinked" })
  29. #define TRACE_RS_DELETE 0
  30. #define TRACE_RS_TREEDEL 1
  31. #define TRACE_RS_INSERT 2
  32. #define TRACE_RS_CLAIM 3
  33. #define rs_func_name(x) __print_symbolic(x, \
  34. { 0, "del " }, \
  35. { 1, "tdel" }, \
  36. { 2, "ins " }, \
  37. { 3, "clm " })
  38. #define show_glock_flags(flags) __print_flags(flags, "", \
  39. {(1UL << GLF_LOCK), "l" }, \
  40. {(1UL << GLF_DEMOTE), "D" }, \
  41. {(1UL << GLF_PENDING_DEMOTE), "d" }, \
  42. {(1UL << GLF_DEMOTE_IN_PROGRESS), "p" }, \
  43. {(1UL << GLF_DIRTY), "y" }, \
  44. {(1UL << GLF_LFLUSH), "f" }, \
  45. {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \
  46. {(1UL << GLF_REPLY_PENDING), "r" }, \
  47. {(1UL << GLF_INITIAL), "I" }, \
  48. {(1UL << GLF_FROZEN), "F" }, \
  49. {(1UL << GLF_QUEUED), "q" }, \
  50. {(1UL << GLF_LRU), "L" }, \
  51. {(1UL << GLF_OBJECT), "o" }, \
  52. {(1UL << GLF_BLOCKING), "b" })
  53. #ifndef NUMPTY
  54. #define NUMPTY
  55. static inline u8 glock_trace_state(unsigned int state)
  56. {
  57. switch(state) {
  58. case LM_ST_SHARED:
  59. return DLM_LOCK_PR;
  60. case LM_ST_DEFERRED:
  61. return DLM_LOCK_CW;
  62. case LM_ST_EXCLUSIVE:
  63. return DLM_LOCK_EX;
  64. }
  65. return DLM_LOCK_NL;
  66. }
  67. #endif
  68. /* Section 1 - Locking
  69. *
  70. * Objectives:
  71. * Latency: Remote demote request to state change
  72. * Latency: Local lock request to state change
  73. * Latency: State change to lock grant
  74. * Correctness: Ordering of local lock state vs. I/O requests
  75. * Correctness: Responses to remote demote requests
  76. */
  77. /* General glock state change (DLM lock request completes) */
  78. TRACE_EVENT(gfs2_glock_state_change,
  79. TP_PROTO(const struct gfs2_glock *gl, unsigned int new_state),
  80. TP_ARGS(gl, new_state),
  81. TP_STRUCT__entry(
  82. __field( dev_t, dev )
  83. __field( u64, glnum )
  84. __field( u32, gltype )
  85. __field( u8, cur_state )
  86. __field( u8, new_state )
  87. __field( u8, dmt_state )
  88. __field( u8, tgt_state )
  89. __field( unsigned long, flags )
  90. ),
  91. TP_fast_assign(
  92. __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
  93. __entry->glnum = gl->gl_name.ln_number;
  94. __entry->gltype = gl->gl_name.ln_type;
  95. __entry->cur_state = glock_trace_state(gl->gl_state);
  96. __entry->new_state = glock_trace_state(new_state);
  97. __entry->tgt_state = glock_trace_state(gl->gl_target);
  98. __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
  99. __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
  100. ),
  101. TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
  102. MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
  103. (unsigned long long)__entry->glnum,
  104. glock_trace_name(__entry->cur_state),
  105. glock_trace_name(__entry->new_state),
  106. glock_trace_name(__entry->tgt_state),
  107. glock_trace_name(__entry->dmt_state),
  108. show_glock_flags(__entry->flags))
  109. );
  110. /* State change -> unlocked, glock is being deallocated */
  111. TRACE_EVENT(gfs2_glock_put,
  112. TP_PROTO(const struct gfs2_glock *gl),
  113. TP_ARGS(gl),
  114. TP_STRUCT__entry(
  115. __field( dev_t, dev )
  116. __field( u64, glnum )
  117. __field( u32, gltype )
  118. __field( u8, cur_state )
  119. __field( unsigned long, flags )
  120. ),
  121. TP_fast_assign(
  122. __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
  123. __entry->gltype = gl->gl_name.ln_type;
  124. __entry->glnum = gl->gl_name.ln_number;
  125. __entry->cur_state = glock_trace_state(gl->gl_state);
  126. __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
  127. ),
  128. TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
  129. MAJOR(__entry->dev), MINOR(__entry->dev),
  130. __entry->gltype, (unsigned long long)__entry->glnum,
  131. glock_trace_name(__entry->cur_state),
  132. glock_trace_name(DLM_LOCK_IV),
  133. show_glock_flags(__entry->flags))
  134. );
  135. /* Callback (local or remote) requesting lock demotion */
  136. TRACE_EVENT(gfs2_demote_rq,
  137. TP_PROTO(const struct gfs2_glock *gl, bool remote),
  138. TP_ARGS(gl, remote),
  139. TP_STRUCT__entry(
  140. __field( dev_t, dev )
  141. __field( u64, glnum )
  142. __field( u32, gltype )
  143. __field( u8, cur_state )
  144. __field( u8, dmt_state )
  145. __field( unsigned long, flags )
  146. __field( bool, remote )
  147. ),
  148. TP_fast_assign(
  149. __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
  150. __entry->gltype = gl->gl_name.ln_type;
  151. __entry->glnum = gl->gl_name.ln_number;
  152. __entry->cur_state = glock_trace_state(gl->gl_state);
  153. __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
  154. __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
  155. __entry->remote = remote;
  156. ),
  157. TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s %s",
  158. MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
  159. (unsigned long long)__entry->glnum,
  160. glock_trace_name(__entry->cur_state),
  161. glock_trace_name(__entry->dmt_state),
  162. show_glock_flags(__entry->flags),
  163. __entry->remote ? "remote" : "local")
  164. );
  165. /* Promotion/grant of a glock */
  166. TRACE_EVENT(gfs2_promote,
  167. TP_PROTO(const struct gfs2_holder *gh, int first),
  168. TP_ARGS(gh, first),
  169. TP_STRUCT__entry(
  170. __field( dev_t, dev )
  171. __field( u64, glnum )
  172. __field( u32, gltype )
  173. __field( int, first )
  174. __field( u8, state )
  175. ),
  176. TP_fast_assign(
  177. __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
  178. __entry->glnum = gh->gh_gl->gl_name.ln_number;
  179. __entry->gltype = gh->gh_gl->gl_name.ln_type;
  180. __entry->first = first;
  181. __entry->state = glock_trace_state(gh->gh_state);
  182. ),
  183. TP_printk("%u,%u glock %u:%llu promote %s %s",
  184. MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
  185. (unsigned long long)__entry->glnum,
  186. __entry->first ? "first": "other",
  187. glock_trace_name(__entry->state))
  188. );
  189. /* Queue/dequeue a lock request */
  190. TRACE_EVENT(gfs2_glock_queue,
  191. TP_PROTO(const struct gfs2_holder *gh, int queue),
  192. TP_ARGS(gh, queue),
  193. TP_STRUCT__entry(
  194. __field( dev_t, dev )
  195. __field( u64, glnum )
  196. __field( u32, gltype )
  197. __field( int, queue )
  198. __field( u8, state )
  199. ),
  200. TP_fast_assign(
  201. __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
  202. __entry->glnum = gh->gh_gl->gl_name.ln_number;
  203. __entry->gltype = gh->gh_gl->gl_name.ln_type;
  204. __entry->queue = queue;
  205. __entry->state = glock_trace_state(gh->gh_state);
  206. ),
  207. TP_printk("%u,%u glock %u:%llu %squeue %s",
  208. MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
  209. (unsigned long long)__entry->glnum,
  210. __entry->queue ? "" : "de",
  211. glock_trace_name(__entry->state))
  212. );
  213. /* DLM sends a reply to GFS2 */
  214. TRACE_EVENT(gfs2_glock_lock_time,
  215. TP_PROTO(const struct gfs2_glock *gl, s64 tdiff),
  216. TP_ARGS(gl, tdiff),
  217. TP_STRUCT__entry(
  218. __field( dev_t, dev )
  219. __field( u64, glnum )
  220. __field( u32, gltype )
  221. __field( int, status )
  222. __field( char, flags )
  223. __field( s64, tdiff )
  224. __field( u64, srtt )
  225. __field( u64, srttvar )
  226. __field( u64, srttb )
  227. __field( u64, srttvarb )
  228. __field( u64, sirt )
  229. __field( u64, sirtvar )
  230. __field( u64, dcount )
  231. __field( u64, qcount )
  232. ),
  233. TP_fast_assign(
  234. __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
  235. __entry->glnum = gl->gl_name.ln_number;
  236. __entry->gltype = gl->gl_name.ln_type;
  237. __entry->status = gl->gl_lksb.sb_status;
  238. __entry->flags = gl->gl_lksb.sb_flags;
  239. __entry->tdiff = tdiff;
  240. __entry->srtt = gl->gl_stats.stats[GFS2_LKS_SRTT];
  241. __entry->srttvar = gl->gl_stats.stats[GFS2_LKS_SRTTVAR];
  242. __entry->srttb = gl->gl_stats.stats[GFS2_LKS_SRTTB];
  243. __entry->srttvarb = gl->gl_stats.stats[GFS2_LKS_SRTTVARB];
  244. __entry->sirt = gl->gl_stats.stats[GFS2_LKS_SIRT];
  245. __entry->sirtvar = gl->gl_stats.stats[GFS2_LKS_SIRTVAR];
  246. __entry->dcount = gl->gl_stats.stats[GFS2_LKS_DCOUNT];
  247. __entry->qcount = gl->gl_stats.stats[GFS2_LKS_QCOUNT];
  248. ),
  249. TP_printk("%u,%u glock %d:%lld status:%d flags:%02x tdiff:%lld srtt:%lld/%lld srttb:%lld/%lld sirt:%lld/%lld dcnt:%lld qcnt:%lld",
  250. MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
  251. (unsigned long long)__entry->glnum,
  252. __entry->status, __entry->flags,
  253. (long long)__entry->tdiff,
  254. (long long)__entry->srtt,
  255. (long long)__entry->srttvar,
  256. (long long)__entry->srttb,
  257. (long long)__entry->srttvarb,
  258. (long long)__entry->sirt,
  259. (long long)__entry->sirtvar,
  260. (long long)__entry->dcount,
  261. (long long)__entry->qcount)
  262. );
  263. /* Section 2 - Log/journal
  264. *
  265. * Objectives:
  266. * Latency: Log flush time
  267. * Correctness: pin/unpin vs. disk I/O ordering
  268. * Performance: Log usage stats
  269. */
  270. /* Pin/unpin a block in the log */
  271. TRACE_EVENT(gfs2_pin,
  272. TP_PROTO(const struct gfs2_bufdata *bd, int pin),
  273. TP_ARGS(bd, pin),
  274. TP_STRUCT__entry(
  275. __field( dev_t, dev )
  276. __field( int, pin )
  277. __field( u32, len )
  278. __field( sector_t, block )
  279. __field( u64, ino )
  280. ),
  281. TP_fast_assign(
  282. __entry->dev = bd->bd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
  283. __entry->pin = pin;
  284. __entry->len = bd->bd_bh->b_size;
  285. __entry->block = bd->bd_bh->b_blocknr;
  286. __entry->ino = bd->bd_gl->gl_name.ln_number;
  287. ),
  288. TP_printk("%u,%u log %s %llu/%lu inode %llu",
  289. MAJOR(__entry->dev), MINOR(__entry->dev),
  290. __entry->pin ? "pin" : "unpin",
  291. (unsigned long long)__entry->block,
  292. (unsigned long)__entry->len,
  293. (unsigned long long)__entry->ino)
  294. );
  295. /* Flushing the log */
  296. TRACE_EVENT(gfs2_log_flush,
  297. TP_PROTO(const struct gfs2_sbd *sdp, int start),
  298. TP_ARGS(sdp, start),
  299. TP_STRUCT__entry(
  300. __field( dev_t, dev )
  301. __field( int, start )
  302. __field( u64, log_seq )
  303. ),
  304. TP_fast_assign(
  305. __entry->dev = sdp->sd_vfs->s_dev;
  306. __entry->start = start;
  307. __entry->log_seq = sdp->sd_log_sequence;
  308. ),
  309. TP_printk("%u,%u log flush %s %llu",
  310. MAJOR(__entry->dev), MINOR(__entry->dev),
  311. __entry->start ? "start" : "end",
  312. (unsigned long long)__entry->log_seq)
  313. );
  314. /* Reserving/releasing blocks in the log */
  315. TRACE_EVENT(gfs2_log_blocks,
  316. TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
  317. TP_ARGS(sdp, blocks),
  318. TP_STRUCT__entry(
  319. __field( dev_t, dev )
  320. __field( int, blocks )
  321. ),
  322. TP_fast_assign(
  323. __entry->dev = sdp->sd_vfs->s_dev;
  324. __entry->blocks = blocks;
  325. ),
  326. TP_printk("%u,%u log reserve %d", MAJOR(__entry->dev),
  327. MINOR(__entry->dev), __entry->blocks)
  328. );
  329. /* Writing back the AIL */
  330. TRACE_EVENT(gfs2_ail_flush,
  331. TP_PROTO(const struct gfs2_sbd *sdp, const struct writeback_control *wbc, int start),
  332. TP_ARGS(sdp, wbc, start),
  333. TP_STRUCT__entry(
  334. __field( dev_t, dev )
  335. __field( int, start )
  336. __field( int, sync_mode )
  337. __field( long, nr_to_write )
  338. ),
  339. TP_fast_assign(
  340. __entry->dev = sdp->sd_vfs->s_dev;
  341. __entry->start = start;
  342. __entry->sync_mode = wbc->sync_mode;
  343. __entry->nr_to_write = wbc->nr_to_write;
  344. ),
  345. TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry->dev),
  346. MINOR(__entry->dev), __entry->start ? "start" : "end",
  347. __entry->sync_mode == WB_SYNC_ALL ? "all" : "none",
  348. __entry->nr_to_write)
  349. );
  350. /* Section 3 - bmap
  351. *
  352. * Objectives:
  353. * Latency: Bmap request time
  354. * Performance: Block allocator tracing
  355. * Correctness: Test of disard generation vs. blocks allocated
  356. */
  357. /* Map an extent of blocks, possibly a new allocation */
  358. TRACE_EVENT(gfs2_bmap,
  359. TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
  360. sector_t lblock, int create, int errno),
  361. TP_ARGS(ip, bh, lblock, create, errno),
  362. TP_STRUCT__entry(
  363. __field( dev_t, dev )
  364. __field( sector_t, lblock )
  365. __field( sector_t, pblock )
  366. __field( u64, inum )
  367. __field( unsigned long, state )
  368. __field( u32, len )
  369. __field( int, create )
  370. __field( int, errno )
  371. ),
  372. TP_fast_assign(
  373. __entry->dev = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
  374. __entry->lblock = lblock;
  375. __entry->pblock = buffer_mapped(bh) ? bh->b_blocknr : 0;
  376. __entry->inum = ip->i_no_addr;
  377. __entry->state = bh->b_state;
  378. __entry->len = bh->b_size;
  379. __entry->create = create;
  380. __entry->errno = errno;
  381. ),
  382. TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
  383. MAJOR(__entry->dev), MINOR(__entry->dev),
  384. (unsigned long long)__entry->inum,
  385. (unsigned long long)__entry->lblock,
  386. (unsigned long)__entry->len,
  387. (unsigned long long)__entry->pblock,
  388. __entry->state, __entry->create ? "create " : "nocreate",
  389. __entry->errno)
  390. );
  391. /* Keep track of blocks as they are allocated/freed */
  392. TRACE_EVENT(gfs2_block_alloc,
  393. TP_PROTO(const struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
  394. u64 block, unsigned len, u8 block_state),
  395. TP_ARGS(ip, rgd, block, len, block_state),
  396. TP_STRUCT__entry(
  397. __field( dev_t, dev )
  398. __field( u64, start )
  399. __field( u64, inum )
  400. __field( u32, len )
  401. __field( u8, block_state )
  402. __field( u64, rd_addr )
  403. __field( u32, rd_free_clone )
  404. __field( u32, rd_reserved )
  405. ),
  406. TP_fast_assign(
  407. __entry->dev = rgd->rd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
  408. __entry->start = block;
  409. __entry->inum = ip->i_no_addr;
  410. __entry->len = len;
  411. __entry->block_state = block_state;
  412. __entry->rd_addr = rgd->rd_addr;
  413. __entry->rd_free_clone = rgd->rd_free_clone;
  414. __entry->rd_reserved = rgd->rd_reserved;
  415. ),
  416. TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
  417. MAJOR(__entry->dev), MINOR(__entry->dev),
  418. (unsigned long long)__entry->inum,
  419. (unsigned long long)__entry->start,
  420. (unsigned long)__entry->len,
  421. block_state_name(__entry->block_state),
  422. (unsigned long long)__entry->rd_addr,
  423. __entry->rd_free_clone, (unsigned long)__entry->rd_reserved)
  424. );
  425. /* Keep track of multi-block reservations as they are allocated/freed */
  426. TRACE_EVENT(gfs2_rs,
  427. TP_PROTO(const struct gfs2_blkreserv *rs, u8 func),
  428. TP_ARGS(rs, func),
  429. TP_STRUCT__entry(
  430. __field( dev_t, dev )
  431. __field( u64, rd_addr )
  432. __field( u32, rd_free_clone )
  433. __field( u32, rd_reserved )
  434. __field( u64, inum )
  435. __field( u64, start )
  436. __field( u32, free )
  437. __field( u8, func )
  438. ),
  439. TP_fast_assign(
  440. __entry->dev = rs->rs_rbm.rgd->rd_sbd->sd_vfs->s_dev;
  441. __entry->rd_addr = rs->rs_rbm.rgd->rd_addr;
  442. __entry->rd_free_clone = rs->rs_rbm.rgd->rd_free_clone;
  443. __entry->rd_reserved = rs->rs_rbm.rgd->rd_reserved;
  444. __entry->inum = rs->rs_inum;
  445. __entry->start = gfs2_rbm_to_block(&rs->rs_rbm);
  446. __entry->free = rs->rs_free;
  447. __entry->func = func;
  448. ),
  449. TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s f:%lu",
  450. MAJOR(__entry->dev), MINOR(__entry->dev),
  451. (unsigned long long)__entry->inum,
  452. (unsigned long long)__entry->start,
  453. (unsigned long long)__entry->rd_addr,
  454. (unsigned long)__entry->rd_free_clone,
  455. (unsigned long)__entry->rd_reserved,
  456. rs_func_name(__entry->func), (unsigned long)__entry->free)
  457. );
  458. #endif /* _TRACE_GFS2_H */
  459. /* This part must be outside protection */
  460. #undef TRACE_INCLUDE_PATH
  461. #define TRACE_INCLUDE_PATH .
  462. #define TRACE_INCLUDE_FILE trace_gfs2
  463. #include <trace/define_trace.h>