Linux Audio

Check our new training course

Loading...
v4.6
 
   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
 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
 177#define show_nfs_fattr_flags(valid) \
 178	__print_flags((unsigned long)valid, "|", \
 179		{ NFS_ATTR_FATTR_TYPE, "TYPE" }, \
 180		{ NFS_ATTR_FATTR_MODE, "MODE" }, \
 181		{ NFS_ATTR_FATTR_NLINK, "NLINK" }, \
 182		{ NFS_ATTR_FATTR_OWNER, "OWNER" }, \
 183		{ NFS_ATTR_FATTR_GROUP, "GROUP" }, \
 184		{ NFS_ATTR_FATTR_RDEV, "RDEV" }, \
 185		{ NFS_ATTR_FATTR_SIZE, "SIZE" }, \
 186		{ NFS_ATTR_FATTR_FSID, "FSID" }, \
 187		{ NFS_ATTR_FATTR_FILEID, "FILEID" }, \
 188		{ NFS_ATTR_FATTR_ATIME, "ATIME" }, \
 189		{ NFS_ATTR_FATTR_MTIME, "MTIME" }, \
 190		{ NFS_ATTR_FATTR_CTIME, "CTIME" }, \
 191		{ NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \
 192		{ NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \
 193		{ NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" })
 194
 195DECLARE_EVENT_CLASS(nfs4_clientid_event,
 196		TP_PROTO(
 197			const struct nfs_client *clp,
 198			int error
 199		),
 200
 201		TP_ARGS(clp, error),
 202
 203		TP_STRUCT__entry(
 204			__string(dstaddr,
 205				rpc_peeraddr2str(clp->cl_rpcclient,
 206					RPC_DISPLAY_ADDR))
 207			__field(int, error)
 208		),
 209
 210		TP_fast_assign(
 211			__entry->error = error;
 212			__assign_str(dstaddr,
 213				rpc_peeraddr2str(clp->cl_rpcclient,
 214						RPC_DISPLAY_ADDR));
 215		),
 216
 217		TP_printk(
 218			"error=%d (%s) dstaddr=%s",
 219			__entry->error,
 220			show_nfsv4_errors(__entry->error),
 221			__get_str(dstaddr)
 222		)
 223);
 224#define DEFINE_NFS4_CLIENTID_EVENT(name) \
 225	DEFINE_EVENT(nfs4_clientid_event, name,	 \
 226			TP_PROTO( \
 227				const struct nfs_client *clp, \
 228				int error \
 229			), \
 230			TP_ARGS(clp, error))
 231DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
 232DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
 233DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
 234DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
 235#ifdef CONFIG_NFS_V4_1
 236DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
 237DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
 238DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
 239DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
 240DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
 241DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
 242DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
 243
 244TRACE_EVENT(nfs4_setup_sequence,
 245		TP_PROTO(
 246			const struct nfs4_session *session,
 247			const struct nfs4_sequence_args *args
 248		),
 249		TP_ARGS(session, args),
 250
 251		TP_STRUCT__entry(
 252			__field(unsigned int, session)
 253			__field(unsigned int, slot_nr)
 254			__field(unsigned int, seq_nr)
 255			__field(unsigned int, highest_used_slotid)
 256		),
 257
 258		TP_fast_assign(
 259			const struct nfs4_slot *sa_slot = args->sa_slot;
 260			__entry->session = nfs_session_id_hash(&session->sess_id);
 261			__entry->slot_nr = sa_slot->slot_nr;
 262			__entry->seq_nr = sa_slot->seq_nr;
 263			__entry->highest_used_slotid =
 264					sa_slot->table->highest_used_slotid;
 265		),
 266		TP_printk(
 267			"session=0x%08x slot_nr=%u seq_nr=%u "
 268			"highest_used_slotid=%u",
 269			__entry->session,
 270			__entry->slot_nr,
 271			__entry->seq_nr,
 272			__entry->highest_used_slotid
 273		)
 274);
 275
 276#define show_nfs4_sequence_status_flags(status) \
 277	__print_flags((unsigned long)status, "|", \
 278		{ SEQ4_STATUS_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
 279		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING, \
 280			"CB_GSS_CONTEXTS_EXPIRING" }, \
 281		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED, \
 282			"CB_GSS_CONTEXTS_EXPIRED" }, \
 283		{ SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, \
 284			"EXPIRED_ALL_STATE_REVOKED" }, \
 285		{ SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, \
 286			"EXPIRED_SOME_STATE_REVOKED" }, \
 287		{ SEQ4_STATUS_ADMIN_STATE_REVOKED, \
 288			"ADMIN_STATE_REVOKED" }, \
 289		{ SEQ4_STATUS_RECALLABLE_STATE_REVOKED,	 \
 290			"RECALLABLE_STATE_REVOKED" }, \
 291		{ SEQ4_STATUS_LEASE_MOVED, "LEASE_MOVED" }, \
 292		{ SEQ4_STATUS_RESTART_RECLAIM_NEEDED, \
 293			"RESTART_RECLAIM_NEEDED" }, \
 294		{ SEQ4_STATUS_CB_PATH_DOWN_SESSION, \
 295			"CB_PATH_DOWN_SESSION" }, \
 296		{ SEQ4_STATUS_BACKCHANNEL_FAULT, \
 297			"BACKCHANNEL_FAULT" })
 298
 299TRACE_EVENT(nfs4_sequence_done,
 300		TP_PROTO(
 301			const struct nfs4_session *session,
 302			const struct nfs4_sequence_res *res
 303		),
 304		TP_ARGS(session, res),
 305
 306		TP_STRUCT__entry(
 307			__field(unsigned int, session)
 308			__field(unsigned int, slot_nr)
 309			__field(unsigned int, seq_nr)
 310			__field(unsigned int, highest_slotid)
 311			__field(unsigned int, target_highest_slotid)
 312			__field(unsigned int, status_flags)
 313			__field(int, error)
 314		),
 315
 316		TP_fast_assign(
 317			const struct nfs4_slot *sr_slot = res->sr_slot;
 318			__entry->session = nfs_session_id_hash(&session->sess_id);
 319			__entry->slot_nr = sr_slot->slot_nr;
 320			__entry->seq_nr = sr_slot->seq_nr;
 321			__entry->highest_slotid = res->sr_highest_slotid;
 322			__entry->target_highest_slotid =
 323					res->sr_target_highest_slotid;
 324			__entry->status_flags = res->sr_status_flags;
 325			__entry->error = res->sr_status;
 
 326		),
 327		TP_printk(
 328			"error=%d (%s) session=0x%08x slot_nr=%u seq_nr=%u "
 329			"highest_slotid=%u target_highest_slotid=%u "
 330			"status_flags=%u (%s)",
 331			__entry->error,
 332			show_nfsv4_errors(__entry->error),
 333			__entry->session,
 334			__entry->slot_nr,
 335			__entry->seq_nr,
 336			__entry->highest_slotid,
 337			__entry->target_highest_slotid,
 338			__entry->status_flags,
 339			show_nfs4_sequence_status_flags(__entry->status_flags)
 340		)
 341);
 342
 343struct cb_sequenceargs;
 344struct cb_sequenceres;
 345
 346TRACE_EVENT(nfs4_cb_sequence,
 347		TP_PROTO(
 348			const struct cb_sequenceargs *args,
 349			const struct cb_sequenceres *res,
 350			__be32 status
 351		),
 352		TP_ARGS(args, res, status),
 353
 354		TP_STRUCT__entry(
 355			__field(unsigned int, session)
 356			__field(unsigned int, slot_nr)
 357			__field(unsigned int, seq_nr)
 358			__field(unsigned int, highest_slotid)
 359			__field(unsigned int, cachethis)
 360			__field(int, error)
 361		),
 362
 363		TP_fast_assign(
 364			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
 365			__entry->slot_nr = args->csa_slotid;
 366			__entry->seq_nr = args->csa_sequenceid;
 367			__entry->highest_slotid = args->csa_highestslotid;
 368			__entry->cachethis = args->csa_cachethis;
 369			__entry->error = -be32_to_cpu(status);
 370		),
 371
 372		TP_printk(
 373			"error=%d (%s) session=0x%08x slot_nr=%u seq_nr=%u "
 374			"highest_slotid=%u",
 375			__entry->error,
 376			show_nfsv4_errors(__entry->error),
 377			__entry->session,
 378			__entry->slot_nr,
 379			__entry->seq_nr,
 380			__entry->highest_slotid
 381		)
 382);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 383#endif /* CONFIG_NFS_V4_1 */
 384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 385DECLARE_EVENT_CLASS(nfs4_open_event,
 386		TP_PROTO(
 387			const struct nfs_open_context *ctx,
 388			int flags,
 389			int error
 390		),
 391
 392		TP_ARGS(ctx, flags, error),
 393
 394		TP_STRUCT__entry(
 395			__field(int, error)
 396			__field(unsigned int, flags)
 397			__field(unsigned int, fmode)
 398			__field(dev_t, dev)
 399			__field(u32, fhandle)
 400			__field(u64, fileid)
 401			__field(u64, dir)
 402			__string(name, ctx->dentry->d_name.name)
 403			__field(int, stateid_seq)
 404			__field(u32, stateid_hash)
 405			__field(int, openstateid_seq)
 406			__field(u32, openstateid_hash)
 407		),
 408
 409		TP_fast_assign(
 410			const struct nfs4_state *state = ctx->state;
 411			const struct inode *inode = NULL;
 412
 413			__entry->error = error;
 414			__entry->flags = flags;
 415			__entry->fmode = (__force unsigned int)ctx->mode;
 416			__entry->dev = ctx->dentry->d_sb->s_dev;
 417			if (!IS_ERR_OR_NULL(state)) {
 418				inode = state->inode;
 419				__entry->stateid_seq =
 420					be32_to_cpu(state->stateid.seqid);
 421				__entry->stateid_hash =
 422					nfs_stateid_hash(&state->stateid);
 423				__entry->openstateid_seq =
 424					be32_to_cpu(state->open_stateid.seqid);
 425				__entry->openstateid_hash =
 426					nfs_stateid_hash(&state->open_stateid);
 427			} else {
 428				__entry->stateid_seq = 0;
 429				__entry->stateid_hash = 0;
 430				__entry->openstateid_seq = 0;
 431				__entry->openstateid_hash = 0;
 432			}
 433			if (inode != NULL) {
 434				__entry->fileid = NFS_FILEID(inode);
 435				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 436			} else {
 437				__entry->fileid = 0;
 438				__entry->fhandle = 0;
 439			}
 440			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
 441			__assign_str(name, ctx->dentry->d_name.name);
 442		),
 443
 444		TP_printk(
 445			"error=%d (%s) flags=%d (%s) fmode=%s "
 446			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 447			"name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
 448			"openstateid=%d:0x%08x",
 449			 __entry->error,
 450			 show_nfsv4_errors(__entry->error),
 451			 __entry->flags,
 452			 show_open_flags(__entry->flags),
 453			 show_fmode_flags(__entry->fmode),
 454			 MAJOR(__entry->dev), MINOR(__entry->dev),
 455			 (unsigned long long)__entry->fileid,
 456			 __entry->fhandle,
 457			 MAJOR(__entry->dev), MINOR(__entry->dev),
 458			 (unsigned long long)__entry->dir,
 459			 __get_str(name),
 460			 __entry->stateid_seq, __entry->stateid_hash,
 461			 __entry->openstateid_seq, __entry->openstateid_hash
 462		)
 463);
 464
 465#define DEFINE_NFS4_OPEN_EVENT(name) \
 466	DEFINE_EVENT(nfs4_open_event, name, \
 467			TP_PROTO( \
 468				const struct nfs_open_context *ctx, \
 469				int flags, \
 470				int error \
 471			), \
 472			TP_ARGS(ctx, flags, error))
 473DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
 474DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
 475DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
 476
 477TRACE_EVENT(nfs4_cached_open,
 478		TP_PROTO(
 479			const struct nfs4_state *state
 480		),
 481		TP_ARGS(state),
 482		TP_STRUCT__entry(
 483			__field(dev_t, dev)
 484			__field(u32, fhandle)
 485			__field(u64, fileid)
 486			__field(unsigned int, fmode)
 487			__field(int, stateid_seq)
 488			__field(u32, stateid_hash)
 489		),
 490
 491		TP_fast_assign(
 492			const struct inode *inode = state->inode;
 493
 494			__entry->dev = inode->i_sb->s_dev;
 495			__entry->fileid = NFS_FILEID(inode);
 496			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 497			__entry->fmode = (__force unsigned int)state->state;
 498			__entry->stateid_seq =
 499				be32_to_cpu(state->stateid.seqid);
 500			__entry->stateid_hash =
 501				nfs_stateid_hash(&state->stateid);
 502		),
 503
 504		TP_printk(
 505			"fmode=%s fileid=%02x:%02x:%llu "
 506			"fhandle=0x%08x stateid=%d:0x%08x",
 507			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
 508					  "closed",
 509			MAJOR(__entry->dev), MINOR(__entry->dev),
 510			(unsigned long long)__entry->fileid,
 511			__entry->fhandle,
 512			__entry->stateid_seq, __entry->stateid_hash
 513		)
 514);
 515
 516TRACE_EVENT(nfs4_close,
 517		TP_PROTO(
 518			const struct nfs4_state *state,
 519			const struct nfs_closeargs *args,
 520			const struct nfs_closeres *res,
 521			int error
 522		),
 523
 524		TP_ARGS(state, args, res, error),
 525
 526		TP_STRUCT__entry(
 527			__field(dev_t, dev)
 528			__field(u32, fhandle)
 529			__field(u64, fileid)
 530			__field(unsigned int, fmode)
 531			__field(int, error)
 532			__field(int, stateid_seq)
 533			__field(u32, stateid_hash)
 534		),
 535
 536		TP_fast_assign(
 537			const struct inode *inode = state->inode;
 538
 539			__entry->dev = inode->i_sb->s_dev;
 540			__entry->fileid = NFS_FILEID(inode);
 541			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 542			__entry->fmode = (__force unsigned int)state->state;
 543			__entry->error = error;
 544			__entry->stateid_seq =
 545				be32_to_cpu(args->stateid.seqid);
 546			__entry->stateid_hash =
 547				nfs_stateid_hash(&args->stateid);
 548		),
 549
 550		TP_printk(
 551			"error=%d (%s) fmode=%s fileid=%02x:%02x:%llu "
 552			"fhandle=0x%08x openstateid=%d:0x%08x",
 553			__entry->error,
 554			show_nfsv4_errors(__entry->error),
 555			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
 556					  "closed",
 557			MAJOR(__entry->dev), MINOR(__entry->dev),
 558			(unsigned long long)__entry->fileid,
 559			__entry->fhandle,
 560			__entry->stateid_seq, __entry->stateid_hash
 561		)
 562);
 563
 564#define show_lock_cmd(type) \
 565	__print_symbolic((int)type, \
 566		{ F_GETLK, "GETLK" }, \
 567		{ F_SETLK, "SETLK" }, \
 568		{ F_SETLKW, "SETLKW" })
 569#define show_lock_type(type) \
 570	__print_symbolic((int)type, \
 571		{ F_RDLCK, "RDLCK" }, \
 572		{ F_WRLCK, "WRLCK" }, \
 573		{ F_UNLCK, "UNLCK" })
 574
 575DECLARE_EVENT_CLASS(nfs4_lock_event,
 576		TP_PROTO(
 577			const struct file_lock *request,
 578			const struct nfs4_state *state,
 579			int cmd,
 580			int error
 581		),
 582
 583		TP_ARGS(request, state, cmd, error),
 584
 585		TP_STRUCT__entry(
 586			__field(int, error)
 587			__field(int, cmd)
 588			__field(char, type)
 589			__field(loff_t, start)
 590			__field(loff_t, end)
 591			__field(dev_t, dev)
 592			__field(u32, fhandle)
 593			__field(u64, fileid)
 594			__field(int, stateid_seq)
 595			__field(u32, stateid_hash)
 596		),
 597
 598		TP_fast_assign(
 599			const struct inode *inode = state->inode;
 600
 601			__entry->error = error;
 602			__entry->cmd = cmd;
 603			__entry->type = request->fl_type;
 604			__entry->start = request->fl_start;
 605			__entry->end = request->fl_end;
 606			__entry->dev = inode->i_sb->s_dev;
 607			__entry->fileid = NFS_FILEID(inode);
 608			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 609			__entry->stateid_seq =
 610				be32_to_cpu(state->stateid.seqid);
 611			__entry->stateid_hash =
 612				nfs_stateid_hash(&state->stateid);
 613		),
 614
 615		TP_printk(
 616			"error=%d (%s) cmd=%s:%s range=%lld:%lld "
 617			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 618			"stateid=%d:0x%08x",
 619			__entry->error,
 620			show_nfsv4_errors(__entry->error),
 621			show_lock_cmd(__entry->cmd),
 622			show_lock_type(__entry->type),
 623			(long long)__entry->start,
 624			(long long)__entry->end,
 625			MAJOR(__entry->dev), MINOR(__entry->dev),
 626			(unsigned long long)__entry->fileid,
 627			__entry->fhandle,
 628			__entry->stateid_seq, __entry->stateid_hash
 629		)
 630);
 631
 632#define DEFINE_NFS4_LOCK_EVENT(name) \
 633	DEFINE_EVENT(nfs4_lock_event, name, \
 634			TP_PROTO( \
 635				const struct file_lock *request, \
 636				const struct nfs4_state *state, \
 637				int cmd, \
 638				int error \
 639			), \
 640			TP_ARGS(request, state, cmd, error))
 641DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
 642DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
 643
 644TRACE_EVENT(nfs4_set_lock,
 645		TP_PROTO(
 646			const struct file_lock *request,
 647			const struct nfs4_state *state,
 648			const nfs4_stateid *lockstateid,
 649			int cmd,
 650			int error
 651		),
 652
 653		TP_ARGS(request, state, lockstateid, cmd, error),
 654
 655		TP_STRUCT__entry(
 656			__field(int, error)
 657			__field(int, cmd)
 658			__field(char, type)
 659			__field(loff_t, start)
 660			__field(loff_t, end)
 661			__field(dev_t, dev)
 662			__field(u32, fhandle)
 663			__field(u64, fileid)
 664			__field(int, stateid_seq)
 665			__field(u32, stateid_hash)
 666			__field(int, lockstateid_seq)
 667			__field(u32, lockstateid_hash)
 668		),
 669
 670		TP_fast_assign(
 671			const struct inode *inode = state->inode;
 672
 673			__entry->error = error;
 674			__entry->cmd = cmd;
 675			__entry->type = request->fl_type;
 676			__entry->start = request->fl_start;
 677			__entry->end = request->fl_end;
 678			__entry->dev = inode->i_sb->s_dev;
 679			__entry->fileid = NFS_FILEID(inode);
 680			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 681			__entry->stateid_seq =
 682				be32_to_cpu(state->stateid.seqid);
 683			__entry->stateid_hash =
 684				nfs_stateid_hash(&state->stateid);
 685			__entry->lockstateid_seq =
 686				be32_to_cpu(lockstateid->seqid);
 687			__entry->lockstateid_hash =
 688				nfs_stateid_hash(lockstateid);
 689		),
 690
 691		TP_printk(
 692			"error=%d (%s) cmd=%s:%s range=%lld:%lld "
 693			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 694			"stateid=%d:0x%08x lockstateid=%d:0x%08x",
 695			__entry->error,
 696			show_nfsv4_errors(__entry->error),
 697			show_lock_cmd(__entry->cmd),
 698			show_lock_type(__entry->type),
 699			(long long)__entry->start,
 700			(long long)__entry->end,
 701			MAJOR(__entry->dev), MINOR(__entry->dev),
 702			(unsigned long long)__entry->fileid,
 703			__entry->fhandle,
 704			__entry->stateid_seq, __entry->stateid_hash,
 705			__entry->lockstateid_seq, __entry->lockstateid_hash
 706		)
 707);
 708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 709DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
 710		TP_PROTO(
 711			const struct inode *inode,
 712			fmode_t fmode
 713		),
 714
 715		TP_ARGS(inode, fmode),
 716
 717		TP_STRUCT__entry(
 718			__field(dev_t, dev)
 719			__field(u32, fhandle)
 720			__field(u64, fileid)
 721			__field(unsigned int, fmode)
 722		),
 723
 724		TP_fast_assign(
 725			__entry->dev = inode->i_sb->s_dev;
 726			__entry->fileid = NFS_FILEID(inode);
 727			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 728			__entry->fmode = (__force unsigned int)fmode;
 729		),
 730
 731		TP_printk(
 732			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
 733			show_fmode_flags(__entry->fmode),
 734			MAJOR(__entry->dev), MINOR(__entry->dev),
 735			(unsigned long long)__entry->fileid,
 736			__entry->fhandle
 737		)
 738);
 739#define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
 740	DEFINE_EVENT(nfs4_set_delegation_event, name, \
 741			TP_PROTO( \
 742				const struct inode *inode, \
 743				fmode_t fmode \
 744			), \
 745			TP_ARGS(inode, fmode))
 746DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
 747DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
 748
 749TRACE_EVENT(nfs4_delegreturn_exit,
 750		TP_PROTO(
 751			const struct nfs4_delegreturnargs *args,
 752			const struct nfs4_delegreturnres *res,
 753			int error
 754		),
 755
 756		TP_ARGS(args, res, error),
 757
 758		TP_STRUCT__entry(
 759			__field(dev_t, dev)
 760			__field(u32, fhandle)
 761			__field(int, error)
 762			__field(int, stateid_seq)
 763			__field(u32, stateid_hash)
 764		),
 765
 766		TP_fast_assign(
 767			__entry->dev = res->server->s_dev;
 768			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
 769			__entry->error = error;
 770			__entry->stateid_seq =
 771				be32_to_cpu(args->stateid->seqid);
 772			__entry->stateid_hash =
 773				nfs_stateid_hash(args->stateid);
 774		),
 775
 776		TP_printk(
 777			"error=%d (%s) dev=%02x:%02x fhandle=0x%08x "
 778			"stateid=%d:0x%08x",
 779			__entry->error,
 780			show_nfsv4_errors(__entry->error),
 781			MAJOR(__entry->dev), MINOR(__entry->dev),
 782			__entry->fhandle,
 783			__entry->stateid_seq, __entry->stateid_hash
 784		)
 785);
 786
 787#ifdef CONFIG_NFS_V4_1
 788DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
 789		TP_PROTO(
 790			const struct nfs4_state *state,
 791			const struct nfs4_lock_state *lsp,
 792			int error
 793		),
 794
 795		TP_ARGS(state, lsp, error),
 796
 797		TP_STRUCT__entry(
 798			__field(int, error)
 799			__field(dev_t, dev)
 800			__field(u32, fhandle)
 801			__field(u64, fileid)
 802			__field(int, stateid_seq)
 803			__field(u32, stateid_hash)
 804		),
 805
 806		TP_fast_assign(
 807			const struct inode *inode = state->inode;
 808
 809			__entry->error = error;
 810			__entry->dev = inode->i_sb->s_dev;
 811			__entry->fileid = NFS_FILEID(inode);
 812			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 813			__entry->stateid_seq =
 814				be32_to_cpu(state->stateid.seqid);
 815			__entry->stateid_hash =
 816				nfs_stateid_hash(&state->stateid);
 817		),
 818
 819		TP_printk(
 820			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
 821			"stateid=%d:0x%08x",
 822			__entry->error,
 823			show_nfsv4_errors(__entry->error),
 824			MAJOR(__entry->dev), MINOR(__entry->dev),
 825			(unsigned long long)__entry->fileid,
 826			__entry->fhandle,
 827			__entry->stateid_seq, __entry->stateid_hash
 828		)
 829);
 830
 831#define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
 832	DEFINE_EVENT(nfs4_test_stateid_event, name, \
 833			TP_PROTO( \
 834				const struct nfs4_state *state, \
 835				const struct nfs4_lock_state *lsp, \
 836				int error \
 837			), \
 838			TP_ARGS(state, lsp, error))
 839DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
 840DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
 841DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
 842#endif /* CONFIG_NFS_V4_1 */
 843
 844DECLARE_EVENT_CLASS(nfs4_lookup_event,
 845		TP_PROTO(
 846			const struct inode *dir,
 847			const struct qstr *name,
 848			int error
 849		),
 850
 851		TP_ARGS(dir, name, error),
 852
 853		TP_STRUCT__entry(
 854			__field(dev_t, dev)
 855			__field(int, error)
 856			__field(u64, dir)
 857			__string(name, name->name)
 858		),
 859
 860		TP_fast_assign(
 861			__entry->dev = dir->i_sb->s_dev;
 862			__entry->dir = NFS_FILEID(dir);
 863			__entry->error = error;
 864			__assign_str(name, name->name);
 865		),
 866
 867		TP_printk(
 868			"error=%d (%s) name=%02x:%02x:%llu/%s",
 869			__entry->error,
 870			show_nfsv4_errors(__entry->error),
 871			MAJOR(__entry->dev), MINOR(__entry->dev),
 872			(unsigned long long)__entry->dir,
 873			__get_str(name)
 874		)
 875);
 876
 877#define DEFINE_NFS4_LOOKUP_EVENT(name) \
 878	DEFINE_EVENT(nfs4_lookup_event, name, \
 879			TP_PROTO( \
 880				const struct inode *dir, \
 881				const struct qstr *name, \
 882				int error \
 883			), \
 884			TP_ARGS(dir, name, error))
 885
 886DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
 887DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
 888DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
 889DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
 890DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
 891DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
 892DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
 893
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 894TRACE_EVENT(nfs4_rename,
 895		TP_PROTO(
 896			const struct inode *olddir,
 897			const struct qstr *oldname,
 898			const struct inode *newdir,
 899			const struct qstr *newname,
 900			int error
 901		),
 902
 903		TP_ARGS(olddir, oldname, newdir, newname, error),
 904
 905		TP_STRUCT__entry(
 906			__field(dev_t, dev)
 907			__field(int, error)
 908			__field(u64, olddir)
 909			__string(oldname, oldname->name)
 910			__field(u64, newdir)
 911			__string(newname, newname->name)
 912		),
 913
 914		TP_fast_assign(
 915			__entry->dev = olddir->i_sb->s_dev;
 916			__entry->olddir = NFS_FILEID(olddir);
 917			__entry->newdir = NFS_FILEID(newdir);
 918			__entry->error = error;
 919			__assign_str(oldname, oldname->name);
 920			__assign_str(newname, newname->name);
 921		),
 922
 923		TP_printk(
 924			"error=%d (%s) oldname=%02x:%02x:%llu/%s "
 925			"newname=%02x:%02x:%llu/%s",
 926			__entry->error,
 927			show_nfsv4_errors(__entry->error),
 928			MAJOR(__entry->dev), MINOR(__entry->dev),
 929			(unsigned long long)__entry->olddir,
 930			__get_str(oldname),
 931			MAJOR(__entry->dev), MINOR(__entry->dev),
 932			(unsigned long long)__entry->newdir,
 933			__get_str(newname)
 934		)
 935);
 936
 937DECLARE_EVENT_CLASS(nfs4_inode_event,
 938		TP_PROTO(
 939			const struct inode *inode,
 940			int error
 941		),
 942
 943		TP_ARGS(inode, error),
 944
 945		TP_STRUCT__entry(
 946			__field(dev_t, dev)
 947			__field(u32, fhandle)
 948			__field(u64, fileid)
 949			__field(int, error)
 950		),
 951
 952		TP_fast_assign(
 953			__entry->dev = inode->i_sb->s_dev;
 954			__entry->fileid = NFS_FILEID(inode);
 955			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 956			__entry->error = error;
 957		),
 958
 959		TP_printk(
 960			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
 961			__entry->error,
 962			show_nfsv4_errors(__entry->error),
 963			MAJOR(__entry->dev), MINOR(__entry->dev),
 964			(unsigned long long)__entry->fileid,
 965			__entry->fhandle
 966		)
 967);
 968
 969#define DEFINE_NFS4_INODE_EVENT(name) \
 970	DEFINE_EVENT(nfs4_inode_event, name, \
 971			TP_PROTO( \
 972				const struct inode *inode, \
 973				int error \
 974			), \
 975			TP_ARGS(inode, error))
 976
 977DEFINE_NFS4_INODE_EVENT(nfs4_access);
 978DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
 979DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
 980DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
 981DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
 982#ifdef CONFIG_NFS_V4_SECURITY_LABEL
 983DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
 984DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
 985#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
 986
 987DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
 988		TP_PROTO(
 989			const struct inode *inode,
 990			const nfs4_stateid *stateid,
 991			int error
 992		),
 993
 994		TP_ARGS(inode, stateid, error),
 995
 996		TP_STRUCT__entry(
 997			__field(dev_t, dev)
 998			__field(u32, fhandle)
 999			__field(u64, fileid)
1000			__field(int, error)
1001			__field(int, stateid_seq)
1002			__field(u32, stateid_hash)
1003		),
1004
1005		TP_fast_assign(
1006			__entry->dev = inode->i_sb->s_dev;
1007			__entry->fileid = NFS_FILEID(inode);
1008			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1009			__entry->error = error;
1010			__entry->stateid_seq =
1011				be32_to_cpu(stateid->seqid);
1012			__entry->stateid_hash =
1013				nfs_stateid_hash(stateid);
1014		),
1015
1016		TP_printk(
1017			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1018			"stateid=%d:0x%08x",
1019			__entry->error,
1020			show_nfsv4_errors(__entry->error),
1021			MAJOR(__entry->dev), MINOR(__entry->dev),
1022			(unsigned long long)__entry->fileid,
1023			__entry->fhandle,
1024			__entry->stateid_seq, __entry->stateid_hash
1025		)
1026);
1027
1028#define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1029	DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1030			TP_PROTO( \
1031				const struct inode *inode, \
1032				const nfs4_stateid *stateid, \
1033				int error \
1034			), \
1035			TP_ARGS(inode, stateid, error))
1036
1037DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1038DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
 
 
 
1039
1040DECLARE_EVENT_CLASS(nfs4_getattr_event,
1041		TP_PROTO(
1042			const struct nfs_server *server,
1043			const struct nfs_fh *fhandle,
1044			const struct nfs_fattr *fattr,
1045			int error
1046		),
1047
1048		TP_ARGS(server, fhandle, fattr, error),
1049
1050		TP_STRUCT__entry(
1051			__field(dev_t, dev)
1052			__field(u32, fhandle)
1053			__field(u64, fileid)
1054			__field(unsigned int, valid)
1055			__field(int, error)
1056		),
1057
1058		TP_fast_assign(
1059			__entry->dev = server->s_dev;
1060			__entry->valid = fattr->valid;
1061			__entry->fhandle = nfs_fhandle_hash(fhandle);
1062			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
1063			__entry->error = error;
1064		),
1065
1066		TP_printk(
1067			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1068			"valid=%s",
1069			__entry->error,
1070			show_nfsv4_errors(__entry->error),
1071			MAJOR(__entry->dev), MINOR(__entry->dev),
1072			(unsigned long long)__entry->fileid,
1073			__entry->fhandle,
1074			show_nfs_fattr_flags(__entry->valid)
1075		)
1076);
1077
1078#define DEFINE_NFS4_GETATTR_EVENT(name) \
1079	DEFINE_EVENT(nfs4_getattr_event, name, \
1080			TP_PROTO( \
1081				const struct nfs_server *server, \
1082				const struct nfs_fh *fhandle, \
1083				const struct nfs_fattr *fattr, \
1084				int error \
1085			), \
1086			TP_ARGS(server, fhandle, fattr, error))
1087DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1088DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1089DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1090
1091DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1092		TP_PROTO(
1093			const struct nfs_client *clp,
1094			const struct nfs_fh *fhandle,
1095			const struct inode *inode,
1096			int error
1097		),
1098
1099		TP_ARGS(clp, fhandle, inode, error),
1100
1101		TP_STRUCT__entry(
1102			__field(int, error)
1103			__field(dev_t, dev)
1104			__field(u32, fhandle)
1105			__field(u64, fileid)
1106			__string(dstaddr, clp ?
1107				rpc_peeraddr2str(clp->cl_rpcclient,
1108					RPC_DISPLAY_ADDR) : "unknown")
1109		),
1110
1111		TP_fast_assign(
1112			__entry->error = error;
1113			__entry->fhandle = nfs_fhandle_hash(fhandle);
1114			if (inode != NULL) {
1115				__entry->fileid = NFS_FILEID(inode);
1116				__entry->dev = inode->i_sb->s_dev;
1117			} else {
1118				__entry->fileid = 0;
1119				__entry->dev = 0;
1120			}
1121			__assign_str(dstaddr, clp ?
1122				rpc_peeraddr2str(clp->cl_rpcclient,
1123					RPC_DISPLAY_ADDR) : "unknown")
1124		),
1125
1126		TP_printk(
1127			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1128			"dstaddr=%s",
1129			__entry->error,
1130			show_nfsv4_errors(__entry->error),
1131			MAJOR(__entry->dev), MINOR(__entry->dev),
1132			(unsigned long long)__entry->fileid,
1133			__entry->fhandle,
1134			__get_str(dstaddr)
1135		)
1136);
1137
1138#define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1139	DEFINE_EVENT(nfs4_inode_callback_event, name, \
1140			TP_PROTO( \
1141				const struct nfs_client *clp, \
1142				const struct nfs_fh *fhandle, \
1143				const struct inode *inode, \
1144				int error \
1145			), \
1146			TP_ARGS(clp, fhandle, inode, error))
1147DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1148
1149DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1150		TP_PROTO(
1151			const struct nfs_client *clp,
1152			const struct nfs_fh *fhandle,
1153			const struct inode *inode,
1154			const nfs4_stateid *stateid,
1155			int error
1156		),
1157
1158		TP_ARGS(clp, fhandle, inode, stateid, error),
1159
1160		TP_STRUCT__entry(
1161			__field(int, error)
1162			__field(dev_t, dev)
1163			__field(u32, fhandle)
1164			__field(u64, fileid)
1165			__string(dstaddr, clp ?
1166				rpc_peeraddr2str(clp->cl_rpcclient,
1167					RPC_DISPLAY_ADDR) : "unknown")
1168			__field(int, stateid_seq)
1169			__field(u32, stateid_hash)
1170		),
1171
1172		TP_fast_assign(
1173			__entry->error = error;
1174			__entry->fhandle = nfs_fhandle_hash(fhandle);
1175			if (inode != NULL) {
1176				__entry->fileid = NFS_FILEID(inode);
1177				__entry->dev = inode->i_sb->s_dev;
1178			} else {
1179				__entry->fileid = 0;
1180				__entry->dev = 0;
1181			}
1182			__assign_str(dstaddr, clp ?
1183				rpc_peeraddr2str(clp->cl_rpcclient,
1184					RPC_DISPLAY_ADDR) : "unknown")
1185			__entry->stateid_seq =
1186				be32_to_cpu(stateid->seqid);
1187			__entry->stateid_hash =
1188				nfs_stateid_hash(stateid);
1189		),
1190
1191		TP_printk(
1192			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1193			"stateid=%d:0x%08x dstaddr=%s",
1194			__entry->error,
1195			show_nfsv4_errors(__entry->error),
1196			MAJOR(__entry->dev), MINOR(__entry->dev),
1197			(unsigned long long)__entry->fileid,
1198			__entry->fhandle,
1199			__entry->stateid_seq, __entry->stateid_hash,
1200			__get_str(dstaddr)
1201		)
1202);
1203
1204#define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1205	DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1206			TP_PROTO( \
1207				const struct nfs_client *clp, \
1208				const struct nfs_fh *fhandle, \
1209				const struct inode *inode, \
1210				const nfs4_stateid *stateid, \
1211				int error \
1212			), \
1213			TP_ARGS(clp, fhandle, inode, stateid, error))
1214DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1215DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
1216
1217DECLARE_EVENT_CLASS(nfs4_idmap_event,
1218		TP_PROTO(
1219			const char *name,
1220			int len,
1221			u32 id,
1222			int error
1223		),
1224
1225		TP_ARGS(name, len, id, error),
1226
1227		TP_STRUCT__entry(
1228			__field(int, error)
1229			__field(u32, id)
1230			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
1231		),
1232
1233		TP_fast_assign(
1234			if (len < 0)
1235				len = 0;
1236			__entry->error = error < 0 ? error : 0;
1237			__entry->id = id;
1238			memcpy(__get_dynamic_array(name), name, len);
1239			((char *)__get_dynamic_array(name))[len] = 0;
1240		),
1241
1242		TP_printk(
1243			"error=%d id=%u name=%s",
1244			__entry->error,
1245			__entry->id,
1246			__get_str(name)
1247		)
1248);
1249#define DEFINE_NFS4_IDMAP_EVENT(name) \
1250	DEFINE_EVENT(nfs4_idmap_event, name, \
1251			TP_PROTO( \
1252				const char *name, \
1253				int len, \
1254				u32 id, \
1255				int error \
1256			), \
1257			TP_ARGS(name, len, id, error))
1258DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1259DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1260DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1261DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1262
 
 
 
 
 
 
 
1263DECLARE_EVENT_CLASS(nfs4_read_event,
1264		TP_PROTO(
1265			const struct nfs_pgio_header *hdr,
1266			int error
1267		),
1268
1269		TP_ARGS(hdr, error),
1270
1271		TP_STRUCT__entry(
1272			__field(dev_t, dev)
1273			__field(u32, fhandle)
1274			__field(u64, fileid)
1275			__field(loff_t, offset)
1276			__field(size_t, count)
1277			__field(int, error)
 
1278			__field(int, stateid_seq)
1279			__field(u32, stateid_hash)
 
 
1280		),
1281
1282		TP_fast_assign(
1283			const struct inode *inode = hdr->inode;
 
 
 
1284			const struct nfs4_state *state =
1285				hdr->args.context->state;
 
 
1286			__entry->dev = inode->i_sb->s_dev;
1287			__entry->fileid = NFS_FILEID(inode);
1288			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1289			__entry->offset = hdr->args.offset;
1290			__entry->count = hdr->args.count;
1291			__entry->error = error;
 
1292			__entry->stateid_seq =
1293				be32_to_cpu(state->stateid.seqid);
1294			__entry->stateid_hash =
1295				nfs_stateid_hash(&state->stateid);
 
 
 
1296		),
1297
1298		TP_printk(
1299			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1300			"offset=%lld count=%zu stateid=%d:0x%08x",
1301			__entry->error,
1302			show_nfsv4_errors(__entry->error),
 
1303			MAJOR(__entry->dev), MINOR(__entry->dev),
1304			(unsigned long long)__entry->fileid,
1305			__entry->fhandle,
1306			(long long)__entry->offset,
1307			__entry->count,
1308			__entry->stateid_seq, __entry->stateid_hash
 
1309		)
1310);
1311#define DEFINE_NFS4_READ_EVENT(name) \
1312	DEFINE_EVENT(nfs4_read_event, name, \
1313			TP_PROTO( \
1314				const struct nfs_pgio_header *hdr, \
1315				int error \
1316			), \
1317			TP_ARGS(hdr, error))
1318DEFINE_NFS4_READ_EVENT(nfs4_read);
1319#ifdef CONFIG_NFS_V4_1
1320DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1321#endif /* CONFIG_NFS_V4_1 */
1322
1323DECLARE_EVENT_CLASS(nfs4_write_event,
1324		TP_PROTO(
1325			const struct nfs_pgio_header *hdr,
1326			int error
1327		),
1328
1329		TP_ARGS(hdr, error),
1330
1331		TP_STRUCT__entry(
1332			__field(dev_t, dev)
1333			__field(u32, fhandle)
1334			__field(u64, fileid)
1335			__field(loff_t, offset)
1336			__field(size_t, count)
1337			__field(int, error)
 
1338			__field(int, stateid_seq)
1339			__field(u32, stateid_hash)
 
 
1340		),
1341
1342		TP_fast_assign(
1343			const struct inode *inode = hdr->inode;
 
 
 
1344			const struct nfs4_state *state =
1345				hdr->args.context->state;
 
 
1346			__entry->dev = inode->i_sb->s_dev;
1347			__entry->fileid = NFS_FILEID(inode);
1348			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1349			__entry->offset = hdr->args.offset;
1350			__entry->count = hdr->args.count;
1351			__entry->error = error;
 
1352			__entry->stateid_seq =
1353				be32_to_cpu(state->stateid.seqid);
1354			__entry->stateid_hash =
1355				nfs_stateid_hash(&state->stateid);
 
 
 
1356		),
1357
1358		TP_printk(
1359			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1360			"offset=%lld count=%zu stateid=%d:0x%08x",
1361			__entry->error,
1362			show_nfsv4_errors(__entry->error),
 
1363			MAJOR(__entry->dev), MINOR(__entry->dev),
1364			(unsigned long long)__entry->fileid,
1365			__entry->fhandle,
1366			(long long)__entry->offset,
1367			__entry->count,
1368			__entry->stateid_seq, __entry->stateid_hash
 
1369		)
1370);
1371
1372#define DEFINE_NFS4_WRITE_EVENT(name) \
1373	DEFINE_EVENT(nfs4_write_event, name, \
1374			TP_PROTO( \
1375				const struct nfs_pgio_header *hdr, \
1376				int error \
1377			), \
1378			TP_ARGS(hdr, error))
1379DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1380#ifdef CONFIG_NFS_V4_1
1381DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1382#endif /* CONFIG_NFS_V4_1 */
1383
1384DECLARE_EVENT_CLASS(nfs4_commit_event,
1385		TP_PROTO(
1386			const struct nfs_commit_data *data,
1387			int error
1388		),
1389
1390		TP_ARGS(data, error),
1391
1392		TP_STRUCT__entry(
1393			__field(dev_t, dev)
1394			__field(u32, fhandle)
1395			__field(u64, fileid)
 
1396			__field(loff_t, offset)
1397			__field(size_t, count)
1398			__field(int, error)
 
1399		),
1400
1401		TP_fast_assign(
1402			const struct inode *inode = data->inode;
 
 
 
 
 
1403			__entry->dev = inode->i_sb->s_dev;
1404			__entry->fileid = NFS_FILEID(inode);
1405			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1406			__entry->offset = data->args.offset;
1407			__entry->count = data->args.count;
1408			__entry->error = error;
 
 
 
1409		),
1410
1411		TP_printk(
1412			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1413			"offset=%lld count=%zu",
1414			__entry->error,
1415			show_nfsv4_errors(__entry->error),
1416			MAJOR(__entry->dev), MINOR(__entry->dev),
1417			(unsigned long long)__entry->fileid,
1418			__entry->fhandle,
1419			(long long)__entry->offset,
1420			__entry->count
 
1421		)
1422);
1423#define DEFINE_NFS4_COMMIT_EVENT(name) \
1424	DEFINE_EVENT(nfs4_commit_event, name, \
1425			TP_PROTO( \
1426				const struct nfs_commit_data *data, \
1427				int error \
1428			), \
1429			TP_ARGS(data, error))
1430DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1431#ifdef CONFIG_NFS_V4_1
1432DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1433
1434#define show_pnfs_iomode(iomode) \
1435	__print_symbolic(iomode, \
1436		{ IOMODE_READ, "READ" }, \
1437		{ IOMODE_RW, "RW" }, \
1438		{ IOMODE_ANY, "ANY" })
1439
1440TRACE_EVENT(nfs4_layoutget,
1441		TP_PROTO(
1442			const struct nfs_open_context *ctx,
1443			const struct pnfs_layout_range *args,
1444			const struct pnfs_layout_range *res,
1445			const nfs4_stateid *layout_stateid,
1446			int error
1447		),
1448
1449		TP_ARGS(ctx, args, res, layout_stateid, error),
1450
1451		TP_STRUCT__entry(
1452			__field(dev_t, dev)
1453			__field(u32, fhandle)
1454			__field(u64, fileid)
1455			__field(u32, iomode)
1456			__field(u64, offset)
1457			__field(u64, count)
1458			__field(int, error)
1459			__field(int, stateid_seq)
1460			__field(u32, stateid_hash)
1461			__field(int, layoutstateid_seq)
1462			__field(u32, layoutstateid_hash)
1463		),
1464
1465		TP_fast_assign(
1466			const struct inode *inode = d_inode(ctx->dentry);
1467			const struct nfs4_state *state = ctx->state;
1468			__entry->dev = inode->i_sb->s_dev;
1469			__entry->fileid = NFS_FILEID(inode);
1470			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1471			__entry->iomode = args->iomode;
1472			__entry->offset = args->offset;
1473			__entry->count = args->length;
1474			__entry->error = error;
1475			__entry->stateid_seq =
1476				be32_to_cpu(state->stateid.seqid);
1477			__entry->stateid_hash =
1478				nfs_stateid_hash(&state->stateid);
1479			if (!error) {
1480				__entry->layoutstateid_seq =
1481				be32_to_cpu(layout_stateid->seqid);
1482				__entry->layoutstateid_hash =
1483				nfs_stateid_hash(layout_stateid);
1484			} else {
1485				__entry->layoutstateid_seq = 0;
1486				__entry->layoutstateid_hash = 0;
1487			}
1488		),
1489
1490		TP_printk(
1491			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1492			"iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1493			"layoutstateid=%d:0x%08x",
1494			__entry->error,
1495			show_nfsv4_errors(__entry->error),
1496			MAJOR(__entry->dev), MINOR(__entry->dev),
1497			(unsigned long long)__entry->fileid,
1498			__entry->fhandle,
1499			show_pnfs_iomode(__entry->iomode),
1500			(unsigned long long)__entry->offset,
1501			(unsigned long long)__entry->count,
1502			__entry->stateid_seq, __entry->stateid_hash,
1503			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1504		)
1505);
1506
1507DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1508DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
1509DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn_on_close);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1510
1511#define show_pnfs_update_layout_reason(reason)				\
1512	__print_symbolic(reason,					\
1513		{ PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" },		\
1514		{ PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" },		\
1515		{ PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" },	\
1516		{ PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" },		\
1517		{ PNFS_UPDATE_LAYOUT_NOMEM, "nomem" },			\
1518		{ PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" },	\
1519		{ PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" },	\
1520		{ PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" },	\
1521		{ PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" },		\
1522		{ PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" },	\
1523		{ PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" })
 
 
 
1524
1525TRACE_EVENT(pnfs_update_layout,
1526		TP_PROTO(struct inode *inode,
1527			loff_t pos,
1528			u64 count,
1529			enum pnfs_iomode iomode,
1530			struct pnfs_layout_hdr *lo,
 
1531			enum pnfs_update_layout_reason reason
1532		),
1533		TP_ARGS(inode, pos, count, iomode, lo, reason),
1534		TP_STRUCT__entry(
1535			__field(dev_t, dev)
1536			__field(u64, fileid)
1537			__field(u32, fhandle)
1538			__field(loff_t, pos)
1539			__field(u64, count)
1540			__field(enum pnfs_iomode, iomode)
1541			__field(int, layoutstateid_seq)
1542			__field(u32, layoutstateid_hash)
 
1543			__field(enum pnfs_update_layout_reason, reason)
1544		),
1545		TP_fast_assign(
1546			__entry->dev = inode->i_sb->s_dev;
1547			__entry->fileid = NFS_FILEID(inode);
1548			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1549			__entry->pos = pos;
1550			__entry->count = count;
1551			__entry->iomode = iomode;
1552			__entry->reason = reason;
1553			if (lo != NULL) {
1554				__entry->layoutstateid_seq =
1555				be32_to_cpu(lo->plh_stateid.seqid);
1556				__entry->layoutstateid_hash =
1557				nfs_stateid_hash(&lo->plh_stateid);
1558			} else {
1559				__entry->layoutstateid_seq = 0;
1560				__entry->layoutstateid_hash = 0;
1561			}
 
1562		),
1563		TP_printk(
1564			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1565			"iomode=%s pos=%llu count=%llu "
1566			"layoutstateid=%d:0x%08x (%s)",
1567			MAJOR(__entry->dev), MINOR(__entry->dev),
1568			(unsigned long long)__entry->fileid,
1569			__entry->fhandle,
1570			show_pnfs_iomode(__entry->iomode),
1571			(unsigned long long)__entry->pos,
1572			(unsigned long long)__entry->count,
1573			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
 
1574			show_pnfs_update_layout_reason(__entry->reason)
1575		)
1576);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1577
1578#endif /* CONFIG_NFS_V4_1 */
1579
1580#endif /* _TRACE_NFS4_H */
1581
1582#undef TRACE_INCLUDE_PATH
1583#define TRACE_INCLUDE_PATH .
1584#define TRACE_INCLUDE_FILE nfs4trace
1585/* This part must be outside protection */
1586#include <trace/define_trace.h>
v6.8
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
   4 */
   5#undef TRACE_SYSTEM
   6#define TRACE_SYSTEM nfs4
   7
   8#if !defined(_TRACE_NFS4_H) || defined(TRACE_HEADER_MULTI_READ)
   9#define _TRACE_NFS4_H
  10
  11#include <linux/tracepoint.h>
  12#include <trace/misc/sunrpc.h>
  13
  14#include <trace/misc/fs.h>
  15#include <trace/misc/nfs.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  16
  17#define show_nfs_fattr_flags(valid) \
  18	__print_flags((unsigned long)valid, "|", \
  19		{ NFS_ATTR_FATTR_TYPE, "TYPE" }, \
  20		{ NFS_ATTR_FATTR_MODE, "MODE" }, \
  21		{ NFS_ATTR_FATTR_NLINK, "NLINK" }, \
  22		{ NFS_ATTR_FATTR_OWNER, "OWNER" }, \
  23		{ NFS_ATTR_FATTR_GROUP, "GROUP" }, \
  24		{ NFS_ATTR_FATTR_RDEV, "RDEV" }, \
  25		{ NFS_ATTR_FATTR_SIZE, "SIZE" }, \
  26		{ NFS_ATTR_FATTR_FSID, "FSID" }, \
  27		{ NFS_ATTR_FATTR_FILEID, "FILEID" }, \
  28		{ NFS_ATTR_FATTR_ATIME, "ATIME" }, \
  29		{ NFS_ATTR_FATTR_MTIME, "MTIME" }, \
  30		{ NFS_ATTR_FATTR_CTIME, "CTIME" }, \
  31		{ NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \
  32		{ NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \
  33		{ NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" })
  34
  35DECLARE_EVENT_CLASS(nfs4_clientid_event,
  36		TP_PROTO(
  37			const struct nfs_client *clp,
  38			int error
  39		),
  40
  41		TP_ARGS(clp, error),
  42
  43		TP_STRUCT__entry(
  44			__string(dstaddr, clp->cl_hostname)
  45			__field(unsigned long, error)
 
 
  46		),
  47
  48		TP_fast_assign(
  49			__entry->error = error < 0 ? -error : 0;
  50			__assign_str(dstaddr, clp->cl_hostname);
 
 
  51		),
  52
  53		TP_printk(
  54			"error=%ld (%s) dstaddr=%s",
  55			-__entry->error,
  56			show_nfs4_status(__entry->error),
  57			__get_str(dstaddr)
  58		)
  59);
  60#define DEFINE_NFS4_CLIENTID_EVENT(name) \
  61	DEFINE_EVENT(nfs4_clientid_event, name,	 \
  62			TP_PROTO( \
  63				const struct nfs_client *clp, \
  64				int error \
  65			), \
  66			TP_ARGS(clp, error))
  67DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
  68DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
  69DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
  70DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
  71#ifdef CONFIG_NFS_V4_1
  72DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
  73DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
  74DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
  75DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
  76DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
  77DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
  78DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
  79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  80TRACE_EVENT(nfs4_sequence_done,
  81		TP_PROTO(
  82			const struct nfs4_session *session,
  83			const struct nfs4_sequence_res *res
  84		),
  85		TP_ARGS(session, res),
  86
  87		TP_STRUCT__entry(
  88			__field(unsigned int, session)
  89			__field(unsigned int, slot_nr)
  90			__field(unsigned int, seq_nr)
  91			__field(unsigned int, highest_slotid)
  92			__field(unsigned int, target_highest_slotid)
  93			__field(unsigned long, status_flags)
  94			__field(unsigned long, error)
  95		),
  96
  97		TP_fast_assign(
  98			const struct nfs4_slot *sr_slot = res->sr_slot;
  99			__entry->session = nfs_session_id_hash(&session->sess_id);
 100			__entry->slot_nr = sr_slot->slot_nr;
 101			__entry->seq_nr = sr_slot->seq_nr;
 102			__entry->highest_slotid = res->sr_highest_slotid;
 103			__entry->target_highest_slotid =
 104					res->sr_target_highest_slotid;
 105			__entry->status_flags = res->sr_status_flags;
 106			__entry->error = res->sr_status < 0 ?
 107					-res->sr_status : 0;
 108		),
 109		TP_printk(
 110			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
 111			"highest_slotid=%u target_highest_slotid=%u "
 112			"status_flags=0x%lx (%s)",
 113			-__entry->error,
 114			show_nfs4_status(__entry->error),
 115			__entry->session,
 116			__entry->slot_nr,
 117			__entry->seq_nr,
 118			__entry->highest_slotid,
 119			__entry->target_highest_slotid,
 120			__entry->status_flags,
 121			show_nfs4_seq4_status(__entry->status_flags)
 122		)
 123);
 124
 125struct cb_sequenceargs;
 126struct cb_sequenceres;
 127
 128TRACE_EVENT(nfs4_cb_sequence,
 129		TP_PROTO(
 130			const struct cb_sequenceargs *args,
 131			const struct cb_sequenceres *res,
 132			__be32 status
 133		),
 134		TP_ARGS(args, res, status),
 135
 136		TP_STRUCT__entry(
 137			__field(unsigned int, session)
 138			__field(unsigned int, slot_nr)
 139			__field(unsigned int, seq_nr)
 140			__field(unsigned int, highest_slotid)
 141			__field(unsigned int, cachethis)
 142			__field(unsigned long, error)
 143		),
 144
 145		TP_fast_assign(
 146			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
 147			__entry->slot_nr = args->csa_slotid;
 148			__entry->seq_nr = args->csa_sequenceid;
 149			__entry->highest_slotid = args->csa_highestslotid;
 150			__entry->cachethis = args->csa_cachethis;
 151			__entry->error = be32_to_cpu(status);
 152		),
 153
 154		TP_printk(
 155			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
 156			"highest_slotid=%u",
 157			-__entry->error,
 158			show_nfs4_status(__entry->error),
 159			__entry->session,
 160			__entry->slot_nr,
 161			__entry->seq_nr,
 162			__entry->highest_slotid
 163		)
 164);
 165
 166TRACE_EVENT(nfs4_cb_seqid_err,
 167		TP_PROTO(
 168			const struct cb_sequenceargs *args,
 169			__be32 status
 170		),
 171		TP_ARGS(args, status),
 172
 173		TP_STRUCT__entry(
 174			__field(unsigned int, session)
 175			__field(unsigned int, slot_nr)
 176			__field(unsigned int, seq_nr)
 177			__field(unsigned int, highest_slotid)
 178			__field(unsigned int, cachethis)
 179			__field(unsigned long, error)
 180		),
 181
 182		TP_fast_assign(
 183			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
 184			__entry->slot_nr = args->csa_slotid;
 185			__entry->seq_nr = args->csa_sequenceid;
 186			__entry->highest_slotid = args->csa_highestslotid;
 187			__entry->cachethis = args->csa_cachethis;
 188			__entry->error = be32_to_cpu(status);
 189		),
 190
 191		TP_printk(
 192			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
 193			"highest_slotid=%u",
 194			-__entry->error,
 195			show_nfs4_status(__entry->error),
 196			__entry->session,
 197			__entry->slot_nr,
 198			__entry->seq_nr,
 199			__entry->highest_slotid
 200		)
 201);
 202
 203TRACE_EVENT(nfs4_cb_offload,
 204		TP_PROTO(
 205			const struct nfs_fh *cb_fh,
 206			const nfs4_stateid *cb_stateid,
 207			uint64_t cb_count,
 208			int cb_error,
 209			int cb_how_stable
 210		),
 211
 212		TP_ARGS(cb_fh, cb_stateid, cb_count, cb_error,
 213			cb_how_stable),
 214
 215		TP_STRUCT__entry(
 216			__field(unsigned long, error)
 217			__field(u32, fhandle)
 218			__field(loff_t, cb_count)
 219			__field(int, cb_how)
 220			__field(int, cb_stateid_seq)
 221			__field(u32, cb_stateid_hash)
 222		),
 223
 224		TP_fast_assign(
 225			__entry->error = cb_error < 0 ? -cb_error : 0;
 226			__entry->fhandle = nfs_fhandle_hash(cb_fh);
 227			__entry->cb_stateid_seq =
 228				be32_to_cpu(cb_stateid->seqid);
 229			__entry->cb_stateid_hash =
 230				nfs_stateid_hash(cb_stateid);
 231			__entry->cb_count = cb_count;
 232			__entry->cb_how = cb_how_stable;
 233		),
 234
 235		TP_printk(
 236			"error=%ld (%s) fhandle=0x%08x cb_stateid=%d:0x%08x "
 237			"cb_count=%llu cb_how=%s",
 238			-__entry->error,
 239			show_nfs4_status(__entry->error),
 240			__entry->fhandle,
 241			__entry->cb_stateid_seq, __entry->cb_stateid_hash,
 242			__entry->cb_count,
 243			show_nfs_stable_how(__entry->cb_how)
 244		)
 245);
 246#endif /* CONFIG_NFS_V4_1 */
 247
 248TRACE_EVENT(nfs4_setup_sequence,
 249		TP_PROTO(
 250			const struct nfs4_session *session,
 251			const struct nfs4_sequence_args *args
 252		),
 253		TP_ARGS(session, args),
 254
 255		TP_STRUCT__entry(
 256			__field(unsigned int, session)
 257			__field(unsigned int, slot_nr)
 258			__field(unsigned int, seq_nr)
 259			__field(unsigned int, highest_used_slotid)
 260		),
 261
 262		TP_fast_assign(
 263			const struct nfs4_slot *sa_slot = args->sa_slot;
 264			__entry->session = session ? nfs_session_id_hash(&session->sess_id) : 0;
 265			__entry->slot_nr = sa_slot->slot_nr;
 266			__entry->seq_nr = sa_slot->seq_nr;
 267			__entry->highest_used_slotid =
 268					sa_slot->table->highest_used_slotid;
 269		),
 270		TP_printk(
 271			"session=0x%08x slot_nr=%u seq_nr=%u "
 272			"highest_used_slotid=%u",
 273			__entry->session,
 274			__entry->slot_nr,
 275			__entry->seq_nr,
 276			__entry->highest_used_slotid
 277		)
 278);
 279
 280TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_RUNNING);
 281TRACE_DEFINE_ENUM(NFS4CLNT_CHECK_LEASE);
 282TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_EXPIRED);
 283TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_REBOOT);
 284TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_NOGRACE);
 285TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN);
 286TRACE_DEFINE_ENUM(NFS4CLNT_SESSION_RESET);
 287TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_CONFIRM);
 288TRACE_DEFINE_ENUM(NFS4CLNT_SERVER_SCOPE_MISMATCH);
 289TRACE_DEFINE_ENUM(NFS4CLNT_PURGE_STATE);
 290TRACE_DEFINE_ENUM(NFS4CLNT_BIND_CONN_TO_SESSION);
 291TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
 292TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
 293TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
 294TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
 295TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_AVAILABLE);
 296TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_RUNNING);
 297TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_READ);
 298TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_RW);
 299TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_DELAYED);
 300
 301#define show_nfs4_clp_state(state) \
 302	__print_flags(state, "|", \
 303	{ BIT(NFS4CLNT_MANAGER_RUNNING),	"MANAGER_RUNNING" }, \
 304	{ BIT(NFS4CLNT_CHECK_LEASE),		"CHECK_LEASE" }, \
 305	{ BIT(NFS4CLNT_LEASE_EXPIRED),	"LEASE_EXPIRED" }, \
 306	{ BIT(NFS4CLNT_RECLAIM_REBOOT),	"RECLAIM_REBOOT" }, \
 307	{ BIT(NFS4CLNT_RECLAIM_NOGRACE),	"RECLAIM_NOGRACE" }, \
 308	{ BIT(NFS4CLNT_DELEGRETURN),		"DELEGRETURN" }, \
 309	{ BIT(NFS4CLNT_SESSION_RESET),	"SESSION_RESET" }, \
 310	{ BIT(NFS4CLNT_LEASE_CONFIRM),	"LEASE_CONFIRM" }, \
 311	{ BIT(NFS4CLNT_SERVER_SCOPE_MISMATCH),	"SERVER_SCOPE_MISMATCH" }, \
 312	{ BIT(NFS4CLNT_PURGE_STATE),		"PURGE_STATE" }, \
 313	{ BIT(NFS4CLNT_BIND_CONN_TO_SESSION),	"BIND_CONN_TO_SESSION" }, \
 314	{ BIT(NFS4CLNT_MOVED),		"MOVED" }, \
 315	{ BIT(NFS4CLNT_LEASE_MOVED),		"LEASE_MOVED" }, \
 316	{ BIT(NFS4CLNT_DELEGATION_EXPIRED),	"DELEGATION_EXPIRED" }, \
 317	{ BIT(NFS4CLNT_RUN_MANAGER),		"RUN_MANAGER" }, \
 318	{ BIT(NFS4CLNT_MANAGER_AVAILABLE), "MANAGER_AVAILABLE" }, \
 319	{ BIT(NFS4CLNT_RECALL_RUNNING),	"RECALL_RUNNING" }, \
 320	{ BIT(NFS4CLNT_RECALL_ANY_LAYOUT_READ), "RECALL_ANY_LAYOUT_READ" }, \
 321	{ BIT(NFS4CLNT_RECALL_ANY_LAYOUT_RW), "RECALL_ANY_LAYOUT_RW" }, \
 322	{ BIT(NFS4CLNT_DELEGRETURN_DELAYED), "DELERETURN_DELAYED" })
 323
 324TRACE_EVENT(nfs4_state_mgr,
 325		TP_PROTO(
 326			const struct nfs_client *clp
 327		),
 328
 329		TP_ARGS(clp),
 330
 331		TP_STRUCT__entry(
 332			__field(unsigned long, state)
 333			__string(hostname, clp->cl_hostname)
 334		),
 335
 336		TP_fast_assign(
 337			__entry->state = clp->cl_state;
 338			__assign_str(hostname, clp->cl_hostname);
 339		),
 340
 341		TP_printk(
 342			"hostname=%s clp state=%s", __get_str(hostname),
 343			show_nfs4_clp_state(__entry->state)
 344		)
 345)
 346
 347TRACE_EVENT(nfs4_state_mgr_failed,
 348		TP_PROTO(
 349			const struct nfs_client *clp,
 350			const char *section,
 351			int status
 352		),
 353
 354		TP_ARGS(clp, section, status),
 355
 356		TP_STRUCT__entry(
 357			__field(unsigned long, error)
 358			__field(unsigned long, state)
 359			__string(hostname, clp->cl_hostname)
 360			__string(section, section)
 361		),
 362
 363		TP_fast_assign(
 364			__entry->error = status < 0 ? -status : 0;
 365			__entry->state = clp->cl_state;
 366			__assign_str(hostname, clp->cl_hostname);
 367			__assign_str(section, section);
 368		),
 369
 370		TP_printk(
 371			"hostname=%s clp state=%s error=%ld (%s) section=%s",
 372			__get_str(hostname),
 373			show_nfs4_clp_state(__entry->state), -__entry->error,
 374			show_nfs4_status(__entry->error), __get_str(section)
 375
 376		)
 377)
 378
 379TRACE_EVENT(nfs4_xdr_bad_operation,
 380		TP_PROTO(
 381			const struct xdr_stream *xdr,
 382			u32 op,
 383			u32 expected
 384		),
 385
 386		TP_ARGS(xdr, op, expected),
 387
 388		TP_STRUCT__entry(
 389			__field(unsigned int, task_id)
 390			__field(unsigned int, client_id)
 391			__field(u32, xid)
 392			__field(u32, op)
 393			__field(u32, expected)
 394		),
 395
 396		TP_fast_assign(
 397			const struct rpc_rqst *rqstp = xdr->rqst;
 398			const struct rpc_task *task = rqstp->rq_task;
 399
 400			__entry->task_id = task->tk_pid;
 401			__entry->client_id = task->tk_client->cl_clid;
 402			__entry->xid = be32_to_cpu(rqstp->rq_xid);
 403			__entry->op = op;
 404			__entry->expected = expected;
 405		),
 406
 407		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
 408			  " xid=0x%08x operation=%u, expected=%u",
 409			__entry->task_id, __entry->client_id, __entry->xid,
 410			__entry->op, __entry->expected
 411		)
 412);
 413
 414DECLARE_EVENT_CLASS(nfs4_xdr_event,
 415		TP_PROTO(
 416			const struct xdr_stream *xdr,
 417			u32 op,
 418			u32 error
 419		),
 420
 421		TP_ARGS(xdr, op, error),
 422
 423		TP_STRUCT__entry(
 424			__field(unsigned int, task_id)
 425			__field(unsigned int, client_id)
 426			__field(u32, xid)
 427			__field(u32, op)
 428			__field(unsigned long, error)
 429		),
 430
 431		TP_fast_assign(
 432			const struct rpc_rqst *rqstp = xdr->rqst;
 433			const struct rpc_task *task = rqstp->rq_task;
 434
 435			__entry->task_id = task->tk_pid;
 436			__entry->client_id = task->tk_client->cl_clid;
 437			__entry->xid = be32_to_cpu(rqstp->rq_xid);
 438			__entry->op = op;
 439			__entry->error = error;
 440		),
 441
 442		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
 443			  " xid=0x%08x error=%ld (%s) operation=%u",
 444			__entry->task_id, __entry->client_id, __entry->xid,
 445			-__entry->error, show_nfs4_status(__entry->error),
 446			__entry->op
 447		)
 448);
 449#define DEFINE_NFS4_XDR_EVENT(name) \
 450	DEFINE_EVENT(nfs4_xdr_event, name, \
 451			TP_PROTO( \
 452				const struct xdr_stream *xdr, \
 453				u32 op, \
 454				u32 error \
 455			), \
 456			TP_ARGS(xdr, op, error))
 457DEFINE_NFS4_XDR_EVENT(nfs4_xdr_status);
 458DEFINE_NFS4_XDR_EVENT(nfs4_xdr_bad_filehandle);
 459
 460DECLARE_EVENT_CLASS(nfs4_cb_error_class,
 461		TP_PROTO(
 462			__be32 xid,
 463			u32 cb_ident
 464		),
 465
 466		TP_ARGS(xid, cb_ident),
 467
 468		TP_STRUCT__entry(
 469			__field(u32, xid)
 470			__field(u32, cbident)
 471		),
 472
 473		TP_fast_assign(
 474			__entry->xid = be32_to_cpu(xid);
 475			__entry->cbident = cb_ident;
 476		),
 477
 478		TP_printk(
 479			"xid=0x%08x cb_ident=0x%08x",
 480			__entry->xid, __entry->cbident
 481		)
 482);
 483
 484#define DEFINE_CB_ERROR_EVENT(name) \
 485	DEFINE_EVENT(nfs4_cb_error_class, nfs_cb_##name, \
 486			TP_PROTO( \
 487				__be32 xid, \
 488				u32 cb_ident \
 489			), \
 490			TP_ARGS(xid, cb_ident))
 491
 492DEFINE_CB_ERROR_EVENT(no_clp);
 493DEFINE_CB_ERROR_EVENT(badprinc);
 494
 495DECLARE_EVENT_CLASS(nfs4_open_event,
 496		TP_PROTO(
 497			const struct nfs_open_context *ctx,
 498			int flags,
 499			int error
 500		),
 501
 502		TP_ARGS(ctx, flags, error),
 503
 504		TP_STRUCT__entry(
 505			__field(unsigned long, error)
 506			__field(unsigned long, flags)
 507			__field(unsigned long, fmode)
 508			__field(dev_t, dev)
 509			__field(u32, fhandle)
 510			__field(u64, fileid)
 511			__field(u64, dir)
 512			__string(name, ctx->dentry->d_name.name)
 513			__field(int, stateid_seq)
 514			__field(u32, stateid_hash)
 515			__field(int, openstateid_seq)
 516			__field(u32, openstateid_hash)
 517		),
 518
 519		TP_fast_assign(
 520			const struct nfs4_state *state = ctx->state;
 521			const struct inode *inode = NULL;
 522
 523			__entry->error = -error;
 524			__entry->flags = flags;
 525			__entry->fmode = (__force unsigned long)ctx->mode;
 526			__entry->dev = ctx->dentry->d_sb->s_dev;
 527			if (!IS_ERR_OR_NULL(state)) {
 528				inode = state->inode;
 529				__entry->stateid_seq =
 530					be32_to_cpu(state->stateid.seqid);
 531				__entry->stateid_hash =
 532					nfs_stateid_hash(&state->stateid);
 533				__entry->openstateid_seq =
 534					be32_to_cpu(state->open_stateid.seqid);
 535				__entry->openstateid_hash =
 536					nfs_stateid_hash(&state->open_stateid);
 537			} else {
 538				__entry->stateid_seq = 0;
 539				__entry->stateid_hash = 0;
 540				__entry->openstateid_seq = 0;
 541				__entry->openstateid_hash = 0;
 542			}
 543			if (inode != NULL) {
 544				__entry->fileid = NFS_FILEID(inode);
 545				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 546			} else {
 547				__entry->fileid = 0;
 548				__entry->fhandle = 0;
 549			}
 550			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
 551			__assign_str(name, ctx->dentry->d_name.name);
 552		),
 553
 554		TP_printk(
 555			"error=%ld (%s) flags=%lu (%s) fmode=%s "
 556			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 557			"name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
 558			"openstateid=%d:0x%08x",
 559			 -__entry->error,
 560			 show_nfs4_status(__entry->error),
 561			 __entry->flags,
 562			 show_fs_fcntl_open_flags(__entry->flags),
 563			 show_fs_fmode_flags(__entry->fmode),
 564			 MAJOR(__entry->dev), MINOR(__entry->dev),
 565			 (unsigned long long)__entry->fileid,
 566			 __entry->fhandle,
 567			 MAJOR(__entry->dev), MINOR(__entry->dev),
 568			 (unsigned long long)__entry->dir,
 569			 __get_str(name),
 570			 __entry->stateid_seq, __entry->stateid_hash,
 571			 __entry->openstateid_seq, __entry->openstateid_hash
 572		)
 573);
 574
 575#define DEFINE_NFS4_OPEN_EVENT(name) \
 576	DEFINE_EVENT(nfs4_open_event, name, \
 577			TP_PROTO( \
 578				const struct nfs_open_context *ctx, \
 579				int flags, \
 580				int error \
 581			), \
 582			TP_ARGS(ctx, flags, error))
 583DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
 584DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
 585DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
 586
 587TRACE_EVENT(nfs4_cached_open,
 588		TP_PROTO(
 589			const struct nfs4_state *state
 590		),
 591		TP_ARGS(state),
 592		TP_STRUCT__entry(
 593			__field(dev_t, dev)
 594			__field(u32, fhandle)
 595			__field(u64, fileid)
 596			__field(unsigned int, fmode)
 597			__field(int, stateid_seq)
 598			__field(u32, stateid_hash)
 599		),
 600
 601		TP_fast_assign(
 602			const struct inode *inode = state->inode;
 603
 604			__entry->dev = inode->i_sb->s_dev;
 605			__entry->fileid = NFS_FILEID(inode);
 606			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 607			__entry->fmode = (__force unsigned int)state->state;
 608			__entry->stateid_seq =
 609				be32_to_cpu(state->stateid.seqid);
 610			__entry->stateid_hash =
 611				nfs_stateid_hash(&state->stateid);
 612		),
 613
 614		TP_printk(
 615			"fmode=%s fileid=%02x:%02x:%llu "
 616			"fhandle=0x%08x stateid=%d:0x%08x",
 617			__entry->fmode ?  show_fs_fmode_flags(__entry->fmode) :
 618					  "closed",
 619			MAJOR(__entry->dev), MINOR(__entry->dev),
 620			(unsigned long long)__entry->fileid,
 621			__entry->fhandle,
 622			__entry->stateid_seq, __entry->stateid_hash
 623		)
 624);
 625
 626TRACE_EVENT(nfs4_close,
 627		TP_PROTO(
 628			const struct nfs4_state *state,
 629			const struct nfs_closeargs *args,
 630			const struct nfs_closeres *res,
 631			int error
 632		),
 633
 634		TP_ARGS(state, args, res, error),
 635
 636		TP_STRUCT__entry(
 637			__field(dev_t, dev)
 638			__field(u32, fhandle)
 639			__field(u64, fileid)
 640			__field(unsigned int, fmode)
 641			__field(unsigned long, error)
 642			__field(int, stateid_seq)
 643			__field(u32, stateid_hash)
 644		),
 645
 646		TP_fast_assign(
 647			const struct inode *inode = state->inode;
 648
 649			__entry->dev = inode->i_sb->s_dev;
 650			__entry->fileid = NFS_FILEID(inode);
 651			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 652			__entry->fmode = (__force unsigned int)state->state;
 653			__entry->error = error < 0 ? -error : 0;
 654			__entry->stateid_seq =
 655				be32_to_cpu(args->stateid.seqid);
 656			__entry->stateid_hash =
 657				nfs_stateid_hash(&args->stateid);
 658		),
 659
 660		TP_printk(
 661			"error=%ld (%s) fmode=%s fileid=%02x:%02x:%llu "
 662			"fhandle=0x%08x openstateid=%d:0x%08x",
 663			-__entry->error,
 664			show_nfs4_status(__entry->error),
 665			__entry->fmode ?  show_fs_fmode_flags(__entry->fmode) :
 666					  "closed",
 667			MAJOR(__entry->dev), MINOR(__entry->dev),
 668			(unsigned long long)__entry->fileid,
 669			__entry->fhandle,
 670			__entry->stateid_seq, __entry->stateid_hash
 671		)
 672);
 673
 
 
 
 
 
 
 
 
 
 
 
 674DECLARE_EVENT_CLASS(nfs4_lock_event,
 675		TP_PROTO(
 676			const struct file_lock *request,
 677			const struct nfs4_state *state,
 678			int cmd,
 679			int error
 680		),
 681
 682		TP_ARGS(request, state, cmd, error),
 683
 684		TP_STRUCT__entry(
 685			__field(unsigned long, error)
 686			__field(unsigned long, cmd)
 687			__field(unsigned long, type)
 688			__field(loff_t, start)
 689			__field(loff_t, end)
 690			__field(dev_t, dev)
 691			__field(u32, fhandle)
 692			__field(u64, fileid)
 693			__field(int, stateid_seq)
 694			__field(u32, stateid_hash)
 695		),
 696
 697		TP_fast_assign(
 698			const struct inode *inode = state->inode;
 699
 700			__entry->error = error < 0 ? -error : 0;
 701			__entry->cmd = cmd;
 702			__entry->type = request->fl_type;
 703			__entry->start = request->fl_start;
 704			__entry->end = request->fl_end;
 705			__entry->dev = inode->i_sb->s_dev;
 706			__entry->fileid = NFS_FILEID(inode);
 707			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 708			__entry->stateid_seq =
 709				be32_to_cpu(state->stateid.seqid);
 710			__entry->stateid_hash =
 711				nfs_stateid_hash(&state->stateid);
 712		),
 713
 714		TP_printk(
 715			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
 716			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 717			"stateid=%d:0x%08x",
 718			-__entry->error,
 719			show_nfs4_status(__entry->error),
 720			show_fs_fcntl_cmd(__entry->cmd),
 721			show_fs_fcntl_lock_type(__entry->type),
 722			(long long)__entry->start,
 723			(long long)__entry->end,
 724			MAJOR(__entry->dev), MINOR(__entry->dev),
 725			(unsigned long long)__entry->fileid,
 726			__entry->fhandle,
 727			__entry->stateid_seq, __entry->stateid_hash
 728		)
 729);
 730
 731#define DEFINE_NFS4_LOCK_EVENT(name) \
 732	DEFINE_EVENT(nfs4_lock_event, name, \
 733			TP_PROTO( \
 734				const struct file_lock *request, \
 735				const struct nfs4_state *state, \
 736				int cmd, \
 737				int error \
 738			), \
 739			TP_ARGS(request, state, cmd, error))
 740DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
 741DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
 742
 743TRACE_EVENT(nfs4_set_lock,
 744		TP_PROTO(
 745			const struct file_lock *request,
 746			const struct nfs4_state *state,
 747			const nfs4_stateid *lockstateid,
 748			int cmd,
 749			int error
 750		),
 751
 752		TP_ARGS(request, state, lockstateid, cmd, error),
 753
 754		TP_STRUCT__entry(
 755			__field(unsigned long, error)
 756			__field(unsigned long, cmd)
 757			__field(unsigned long, type)
 758			__field(loff_t, start)
 759			__field(loff_t, end)
 760			__field(dev_t, dev)
 761			__field(u32, fhandle)
 762			__field(u64, fileid)
 763			__field(int, stateid_seq)
 764			__field(u32, stateid_hash)
 765			__field(int, lockstateid_seq)
 766			__field(u32, lockstateid_hash)
 767		),
 768
 769		TP_fast_assign(
 770			const struct inode *inode = state->inode;
 771
 772			__entry->error = error < 0 ? -error : 0;
 773			__entry->cmd = cmd;
 774			__entry->type = request->fl_type;
 775			__entry->start = request->fl_start;
 776			__entry->end = request->fl_end;
 777			__entry->dev = inode->i_sb->s_dev;
 778			__entry->fileid = NFS_FILEID(inode);
 779			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 780			__entry->stateid_seq =
 781				be32_to_cpu(state->stateid.seqid);
 782			__entry->stateid_hash =
 783				nfs_stateid_hash(&state->stateid);
 784			__entry->lockstateid_seq =
 785				be32_to_cpu(lockstateid->seqid);
 786			__entry->lockstateid_hash =
 787				nfs_stateid_hash(lockstateid);
 788		),
 789
 790		TP_printk(
 791			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
 792			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 793			"stateid=%d:0x%08x lockstateid=%d:0x%08x",
 794			-__entry->error,
 795			show_nfs4_status(__entry->error),
 796			show_fs_fcntl_cmd(__entry->cmd),
 797			show_fs_fcntl_lock_type(__entry->type),
 798			(long long)__entry->start,
 799			(long long)__entry->end,
 800			MAJOR(__entry->dev), MINOR(__entry->dev),
 801			(unsigned long long)__entry->fileid,
 802			__entry->fhandle,
 803			__entry->stateid_seq, __entry->stateid_hash,
 804			__entry->lockstateid_seq, __entry->lockstateid_hash
 805		)
 806);
 807
 808TRACE_DEFINE_ENUM(LK_STATE_IN_USE);
 809TRACE_DEFINE_ENUM(NFS_DELEGATED_STATE);
 810TRACE_DEFINE_ENUM(NFS_OPEN_STATE);
 811TRACE_DEFINE_ENUM(NFS_O_RDONLY_STATE);
 812TRACE_DEFINE_ENUM(NFS_O_WRONLY_STATE);
 813TRACE_DEFINE_ENUM(NFS_O_RDWR_STATE);
 814TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_REBOOT);
 815TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_NOGRACE);
 816TRACE_DEFINE_ENUM(NFS_STATE_POSIX_LOCKS);
 817TRACE_DEFINE_ENUM(NFS_STATE_RECOVERY_FAILED);
 818TRACE_DEFINE_ENUM(NFS_STATE_MAY_NOTIFY_LOCK);
 819TRACE_DEFINE_ENUM(NFS_STATE_CHANGE_WAIT);
 820TRACE_DEFINE_ENUM(NFS_CLNT_DST_SSC_COPY_STATE);
 821TRACE_DEFINE_ENUM(NFS_CLNT_SRC_SSC_COPY_STATE);
 822TRACE_DEFINE_ENUM(NFS_SRV_SSC_COPY_STATE);
 823
 824#define show_nfs4_state_flags(flags) \
 825	__print_flags(flags, "|", \
 826		{ LK_STATE_IN_USE,		"IN_USE" }, \
 827		{ NFS_DELEGATED_STATE,		"DELEGATED" }, \
 828		{ NFS_OPEN_STATE,		"OPEN" }, \
 829		{ NFS_O_RDONLY_STATE,		"O_RDONLY" }, \
 830		{ NFS_O_WRONLY_STATE,		"O_WRONLY" }, \
 831		{ NFS_O_RDWR_STATE,		"O_RDWR" }, \
 832		{ NFS_STATE_RECLAIM_REBOOT,	"RECLAIM_REBOOT" }, \
 833		{ NFS_STATE_RECLAIM_NOGRACE,	"RECLAIM_NOGRACE" }, \
 834		{ NFS_STATE_POSIX_LOCKS,	"POSIX_LOCKS" }, \
 835		{ NFS_STATE_RECOVERY_FAILED,	"RECOVERY_FAILED" }, \
 836		{ NFS_STATE_MAY_NOTIFY_LOCK,	"MAY_NOTIFY_LOCK" }, \
 837		{ NFS_STATE_CHANGE_WAIT,	"CHANGE_WAIT" }, \
 838		{ NFS_CLNT_DST_SSC_COPY_STATE,	"CLNT_DST_SSC_COPY" }, \
 839		{ NFS_CLNT_SRC_SSC_COPY_STATE,	"CLNT_SRC_SSC_COPY" }, \
 840		{ NFS_SRV_SSC_COPY_STATE,	"SRV_SSC_COPY" })
 841
 842#define show_nfs4_lock_flags(flags) \
 843	__print_flags(flags, "|", \
 844		{ BIT(NFS_LOCK_INITIALIZED),	"INITIALIZED" }, \
 845		{ BIT(NFS_LOCK_LOST),		"LOST" })
 846
 847TRACE_EVENT(nfs4_state_lock_reclaim,
 848		TP_PROTO(
 849			const struct nfs4_state *state,
 850			const struct nfs4_lock_state *lock
 851		),
 852
 853		TP_ARGS(state, lock),
 854
 855		TP_STRUCT__entry(
 856			__field(dev_t, dev)
 857			__field(u32, fhandle)
 858			__field(u64, fileid)
 859			__field(unsigned long, state_flags)
 860			__field(unsigned long, lock_flags)
 861			__field(int, stateid_seq)
 862			__field(u32, stateid_hash)
 863		),
 864
 865		TP_fast_assign(
 866			const struct inode *inode = state->inode;
 867
 868			__entry->dev = inode->i_sb->s_dev;
 869			__entry->fileid = NFS_FILEID(inode);
 870			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 871			__entry->state_flags = state->flags;
 872			__entry->lock_flags = lock->ls_flags;
 873			__entry->stateid_seq =
 874				be32_to_cpu(state->stateid.seqid);
 875			__entry->stateid_hash =
 876				nfs_stateid_hash(&state->stateid);
 877		),
 878
 879		TP_printk(
 880			"fileid=%02x:%02x:%llu fhandle=0x%08x "
 881			"stateid=%d:0x%08x state_flags=%s lock_flags=%s",
 882			MAJOR(__entry->dev), MINOR(__entry->dev),
 883			(unsigned long long)__entry->fileid, __entry->fhandle,
 884			__entry->stateid_seq, __entry->stateid_hash,
 885			show_nfs4_state_flags(__entry->state_flags),
 886			show_nfs4_lock_flags(__entry->lock_flags)
 887		)
 888)
 889
 890DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
 891		TP_PROTO(
 892			const struct inode *inode,
 893			fmode_t fmode
 894		),
 895
 896		TP_ARGS(inode, fmode),
 897
 898		TP_STRUCT__entry(
 899			__field(dev_t, dev)
 900			__field(u32, fhandle)
 901			__field(u64, fileid)
 902			__field(unsigned int, fmode)
 903		),
 904
 905		TP_fast_assign(
 906			__entry->dev = inode->i_sb->s_dev;
 907			__entry->fileid = NFS_FILEID(inode);
 908			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 909			__entry->fmode = (__force unsigned int)fmode;
 910		),
 911
 912		TP_printk(
 913			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
 914			show_fs_fmode_flags(__entry->fmode),
 915			MAJOR(__entry->dev), MINOR(__entry->dev),
 916			(unsigned long long)__entry->fileid,
 917			__entry->fhandle
 918		)
 919);
 920#define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
 921	DEFINE_EVENT(nfs4_set_delegation_event, name, \
 922			TP_PROTO( \
 923				const struct inode *inode, \
 924				fmode_t fmode \
 925			), \
 926			TP_ARGS(inode, fmode))
 927DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
 928DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
 929
 930TRACE_EVENT(nfs4_delegreturn_exit,
 931		TP_PROTO(
 932			const struct nfs4_delegreturnargs *args,
 933			const struct nfs4_delegreturnres *res,
 934			int error
 935		),
 936
 937		TP_ARGS(args, res, error),
 938
 939		TP_STRUCT__entry(
 940			__field(dev_t, dev)
 941			__field(u32, fhandle)
 942			__field(unsigned long, error)
 943			__field(int, stateid_seq)
 944			__field(u32, stateid_hash)
 945		),
 946
 947		TP_fast_assign(
 948			__entry->dev = res->server->s_dev;
 949			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
 950			__entry->error = error < 0 ? -error : 0;
 951			__entry->stateid_seq =
 952				be32_to_cpu(args->stateid->seqid);
 953			__entry->stateid_hash =
 954				nfs_stateid_hash(args->stateid);
 955		),
 956
 957		TP_printk(
 958			"error=%ld (%s) dev=%02x:%02x fhandle=0x%08x "
 959			"stateid=%d:0x%08x",
 960			-__entry->error,
 961			show_nfs4_status(__entry->error),
 962			MAJOR(__entry->dev), MINOR(__entry->dev),
 963			__entry->fhandle,
 964			__entry->stateid_seq, __entry->stateid_hash
 965		)
 966);
 967
 968#ifdef CONFIG_NFS_V4_1
 969DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
 970		TP_PROTO(
 971			const struct nfs4_state *state,
 972			const struct nfs4_lock_state *lsp,
 973			int error
 974		),
 975
 976		TP_ARGS(state, lsp, error),
 977
 978		TP_STRUCT__entry(
 979			__field(unsigned long, error)
 980			__field(dev_t, dev)
 981			__field(u32, fhandle)
 982			__field(u64, fileid)
 983			__field(int, stateid_seq)
 984			__field(u32, stateid_hash)
 985		),
 986
 987		TP_fast_assign(
 988			const struct inode *inode = state->inode;
 989
 990			__entry->error = error < 0 ? -error : 0;
 991			__entry->dev = inode->i_sb->s_dev;
 992			__entry->fileid = NFS_FILEID(inode);
 993			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 994			__entry->stateid_seq =
 995				be32_to_cpu(state->stateid.seqid);
 996			__entry->stateid_hash =
 997				nfs_stateid_hash(&state->stateid);
 998		),
 999
1000		TP_printk(
1001			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1002			"stateid=%d:0x%08x",
1003			-__entry->error,
1004			show_nfs4_status(__entry->error),
1005			MAJOR(__entry->dev), MINOR(__entry->dev),
1006			(unsigned long long)__entry->fileid,
1007			__entry->fhandle,
1008			__entry->stateid_seq, __entry->stateid_hash
1009		)
1010);
1011
1012#define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
1013	DEFINE_EVENT(nfs4_test_stateid_event, name, \
1014			TP_PROTO( \
1015				const struct nfs4_state *state, \
1016				const struct nfs4_lock_state *lsp, \
1017				int error \
1018			), \
1019			TP_ARGS(state, lsp, error))
1020DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
1021DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
1022DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
1023#endif /* CONFIG_NFS_V4_1 */
1024
1025DECLARE_EVENT_CLASS(nfs4_lookup_event,
1026		TP_PROTO(
1027			const struct inode *dir,
1028			const struct qstr *name,
1029			int error
1030		),
1031
1032		TP_ARGS(dir, name, error),
1033
1034		TP_STRUCT__entry(
1035			__field(dev_t, dev)
1036			__field(unsigned long, error)
1037			__field(u64, dir)
1038			__string(name, name->name)
1039		),
1040
1041		TP_fast_assign(
1042			__entry->dev = dir->i_sb->s_dev;
1043			__entry->dir = NFS_FILEID(dir);
1044			__entry->error = -error;
1045			__assign_str(name, name->name);
1046		),
1047
1048		TP_printk(
1049			"error=%ld (%s) name=%02x:%02x:%llu/%s",
1050			-__entry->error,
1051			show_nfs4_status(__entry->error),
1052			MAJOR(__entry->dev), MINOR(__entry->dev),
1053			(unsigned long long)__entry->dir,
1054			__get_str(name)
1055		)
1056);
1057
1058#define DEFINE_NFS4_LOOKUP_EVENT(name) \
1059	DEFINE_EVENT(nfs4_lookup_event, name, \
1060			TP_PROTO( \
1061				const struct inode *dir, \
1062				const struct qstr *name, \
1063				int error \
1064			), \
1065			TP_ARGS(dir, name, error))
1066
1067DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
1068DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
1069DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
1070DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
1071DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
1072DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
1073DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
1074
1075TRACE_EVENT(nfs4_lookupp,
1076		TP_PROTO(
1077			const struct inode *inode,
1078			int error
1079		),
1080
1081		TP_ARGS(inode, error),
1082
1083		TP_STRUCT__entry(
1084			__field(dev_t, dev)
1085			__field(u64, ino)
1086			__field(unsigned long, error)
1087		),
1088
1089		TP_fast_assign(
1090			__entry->dev = inode->i_sb->s_dev;
1091			__entry->ino = NFS_FILEID(inode);
1092			__entry->error = error < 0 ? -error : 0;
1093		),
1094
1095		TP_printk(
1096			"error=%ld (%s) inode=%02x:%02x:%llu",
1097			-__entry->error,
1098			show_nfs4_status(__entry->error),
1099			MAJOR(__entry->dev), MINOR(__entry->dev),
1100			(unsigned long long)__entry->ino
1101		)
1102);
1103
1104TRACE_EVENT(nfs4_rename,
1105		TP_PROTO(
1106			const struct inode *olddir,
1107			const struct qstr *oldname,
1108			const struct inode *newdir,
1109			const struct qstr *newname,
1110			int error
1111		),
1112
1113		TP_ARGS(olddir, oldname, newdir, newname, error),
1114
1115		TP_STRUCT__entry(
1116			__field(dev_t, dev)
1117			__field(unsigned long, error)
1118			__field(u64, olddir)
1119			__string(oldname, oldname->name)
1120			__field(u64, newdir)
1121			__string(newname, newname->name)
1122		),
1123
1124		TP_fast_assign(
1125			__entry->dev = olddir->i_sb->s_dev;
1126			__entry->olddir = NFS_FILEID(olddir);
1127			__entry->newdir = NFS_FILEID(newdir);
1128			__entry->error = error < 0 ? -error : 0;
1129			__assign_str(oldname, oldname->name);
1130			__assign_str(newname, newname->name);
1131		),
1132
1133		TP_printk(
1134			"error=%ld (%s) oldname=%02x:%02x:%llu/%s "
1135			"newname=%02x:%02x:%llu/%s",
1136			-__entry->error,
1137			show_nfs4_status(__entry->error),
1138			MAJOR(__entry->dev), MINOR(__entry->dev),
1139			(unsigned long long)__entry->olddir,
1140			__get_str(oldname),
1141			MAJOR(__entry->dev), MINOR(__entry->dev),
1142			(unsigned long long)__entry->newdir,
1143			__get_str(newname)
1144		)
1145);
1146
1147DECLARE_EVENT_CLASS(nfs4_inode_event,
1148		TP_PROTO(
1149			const struct inode *inode,
1150			int error
1151		),
1152
1153		TP_ARGS(inode, error),
1154
1155		TP_STRUCT__entry(
1156			__field(dev_t, dev)
1157			__field(u32, fhandle)
1158			__field(u64, fileid)
1159			__field(unsigned long, error)
1160		),
1161
1162		TP_fast_assign(
1163			__entry->dev = inode->i_sb->s_dev;
1164			__entry->fileid = NFS_FILEID(inode);
1165			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1166			__entry->error = error < 0 ? -error : 0;
1167		),
1168
1169		TP_printk(
1170			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
1171			-__entry->error,
1172			show_nfs4_status(__entry->error),
1173			MAJOR(__entry->dev), MINOR(__entry->dev),
1174			(unsigned long long)__entry->fileid,
1175			__entry->fhandle
1176		)
1177);
1178
1179#define DEFINE_NFS4_INODE_EVENT(name) \
1180	DEFINE_EVENT(nfs4_inode_event, name, \
1181			TP_PROTO( \
1182				const struct inode *inode, \
1183				int error \
1184			), \
1185			TP_ARGS(inode, error))
1186
1187DEFINE_NFS4_INODE_EVENT(nfs4_access);
1188DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
1189DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
1190DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
1191DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
1192#ifdef CONFIG_NFS_V4_SECURITY_LABEL
1193DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
1194DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
1195#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
1196
1197DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
1198		TP_PROTO(
1199			const struct inode *inode,
1200			const nfs4_stateid *stateid,
1201			int error
1202		),
1203
1204		TP_ARGS(inode, stateid, error),
1205
1206		TP_STRUCT__entry(
1207			__field(dev_t, dev)
1208			__field(u32, fhandle)
1209			__field(u64, fileid)
1210			__field(unsigned long, error)
1211			__field(int, stateid_seq)
1212			__field(u32, stateid_hash)
1213		),
1214
1215		TP_fast_assign(
1216			__entry->dev = inode->i_sb->s_dev;
1217			__entry->fileid = NFS_FILEID(inode);
1218			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1219			__entry->error = error < 0 ? -error : 0;
1220			__entry->stateid_seq =
1221				be32_to_cpu(stateid->seqid);
1222			__entry->stateid_hash =
1223				nfs_stateid_hash(stateid);
1224		),
1225
1226		TP_printk(
1227			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1228			"stateid=%d:0x%08x",
1229			-__entry->error,
1230			show_nfs4_status(__entry->error),
1231			MAJOR(__entry->dev), MINOR(__entry->dev),
1232			(unsigned long long)__entry->fileid,
1233			__entry->fhandle,
1234			__entry->stateid_seq, __entry->stateid_hash
1235		)
1236);
1237
1238#define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1239	DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1240			TP_PROTO( \
1241				const struct inode *inode, \
1242				const nfs4_stateid *stateid, \
1243				int error \
1244			), \
1245			TP_ARGS(inode, stateid, error))
1246
1247DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1248DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
1249DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
1250DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
1251DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_close_stateid_update_wait);
1252
1253DECLARE_EVENT_CLASS(nfs4_getattr_event,
1254		TP_PROTO(
1255			const struct nfs_server *server,
1256			const struct nfs_fh *fhandle,
1257			const struct nfs_fattr *fattr,
1258			int error
1259		),
1260
1261		TP_ARGS(server, fhandle, fattr, error),
1262
1263		TP_STRUCT__entry(
1264			__field(dev_t, dev)
1265			__field(u32, fhandle)
1266			__field(u64, fileid)
1267			__field(unsigned int, valid)
1268			__field(unsigned long, error)
1269		),
1270
1271		TP_fast_assign(
1272			__entry->dev = server->s_dev;
1273			__entry->valid = fattr->valid;
1274			__entry->fhandle = nfs_fhandle_hash(fhandle);
1275			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
1276			__entry->error = error < 0 ? -error : 0;
1277		),
1278
1279		TP_printk(
1280			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1281			"valid=%s",
1282			-__entry->error,
1283			show_nfs4_status(__entry->error),
1284			MAJOR(__entry->dev), MINOR(__entry->dev),
1285			(unsigned long long)__entry->fileid,
1286			__entry->fhandle,
1287			show_nfs_fattr_flags(__entry->valid)
1288		)
1289);
1290
1291#define DEFINE_NFS4_GETATTR_EVENT(name) \
1292	DEFINE_EVENT(nfs4_getattr_event, name, \
1293			TP_PROTO( \
1294				const struct nfs_server *server, \
1295				const struct nfs_fh *fhandle, \
1296				const struct nfs_fattr *fattr, \
1297				int error \
1298			), \
1299			TP_ARGS(server, fhandle, fattr, error))
1300DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1301DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1302DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1303
1304DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1305		TP_PROTO(
1306			const struct nfs_client *clp,
1307			const struct nfs_fh *fhandle,
1308			const struct inode *inode,
1309			int error
1310		),
1311
1312		TP_ARGS(clp, fhandle, inode, error),
1313
1314		TP_STRUCT__entry(
1315			__field(unsigned long, error)
1316			__field(dev_t, dev)
1317			__field(u32, fhandle)
1318			__field(u64, fileid)
1319			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
 
 
1320		),
1321
1322		TP_fast_assign(
1323			__entry->error = error < 0 ? -error : 0;
1324			__entry->fhandle = nfs_fhandle_hash(fhandle);
1325			if (!IS_ERR_OR_NULL(inode)) {
1326				__entry->fileid = NFS_FILEID(inode);
1327				__entry->dev = inode->i_sb->s_dev;
1328			} else {
1329				__entry->fileid = 0;
1330				__entry->dev = 0;
1331			}
1332			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
 
 
1333		),
1334
1335		TP_printk(
1336			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1337			"dstaddr=%s",
1338			-__entry->error,
1339			show_nfs4_status(__entry->error),
1340			MAJOR(__entry->dev), MINOR(__entry->dev),
1341			(unsigned long long)__entry->fileid,
1342			__entry->fhandle,
1343			__get_str(dstaddr)
1344		)
1345);
1346
1347#define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1348	DEFINE_EVENT(nfs4_inode_callback_event, name, \
1349			TP_PROTO( \
1350				const struct nfs_client *clp, \
1351				const struct nfs_fh *fhandle, \
1352				const struct inode *inode, \
1353				int error \
1354			), \
1355			TP_ARGS(clp, fhandle, inode, error))
1356DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1357
1358DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1359		TP_PROTO(
1360			const struct nfs_client *clp,
1361			const struct nfs_fh *fhandle,
1362			const struct inode *inode,
1363			const nfs4_stateid *stateid,
1364			int error
1365		),
1366
1367		TP_ARGS(clp, fhandle, inode, stateid, error),
1368
1369		TP_STRUCT__entry(
1370			__field(unsigned long, error)
1371			__field(dev_t, dev)
1372			__field(u32, fhandle)
1373			__field(u64, fileid)
1374			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
 
 
1375			__field(int, stateid_seq)
1376			__field(u32, stateid_hash)
1377		),
1378
1379		TP_fast_assign(
1380			__entry->error = error < 0 ? -error : 0;
1381			__entry->fhandle = nfs_fhandle_hash(fhandle);
1382			if (!IS_ERR_OR_NULL(inode)) {
1383				__entry->fileid = NFS_FILEID(inode);
1384				__entry->dev = inode->i_sb->s_dev;
1385			} else {
1386				__entry->fileid = 0;
1387				__entry->dev = 0;
1388			}
1389			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
 
 
1390			__entry->stateid_seq =
1391				be32_to_cpu(stateid->seqid);
1392			__entry->stateid_hash =
1393				nfs_stateid_hash(stateid);
1394		),
1395
1396		TP_printk(
1397			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1398			"stateid=%d:0x%08x dstaddr=%s",
1399			-__entry->error,
1400			show_nfs4_status(__entry->error),
1401			MAJOR(__entry->dev), MINOR(__entry->dev),
1402			(unsigned long long)__entry->fileid,
1403			__entry->fhandle,
1404			__entry->stateid_seq, __entry->stateid_hash,
1405			__get_str(dstaddr)
1406		)
1407);
1408
1409#define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1410	DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1411			TP_PROTO( \
1412				const struct nfs_client *clp, \
1413				const struct nfs_fh *fhandle, \
1414				const struct inode *inode, \
1415				const nfs4_stateid *stateid, \
1416				int error \
1417			), \
1418			TP_ARGS(clp, fhandle, inode, stateid, error))
1419DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1420DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
1421
1422DECLARE_EVENT_CLASS(nfs4_idmap_event,
1423		TP_PROTO(
1424			const char *name,
1425			int len,
1426			u32 id,
1427			int error
1428		),
1429
1430		TP_ARGS(name, len, id, error),
1431
1432		TP_STRUCT__entry(
1433			__field(unsigned long, error)
1434			__field(u32, id)
1435			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
1436		),
1437
1438		TP_fast_assign(
1439			if (len < 0)
1440				len = 0;
1441			__entry->error = error < 0 ? error : 0;
1442			__entry->id = id;
1443			memcpy(__get_str(name), name, len);
1444			__get_str(name)[len] = 0;
1445		),
1446
1447		TP_printk(
1448			"error=%ld (%s) id=%u name=%s",
1449			-__entry->error, show_nfs4_status(__entry->error),
1450			__entry->id,
1451			__get_str(name)
1452		)
1453);
1454#define DEFINE_NFS4_IDMAP_EVENT(name) \
1455	DEFINE_EVENT(nfs4_idmap_event, name, \
1456			TP_PROTO( \
1457				const char *name, \
1458				int len, \
1459				u32 id, \
1460				int error \
1461			), \
1462			TP_ARGS(name, len, id, error))
1463DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1464DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1465DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1466DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1467
1468#ifdef CONFIG_NFS_V4_1
1469#define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) \
1470	(lseg ? nfs_stateid_hash(&lseg->pls_layout->plh_stateid) : 0)
1471#else
1472#define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) (0)
1473#endif
1474
1475DECLARE_EVENT_CLASS(nfs4_read_event,
1476		TP_PROTO(
1477			const struct nfs_pgio_header *hdr,
1478			int error
1479		),
1480
1481		TP_ARGS(hdr, error),
1482
1483		TP_STRUCT__entry(
1484			__field(dev_t, dev)
1485			__field(u32, fhandle)
1486			__field(u64, fileid)
1487			__field(loff_t, offset)
1488			__field(u32, arg_count)
1489			__field(u32, res_count)
1490			__field(unsigned long, error)
1491			__field(int, stateid_seq)
1492			__field(u32, stateid_hash)
1493			__field(int, layoutstateid_seq)
1494			__field(u32, layoutstateid_hash)
1495		),
1496
1497		TP_fast_assign(
1498			const struct inode *inode = hdr->inode;
1499			const struct nfs_inode *nfsi = NFS_I(inode);
1500			const struct nfs_fh *fh = hdr->args.fh ?
1501						  hdr->args.fh : &nfsi->fh;
1502			const struct nfs4_state *state =
1503				hdr->args.context->state;
1504			const struct pnfs_layout_segment *lseg = hdr->lseg;
1505
1506			__entry->dev = inode->i_sb->s_dev;
1507			__entry->fileid = nfsi->fileid;
1508			__entry->fhandle = nfs_fhandle_hash(fh);
1509			__entry->offset = hdr->args.offset;
1510			__entry->arg_count = hdr->args.count;
1511			__entry->res_count = hdr->res.count;
1512			__entry->error = error < 0 ? -error : 0;
1513			__entry->stateid_seq =
1514				be32_to_cpu(state->stateid.seqid);
1515			__entry->stateid_hash =
1516				nfs_stateid_hash(&state->stateid);
1517			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1518			__entry->layoutstateid_hash =
1519				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1520		),
1521
1522		TP_printk(
1523			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1524			"offset=%lld count=%u res=%u stateid=%d:0x%08x "
1525			"layoutstateid=%d:0x%08x",
1526			-__entry->error,
1527			show_nfs4_status(__entry->error),
1528			MAJOR(__entry->dev), MINOR(__entry->dev),
1529			(unsigned long long)__entry->fileid,
1530			__entry->fhandle,
1531			(long long)__entry->offset,
1532			__entry->arg_count, __entry->res_count,
1533			__entry->stateid_seq, __entry->stateid_hash,
1534			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1535		)
1536);
1537#define DEFINE_NFS4_READ_EVENT(name) \
1538	DEFINE_EVENT(nfs4_read_event, name, \
1539			TP_PROTO( \
1540				const struct nfs_pgio_header *hdr, \
1541				int error \
1542			), \
1543			TP_ARGS(hdr, error))
1544DEFINE_NFS4_READ_EVENT(nfs4_read);
1545#ifdef CONFIG_NFS_V4_1
1546DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1547#endif /* CONFIG_NFS_V4_1 */
1548
1549DECLARE_EVENT_CLASS(nfs4_write_event,
1550		TP_PROTO(
1551			const struct nfs_pgio_header *hdr,
1552			int error
1553		),
1554
1555		TP_ARGS(hdr, error),
1556
1557		TP_STRUCT__entry(
1558			__field(dev_t, dev)
1559			__field(u32, fhandle)
1560			__field(u64, fileid)
1561			__field(loff_t, offset)
1562			__field(u32, arg_count)
1563			__field(u32, res_count)
1564			__field(unsigned long, error)
1565			__field(int, stateid_seq)
1566			__field(u32, stateid_hash)
1567			__field(int, layoutstateid_seq)
1568			__field(u32, layoutstateid_hash)
1569		),
1570
1571		TP_fast_assign(
1572			const struct inode *inode = hdr->inode;
1573			const struct nfs_inode *nfsi = NFS_I(inode);
1574			const struct nfs_fh *fh = hdr->args.fh ?
1575						  hdr->args.fh : &nfsi->fh;
1576			const struct nfs4_state *state =
1577				hdr->args.context->state;
1578			const struct pnfs_layout_segment *lseg = hdr->lseg;
1579
1580			__entry->dev = inode->i_sb->s_dev;
1581			__entry->fileid = nfsi->fileid;
1582			__entry->fhandle = nfs_fhandle_hash(fh);
1583			__entry->offset = hdr->args.offset;
1584			__entry->arg_count = hdr->args.count;
1585			__entry->res_count = hdr->res.count;
1586			__entry->error = error < 0 ? -error : 0;
1587			__entry->stateid_seq =
1588				be32_to_cpu(state->stateid.seqid);
1589			__entry->stateid_hash =
1590				nfs_stateid_hash(&state->stateid);
1591			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1592			__entry->layoutstateid_hash =
1593				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1594		),
1595
1596		TP_printk(
1597			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1598			"offset=%lld count=%u res=%u stateid=%d:0x%08x "
1599			"layoutstateid=%d:0x%08x",
1600			-__entry->error,
1601			show_nfs4_status(__entry->error),
1602			MAJOR(__entry->dev), MINOR(__entry->dev),
1603			(unsigned long long)__entry->fileid,
1604			__entry->fhandle,
1605			(long long)__entry->offset,
1606			__entry->arg_count, __entry->res_count,
1607			__entry->stateid_seq, __entry->stateid_hash,
1608			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1609		)
1610);
1611
1612#define DEFINE_NFS4_WRITE_EVENT(name) \
1613	DEFINE_EVENT(nfs4_write_event, name, \
1614			TP_PROTO( \
1615				const struct nfs_pgio_header *hdr, \
1616				int error \
1617			), \
1618			TP_ARGS(hdr, error))
1619DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1620#ifdef CONFIG_NFS_V4_1
1621DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1622#endif /* CONFIG_NFS_V4_1 */
1623
1624DECLARE_EVENT_CLASS(nfs4_commit_event,
1625		TP_PROTO(
1626			const struct nfs_commit_data *data,
1627			int error
1628		),
1629
1630		TP_ARGS(data, error),
1631
1632		TP_STRUCT__entry(
1633			__field(dev_t, dev)
1634			__field(u32, fhandle)
1635			__field(u64, fileid)
1636			__field(unsigned long, error)
1637			__field(loff_t, offset)
1638			__field(u32, count)
1639			__field(int, layoutstateid_seq)
1640			__field(u32, layoutstateid_hash)
1641		),
1642
1643		TP_fast_assign(
1644			const struct inode *inode = data->inode;
1645			const struct nfs_inode *nfsi = NFS_I(inode);
1646			const struct nfs_fh *fh = data->args.fh ?
1647						  data->args.fh : &nfsi->fh;
1648			const struct pnfs_layout_segment *lseg = data->lseg;
1649
1650			__entry->dev = inode->i_sb->s_dev;
1651			__entry->fileid = nfsi->fileid;
1652			__entry->fhandle = nfs_fhandle_hash(fh);
1653			__entry->offset = data->args.offset;
1654			__entry->count = data->args.count;
1655			__entry->error = error < 0 ? -error : 0;
1656			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1657			__entry->layoutstateid_hash =
1658				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1659		),
1660
1661		TP_printk(
1662			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1663			"offset=%lld count=%u layoutstateid=%d:0x%08x",
1664			-__entry->error,
1665			show_nfs4_status(__entry->error),
1666			MAJOR(__entry->dev), MINOR(__entry->dev),
1667			(unsigned long long)__entry->fileid,
1668			__entry->fhandle,
1669			(long long)__entry->offset,
1670			__entry->count,
1671			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1672		)
1673);
1674#define DEFINE_NFS4_COMMIT_EVENT(name) \
1675	DEFINE_EVENT(nfs4_commit_event, name, \
1676			TP_PROTO( \
1677				const struct nfs_commit_data *data, \
1678				int error \
1679			), \
1680			TP_ARGS(data, error))
1681DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1682#ifdef CONFIG_NFS_V4_1
1683DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1684
 
 
 
 
 
 
1685TRACE_EVENT(nfs4_layoutget,
1686		TP_PROTO(
1687			const struct nfs_open_context *ctx,
1688			const struct pnfs_layout_range *args,
1689			const struct pnfs_layout_range *res,
1690			const nfs4_stateid *layout_stateid,
1691			int error
1692		),
1693
1694		TP_ARGS(ctx, args, res, layout_stateid, error),
1695
1696		TP_STRUCT__entry(
1697			__field(dev_t, dev)
1698			__field(u32, fhandle)
1699			__field(u64, fileid)
1700			__field(u32, iomode)
1701			__field(u64, offset)
1702			__field(u64, count)
1703			__field(unsigned long, error)
1704			__field(int, stateid_seq)
1705			__field(u32, stateid_hash)
1706			__field(int, layoutstateid_seq)
1707			__field(u32, layoutstateid_hash)
1708		),
1709
1710		TP_fast_assign(
1711			const struct inode *inode = d_inode(ctx->dentry);
1712			const struct nfs4_state *state = ctx->state;
1713			__entry->dev = inode->i_sb->s_dev;
1714			__entry->fileid = NFS_FILEID(inode);
1715			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1716			__entry->iomode = args->iomode;
1717			__entry->offset = args->offset;
1718			__entry->count = args->length;
1719			__entry->error = error < 0 ? -error : 0;
1720			__entry->stateid_seq =
1721				be32_to_cpu(state->stateid.seqid);
1722			__entry->stateid_hash =
1723				nfs_stateid_hash(&state->stateid);
1724			if (!error) {
1725				__entry->layoutstateid_seq =
1726				be32_to_cpu(layout_stateid->seqid);
1727				__entry->layoutstateid_hash =
1728				nfs_stateid_hash(layout_stateid);
1729			} else {
1730				__entry->layoutstateid_seq = 0;
1731				__entry->layoutstateid_hash = 0;
1732			}
1733		),
1734
1735		TP_printk(
1736			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1737			"iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1738			"layoutstateid=%d:0x%08x",
1739			-__entry->error,
1740			show_nfs4_status(__entry->error),
1741			MAJOR(__entry->dev), MINOR(__entry->dev),
1742			(unsigned long long)__entry->fileid,
1743			__entry->fhandle,
1744			show_pnfs_layout_iomode(__entry->iomode),
1745			(unsigned long long)__entry->offset,
1746			(unsigned long long)__entry->count,
1747			__entry->stateid_seq, __entry->stateid_hash,
1748			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1749		)
1750);
1751
1752DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1753DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
1754DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn_on_close);
1755DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layouterror);
1756DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutstats);
1757
1758TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN);
1759TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS);
1760TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN);
1761TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH);
1762TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM);
1763TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL);
1764TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL);
1765TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED);
1766TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN);
1767TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED);
1768TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN);
1769TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY);
1770TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
1771TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_EXIT);
1772
1773#define show_pnfs_update_layout_reason(reason)				\
1774	__print_symbolic(reason,					\
1775		{ PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" },		\
1776		{ PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" },		\
1777		{ PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" },	\
1778		{ PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" },		\
1779		{ PNFS_UPDATE_LAYOUT_NOMEM, "nomem" },			\
1780		{ PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" },	\
1781		{ PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" },	\
1782		{ PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" },	\
1783		{ PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" },		\
1784		{ PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" },	\
1785		{ PNFS_UPDATE_LAYOUT_INVALID_OPEN, "invalid open" },	\
1786		{ PNFS_UPDATE_LAYOUT_RETRY, "retrying" },	\
1787		{ PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" }, \
1788		{ PNFS_UPDATE_LAYOUT_EXIT, "exit" })
1789
1790TRACE_EVENT(pnfs_update_layout,
1791		TP_PROTO(struct inode *inode,
1792			loff_t pos,
1793			u64 count,
1794			enum pnfs_iomode iomode,
1795			struct pnfs_layout_hdr *lo,
1796			struct pnfs_layout_segment *lseg,
1797			enum pnfs_update_layout_reason reason
1798		),
1799		TP_ARGS(inode, pos, count, iomode, lo, lseg, reason),
1800		TP_STRUCT__entry(
1801			__field(dev_t, dev)
1802			__field(u64, fileid)
1803			__field(u32, fhandle)
1804			__field(loff_t, pos)
1805			__field(u64, count)
1806			__field(enum pnfs_iomode, iomode)
1807			__field(int, layoutstateid_seq)
1808			__field(u32, layoutstateid_hash)
1809			__field(long, lseg)
1810			__field(enum pnfs_update_layout_reason, reason)
1811		),
1812		TP_fast_assign(
1813			__entry->dev = inode->i_sb->s_dev;
1814			__entry->fileid = NFS_FILEID(inode);
1815			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1816			__entry->pos = pos;
1817			__entry->count = count;
1818			__entry->iomode = iomode;
1819			__entry->reason = reason;
1820			if (lo != NULL && pnfs_layout_is_valid(lo)) {
1821				__entry->layoutstateid_seq =
1822				be32_to_cpu(lo->plh_stateid.seqid);
1823				__entry->layoutstateid_hash =
1824				nfs_stateid_hash(&lo->plh_stateid);
1825			} else {
1826				__entry->layoutstateid_seq = 0;
1827				__entry->layoutstateid_hash = 0;
1828			}
1829			__entry->lseg = (long)lseg;
1830		),
1831		TP_printk(
1832			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1833			"iomode=%s pos=%llu count=%llu "
1834			"layoutstateid=%d:0x%08x lseg=0x%lx (%s)",
1835			MAJOR(__entry->dev), MINOR(__entry->dev),
1836			(unsigned long long)__entry->fileid,
1837			__entry->fhandle,
1838			show_pnfs_layout_iomode(__entry->iomode),
1839			(unsigned long long)__entry->pos,
1840			(unsigned long long)__entry->count,
1841			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1842			__entry->lseg,
1843			show_pnfs_update_layout_reason(__entry->reason)
1844		)
1845);
1846
1847DECLARE_EVENT_CLASS(pnfs_layout_event,
1848		TP_PROTO(struct inode *inode,
1849			loff_t pos,
1850			u64 count,
1851			enum pnfs_iomode iomode,
1852			struct pnfs_layout_hdr *lo,
1853			struct pnfs_layout_segment *lseg
1854		),
1855		TP_ARGS(inode, pos, count, iomode, lo, lseg),
1856		TP_STRUCT__entry(
1857			__field(dev_t, dev)
1858			__field(u64, fileid)
1859			__field(u32, fhandle)
1860			__field(loff_t, pos)
1861			__field(u64, count)
1862			__field(enum pnfs_iomode, iomode)
1863			__field(int, layoutstateid_seq)
1864			__field(u32, layoutstateid_hash)
1865			__field(long, lseg)
1866		),
1867		TP_fast_assign(
1868			__entry->dev = inode->i_sb->s_dev;
1869			__entry->fileid = NFS_FILEID(inode);
1870			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1871			__entry->pos = pos;
1872			__entry->count = count;
1873			__entry->iomode = iomode;
1874			if (lo != NULL && pnfs_layout_is_valid(lo)) {
1875				__entry->layoutstateid_seq =
1876				be32_to_cpu(lo->plh_stateid.seqid);
1877				__entry->layoutstateid_hash =
1878				nfs_stateid_hash(&lo->plh_stateid);
1879			} else {
1880				__entry->layoutstateid_seq = 0;
1881				__entry->layoutstateid_hash = 0;
1882			}
1883			__entry->lseg = (long)lseg;
1884		),
1885		TP_printk(
1886			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1887			"iomode=%s pos=%llu count=%llu "
1888			"layoutstateid=%d:0x%08x lseg=0x%lx",
1889			MAJOR(__entry->dev), MINOR(__entry->dev),
1890			(unsigned long long)__entry->fileid,
1891			__entry->fhandle,
1892			show_pnfs_layout_iomode(__entry->iomode),
1893			(unsigned long long)__entry->pos,
1894			(unsigned long long)__entry->count,
1895			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1896			__entry->lseg
1897		)
1898);
1899
1900#define DEFINE_PNFS_LAYOUT_EVENT(name) \
1901	DEFINE_EVENT(pnfs_layout_event, name, \
1902		TP_PROTO(struct inode *inode, \
1903			loff_t pos, \
1904			u64 count, \
1905			enum pnfs_iomode iomode, \
1906			struct pnfs_layout_hdr *lo, \
1907			struct pnfs_layout_segment *lseg \
1908		), \
1909		TP_ARGS(inode, pos, count, iomode, lo, lseg))
1910
1911DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_read);
1912DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_write);
1913DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_get_mirror_count);
1914DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_done);
1915DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
1916DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
1917DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
1918
1919DECLARE_EVENT_CLASS(nfs4_deviceid_event,
1920		TP_PROTO(
1921			const struct nfs_client *clp,
1922			const struct nfs4_deviceid *deviceid
1923		),
1924
1925		TP_ARGS(clp, deviceid),
1926
1927		TP_STRUCT__entry(
1928			__string(dstaddr, clp->cl_hostname)
1929			__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1930		),
1931
1932		TP_fast_assign(
1933			__assign_str(dstaddr, clp->cl_hostname);
1934			memcpy(__entry->deviceid, deviceid->data,
1935			       NFS4_DEVICEID4_SIZE);
1936		),
1937
1938		TP_printk(
1939			"deviceid=%s, dstaddr=%s",
1940			__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1941			__get_str(dstaddr)
1942		)
1943);
1944#define DEFINE_PNFS_DEVICEID_EVENT(name) \
1945	DEFINE_EVENT(nfs4_deviceid_event, name, \
1946			TP_PROTO(const struct nfs_client *clp, \
1947				const struct nfs4_deviceid *deviceid \
1948			), \
1949			TP_ARGS(clp, deviceid))
1950DEFINE_PNFS_DEVICEID_EVENT(nfs4_deviceid_free);
1951
1952DECLARE_EVENT_CLASS(nfs4_deviceid_status,
1953		TP_PROTO(
1954			const struct nfs_server *server,
1955			const struct nfs4_deviceid *deviceid,
1956			int status
1957		),
1958
1959		TP_ARGS(server, deviceid, status),
1960
1961		TP_STRUCT__entry(
1962			__field(dev_t, dev)
1963			__field(int, status)
1964			__string(dstaddr, server->nfs_client->cl_hostname)
1965			__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1966		),
1967
1968		TP_fast_assign(
1969			__entry->dev = server->s_dev;
1970			__entry->status = status;
1971			__assign_str(dstaddr, server->nfs_client->cl_hostname);
1972			memcpy(__entry->deviceid, deviceid->data,
1973			       NFS4_DEVICEID4_SIZE);
1974		),
1975
1976		TP_printk(
1977			"dev=%02x:%02x: deviceid=%s, dstaddr=%s, status=%d",
1978			MAJOR(__entry->dev), MINOR(__entry->dev),
1979			__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1980			__get_str(dstaddr),
1981			__entry->status
1982		)
1983);
1984#define DEFINE_PNFS_DEVICEID_STATUS(name) \
1985	DEFINE_EVENT(nfs4_deviceid_status, name, \
1986			TP_PROTO(const struct nfs_server *server, \
1987				const struct nfs4_deviceid *deviceid, \
1988				int status \
1989			), \
1990			TP_ARGS(server, deviceid, status))
1991DEFINE_PNFS_DEVICEID_STATUS(nfs4_getdeviceinfo);
1992DEFINE_PNFS_DEVICEID_STATUS(nfs4_find_deviceid);
1993
1994DECLARE_EVENT_CLASS(nfs4_flexfiles_io_event,
1995		TP_PROTO(
1996			const struct nfs_pgio_header *hdr
1997		),
1998
1999		TP_ARGS(hdr),
2000
2001		TP_STRUCT__entry(
2002			__field(unsigned long, error)
2003			__field(dev_t, dev)
2004			__field(u32, fhandle)
2005			__field(u64, fileid)
2006			__field(loff_t, offset)
2007			__field(u32, count)
2008			__field(int, stateid_seq)
2009			__field(u32, stateid_hash)
2010			__string(dstaddr, hdr->ds_clp ?
2011				rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
2012					RPC_DISPLAY_ADDR) : "unknown")
2013		),
2014
2015		TP_fast_assign(
2016			const struct inode *inode = hdr->inode;
2017
2018			__entry->error = hdr->res.op_status;
2019			__entry->fhandle = nfs_fhandle_hash(hdr->args.fh);
2020			__entry->fileid = NFS_FILEID(inode);
2021			__entry->dev = inode->i_sb->s_dev;
2022			__entry->offset = hdr->args.offset;
2023			__entry->count = hdr->args.count;
2024			__entry->stateid_seq =
2025				be32_to_cpu(hdr->args.stateid.seqid);
2026			__entry->stateid_hash =
2027				nfs_stateid_hash(&hdr->args.stateid);
2028			__assign_str(dstaddr, hdr->ds_clp ?
2029				rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
2030					RPC_DISPLAY_ADDR) : "unknown");
2031		),
2032
2033		TP_printk(
2034			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2035			"offset=%llu count=%u stateid=%d:0x%08x dstaddr=%s",
2036			-__entry->error,
2037			show_nfs4_status(__entry->error),
2038			MAJOR(__entry->dev), MINOR(__entry->dev),
2039			(unsigned long long)__entry->fileid,
2040			__entry->fhandle,
2041			__entry->offset, __entry->count,
2042			__entry->stateid_seq, __entry->stateid_hash,
2043			__get_str(dstaddr)
2044		)
2045);
2046
2047#define DEFINE_NFS4_FLEXFILES_IO_EVENT(name) \
2048	DEFINE_EVENT(nfs4_flexfiles_io_event, name, \
2049			TP_PROTO( \
2050				const struct nfs_pgio_header *hdr \
2051			), \
2052			TP_ARGS(hdr))
2053DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_read_error);
2054DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_write_error);
2055
2056TRACE_EVENT(ff_layout_commit_error,
2057		TP_PROTO(
2058			const struct nfs_commit_data *data
2059		),
2060
2061		TP_ARGS(data),
2062
2063		TP_STRUCT__entry(
2064			__field(unsigned long, error)
2065			__field(dev_t, dev)
2066			__field(u32, fhandle)
2067			__field(u64, fileid)
2068			__field(loff_t, offset)
2069			__field(u32, count)
2070			__string(dstaddr, data->ds_clp ?
2071				rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2072					RPC_DISPLAY_ADDR) : "unknown")
2073		),
2074
2075		TP_fast_assign(
2076			const struct inode *inode = data->inode;
2077
2078			__entry->error = data->res.op_status;
2079			__entry->fhandle = nfs_fhandle_hash(data->args.fh);
2080			__entry->fileid = NFS_FILEID(inode);
2081			__entry->dev = inode->i_sb->s_dev;
2082			__entry->offset = data->args.offset;
2083			__entry->count = data->args.count;
2084			__assign_str(dstaddr, data->ds_clp ?
2085				rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2086					RPC_DISPLAY_ADDR) : "unknown");
2087		),
2088
2089		TP_printk(
2090			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2091			"offset=%llu count=%u dstaddr=%s",
2092			-__entry->error,
2093			show_nfs4_status(__entry->error),
2094			MAJOR(__entry->dev), MINOR(__entry->dev),
2095			(unsigned long long)__entry->fileid,
2096			__entry->fhandle,
2097			__entry->offset, __entry->count,
2098			__get_str(dstaddr)
2099		)
2100);
2101
2102#ifdef CONFIG_NFS_V4_2
2103TRACE_DEFINE_ENUM(NFS4_CONTENT_DATA);
2104TRACE_DEFINE_ENUM(NFS4_CONTENT_HOLE);
2105
2106#define show_llseek_mode(what)			\
2107	__print_symbolic(what,			\
2108		{ NFS4_CONTENT_DATA, "DATA" },		\
2109		{ NFS4_CONTENT_HOLE, "HOLE" })
2110
2111TRACE_EVENT(nfs4_llseek,
2112		TP_PROTO(
2113			const struct inode *inode,
2114			const struct nfs42_seek_args *args,
2115			const struct nfs42_seek_res *res,
2116			int error
2117		),
2118
2119		TP_ARGS(inode, args, res, error),
2120
2121		TP_STRUCT__entry(
2122			__field(unsigned long, error)
2123			__field(u32, fhandle)
2124			__field(u32, fileid)
2125			__field(dev_t, dev)
2126			__field(int, stateid_seq)
2127			__field(u32, stateid_hash)
2128			__field(loff_t, offset_s)
2129			__field(u32, what)
2130			__field(loff_t, offset_r)
2131			__field(u32, eof)
2132		),
2133
2134		TP_fast_assign(
2135			const struct nfs_inode *nfsi = NFS_I(inode);
2136			const struct nfs_fh *fh = args->sa_fh;
2137
2138			__entry->fileid = nfsi->fileid;
2139			__entry->dev = inode->i_sb->s_dev;
2140			__entry->fhandle = nfs_fhandle_hash(fh);
2141			__entry->offset_s = args->sa_offset;
2142			__entry->stateid_seq =
2143				be32_to_cpu(args->sa_stateid.seqid);
2144			__entry->stateid_hash =
2145				nfs_stateid_hash(&args->sa_stateid);
2146			__entry->what = args->sa_what;
2147			if (error) {
2148				__entry->error = -error;
2149				__entry->offset_r = 0;
2150				__entry->eof = 0;
2151			} else {
2152				__entry->error = 0;
2153				__entry->offset_r = res->sr_offset;
2154				__entry->eof = res->sr_eof;
2155			}
2156		),
2157
2158		TP_printk(
2159			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2160			"stateid=%d:0x%08x offset_s=%llu what=%s "
2161			"offset_r=%llu eof=%u",
2162			-__entry->error,
2163			show_nfs4_status(__entry->error),
2164			MAJOR(__entry->dev), MINOR(__entry->dev),
2165			(unsigned long long)__entry->fileid,
2166			__entry->fhandle,
2167			__entry->stateid_seq, __entry->stateid_hash,
2168			__entry->offset_s,
2169			show_llseek_mode(__entry->what),
2170			__entry->offset_r,
2171			__entry->eof
2172		)
2173);
2174
2175DECLARE_EVENT_CLASS(nfs4_sparse_event,
2176		TP_PROTO(
2177			const struct inode *inode,
2178			const struct nfs42_falloc_args *args,
2179			int error
2180		),
2181
2182		TP_ARGS(inode, args, error),
2183
2184		TP_STRUCT__entry(
2185			__field(unsigned long, error)
2186			__field(loff_t, offset)
2187			__field(loff_t, len)
2188			__field(dev_t, dev)
2189			__field(u32, fhandle)
2190			__field(u64, fileid)
2191			__field(int, stateid_seq)
2192			__field(u32, stateid_hash)
2193		),
2194
2195		TP_fast_assign(
2196			__entry->error = error < 0 ? -error : 0;
2197			__entry->offset = args->falloc_offset;
2198			__entry->len = args->falloc_length;
2199			__entry->dev = inode->i_sb->s_dev;
2200			__entry->fileid = NFS_FILEID(inode);
2201			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
2202			__entry->stateid_seq =
2203				be32_to_cpu(args->falloc_stateid.seqid);
2204			__entry->stateid_hash =
2205				nfs_stateid_hash(&args->falloc_stateid);
2206		),
2207
2208		TP_printk(
2209			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2210			"stateid=%d:0x%08x offset=%llu len=%llu",
2211			-__entry->error,
2212			show_nfs4_status(__entry->error),
2213			MAJOR(__entry->dev), MINOR(__entry->dev),
2214			(unsigned long long)__entry->fileid,
2215			__entry->fhandle,
2216			__entry->stateid_seq, __entry->stateid_hash,
2217			(long long)__entry->offset,
2218			(long long)__entry->len
2219		)
2220);
2221#define DEFINE_NFS4_SPARSE_EVENT(name) \
2222	DEFINE_EVENT(nfs4_sparse_event, name, \
2223			TP_PROTO( \
2224				const struct inode *inode, \
2225				const struct nfs42_falloc_args *args, \
2226				int error \
2227			), \
2228			TP_ARGS(inode, args, error))
2229DEFINE_NFS4_SPARSE_EVENT(nfs4_fallocate);
2230DEFINE_NFS4_SPARSE_EVENT(nfs4_deallocate);
2231
2232TRACE_EVENT(nfs4_copy,
2233		TP_PROTO(
2234			const struct inode *src_inode,
2235			const struct inode *dst_inode,
2236			const struct nfs42_copy_args *args,
2237			const struct nfs42_copy_res *res,
2238			const struct nl4_server *nss,
2239			int error
2240		),
2241
2242		TP_ARGS(src_inode, dst_inode, args, res, nss, error),
2243
2244		TP_STRUCT__entry(
2245			__field(unsigned long, error)
2246			__field(u32, src_fhandle)
2247			__field(u32, src_fileid)
2248			__field(u32, dst_fhandle)
2249			__field(u32, dst_fileid)
2250			__field(dev_t, src_dev)
2251			__field(dev_t, dst_dev)
2252			__field(int, src_stateid_seq)
2253			__field(u32, src_stateid_hash)
2254			__field(int, dst_stateid_seq)
2255			__field(u32, dst_stateid_hash)
2256			__field(loff_t, src_offset)
2257			__field(loff_t, dst_offset)
2258			__field(bool, sync)
2259			__field(loff_t, len)
2260			__field(int, res_stateid_seq)
2261			__field(u32, res_stateid_hash)
2262			__field(loff_t, res_count)
2263			__field(bool, res_sync)
2264			__field(bool, res_cons)
2265			__field(bool, intra)
2266		),
2267
2268		TP_fast_assign(
2269			const struct nfs_inode *src_nfsi = NFS_I(src_inode);
2270			const struct nfs_inode *dst_nfsi = NFS_I(dst_inode);
2271
2272			__entry->src_fileid = src_nfsi->fileid;
2273			__entry->src_dev = src_inode->i_sb->s_dev;
2274			__entry->src_fhandle = nfs_fhandle_hash(args->src_fh);
2275			__entry->src_offset = args->src_pos;
2276			__entry->dst_fileid = dst_nfsi->fileid;
2277			__entry->dst_dev = dst_inode->i_sb->s_dev;
2278			__entry->dst_fhandle = nfs_fhandle_hash(args->dst_fh);
2279			__entry->dst_offset = args->dst_pos;
2280			__entry->len = args->count;
2281			__entry->sync = args->sync;
2282			__entry->src_stateid_seq =
2283				be32_to_cpu(args->src_stateid.seqid);
2284			__entry->src_stateid_hash =
2285				nfs_stateid_hash(&args->src_stateid);
2286			__entry->dst_stateid_seq =
2287				be32_to_cpu(args->dst_stateid.seqid);
2288			__entry->dst_stateid_hash =
2289				nfs_stateid_hash(&args->dst_stateid);
2290			__entry->intra = nss ? 0 : 1;
2291			if (error) {
2292				__entry->error = -error;
2293				__entry->res_stateid_seq = 0;
2294				__entry->res_stateid_hash = 0;
2295				__entry->res_count = 0;
2296				__entry->res_sync = 0;
2297				__entry->res_cons = 0;
2298			} else {
2299				__entry->error = 0;
2300				__entry->res_stateid_seq =
2301					be32_to_cpu(res->write_res.stateid.seqid);
2302				__entry->res_stateid_hash =
2303					nfs_stateid_hash(&res->write_res.stateid);
2304				__entry->res_count = res->write_res.count;
2305				__entry->res_sync = res->synchronous;
2306				__entry->res_cons = res->consecutive;
2307			}
2308		),
2309
2310		TP_printk(
2311			"error=%ld (%s) intra=%d src_fileid=%02x:%02x:%llu "
2312			"src_fhandle=0x%08x dst_fileid=%02x:%02x:%llu "
2313			"dst_fhandle=0x%08x src_stateid=%d:0x%08x "
2314			"dst_stateid=%d:0x%08x src_offset=%llu dst_offset=%llu "
2315			"len=%llu sync=%d cb_stateid=%d:0x%08x res_sync=%d "
2316			"res_cons=%d res_count=%llu",
2317			-__entry->error,
2318			show_nfs4_status(__entry->error),
2319			__entry->intra,
2320			MAJOR(__entry->src_dev), MINOR(__entry->src_dev),
2321			(unsigned long long)__entry->src_fileid,
2322			__entry->src_fhandle,
2323			MAJOR(__entry->dst_dev), MINOR(__entry->dst_dev),
2324			(unsigned long long)__entry->dst_fileid,
2325			__entry->dst_fhandle,
2326			__entry->src_stateid_seq, __entry->src_stateid_hash,
2327			__entry->dst_stateid_seq, __entry->dst_stateid_hash,
2328			__entry->src_offset,
2329			__entry->dst_offset,
2330			__entry->len,
2331			__entry->sync,
2332			__entry->res_stateid_seq, __entry->res_stateid_hash,
2333			__entry->res_sync,
2334			__entry->res_cons,
2335			__entry->res_count
2336		)
2337);
2338
2339TRACE_EVENT(nfs4_clone,
2340		TP_PROTO(
2341			const struct inode *src_inode,
2342			const struct inode *dst_inode,
2343			const struct nfs42_clone_args *args,
2344			int error
2345		),
2346
2347		TP_ARGS(src_inode, dst_inode, args, error),
2348
2349		TP_STRUCT__entry(
2350			__field(unsigned long, error)
2351			__field(u32, src_fhandle)
2352			__field(u32, src_fileid)
2353			__field(u32, dst_fhandle)
2354			__field(u32, dst_fileid)
2355			__field(dev_t, src_dev)
2356			__field(dev_t, dst_dev)
2357			__field(loff_t, src_offset)
2358			__field(loff_t, dst_offset)
2359			__field(int, src_stateid_seq)
2360			__field(u32, src_stateid_hash)
2361			__field(int, dst_stateid_seq)
2362			__field(u32, dst_stateid_hash)
2363			__field(loff_t, len)
2364		),
2365
2366		TP_fast_assign(
2367			const struct nfs_inode *src_nfsi = NFS_I(src_inode);
2368			const struct nfs_inode *dst_nfsi = NFS_I(dst_inode);
2369
2370			__entry->src_fileid = src_nfsi->fileid;
2371			__entry->src_dev = src_inode->i_sb->s_dev;
2372			__entry->src_fhandle = nfs_fhandle_hash(args->src_fh);
2373			__entry->src_offset = args->src_offset;
2374			__entry->dst_fileid = dst_nfsi->fileid;
2375			__entry->dst_dev = dst_inode->i_sb->s_dev;
2376			__entry->dst_fhandle = nfs_fhandle_hash(args->dst_fh);
2377			__entry->dst_offset = args->dst_offset;
2378			__entry->len = args->count;
2379			__entry->error = error < 0 ? -error : 0;
2380			__entry->src_stateid_seq =
2381				be32_to_cpu(args->src_stateid.seqid);
2382			__entry->src_stateid_hash =
2383				nfs_stateid_hash(&args->src_stateid);
2384			__entry->dst_stateid_seq =
2385				be32_to_cpu(args->dst_stateid.seqid);
2386			__entry->dst_stateid_hash =
2387				nfs_stateid_hash(&args->dst_stateid);
2388		),
2389
2390		TP_printk(
2391			"error=%ld (%s) src_fileid=%02x:%02x:%llu "
2392			"src_fhandle=0x%08x dst_fileid=%02x:%02x:%llu "
2393			"dst_fhandle=0x%08x src_stateid=%d:0x%08x "
2394			"dst_stateid=%d:0x%08x src_offset=%llu "
2395			"dst_offset=%llu len=%llu",
2396			-__entry->error,
2397			show_nfs4_status(__entry->error),
2398			MAJOR(__entry->src_dev), MINOR(__entry->src_dev),
2399			(unsigned long long)__entry->src_fileid,
2400			__entry->src_fhandle,
2401			MAJOR(__entry->dst_dev), MINOR(__entry->dst_dev),
2402			(unsigned long long)__entry->dst_fileid,
2403			__entry->dst_fhandle,
2404			__entry->src_stateid_seq, __entry->src_stateid_hash,
2405			__entry->dst_stateid_seq, __entry->dst_stateid_hash,
2406			__entry->src_offset,
2407			__entry->dst_offset,
2408			__entry->len
2409		)
2410);
2411
2412TRACE_EVENT(nfs4_copy_notify,
2413		TP_PROTO(
2414			const struct inode *inode,
2415			const struct nfs42_copy_notify_args *args,
2416			const struct nfs42_copy_notify_res *res,
2417			int error
2418		),
2419
2420		TP_ARGS(inode, args, res, error),
2421
2422		TP_STRUCT__entry(
2423			__field(unsigned long, error)
2424			__field(u32, fhandle)
2425			__field(u32, fileid)
2426			__field(dev_t, dev)
2427			__field(int, stateid_seq)
2428			__field(u32, stateid_hash)
2429			__field(int, res_stateid_seq)
2430			__field(u32, res_stateid_hash)
2431		),
2432
2433		TP_fast_assign(
2434			const struct nfs_inode *nfsi = NFS_I(inode);
2435
2436			__entry->fileid = nfsi->fileid;
2437			__entry->dev = inode->i_sb->s_dev;
2438			__entry->fhandle = nfs_fhandle_hash(args->cna_src_fh);
2439			__entry->stateid_seq =
2440				be32_to_cpu(args->cna_src_stateid.seqid);
2441			__entry->stateid_hash =
2442				nfs_stateid_hash(&args->cna_src_stateid);
2443			if (error) {
2444				__entry->error = -error;
2445				__entry->res_stateid_seq = 0;
2446				__entry->res_stateid_hash = 0;
2447			} else {
2448				__entry->error = 0;
2449				__entry->res_stateid_seq =
2450					be32_to_cpu(res->cnr_stateid.seqid);
2451				__entry->res_stateid_hash =
2452					nfs_stateid_hash(&res->cnr_stateid);
2453			}
2454		),
2455
2456		TP_printk(
2457			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2458			"stateid=%d:0x%08x res_stateid=%d:0x%08x",
2459			-__entry->error,
2460			show_nfs4_status(__entry->error),
2461			MAJOR(__entry->dev), MINOR(__entry->dev),
2462			(unsigned long long)__entry->fileid,
2463			__entry->fhandle,
2464			__entry->stateid_seq, __entry->stateid_hash,
2465			__entry->res_stateid_seq, __entry->res_stateid_hash
2466		)
2467);
2468
2469TRACE_EVENT(nfs4_offload_cancel,
2470		TP_PROTO(
2471			const struct nfs42_offload_status_args *args,
2472			int error
2473		),
2474
2475		TP_ARGS(args, error),
2476
2477		TP_STRUCT__entry(
2478			__field(unsigned long, error)
2479			__field(u32, fhandle)
2480			__field(int, stateid_seq)
2481			__field(u32, stateid_hash)
2482		),
2483
2484		TP_fast_assign(
2485			__entry->fhandle = nfs_fhandle_hash(args->osa_src_fh);
2486			__entry->error = error < 0 ? -error : 0;
2487			__entry->stateid_seq =
2488				be32_to_cpu(args->osa_stateid.seqid);
2489			__entry->stateid_hash =
2490				nfs_stateid_hash(&args->osa_stateid);
2491		),
2492
2493		TP_printk(
2494			"error=%ld (%s) fhandle=0x%08x stateid=%d:0x%08x",
2495			-__entry->error,
2496			show_nfs4_status(__entry->error),
2497			__entry->fhandle,
2498			__entry->stateid_seq, __entry->stateid_hash
2499		)
2500);
2501
2502DECLARE_EVENT_CLASS(nfs4_xattr_event,
2503		TP_PROTO(
2504			const struct inode *inode,
2505			const char *name,
2506			int error
2507		),
2508
2509		TP_ARGS(inode, name, error),
2510
2511		TP_STRUCT__entry(
2512			__field(unsigned long, error)
2513			__field(dev_t, dev)
2514			__field(u32, fhandle)
2515			__field(u64, fileid)
2516			__string(name, name)
2517		),
2518
2519		TP_fast_assign(
2520			__entry->error = error < 0 ? -error : 0;
2521			__entry->dev = inode->i_sb->s_dev;
2522			__entry->fileid = NFS_FILEID(inode);
2523			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
2524			__assign_str(name, name);
2525		),
2526
2527		TP_printk(
2528			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2529			"name=%s",
2530			-__entry->error, show_nfs4_status(__entry->error),
2531			MAJOR(__entry->dev), MINOR(__entry->dev),
2532			(unsigned long long)__entry->fileid,
2533			__entry->fhandle, __get_str(name)
2534		)
2535);
2536#define DEFINE_NFS4_XATTR_EVENT(name) \
2537	DEFINE_EVENT(nfs4_xattr_event, name,  \
2538			TP_PROTO( \
2539				const struct inode *inode, \
2540				const char *name, \
2541				int error \
2542			), \
2543			TP_ARGS(inode, name, error))
2544DEFINE_NFS4_XATTR_EVENT(nfs4_getxattr);
2545DEFINE_NFS4_XATTR_EVENT(nfs4_setxattr);
2546DEFINE_NFS4_XATTR_EVENT(nfs4_removexattr);
2547
2548DEFINE_NFS4_INODE_EVENT(nfs4_listxattr);
2549#endif /* CONFIG_NFS_V4_2 */
2550
2551#endif /* CONFIG_NFS_V4_1 */
2552
2553#endif /* _TRACE_NFS4_H */
2554
2555#undef TRACE_INCLUDE_PATH
2556#define TRACE_INCLUDE_PATH .
2557#define TRACE_INCLUDE_FILE nfs4trace
2558/* This part must be outside protection */
2559#include <trace/define_trace.h>