19e91c572SChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0 */ 29e91c572SChristoph Hellwig /* 3f4b896c2SChristoph Hellwig * Copyright (c) 2009-2021 Christoph Hellwig 49e91c572SChristoph Hellwig * 5d9d381f3SChristoph Hellwig * NOTE: none of these tracepoints shall be considered a stable kernel ABI 69e91c572SChristoph Hellwig * as they can change at any time. 703b8df8dSDarrick J. Wong * 803b8df8dSDarrick J. Wong * Current conventions for printing numbers measuring specific units: 903b8df8dSDarrick J. Wong * 1003b8df8dSDarrick J. Wong * offset: byte offset into a subcomponent of a file operation 1103b8df8dSDarrick J. Wong * pos: file offset, in bytes 1203b8df8dSDarrick J. Wong * length: length of a file operation, in bytes 1303b8df8dSDarrick J. Wong * ino: inode number 1403b8df8dSDarrick J. Wong * 1503b8df8dSDarrick J. Wong * Numbers describing space allocations should be formatted in hexadecimal. 169e91c572SChristoph Hellwig */ 179e91c572SChristoph Hellwig #undef TRACE_SYSTEM 189e91c572SChristoph Hellwig #define TRACE_SYSTEM iomap 199e91c572SChristoph Hellwig 209e91c572SChristoph Hellwig #if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 219e91c572SChristoph Hellwig #define _IOMAP_TRACE_H 229e91c572SChristoph Hellwig 239e91c572SChristoph Hellwig #include <linux/tracepoint.h> 249e91c572SChristoph Hellwig 259e91c572SChristoph Hellwig struct inode; 269e91c572SChristoph Hellwig 279e91c572SChristoph Hellwig DECLARE_EVENT_CLASS(iomap_readpage_class, 289e91c572SChristoph Hellwig TP_PROTO(struct inode *inode, int nr_pages), 299e91c572SChristoph Hellwig TP_ARGS(inode, nr_pages), 309e91c572SChristoph Hellwig TP_STRUCT__entry( 319e91c572SChristoph Hellwig __field(dev_t, dev) 329e91c572SChristoph Hellwig __field(u64, ino) 339e91c572SChristoph Hellwig __field(int, nr_pages) 349e91c572SChristoph Hellwig ), 359e91c572SChristoph Hellwig TP_fast_assign( 369e91c572SChristoph Hellwig __entry->dev = inode->i_sb->s_dev; 379e91c572SChristoph Hellwig __entry->ino = inode->i_ino; 389e91c572SChristoph Hellwig __entry->nr_pages = nr_pages; 399e91c572SChristoph Hellwig ), 409e91c572SChristoph Hellwig TP_printk("dev %d:%d ino 0x%llx nr_pages %d", 419e91c572SChristoph Hellwig MAJOR(__entry->dev), MINOR(__entry->dev), 429e91c572SChristoph Hellwig __entry->ino, 439e91c572SChristoph Hellwig __entry->nr_pages) 449e91c572SChristoph Hellwig ) 459e91c572SChristoph Hellwig 469e91c572SChristoph Hellwig #define DEFINE_READPAGE_EVENT(name) \ 479e91c572SChristoph Hellwig DEFINE_EVENT(iomap_readpage_class, name, \ 489e91c572SChristoph Hellwig TP_PROTO(struct inode *inode, int nr_pages), \ 499e91c572SChristoph Hellwig TP_ARGS(inode, nr_pages)) 509e91c572SChristoph Hellwig DEFINE_READPAGE_EVENT(iomap_readpage); 519d24a13aSMatthew Wilcox (Oracle) DEFINE_READPAGE_EVENT(iomap_readahead); 529e91c572SChristoph Hellwig 531ac99452SMatthew Wilcox (Oracle) DECLARE_EVENT_CLASS(iomap_range_class, 5403b8df8dSDarrick J. Wong TP_PROTO(struct inode *inode, loff_t off, u64 len), 551ac99452SMatthew Wilcox (Oracle) TP_ARGS(inode, off, len), 569e91c572SChristoph Hellwig TP_STRUCT__entry( 579e91c572SChristoph Hellwig __field(dev_t, dev) 589e91c572SChristoph Hellwig __field(u64, ino) 599e91c572SChristoph Hellwig __field(loff_t, size) 6003b8df8dSDarrick J. Wong __field(loff_t, offset) 6103b8df8dSDarrick J. Wong __field(u64, length) 629e91c572SChristoph Hellwig ), 639e91c572SChristoph Hellwig TP_fast_assign( 649e91c572SChristoph Hellwig __entry->dev = inode->i_sb->s_dev; 659e91c572SChristoph Hellwig __entry->ino = inode->i_ino; 669e91c572SChristoph Hellwig __entry->size = i_size_read(inode); 679e91c572SChristoph Hellwig __entry->offset = off; 689e91c572SChristoph Hellwig __entry->length = len; 699e91c572SChristoph Hellwig ), 7003b8df8dSDarrick J. Wong TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx length 0x%llx", 719e91c572SChristoph Hellwig MAJOR(__entry->dev), MINOR(__entry->dev), 729e91c572SChristoph Hellwig __entry->ino, 739e91c572SChristoph Hellwig __entry->size, 749e91c572SChristoph Hellwig __entry->offset, 759e91c572SChristoph Hellwig __entry->length) 769e91c572SChristoph Hellwig ) 779e91c572SChristoph Hellwig 781ac99452SMatthew Wilcox (Oracle) #define DEFINE_RANGE_EVENT(name) \ 791ac99452SMatthew Wilcox (Oracle) DEFINE_EVENT(iomap_range_class, name, \ 8003b8df8dSDarrick J. Wong TP_PROTO(struct inode *inode, loff_t off, u64 len),\ 811ac99452SMatthew Wilcox (Oracle) TP_ARGS(inode, off, len)) 821ac99452SMatthew Wilcox (Oracle) DEFINE_RANGE_EVENT(iomap_writepage); 838597447dSMatthew Wilcox (Oracle) DEFINE_RANGE_EVENT(iomap_release_folio); 84d82354f6SMatthew Wilcox (Oracle) DEFINE_RANGE_EVENT(iomap_invalidate_folio); 8560263d58SChristoph Hellwig DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail); 86*3fd41721SRitesh Harjani (IBM) DEFINE_RANGE_EVENT(iomap_dio_rw_queued); 879e91c572SChristoph Hellwig 886334b91eSDarrick J. Wong #define IOMAP_TYPE_STRINGS \ 896334b91eSDarrick J. Wong { IOMAP_HOLE, "HOLE" }, \ 906334b91eSDarrick J. Wong { IOMAP_DELALLOC, "DELALLOC" }, \ 916334b91eSDarrick J. Wong { IOMAP_MAPPED, "MAPPED" }, \ 926334b91eSDarrick J. Wong { IOMAP_UNWRITTEN, "UNWRITTEN" }, \ 936334b91eSDarrick J. Wong { IOMAP_INLINE, "INLINE" } 946334b91eSDarrick J. Wong 956334b91eSDarrick J. Wong #define IOMAP_FLAGS_STRINGS \ 966334b91eSDarrick J. Wong { IOMAP_WRITE, "WRITE" }, \ 976334b91eSDarrick J. Wong { IOMAP_ZERO, "ZERO" }, \ 986334b91eSDarrick J. Wong { IOMAP_REPORT, "REPORT" }, \ 996334b91eSDarrick J. Wong { IOMAP_FAULT, "FAULT" }, \ 1006334b91eSDarrick J. Wong { IOMAP_DIRECT, "DIRECT" }, \ 1016334b91eSDarrick J. Wong { IOMAP_NOWAIT, "NOWAIT" } 1026334b91eSDarrick J. Wong 1036334b91eSDarrick J. Wong #define IOMAP_F_FLAGS_STRINGS \ 1046334b91eSDarrick J. Wong { IOMAP_F_NEW, "NEW" }, \ 1056334b91eSDarrick J. Wong { IOMAP_F_DIRTY, "DIRTY" }, \ 1066334b91eSDarrick J. Wong { IOMAP_F_SHARED, "SHARED" }, \ 1076334b91eSDarrick J. Wong { IOMAP_F_MERGED, "MERGED" }, \ 1086334b91eSDarrick J. Wong { IOMAP_F_BUFFER_HEAD, "BH" }, \ 1096334b91eSDarrick J. Wong { IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" } 1106334b91eSDarrick J. Wong 111*3fd41721SRitesh Harjani (IBM) #define IOMAP_DIO_STRINGS \ 112*3fd41721SRitesh Harjani (IBM) {IOMAP_DIO_FORCE_WAIT, "DIO_FORCE_WAIT" }, \ 113*3fd41721SRitesh Harjani (IBM) {IOMAP_DIO_OVERWRITE_ONLY, "DIO_OVERWRITE_ONLY" }, \ 114*3fd41721SRitesh Harjani (IBM) {IOMAP_DIO_PARTIAL, "DIO_PARTIAL" } 115*3fd41721SRitesh Harjani (IBM) 1166334b91eSDarrick J. Wong DECLARE_EVENT_CLASS(iomap_class, 1176334b91eSDarrick J. Wong TP_PROTO(struct inode *inode, struct iomap *iomap), 1186334b91eSDarrick J. Wong TP_ARGS(inode, iomap), 1196334b91eSDarrick J. Wong TP_STRUCT__entry( 1206334b91eSDarrick J. Wong __field(dev_t, dev) 1216334b91eSDarrick J. Wong __field(u64, ino) 1226334b91eSDarrick J. Wong __field(u64, addr) 1236334b91eSDarrick J. Wong __field(loff_t, offset) 1246334b91eSDarrick J. Wong __field(u64, length) 1256334b91eSDarrick J. Wong __field(u16, type) 1266334b91eSDarrick J. Wong __field(u16, flags) 1276334b91eSDarrick J. Wong __field(dev_t, bdev) 1286334b91eSDarrick J. Wong ), 1296334b91eSDarrick J. Wong TP_fast_assign( 1306334b91eSDarrick J. Wong __entry->dev = inode->i_sb->s_dev; 1316334b91eSDarrick J. Wong __entry->ino = inode->i_ino; 1326334b91eSDarrick J. Wong __entry->addr = iomap->addr; 1336334b91eSDarrick J. Wong __entry->offset = iomap->offset; 1346334b91eSDarrick J. Wong __entry->length = iomap->length; 1356334b91eSDarrick J. Wong __entry->type = iomap->type; 1366334b91eSDarrick J. Wong __entry->flags = iomap->flags; 1376334b91eSDarrick J. Wong __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0; 1386334b91eSDarrick J. Wong ), 13903b8df8dSDarrick J. Wong TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr 0x%llx offset 0x%llx " 14003b8df8dSDarrick J. Wong "length 0x%llx type %s flags %s", 1416334b91eSDarrick J. Wong MAJOR(__entry->dev), MINOR(__entry->dev), 1426334b91eSDarrick J. Wong __entry->ino, 1436334b91eSDarrick J. Wong MAJOR(__entry->bdev), MINOR(__entry->bdev), 1446334b91eSDarrick J. Wong __entry->addr, 1456334b91eSDarrick J. Wong __entry->offset, 1466334b91eSDarrick J. Wong __entry->length, 1476334b91eSDarrick J. Wong __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS), 1486334b91eSDarrick J. Wong __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS)) 1496334b91eSDarrick J. Wong ) 1506334b91eSDarrick J. Wong 1516334b91eSDarrick J. Wong #define DEFINE_IOMAP_EVENT(name) \ 1526334b91eSDarrick J. Wong DEFINE_EVENT(iomap_class, name, \ 1536334b91eSDarrick J. Wong TP_PROTO(struct inode *inode, struct iomap *iomap), \ 1546334b91eSDarrick J. Wong TP_ARGS(inode, iomap)) 155f4b896c2SChristoph Hellwig DEFINE_IOMAP_EVENT(iomap_iter_dstmap); 156f4b896c2SChristoph Hellwig DEFINE_IOMAP_EVENT(iomap_iter_srcmap); 157adc9c2e5SDarrick J. Wong DEFINE_IOMAP_EVENT(iomap_writepage_map); 1586334b91eSDarrick J. Wong 159f4b896c2SChristoph Hellwig TRACE_EVENT(iomap_iter, 160f4b896c2SChristoph Hellwig TP_PROTO(struct iomap_iter *iter, const void *ops, 161f4b896c2SChristoph Hellwig unsigned long caller), 162f4b896c2SChristoph Hellwig TP_ARGS(iter, ops, caller), 163f4b896c2SChristoph Hellwig TP_STRUCT__entry( 164f4b896c2SChristoph Hellwig __field(dev_t, dev) 165f4b896c2SChristoph Hellwig __field(u64, ino) 166f4b896c2SChristoph Hellwig __field(loff_t, pos) 16703b8df8dSDarrick J. Wong __field(u64, length) 168f4b896c2SChristoph Hellwig __field(unsigned int, flags) 169f4b896c2SChristoph Hellwig __field(const void *, ops) 170f4b896c2SChristoph Hellwig __field(unsigned long, caller) 171f4b896c2SChristoph Hellwig ), 172f4b896c2SChristoph Hellwig TP_fast_assign( 173f4b896c2SChristoph Hellwig __entry->dev = iter->inode->i_sb->s_dev; 174f4b896c2SChristoph Hellwig __entry->ino = iter->inode->i_ino; 175f4b896c2SChristoph Hellwig __entry->pos = iter->pos; 176f4b896c2SChristoph Hellwig __entry->length = iomap_length(iter); 177f4b896c2SChristoph Hellwig __entry->flags = iter->flags; 178f4b896c2SChristoph Hellwig __entry->ops = ops; 179f4b896c2SChristoph Hellwig __entry->caller = caller; 180f4b896c2SChristoph Hellwig ), 18103b8df8dSDarrick J. Wong TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx flags %s (0x%x) ops %ps caller %pS", 182f4b896c2SChristoph Hellwig MAJOR(__entry->dev), MINOR(__entry->dev), 183f4b896c2SChristoph Hellwig __entry->ino, 184f4b896c2SChristoph Hellwig __entry->pos, 185f4b896c2SChristoph Hellwig __entry->length, 186f4b896c2SChristoph Hellwig __print_flags(__entry->flags, "|", IOMAP_FLAGS_STRINGS), 187f4b896c2SChristoph Hellwig __entry->flags, 188f4b896c2SChristoph Hellwig __entry->ops, 189f4b896c2SChristoph Hellwig (void *)__entry->caller) 190f4b896c2SChristoph Hellwig ); 191f4b896c2SChristoph Hellwig 192*3fd41721SRitesh Harjani (IBM) TRACE_EVENT(iomap_dio_rw_begin, 193*3fd41721SRitesh Harjani (IBM) TP_PROTO(struct kiocb *iocb, struct iov_iter *iter, 194*3fd41721SRitesh Harjani (IBM) unsigned int dio_flags, size_t done_before), 195*3fd41721SRitesh Harjani (IBM) TP_ARGS(iocb, iter, dio_flags, done_before), 196*3fd41721SRitesh Harjani (IBM) TP_STRUCT__entry( 197*3fd41721SRitesh Harjani (IBM) __field(dev_t, dev) 198*3fd41721SRitesh Harjani (IBM) __field(ino_t, ino) 199*3fd41721SRitesh Harjani (IBM) __field(loff_t, isize) 200*3fd41721SRitesh Harjani (IBM) __field(loff_t, pos) 201*3fd41721SRitesh Harjani (IBM) __field(size_t, count) 202*3fd41721SRitesh Harjani (IBM) __field(size_t, done_before) 203*3fd41721SRitesh Harjani (IBM) __field(int, ki_flags) 204*3fd41721SRitesh Harjani (IBM) __field(unsigned int, dio_flags) 205*3fd41721SRitesh Harjani (IBM) __field(bool, aio) 206*3fd41721SRitesh Harjani (IBM) ), 207*3fd41721SRitesh Harjani (IBM) TP_fast_assign( 208*3fd41721SRitesh Harjani (IBM) __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev; 209*3fd41721SRitesh Harjani (IBM) __entry->ino = file_inode(iocb->ki_filp)->i_ino; 210*3fd41721SRitesh Harjani (IBM) __entry->isize = file_inode(iocb->ki_filp)->i_size; 211*3fd41721SRitesh Harjani (IBM) __entry->pos = iocb->ki_pos; 212*3fd41721SRitesh Harjani (IBM) __entry->count = iov_iter_count(iter); 213*3fd41721SRitesh Harjani (IBM) __entry->done_before = done_before; 214*3fd41721SRitesh Harjani (IBM) __entry->ki_flags = iocb->ki_flags; 215*3fd41721SRitesh Harjani (IBM) __entry->dio_flags = dio_flags; 216*3fd41721SRitesh Harjani (IBM) __entry->aio = !is_sync_kiocb(iocb); 217*3fd41721SRitesh Harjani (IBM) ), 218*3fd41721SRitesh Harjani (IBM) 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", 219*3fd41721SRitesh Harjani (IBM) MAJOR(__entry->dev), MINOR(__entry->dev), 220*3fd41721SRitesh Harjani (IBM) __entry->ino, 221*3fd41721SRitesh Harjani (IBM) __entry->isize, 222*3fd41721SRitesh Harjani (IBM) __entry->pos, 223*3fd41721SRitesh Harjani (IBM) __entry->count, 224*3fd41721SRitesh Harjani (IBM) __entry->done_before, 225*3fd41721SRitesh Harjani (IBM) __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS), 226*3fd41721SRitesh Harjani (IBM) __print_flags(__entry->dio_flags, "|", IOMAP_DIO_STRINGS), 227*3fd41721SRitesh Harjani (IBM) __entry->aio) 228*3fd41721SRitesh Harjani (IBM) ); 229*3fd41721SRitesh Harjani (IBM) 230*3fd41721SRitesh Harjani (IBM) TRACE_EVENT(iomap_dio_complete, 231*3fd41721SRitesh Harjani (IBM) TP_PROTO(struct kiocb *iocb, int error, ssize_t ret), 232*3fd41721SRitesh Harjani (IBM) TP_ARGS(iocb, error, ret), 233*3fd41721SRitesh Harjani (IBM) TP_STRUCT__entry( 234*3fd41721SRitesh Harjani (IBM) __field(dev_t, dev) 235*3fd41721SRitesh Harjani (IBM) __field(ino_t, ino) 236*3fd41721SRitesh Harjani (IBM) __field(loff_t, isize) 237*3fd41721SRitesh Harjani (IBM) __field(loff_t, pos) 238*3fd41721SRitesh Harjani (IBM) __field(int, ki_flags) 239*3fd41721SRitesh Harjani (IBM) __field(bool, aio) 240*3fd41721SRitesh Harjani (IBM) __field(int, error) 241*3fd41721SRitesh Harjani (IBM) __field(ssize_t, ret) 242*3fd41721SRitesh Harjani (IBM) ), 243*3fd41721SRitesh Harjani (IBM) TP_fast_assign( 244*3fd41721SRitesh Harjani (IBM) __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev; 245*3fd41721SRitesh Harjani (IBM) __entry->ino = file_inode(iocb->ki_filp)->i_ino; 246*3fd41721SRitesh Harjani (IBM) __entry->isize = file_inode(iocb->ki_filp)->i_size; 247*3fd41721SRitesh Harjani (IBM) __entry->pos = iocb->ki_pos; 248*3fd41721SRitesh Harjani (IBM) __entry->ki_flags = iocb->ki_flags; 249*3fd41721SRitesh Harjani (IBM) __entry->aio = !is_sync_kiocb(iocb); 250*3fd41721SRitesh Harjani (IBM) __entry->error = error; 251*3fd41721SRitesh Harjani (IBM) __entry->ret = ret; 252*3fd41721SRitesh Harjani (IBM) ), 253*3fd41721SRitesh Harjani (IBM) TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd", 254*3fd41721SRitesh Harjani (IBM) MAJOR(__entry->dev), MINOR(__entry->dev), 255*3fd41721SRitesh Harjani (IBM) __entry->ino, 256*3fd41721SRitesh Harjani (IBM) __entry->isize, 257*3fd41721SRitesh Harjani (IBM) __entry->pos, 258*3fd41721SRitesh Harjani (IBM) __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS), 259*3fd41721SRitesh Harjani (IBM) __entry->aio, 260*3fd41721SRitesh Harjani (IBM) __entry->error, 261*3fd41721SRitesh Harjani (IBM) __entry->ret) 262*3fd41721SRitesh Harjani (IBM) ); 263*3fd41721SRitesh Harjani (IBM) 2649e91c572SChristoph Hellwig #endif /* _IOMAP_TRACE_H */ 2659e91c572SChristoph Hellwig 2669e91c572SChristoph Hellwig #undef TRACE_INCLUDE_PATH 2679e91c572SChristoph Hellwig #define TRACE_INCLUDE_PATH . 2689e91c572SChristoph Hellwig #define TRACE_INCLUDE_FILE trace 2699e91c572SChristoph Hellwig #include <trace/define_trace.h> 270