1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM erofs 4 5 #if !defined(_TRACE_EROFS_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_EROFS_H 7 8 #include <linux/tracepoint.h> 9 #include <linux/fs.h> 10 11 struct erofs_map_blocks; 12 13 #define show_dev(dev) MAJOR(dev), MINOR(dev) 14 #define show_dev_nid(entry) show_dev(entry->dev), entry->nid 15 16 #define show_file_type(type) \ 17 __print_symbolic(type, \ 18 { 0, "FILE" }, \ 19 { 1, "DIR" }) 20 21 #define show_map_flags(flags) __print_flags(flags, "|", \ 22 { EROFS_GET_BLOCKS_RAW, "RAW" }) 23 24 #define show_mflags(flags) __print_flags(flags, "", \ 25 { EROFS_MAP_MAPPED, "M" }, \ 26 { EROFS_MAP_META, "I" }, \ 27 { EROFS_MAP_ENCODED, "E" }) 28 29 TRACE_EVENT(erofs_lookup, 30 31 TP_PROTO(struct inode *dir, struct dentry *dentry, unsigned int flags), 32 33 TP_ARGS(dir, dentry, flags), 34 35 TP_STRUCT__entry( 36 __field(dev_t, dev ) 37 __field(erofs_nid_t, nid ) 38 __string(name, dentry->d_name.name ) 39 __field(unsigned int, flags ) 40 ), 41 42 TP_fast_assign( 43 __entry->dev = dir->i_sb->s_dev; 44 __entry->nid = EROFS_I(dir)->nid; 45 __assign_str(name, dentry->d_name.name); 46 __entry->flags = flags; 47 ), 48 49 TP_printk("dev = (%d,%d), pnid = %llu, name:%s, flags:%x", 50 show_dev_nid(__entry), 51 __get_str(name), 52 __entry->flags) 53 ); 54 55 TRACE_EVENT(erofs_fill_inode, 56 TP_PROTO(struct inode *inode), 57 TP_ARGS(inode), 58 59 TP_STRUCT__entry( 60 __field(dev_t, dev ) 61 __field(erofs_nid_t, nid ) 62 __field(erofs_blk_t, blkaddr ) 63 __field(unsigned int, ofs ) 64 ), 65 66 TP_fast_assign( 67 __entry->dev = inode->i_sb->s_dev; 68 __entry->nid = EROFS_I(inode)->nid; 69 __entry->blkaddr = erofs_blknr(iloc(EROFS_I_SB(inode), __entry->nid)); 70 __entry->ofs = erofs_blkoff(iloc(EROFS_I_SB(inode), __entry->nid)); 71 ), 72 73 TP_printk("dev = (%d,%d), nid = %llu, blkaddr %u ofs %u", 74 show_dev_nid(__entry), 75 __entry->blkaddr, __entry->ofs) 76 ); 77 78 TRACE_EVENT(erofs_readpage, 79 80 TP_PROTO(struct page *page, bool raw), 81 82 TP_ARGS(page, raw), 83 84 TP_STRUCT__entry( 85 __field(dev_t, dev ) 86 __field(erofs_nid_t, nid ) 87 __field(int, dir ) 88 __field(pgoff_t, index ) 89 __field(int, uptodate) 90 __field(bool, raw ) 91 ), 92 93 TP_fast_assign( 94 __entry->dev = page->mapping->host->i_sb->s_dev; 95 __entry->nid = EROFS_I(page->mapping->host)->nid; 96 __entry->dir = S_ISDIR(page->mapping->host->i_mode); 97 __entry->index = page->index; 98 __entry->uptodate = PageUptodate(page); 99 __entry->raw = raw; 100 ), 101 102 TP_printk("dev = (%d,%d), nid = %llu, %s, index = %lu, uptodate = %d " 103 "raw = %d", 104 show_dev_nid(__entry), 105 show_file_type(__entry->dir), 106 (unsigned long)__entry->index, 107 __entry->uptodate, 108 __entry->raw) 109 ); 110 111 TRACE_EVENT(erofs_readpages, 112 113 TP_PROTO(struct inode *inode, pgoff_t start, unsigned int nrpage, 114 bool raw), 115 116 TP_ARGS(inode, start, nrpage, raw), 117 118 TP_STRUCT__entry( 119 __field(dev_t, dev ) 120 __field(erofs_nid_t, nid ) 121 __field(pgoff_t, start ) 122 __field(unsigned int, nrpage ) 123 __field(bool, raw ) 124 ), 125 126 TP_fast_assign( 127 __entry->dev = inode->i_sb->s_dev; 128 __entry->nid = EROFS_I(inode)->nid; 129 __entry->start = start; 130 __entry->nrpage = nrpage; 131 __entry->raw = raw; 132 ), 133 134 TP_printk("dev = (%d,%d), nid = %llu, start = %lu nrpage = %u raw = %d", 135 show_dev_nid(__entry), 136 (unsigned long)__entry->start, 137 __entry->nrpage, 138 __entry->raw) 139 ); 140 141 DECLARE_EVENT_CLASS(erofs__map_blocks_enter, 142 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 143 unsigned int flags), 144 145 TP_ARGS(inode, map, flags), 146 147 TP_STRUCT__entry( 148 __field( dev_t, dev ) 149 __field( erofs_nid_t, nid ) 150 __field( erofs_off_t, la ) 151 __field( u64, llen ) 152 __field( unsigned int, flags ) 153 ), 154 155 TP_fast_assign( 156 __entry->dev = inode->i_sb->s_dev; 157 __entry->nid = EROFS_I(inode)->nid; 158 __entry->la = map->m_la; 159 __entry->llen = map->m_llen; 160 __entry->flags = flags; 161 ), 162 163 TP_printk("dev = (%d,%d), nid = %llu, la %llu llen %llu flags %s", 164 show_dev_nid(__entry), 165 __entry->la, __entry->llen, 166 __entry->flags ? show_map_flags(__entry->flags) : "NULL") 167 ); 168 169 DEFINE_EVENT(erofs__map_blocks_enter, erofs_map_blocks_enter, 170 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 171 unsigned flags), 172 173 TP_ARGS(inode, map, flags) 174 ); 175 176 DEFINE_EVENT(erofs__map_blocks_enter, z_erofs_map_blocks_iter_enter, 177 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 178 unsigned int flags), 179 180 TP_ARGS(inode, map, flags) 181 ); 182 183 DECLARE_EVENT_CLASS(erofs__map_blocks_exit, 184 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 185 unsigned int flags, int ret), 186 187 TP_ARGS(inode, map, flags, ret), 188 189 TP_STRUCT__entry( 190 __field( dev_t, dev ) 191 __field( erofs_nid_t, nid ) 192 __field( unsigned int, flags ) 193 __field( erofs_off_t, la ) 194 __field( erofs_off_t, pa ) 195 __field( u64, llen ) 196 __field( u64, plen ) 197 __field( unsigned int, mflags ) 198 __field( int, ret ) 199 ), 200 201 TP_fast_assign( 202 __entry->dev = inode->i_sb->s_dev; 203 __entry->nid = EROFS_I(inode)->nid; 204 __entry->flags = flags; 205 __entry->la = map->m_la; 206 __entry->pa = map->m_pa; 207 __entry->llen = map->m_llen; 208 __entry->plen = map->m_plen; 209 __entry->mflags = map->m_flags; 210 __entry->ret = ret; 211 ), 212 213 TP_printk("dev = (%d,%d), nid = %llu, flags %s " 214 "la %llu pa %llu llen %llu plen %llu mflags %s ret %d", 215 show_dev_nid(__entry), 216 __entry->flags ? show_map_flags(__entry->flags) : "NULL", 217 __entry->la, __entry->pa, __entry->llen, __entry->plen, 218 show_mflags(__entry->mflags), __entry->ret) 219 ); 220 221 DEFINE_EVENT(erofs__map_blocks_exit, erofs_map_blocks_exit, 222 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 223 unsigned flags, int ret), 224 225 TP_ARGS(inode, map, flags, ret) 226 ); 227 228 DEFINE_EVENT(erofs__map_blocks_exit, z_erofs_map_blocks_iter_exit, 229 TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, 230 unsigned int flags, int ret), 231 232 TP_ARGS(inode, map, flags, ret) 233 ); 234 235 TRACE_EVENT(erofs_destroy_inode, 236 TP_PROTO(struct inode *inode), 237 238 TP_ARGS(inode), 239 240 TP_STRUCT__entry( 241 __field( dev_t, dev ) 242 __field( erofs_nid_t, nid ) 243 ), 244 245 TP_fast_assign( 246 __entry->dev = inode->i_sb->s_dev; 247 __entry->nid = EROFS_I(inode)->nid; 248 ), 249 250 TP_printk("dev = (%d,%d), nid = %llu", show_dev_nid(__entry)) 251 ); 252 253 #endif /* _TRACE_EROFS_H */ 254 255 /* This part must be outside protection */ 256 #include <trace/define_trace.h> 257