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