1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2009-2021 Christoph Hellwig 4 * 5 * NOTE: none of these tracepoints shall be considered a stable kernel ABI 6 * as they can change at any time. 7 * 8 * Current conventions for printing numbers measuring specific units: 9 * 10 * offset: byte offset into a subcomponent of a file operation 11 * pos: file offset, in bytes 12 * length: length of a file operation, in bytes 13 * ino: inode number 14 * 15 * Numbers describing space allocations should be formatted in hexadecimal. 16 */ 17 #undef TRACE_SYSTEM 18 #define TRACE_SYSTEM iomap 19 20 #if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 21 #define _IOMAP_TRACE_H 22 23 #include <linux/tracepoint.h> 24 25 struct inode; 26 27 DECLARE_EVENT_CLASS(iomap_readpage_class, 28 TP_PROTO(struct inode *inode, int nr_pages), 29 TP_ARGS(inode, nr_pages), 30 TP_STRUCT__entry( 31 __field(dev_t, dev) 32 __field(u64, ino) 33 __field(int, nr_pages) 34 ), 35 TP_fast_assign( 36 __entry->dev = inode->i_sb->s_dev; 37 __entry->ino = inode->i_ino; 38 __entry->nr_pages = nr_pages; 39 ), 40 TP_printk("dev %d:%d ino 0x%llx nr_pages %d", 41 MAJOR(__entry->dev), MINOR(__entry->dev), 42 __entry->ino, 43 __entry->nr_pages) 44 ) 45 46 #define DEFINE_READPAGE_EVENT(name) \ 47 DEFINE_EVENT(iomap_readpage_class, name, \ 48 TP_PROTO(struct inode *inode, int nr_pages), \ 49 TP_ARGS(inode, nr_pages)) 50 DEFINE_READPAGE_EVENT(iomap_readpage); 51 DEFINE_READPAGE_EVENT(iomap_readahead); 52 53 DECLARE_EVENT_CLASS(iomap_range_class, 54 TP_PROTO(struct inode *inode, loff_t off, u64 len), 55 TP_ARGS(inode, off, len), 56 TP_STRUCT__entry( 57 __field(dev_t, dev) 58 __field(u64, ino) 59 __field(loff_t, size) 60 __field(loff_t, offset) 61 __field(u64, length) 62 ), 63 TP_fast_assign( 64 __entry->dev = inode->i_sb->s_dev; 65 __entry->ino = inode->i_ino; 66 __entry->size = i_size_read(inode); 67 __entry->offset = off; 68 __entry->length = len; 69 ), 70 TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx length 0x%llx", 71 MAJOR(__entry->dev), MINOR(__entry->dev), 72 __entry->ino, 73 __entry->size, 74 __entry->offset, 75 __entry->length) 76 ) 77 78 #define DEFINE_RANGE_EVENT(name) \ 79 DEFINE_EVENT(iomap_range_class, name, \ 80 TP_PROTO(struct inode *inode, loff_t off, u64 len),\ 81 TP_ARGS(inode, off, len)) 82 DEFINE_RANGE_EVENT(iomap_writepage); 83 DEFINE_RANGE_EVENT(iomap_release_folio); 84 DEFINE_RANGE_EVENT(iomap_invalidate_folio); 85 DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail); 86 DEFINE_RANGE_EVENT(iomap_dio_rw_queued); 87 88 #define IOMAP_TYPE_STRINGS \ 89 { IOMAP_HOLE, "HOLE" }, \ 90 { IOMAP_DELALLOC, "DELALLOC" }, \ 91 { IOMAP_MAPPED, "MAPPED" }, \ 92 { IOMAP_UNWRITTEN, "UNWRITTEN" }, \ 93 { IOMAP_INLINE, "INLINE" } 94 95 #define IOMAP_FLAGS_STRINGS \ 96 { IOMAP_WRITE, "WRITE" }, \ 97 { IOMAP_ZERO, "ZERO" }, \ 98 { IOMAP_REPORT, "REPORT" }, \ 99 { IOMAP_FAULT, "FAULT" }, \ 100 { IOMAP_DIRECT, "DIRECT" }, \ 101 { IOMAP_NOWAIT, "NOWAIT" }, \ 102 { IOMAP_ATOMIC, "ATOMIC" } 103 104 #define IOMAP_F_FLAGS_STRINGS \ 105 { IOMAP_F_NEW, "NEW" }, \ 106 { IOMAP_F_DIRTY, "DIRTY" }, \ 107 { IOMAP_F_SHARED, "SHARED" }, \ 108 { IOMAP_F_MERGED, "MERGED" }, \ 109 { IOMAP_F_BUFFER_HEAD, "BH" }, \ 110 { IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" } 111 112 #define IOMAP_DIO_STRINGS \ 113 {IOMAP_DIO_FORCE_WAIT, "DIO_FORCE_WAIT" }, \ 114 {IOMAP_DIO_OVERWRITE_ONLY, "DIO_OVERWRITE_ONLY" }, \ 115 {IOMAP_DIO_PARTIAL, "DIO_PARTIAL" } 116 117 DECLARE_EVENT_CLASS(iomap_class, 118 TP_PROTO(struct inode *inode, struct iomap *iomap), 119 TP_ARGS(inode, iomap), 120 TP_STRUCT__entry( 121 __field(dev_t, dev) 122 __field(u64, ino) 123 __field(u64, addr) 124 __field(loff_t, offset) 125 __field(u64, length) 126 __field(u16, type) 127 __field(u16, flags) 128 __field(dev_t, bdev) 129 ), 130 TP_fast_assign( 131 __entry->dev = inode->i_sb->s_dev; 132 __entry->ino = inode->i_ino; 133 __entry->addr = iomap->addr; 134 __entry->offset = iomap->offset; 135 __entry->length = iomap->length; 136 __entry->type = iomap->type; 137 __entry->flags = iomap->flags; 138 __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0; 139 ), 140 TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr 0x%llx offset 0x%llx " 141 "length 0x%llx type %s flags %s", 142 MAJOR(__entry->dev), MINOR(__entry->dev), 143 __entry->ino, 144 MAJOR(__entry->bdev), MINOR(__entry->bdev), 145 __entry->addr, 146 __entry->offset, 147 __entry->length, 148 __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS), 149 __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS)) 150 ) 151 152 #define DEFINE_IOMAP_EVENT(name) \ 153 DEFINE_EVENT(iomap_class, name, \ 154 TP_PROTO(struct inode *inode, struct iomap *iomap), \ 155 TP_ARGS(inode, iomap)) 156 DEFINE_IOMAP_EVENT(iomap_iter_dstmap); 157 DEFINE_IOMAP_EVENT(iomap_iter_srcmap); 158 159 TRACE_EVENT(iomap_writepage_map, 160 TP_PROTO(struct inode *inode, u64 pos, unsigned int dirty_len, 161 struct iomap *iomap), 162 TP_ARGS(inode, pos, dirty_len, iomap), 163 TP_STRUCT__entry( 164 __field(dev_t, dev) 165 __field(u64, ino) 166 __field(u64, pos) 167 __field(u64, dirty_len) 168 __field(u64, addr) 169 __field(loff_t, offset) 170 __field(u64, length) 171 __field(u16, type) 172 __field(u16, flags) 173 __field(dev_t, bdev) 174 ), 175 TP_fast_assign( 176 __entry->dev = inode->i_sb->s_dev; 177 __entry->ino = inode->i_ino; 178 __entry->pos = pos; 179 __entry->dirty_len = dirty_len; 180 __entry->addr = iomap->addr; 181 __entry->offset = iomap->offset; 182 __entry->length = iomap->length; 183 __entry->type = iomap->type; 184 __entry->flags = iomap->flags; 185 __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0; 186 ), 187 TP_printk("dev %d:%d ino 0x%llx bdev %d:%d pos 0x%llx dirty len 0x%llx " 188 "addr 0x%llx offset 0x%llx length 0x%llx type %s flags %s", 189 MAJOR(__entry->dev), MINOR(__entry->dev), 190 __entry->ino, 191 MAJOR(__entry->bdev), MINOR(__entry->bdev), 192 __entry->pos, 193 __entry->dirty_len, 194 __entry->addr, 195 __entry->offset, 196 __entry->length, 197 __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS), 198 __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS)) 199 ); 200 201 TRACE_EVENT(iomap_iter, 202 TP_PROTO(struct iomap_iter *iter, const void *ops, 203 unsigned long caller), 204 TP_ARGS(iter, ops, caller), 205 TP_STRUCT__entry( 206 __field(dev_t, dev) 207 __field(u64, ino) 208 __field(loff_t, pos) 209 __field(u64, length) 210 __field(s64, processed) 211 __field(unsigned int, flags) 212 __field(const void *, ops) 213 __field(unsigned long, caller) 214 ), 215 TP_fast_assign( 216 __entry->dev = iter->inode->i_sb->s_dev; 217 __entry->ino = iter->inode->i_ino; 218 __entry->pos = iter->pos; 219 __entry->length = iomap_length(iter); 220 __entry->processed = iter->processed; 221 __entry->flags = iter->flags; 222 __entry->ops = ops; 223 __entry->caller = caller; 224 ), 225 TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx processed %lld flags %s (0x%x) ops %ps caller %pS", 226 MAJOR(__entry->dev), MINOR(__entry->dev), 227 __entry->ino, 228 __entry->pos, 229 __entry->length, 230 __entry->processed, 231 __print_flags(__entry->flags, "|", IOMAP_FLAGS_STRINGS), 232 __entry->flags, 233 __entry->ops, 234 (void *)__entry->caller) 235 ); 236 237 TRACE_EVENT(iomap_dio_rw_begin, 238 TP_PROTO(struct kiocb *iocb, struct iov_iter *iter, 239 unsigned int dio_flags, size_t done_before), 240 TP_ARGS(iocb, iter, dio_flags, done_before), 241 TP_STRUCT__entry( 242 __field(dev_t, dev) 243 __field(ino_t, ino) 244 __field(loff_t, isize) 245 __field(loff_t, pos) 246 __field(size_t, count) 247 __field(size_t, done_before) 248 __field(int, ki_flags) 249 __field(unsigned int, dio_flags) 250 __field(bool, aio) 251 ), 252 TP_fast_assign( 253 __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev; 254 __entry->ino = file_inode(iocb->ki_filp)->i_ino; 255 __entry->isize = file_inode(iocb->ki_filp)->i_size; 256 __entry->pos = iocb->ki_pos; 257 __entry->count = iov_iter_count(iter); 258 __entry->done_before = done_before; 259 __entry->ki_flags = iocb->ki_flags; 260 __entry->dio_flags = dio_flags; 261 __entry->aio = !is_sync_kiocb(iocb); 262 ), 263 TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx length 0x%zx done_before 0x%zx flags %s dio_flags %s aio %d", 264 MAJOR(__entry->dev), MINOR(__entry->dev), 265 __entry->ino, 266 __entry->isize, 267 __entry->pos, 268 __entry->count, 269 __entry->done_before, 270 __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS), 271 __print_flags(__entry->dio_flags, "|", IOMAP_DIO_STRINGS), 272 __entry->aio) 273 ); 274 275 TRACE_EVENT(iomap_dio_complete, 276 TP_PROTO(struct kiocb *iocb, int error, ssize_t ret), 277 TP_ARGS(iocb, error, ret), 278 TP_STRUCT__entry( 279 __field(dev_t, dev) 280 __field(ino_t, ino) 281 __field(loff_t, isize) 282 __field(loff_t, pos) 283 __field(int, ki_flags) 284 __field(bool, aio) 285 __field(int, error) 286 __field(ssize_t, ret) 287 ), 288 TP_fast_assign( 289 __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev; 290 __entry->ino = file_inode(iocb->ki_filp)->i_ino; 291 __entry->isize = file_inode(iocb->ki_filp)->i_size; 292 __entry->pos = iocb->ki_pos; 293 __entry->ki_flags = iocb->ki_flags; 294 __entry->aio = !is_sync_kiocb(iocb); 295 __entry->error = error; 296 __entry->ret = ret; 297 ), 298 TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd", 299 MAJOR(__entry->dev), MINOR(__entry->dev), 300 __entry->ino, 301 __entry->isize, 302 __entry->pos, 303 __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS), 304 __entry->aio, 305 __entry->error, 306 __entry->ret) 307 ); 308 309 #endif /* _IOMAP_TRACE_H */ 310 311 #undef TRACE_INCLUDE_PATH 312 #define TRACE_INCLUDE_PATH . 313 #define TRACE_INCLUDE_FILE trace 314 #include <trace/define_trace.h> 315