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