Trond Myklebust | c6d01c6 | 2013-08-09 11:51:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> |
| 3 | */ |
| 4 | #undef TRACE_SYSTEM |
| 5 | #define TRACE_SYSTEM nfs4 |
| 6 | |
| 7 | #if !defined(_TRACE_NFS4_H) || defined(TRACE_HEADER_MULTI_READ) |
| 8 | #define _TRACE_NFS4_H |
| 9 | |
| 10 | #include <linux/tracepoint.h> |
| 11 | |
| 12 | #define show_nfsv4_errors(error) \ |
| 13 | __print_symbolic(error, \ |
| 14 | { NFS4_OK, "OK" }, \ |
| 15 | /* Mapped by nfs4_stat_to_errno() */ \ |
| 16 | { -EPERM, "EPERM" }, \ |
| 17 | { -ENOENT, "ENOENT" }, \ |
| 18 | { -EIO, "EIO" }, \ |
| 19 | { -ENXIO, "ENXIO" }, \ |
| 20 | { -EACCES, "EACCES" }, \ |
| 21 | { -EEXIST, "EEXIST" }, \ |
| 22 | { -EXDEV, "EXDEV" }, \ |
| 23 | { -ENOTDIR, "ENOTDIR" }, \ |
| 24 | { -EISDIR, "EISDIR" }, \ |
| 25 | { -EFBIG, "EFBIG" }, \ |
| 26 | { -ENOSPC, "ENOSPC" }, \ |
| 27 | { -EROFS, "EROFS" }, \ |
| 28 | { -EMLINK, "EMLINK" }, \ |
| 29 | { -ENAMETOOLONG, "ENAMETOOLONG" }, \ |
| 30 | { -ENOTEMPTY, "ENOTEMPTY" }, \ |
| 31 | { -EDQUOT, "EDQUOT" }, \ |
| 32 | { -ESTALE, "ESTALE" }, \ |
| 33 | { -EBADHANDLE, "EBADHANDLE" }, \ |
| 34 | { -EBADCOOKIE, "EBADCOOKIE" }, \ |
| 35 | { -ENOTSUPP, "ENOTSUPP" }, \ |
| 36 | { -ETOOSMALL, "ETOOSMALL" }, \ |
| 37 | { -EREMOTEIO, "EREMOTEIO" }, \ |
| 38 | { -EBADTYPE, "EBADTYPE" }, \ |
| 39 | { -EAGAIN, "EAGAIN" }, \ |
| 40 | { -ELOOP, "ELOOP" }, \ |
| 41 | { -EOPNOTSUPP, "EOPNOTSUPP" }, \ |
| 42 | { -EDEADLK, "EDEADLK" }, \ |
| 43 | /* RPC errors */ \ |
| 44 | { -ENOMEM, "ENOMEM" }, \ |
| 45 | { -EKEYEXPIRED, "EKEYEXPIRED" }, \ |
| 46 | { -ETIMEDOUT, "ETIMEDOUT" }, \ |
| 47 | { -ERESTARTSYS, "ERESTARTSYS" }, \ |
| 48 | { -ECONNREFUSED, "ECONNREFUSED" }, \ |
| 49 | { -ECONNRESET, "ECONNRESET" }, \ |
| 50 | { -ENETUNREACH, "ENETUNREACH" }, \ |
| 51 | { -EHOSTUNREACH, "EHOSTUNREACH" }, \ |
| 52 | { -EHOSTDOWN, "EHOSTDOWN" }, \ |
| 53 | { -EPIPE, "EPIPE" }, \ |
| 54 | { -EPFNOSUPPORT, "EPFNOSUPPORT" }, \ |
| 55 | { -EPROTONOSUPPORT, "EPROTONOSUPPORT" }, \ |
| 56 | /* NFSv4 native errors */ \ |
| 57 | { -NFS4ERR_ACCESS, "ACCESS" }, \ |
| 58 | { -NFS4ERR_ATTRNOTSUPP, "ATTRNOTSUPP" }, \ |
| 59 | { -NFS4ERR_ADMIN_REVOKED, "ADMIN_REVOKED" }, \ |
| 60 | { -NFS4ERR_BACK_CHAN_BUSY, "BACK_CHAN_BUSY" }, \ |
| 61 | { -NFS4ERR_BADCHAR, "BADCHAR" }, \ |
| 62 | { -NFS4ERR_BADHANDLE, "BADHANDLE" }, \ |
| 63 | { -NFS4ERR_BADIOMODE, "BADIOMODE" }, \ |
| 64 | { -NFS4ERR_BADLAYOUT, "BADLAYOUT" }, \ |
| 65 | { -NFS4ERR_BADLABEL, "BADLABEL" }, \ |
| 66 | { -NFS4ERR_BADNAME, "BADNAME" }, \ |
| 67 | { -NFS4ERR_BADOWNER, "BADOWNER" }, \ |
| 68 | { -NFS4ERR_BADSESSION, "BADSESSION" }, \ |
| 69 | { -NFS4ERR_BADSLOT, "BADSLOT" }, \ |
| 70 | { -NFS4ERR_BADTYPE, "BADTYPE" }, \ |
| 71 | { -NFS4ERR_BADXDR, "BADXDR" }, \ |
| 72 | { -NFS4ERR_BAD_COOKIE, "BAD_COOKIE" }, \ |
| 73 | { -NFS4ERR_BAD_HIGH_SLOT, "BAD_HIGH_SLOT" }, \ |
| 74 | { -NFS4ERR_BAD_RANGE, "BAD_RANGE" }, \ |
| 75 | { -NFS4ERR_BAD_SEQID, "BAD_SEQID" }, \ |
| 76 | { -NFS4ERR_BAD_SESSION_DIGEST, "BAD_SESSION_DIGEST" }, \ |
| 77 | { -NFS4ERR_BAD_STATEID, "BAD_STATEID" }, \ |
| 78 | { -NFS4ERR_CB_PATH_DOWN, "CB_PATH_DOWN" }, \ |
| 79 | { -NFS4ERR_CLID_INUSE, "CLID_INUSE" }, \ |
| 80 | { -NFS4ERR_CLIENTID_BUSY, "CLIENTID_BUSY" }, \ |
| 81 | { -NFS4ERR_COMPLETE_ALREADY, "COMPLETE_ALREADY" }, \ |
| 82 | { -NFS4ERR_CONN_NOT_BOUND_TO_SESSION, \ |
| 83 | "CONN_NOT_BOUND_TO_SESSION" }, \ |
| 84 | { -NFS4ERR_DEADLOCK, "DEADLOCK" }, \ |
| 85 | { -NFS4ERR_DEADSESSION, "DEAD_SESSION" }, \ |
| 86 | { -NFS4ERR_DELAY, "DELAY" }, \ |
| 87 | { -NFS4ERR_DELEG_ALREADY_WANTED, \ |
| 88 | "DELEG_ALREADY_WANTED" }, \ |
| 89 | { -NFS4ERR_DELEG_REVOKED, "DELEG_REVOKED" }, \ |
| 90 | { -NFS4ERR_DENIED, "DENIED" }, \ |
| 91 | { -NFS4ERR_DIRDELEG_UNAVAIL, "DIRDELEG_UNAVAIL" }, \ |
| 92 | { -NFS4ERR_DQUOT, "DQUOT" }, \ |
| 93 | { -NFS4ERR_ENCR_ALG_UNSUPP, "ENCR_ALG_UNSUPP" }, \ |
| 94 | { -NFS4ERR_EXIST, "EXIST" }, \ |
| 95 | { -NFS4ERR_EXPIRED, "EXPIRED" }, \ |
| 96 | { -NFS4ERR_FBIG, "FBIG" }, \ |
| 97 | { -NFS4ERR_FHEXPIRED, "FHEXPIRED" }, \ |
| 98 | { -NFS4ERR_FILE_OPEN, "FILE_OPEN" }, \ |
| 99 | { -NFS4ERR_GRACE, "GRACE" }, \ |
| 100 | { -NFS4ERR_HASH_ALG_UNSUPP, "HASH_ALG_UNSUPP" }, \ |
| 101 | { -NFS4ERR_INVAL, "INVAL" }, \ |
| 102 | { -NFS4ERR_IO, "IO" }, \ |
| 103 | { -NFS4ERR_ISDIR, "ISDIR" }, \ |
| 104 | { -NFS4ERR_LAYOUTTRYLATER, "LAYOUTTRYLATER" }, \ |
| 105 | { -NFS4ERR_LAYOUTUNAVAILABLE, "LAYOUTUNAVAILABLE" }, \ |
| 106 | { -NFS4ERR_LEASE_MOVED, "LEASE_MOVED" }, \ |
| 107 | { -NFS4ERR_LOCKED, "LOCKED" }, \ |
| 108 | { -NFS4ERR_LOCKS_HELD, "LOCKS_HELD" }, \ |
| 109 | { -NFS4ERR_LOCK_RANGE, "LOCK_RANGE" }, \ |
| 110 | { -NFS4ERR_MINOR_VERS_MISMATCH, "MINOR_VERS_MISMATCH" }, \ |
| 111 | { -NFS4ERR_MLINK, "MLINK" }, \ |
| 112 | { -NFS4ERR_MOVED, "MOVED" }, \ |
| 113 | { -NFS4ERR_NAMETOOLONG, "NAMETOOLONG" }, \ |
| 114 | { -NFS4ERR_NOENT, "NOENT" }, \ |
| 115 | { -NFS4ERR_NOFILEHANDLE, "NOFILEHANDLE" }, \ |
| 116 | { -NFS4ERR_NOMATCHING_LAYOUT, "NOMATCHING_LAYOUT" }, \ |
| 117 | { -NFS4ERR_NOSPC, "NOSPC" }, \ |
| 118 | { -NFS4ERR_NOTDIR, "NOTDIR" }, \ |
| 119 | { -NFS4ERR_NOTEMPTY, "NOTEMPTY" }, \ |
| 120 | { -NFS4ERR_NOTSUPP, "NOTSUPP" }, \ |
| 121 | { -NFS4ERR_NOT_ONLY_OP, "NOT_ONLY_OP" }, \ |
| 122 | { -NFS4ERR_NOT_SAME, "NOT_SAME" }, \ |
| 123 | { -NFS4ERR_NO_GRACE, "NO_GRACE" }, \ |
| 124 | { -NFS4ERR_NXIO, "NXIO" }, \ |
| 125 | { -NFS4ERR_OLD_STATEID, "OLD_STATEID" }, \ |
| 126 | { -NFS4ERR_OPENMODE, "OPENMODE" }, \ |
| 127 | { -NFS4ERR_OP_ILLEGAL, "OP_ILLEGAL" }, \ |
| 128 | { -NFS4ERR_OP_NOT_IN_SESSION, "OP_NOT_IN_SESSION" }, \ |
| 129 | { -NFS4ERR_PERM, "PERM" }, \ |
| 130 | { -NFS4ERR_PNFS_IO_HOLE, "PNFS_IO_HOLE" }, \ |
| 131 | { -NFS4ERR_PNFS_NO_LAYOUT, "PNFS_NO_LAYOUT" }, \ |
| 132 | { -NFS4ERR_RECALLCONFLICT, "RECALLCONFLICT" }, \ |
| 133 | { -NFS4ERR_RECLAIM_BAD, "RECLAIM_BAD" }, \ |
| 134 | { -NFS4ERR_RECLAIM_CONFLICT, "RECLAIM_CONFLICT" }, \ |
| 135 | { -NFS4ERR_REJECT_DELEG, "REJECT_DELEG" }, \ |
| 136 | { -NFS4ERR_REP_TOO_BIG, "REP_TOO_BIG" }, \ |
| 137 | { -NFS4ERR_REP_TOO_BIG_TO_CACHE, \ |
| 138 | "REP_TOO_BIG_TO_CACHE" }, \ |
| 139 | { -NFS4ERR_REQ_TOO_BIG, "REQ_TOO_BIG" }, \ |
| 140 | { -NFS4ERR_RESOURCE, "RESOURCE" }, \ |
| 141 | { -NFS4ERR_RESTOREFH, "RESTOREFH" }, \ |
| 142 | { -NFS4ERR_RETRY_UNCACHED_REP, "RETRY_UNCACHED_REP" }, \ |
| 143 | { -NFS4ERR_RETURNCONFLICT, "RETURNCONFLICT" }, \ |
| 144 | { -NFS4ERR_ROFS, "ROFS" }, \ |
| 145 | { -NFS4ERR_SAME, "SAME" }, \ |
| 146 | { -NFS4ERR_SHARE_DENIED, "SHARE_DENIED" }, \ |
| 147 | { -NFS4ERR_SEQUENCE_POS, "SEQUENCE_POS" }, \ |
| 148 | { -NFS4ERR_SEQ_FALSE_RETRY, "SEQ_FALSE_RETRY" }, \ |
| 149 | { -NFS4ERR_SEQ_MISORDERED, "SEQ_MISORDERED" }, \ |
| 150 | { -NFS4ERR_SERVERFAULT, "SERVERFAULT" }, \ |
| 151 | { -NFS4ERR_STALE, "STALE" }, \ |
| 152 | { -NFS4ERR_STALE_CLIENTID, "STALE_CLIENTID" }, \ |
| 153 | { -NFS4ERR_STALE_STATEID, "STALE_STATEID" }, \ |
| 154 | { -NFS4ERR_SYMLINK, "SYMLINK" }, \ |
| 155 | { -NFS4ERR_TOOSMALL, "TOOSMALL" }, \ |
| 156 | { -NFS4ERR_TOO_MANY_OPS, "TOO_MANY_OPS" }, \ |
| 157 | { -NFS4ERR_UNKNOWN_LAYOUTTYPE, "UNKNOWN_LAYOUTTYPE" }, \ |
| 158 | { -NFS4ERR_UNSAFE_COMPOUND, "UNSAFE_COMPOUND" }, \ |
| 159 | { -NFS4ERR_WRONGSEC, "WRONGSEC" }, \ |
| 160 | { -NFS4ERR_WRONG_CRED, "WRONG_CRED" }, \ |
| 161 | { -NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \ |
| 162 | { -NFS4ERR_XDEV, "XDEV" }) |
| 163 | |
Trond Myklebust | 42113a7 | 2013-08-12 16:19:27 -0400 | [diff] [blame^] | 164 | #define show_open_flags(flags) \ |
| 165 | __print_flags(flags, "|", \ |
| 166 | { O_CREAT, "O_CREAT" }, \ |
| 167 | { O_EXCL, "O_EXCL" }, \ |
| 168 | { O_TRUNC, "O_TRUNC" }, \ |
| 169 | { O_DIRECT, "O_DIRECT" }) |
| 170 | |
| 171 | #define show_fmode_flags(mode) \ |
| 172 | __print_flags(mode, "|", \ |
| 173 | { ((__force unsigned long)FMODE_READ), "READ" }, \ |
| 174 | { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \ |
| 175 | { ((__force unsigned long)FMODE_EXEC), "EXEC" }) |
| 176 | |
Trond Myklebust | c6d01c6 | 2013-08-09 11:51:26 -0400 | [diff] [blame] | 177 | DECLARE_EVENT_CLASS(nfs4_clientid_event, |
| 178 | TP_PROTO( |
| 179 | const struct nfs_client *clp, |
| 180 | int error |
| 181 | ), |
| 182 | |
| 183 | TP_ARGS(clp, error), |
| 184 | |
| 185 | TP_STRUCT__entry( |
| 186 | __string(dstaddr, |
| 187 | rpc_peeraddr2str(clp->cl_rpcclient, |
| 188 | RPC_DISPLAY_ADDR)) |
| 189 | __field(int, error) |
| 190 | ), |
| 191 | |
| 192 | TP_fast_assign( |
| 193 | __entry->error = error; |
| 194 | __assign_str(dstaddr, |
| 195 | rpc_peeraddr2str(clp->cl_rpcclient, |
| 196 | RPC_DISPLAY_ADDR)); |
| 197 | ), |
| 198 | |
| 199 | TP_printk( |
| 200 | "error=%d (%s) dstaddr=%s", |
| 201 | __entry->error, |
| 202 | show_nfsv4_errors(__entry->error), |
| 203 | __get_str(dstaddr) |
| 204 | ) |
| 205 | ); |
| 206 | #define DEFINE_NFS4_CLIENTID_EVENT(name) \ |
| 207 | DEFINE_EVENT(nfs4_clientid_event, name, \ |
| 208 | TP_PROTO( \ |
| 209 | const struct nfs_client *clp, \ |
| 210 | int error \ |
| 211 | ), \ |
| 212 | TP_ARGS(clp, error)) |
| 213 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid); |
| 214 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm); |
| 215 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew); |
| 216 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async); |
| 217 | #ifdef CONFIG_NFS_V4_1 |
| 218 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id); |
| 219 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session); |
| 220 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session); |
| 221 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid); |
| 222 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session); |
| 223 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence); |
| 224 | DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete); |
| 225 | #endif /* CONFIG_NFS_V4_1 */ |
| 226 | |
Trond Myklebust | 42113a7 | 2013-08-12 16:19:27 -0400 | [diff] [blame^] | 227 | DECLARE_EVENT_CLASS(nfs4_open_event, |
| 228 | TP_PROTO( |
| 229 | const struct nfs_open_context *ctx, |
| 230 | int flags, |
| 231 | int error |
| 232 | ), |
| 233 | |
| 234 | TP_ARGS(ctx, flags, error), |
| 235 | |
| 236 | TP_STRUCT__entry( |
| 237 | __field(int, error) |
| 238 | __field(unsigned int, flags) |
| 239 | __field(unsigned int, fmode) |
| 240 | __field(dev_t, dev) |
| 241 | __field(u32, fhandle) |
| 242 | __field(u64, fileid) |
| 243 | __field(u64, dir) |
| 244 | __string(name, ctx->dentry->d_name.name) |
| 245 | ), |
| 246 | |
| 247 | TP_fast_assign( |
| 248 | const struct nfs4_state *state = ctx->state; |
| 249 | const struct inode *inode = NULL; |
| 250 | |
| 251 | __entry->error = error; |
| 252 | __entry->flags = flags; |
| 253 | __entry->fmode = (__force unsigned int)ctx->mode; |
| 254 | __entry->dev = ctx->dentry->d_sb->s_dev; |
| 255 | if (!IS_ERR(state)) |
| 256 | inode = state->inode; |
| 257 | if (inode != NULL) { |
| 258 | __entry->fileid = NFS_FILEID(inode); |
| 259 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); |
| 260 | } else { |
| 261 | __entry->fileid = 0; |
| 262 | __entry->fhandle = 0; |
| 263 | } |
| 264 | __entry->dir = NFS_FILEID(ctx->dentry->d_parent->d_inode); |
| 265 | __assign_str(name, ctx->dentry->d_name.name); |
| 266 | ), |
| 267 | |
| 268 | TP_printk( |
| 269 | "error=%d (%s) flags=%d (%s) fmode=%s " |
| 270 | "fileid=%02x:%02x:%llu fhandle=0x%08x " |
| 271 | "name=%02x:%02x:%llu/%s", |
| 272 | __entry->error, |
| 273 | show_nfsv4_errors(__entry->error), |
| 274 | __entry->flags, |
| 275 | show_open_flags(__entry->flags), |
| 276 | show_fmode_flags(__entry->fmode), |
| 277 | MAJOR(__entry->dev), MINOR(__entry->dev), |
| 278 | (unsigned long long)__entry->fileid, |
| 279 | __entry->fhandle, |
| 280 | MAJOR(__entry->dev), MINOR(__entry->dev), |
| 281 | (unsigned long long)__entry->dir, |
| 282 | __get_str(name) |
| 283 | ) |
| 284 | ); |
| 285 | |
| 286 | #define DEFINE_NFS4_OPEN_EVENT(name) \ |
| 287 | DEFINE_EVENT(nfs4_open_event, name, \ |
| 288 | TP_PROTO( \ |
| 289 | const struct nfs_open_context *ctx, \ |
| 290 | int flags, \ |
| 291 | int error \ |
| 292 | ), \ |
| 293 | TP_ARGS(ctx, flags, error)) |
| 294 | DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim); |
| 295 | DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired); |
| 296 | DEFINE_NFS4_OPEN_EVENT(nfs4_open_file); |
| 297 | |
| 298 | TRACE_EVENT(nfs4_close, |
| 299 | TP_PROTO( |
| 300 | const struct nfs4_state *state, |
| 301 | const struct nfs_closeargs *args, |
| 302 | const struct nfs_closeres *res, |
| 303 | int error |
| 304 | ), |
| 305 | |
| 306 | TP_ARGS(state, args, res, error), |
| 307 | |
| 308 | TP_STRUCT__entry( |
| 309 | __field(dev_t, dev) |
| 310 | __field(u32, fhandle) |
| 311 | __field(u64, fileid) |
| 312 | __field(unsigned int, fmode) |
| 313 | __field(int, error) |
| 314 | ), |
| 315 | |
| 316 | TP_fast_assign( |
| 317 | const struct inode *inode = state->inode; |
| 318 | |
| 319 | __entry->dev = inode->i_sb->s_dev; |
| 320 | __entry->fileid = NFS_FILEID(inode); |
| 321 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); |
| 322 | __entry->fmode = (__force unsigned int)state->state; |
| 323 | __entry->error = error; |
| 324 | ), |
| 325 | |
| 326 | TP_printk( |
| 327 | "error=%d (%s) fmode=%s fileid=%02x:%02x:%llu " |
| 328 | "fhandle=0x%08x", |
| 329 | __entry->error, |
| 330 | show_nfsv4_errors(__entry->error), |
| 331 | __entry->fmode ? show_fmode_flags(__entry->fmode) : |
| 332 | "closed", |
| 333 | MAJOR(__entry->dev), MINOR(__entry->dev), |
| 334 | (unsigned long long)__entry->fileid, |
| 335 | __entry->fhandle |
| 336 | ) |
| 337 | ); |
| 338 | |
Trond Myklebust | c6d01c6 | 2013-08-09 11:51:26 -0400 | [diff] [blame] | 339 | #endif /* _TRACE_NFS4_H */ |
| 340 | |
| 341 | #undef TRACE_INCLUDE_PATH |
| 342 | #define TRACE_INCLUDE_PATH . |
| 343 | #define TRACE_INCLUDE_FILE nfs4trace |
| 344 | /* This part must be outside protection */ |
| 345 | #include <trace/define_trace.h> |