blktrace_api.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _UAPIBLKTRACE_H
  2. #define _UAPIBLKTRACE_H
  3. #include <linux/types.h>
  4. /*
  5. * Trace categories
  6. */
  7. enum blktrace_cat {
  8. BLK_TC_READ = 1 << 0, /* reads */
  9. BLK_TC_WRITE = 1 << 1, /* writes */
  10. BLK_TC_FLUSH = 1 << 2, /* flush */
  11. BLK_TC_SYNC = 1 << 3, /* sync IO */
  12. BLK_TC_SYNCIO = BLK_TC_SYNC,
  13. BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
  14. BLK_TC_REQUEUE = 1 << 5, /* requeueing */
  15. BLK_TC_ISSUE = 1 << 6, /* issue */
  16. BLK_TC_COMPLETE = 1 << 7, /* completions */
  17. BLK_TC_FS = 1 << 8, /* fs requests */
  18. BLK_TC_PC = 1 << 9, /* pc requests */
  19. BLK_TC_NOTIFY = 1 << 10, /* special message */
  20. BLK_TC_AHEAD = 1 << 11, /* readahead */
  21. BLK_TC_META = 1 << 12, /* metadata */
  22. BLK_TC_DISCARD = 1 << 13, /* discard requests */
  23. BLK_TC_DRV_DATA = 1 << 14, /* binary per-driver data */
  24. BLK_TC_FUA = 1 << 15, /* fua requests */
  25. BLK_TC_END = 1 << 15, /* we've run out of bits! */
  26. };
  27. #define BLK_TC_SHIFT (16)
  28. #define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
  29. /*
  30. * Basic trace actions
  31. */
  32. enum blktrace_act {
  33. __BLK_TA_QUEUE = 1, /* queued */
  34. __BLK_TA_BACKMERGE, /* back merged to existing rq */
  35. __BLK_TA_FRONTMERGE, /* front merge to existing rq */
  36. __BLK_TA_GETRQ, /* allocated new request */
  37. __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */
  38. __BLK_TA_REQUEUE, /* request requeued */
  39. __BLK_TA_ISSUE, /* sent to driver */
  40. __BLK_TA_COMPLETE, /* completed by driver */
  41. __BLK_TA_PLUG, /* queue was plugged */
  42. __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */
  43. __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */
  44. __BLK_TA_INSERT, /* insert request */
  45. __BLK_TA_SPLIT, /* bio was split */
  46. __BLK_TA_BOUNCE, /* bio was bounced */
  47. __BLK_TA_REMAP, /* bio was remapped */
  48. __BLK_TA_ABORT, /* request aborted */
  49. __BLK_TA_DRV_DATA, /* driver-specific binary data */
  50. };
  51. /*
  52. * Notify events.
  53. */
  54. enum blktrace_notify {
  55. __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
  56. __BLK_TN_TIMESTAMP, /* include system clock */
  57. __BLK_TN_MESSAGE, /* Character string message */
  58. };
  59. /*
  60. * Trace actions in full. Additionally, read or write is masked
  61. */
  62. #define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
  63. #define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
  64. #define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
  65. #define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
  66. #define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
  67. #define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
  68. #define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
  69. #define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
  70. #define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
  71. #define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
  72. #define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
  73. #define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
  74. #define BLK_TA_SPLIT (__BLK_TA_SPLIT)
  75. #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
  76. #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
  77. #define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
  78. #define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
  79. #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
  80. #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
  81. #define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
  82. #define BLK_IO_TRACE_MAGIC 0x65617400
  83. #define BLK_IO_TRACE_VERSION 0x07
  84. /*
  85. * The trace itself
  86. */
  87. struct blk_io_trace {
  88. __u32 magic; /* MAGIC << 8 | version */
  89. __u32 sequence; /* event number */
  90. __u64 time; /* in microseconds */
  91. __u64 sector; /* disk offset */
  92. __u32 bytes; /* transfer length */
  93. __u32 action; /* what happened */
  94. __u32 pid; /* who did it */
  95. __u32 device; /* device number */
  96. __u32 cpu; /* on what cpu did it happen */
  97. __u16 error; /* completion error */
  98. __u16 pdu_len; /* length of data after this trace */
  99. };
  100. /*
  101. * The remap event
  102. */
  103. struct blk_io_trace_remap {
  104. __be32 device_from;
  105. __be32 device_to;
  106. __be64 sector_from;
  107. };
  108. enum {
  109. Blktrace_setup = 1,
  110. Blktrace_running,
  111. Blktrace_stopped,
  112. };
  113. #define BLKTRACE_BDEV_SIZE 32
  114. /*
  115. * User setup structure passed with BLKTRACESTART
  116. */
  117. struct blk_user_trace_setup {
  118. char name[BLKTRACE_BDEV_SIZE]; /* output */
  119. __u16 act_mask; /* input */
  120. __u32 buf_size; /* input */
  121. __u32 buf_nr; /* input */
  122. __u64 start_lba;
  123. __u64 end_lba;
  124. __u32 pid;
  125. };
  126. #endif /* _UAPIBLKTRACE_H */