diff --git a/nfsdtop/kernel-patches/linux-4.14-nfsd-Add-trace-events-for-all-v4-operations.patch b/nfsdtop/kernel-patches/linux-4.14-nfsd-Add-trace-events-for-all-v4-operations.patch new file mode 100644 index 0000000..91b7f7f --- /dev/null +++ b/nfsdtop/kernel-patches/linux-4.14-nfsd-Add-trace-events-for-all-v4-operations.patch @@ -0,0 +1,700 @@ +From 138aec8ac611f3ef8f95ab0c841711c9ef1d419d Mon Sep 17 00:00:00 2001 +From: Donald Buczek +Date: Wed, 19 Sep 2018 13:44:32 +0200 +Subject: [PATCH] nfsd: Add trace events for all v4 operations + +Add trace events to all v4 operations. Record client ip for ipv4 +clients. Record uid from request credentials. + +For READ and WRITE ops, additionally record offset and length request +arguments and device,inode and filename of the affected file. +--- + fs/nfsd/nfs4proc.c | 66 ++++++++++++++++++ + fs/nfsd/nfs4state.c | 43 ++++++++++++ + fs/nfsd/trace.h | 161 ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 270 insertions(+) + +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c +index 5b6ff168d11a..f0abdc53bc05 100644 +--- a/fs/nfsd/nfs4proc.c ++++ b/fs/nfsd/nfs4proc.c +@@ -355,6 +355,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_open(rqstp); ++ + dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", + (int)open->op_fname.len, open->op_fname.data, + open->op_openowner); +@@ -488,6 +490,8 @@ static __be32 + nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_getfh(rqstp); ++ + if (!cstate->current_fh.fh_dentry) + return nfserr_nofilehandle; + +@@ -501,6 +505,8 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_putfh *putfh = &u->putfh; + ++ trace_nfsd4_putfh(rqstp); ++ + fh_put(&cstate->current_fh); + cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; + memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, +@@ -514,6 +520,8 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_putrootfh(rqstp); ++ + fh_put(&cstate->current_fh); + status = exp_pseudoroot(rqstp, &cstate->current_fh); + return status; +@@ -523,6 +531,8 @@ static __be32 + nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_restorefh(rqstp); ++ + if (!cstate->save_fh.fh_dentry) + return nfserr_restorefh; + +@@ -538,6 +548,8 @@ static __be32 + nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_savefh(rqstp); ++ + if (!cstate->current_fh.fh_dentry) + return nfserr_nofilehandle; + +@@ -558,6 +570,8 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_access *access = &u->access; + ++ trace_nfsd4_access(rqstp); ++ + if (access->ac_req_access & ~NFS3_ACCESS_FULL) + return nfserr_inval; + +@@ -586,6 +600,8 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_commit *commit = &u->commit; + ++ trace_nfsd4_commit(rqstp); ++ + gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp)); + return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, + commit->co_count); +@@ -600,6 +616,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + dev_t rdev; + ++ trace_nfsd4_create(rqstp); ++ + fh_init(&resfh, NFS4_FHSIZE); + + status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); +@@ -691,6 +709,8 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_getattr *getattr = &u->getattr; + __be32 status; + ++ trace_nfsd4_getattr(rqstp); ++ + status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); + if (status) + return status; +@@ -713,6 +733,8 @@ nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_link *link = &u->link; + __be32 status = nfserr_nofilehandle; + ++ trace_nfsd4_link(rqstp); ++ + if (!cstate->save_fh.fh_dentry) + return status; + status = nfsd_link(rqstp, &cstate->current_fh, +@@ -743,6 +765,8 @@ static __be32 + nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookupp(rqstp); ++ + return nfsd4_do_lookupp(rqstp, &cstate->current_fh); + } + +@@ -750,6 +774,8 @@ static __be32 + nfsd4_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookup(rqstp); ++ + return nfsd_lookup(rqstp, &cstate->current_fh, + u->lookup.lo_name, u->lookup.lo_len, + &cstate->current_fh); +@@ -762,6 +788,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_read *read = &u->read; + __be32 status; + ++ trace_nfsd4_read(rqstp,cstate,read); ++ + read->rd_filp = NULL; + if (read->rd_offset >= OFFSET_MAX) + return nfserr_inval; +@@ -808,6 +836,8 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + u64 cookie = readdir->rd_cookie; + static const nfs4_verifier zeroverf; + ++ trace_nfsd4_readdir(rqstp); ++ + /* no need to check permission - this will be done in nfsd_readdir() */ + + if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) +@@ -830,6 +860,8 @@ static __be32 + nfsd4_readlink(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_readlink(rqstp); ++ + u->readlink.rl_rqstp = rqstp; + u->readlink.rl_fhp = &cstate->current_fh; + return nfs_ok; +@@ -842,6 +874,8 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_remove *remove = &u->remove; + __be32 status; + ++ trace_nfsd4_remove(rqstp); ++ + if (opens_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + status = nfsd_unlink(rqstp, &cstate->current_fh, 0, +@@ -860,6 +894,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_rename *rename = &u->rename; + __be32 status = nfserr_nofilehandle; + ++ trace_nfsd4_rename(rqstp); ++ + if (!cstate->save_fh.fh_dentry) + return status; + if (opens_in_grace(SVC_NET(rqstp)) && +@@ -884,6 +920,8 @@ nfsd4_secinfo(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct dentry *dentry; + __be32 err; + ++ trace_nfsd4_secinfo(rqstp); ++ + err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); + if (err) + return err; +@@ -911,6 +949,8 @@ nfsd4_secinfo_no_name(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstat + { + __be32 err; + ++ trace_nfsd4_secinfo_no_name(rqstp); ++ + switch (u->secinfo_no_name.sin_style) { + case NFS4_SECINFO_STYLE4_CURRENT_FH: + break; +@@ -950,6 +990,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status = nfs_ok; + int err; + ++ trace_nfsd4_setattr(rqstp); ++ + if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { + status = nfs4_preprocess_stateid_op(rqstp, cstate, + &cstate->current_fh, &setattr->sa_stateid, +@@ -1015,6 +1057,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + unsigned long cnt; + int nvecs; + ++ trace_nfsd4_write(rqstp,cstate,write); ++ + if (write->wr_offset >= OFFSET_MAX) + return nfserr_inval; + +@@ -1087,6 +1131,8 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct file *src, *dst; + __be32 status; + ++ trace_nfsd4_clone(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, + &clone->cl_dst_stateid, &dst); + if (status) +@@ -1110,6 +1156,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + ssize_t bytes; + ++ trace_nfsd4_copy(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, ©->cp_src_stateid, &src, + ©->cp_dst_stateid, &dst); + if (status) +@@ -1162,6 +1210,8 @@ static __be32 + nfsd4_allocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_allocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); + } + +@@ -1169,6 +1219,8 @@ static __be32 + nfsd4_deallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_deallocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->deallocate, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE); + } +@@ -1182,6 +1234,8 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct file *file; + ++ trace_nfsd4_seek(rqstp); ++ + status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, + &seek->seek_stateid, + RD_STATE, &file, NULL); +@@ -1286,6 +1340,8 @@ nfsd4_nverify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_nverify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->verify); + return status == nfserr_not_same ? nfs_ok : status; + } +@@ -1296,6 +1352,8 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_verify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->nverify); + return status == nfserr_same ? nfs_ok : status; + } +@@ -1329,6 +1387,8 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp, + struct svc_export *exp; + __be32 nfserr; + ++ trace_nfsd4_getdeviceinfo(rqstp); ++ + dprintk("%s: layout_type %u dev_id [0x%llx:0x%x] maxcnt %u\n", + __func__, + gdp->gd_layout_type, +@@ -1382,6 +1442,8 @@ nfsd4_layoutget(struct svc_rqst *rqstp, + __be32 nfserr; + int accmode = NFSD_MAY_READ_IF_EXEC; + ++ trace_nfsd4_layoutget(rqstp); ++ + switch (lgp->lg_seg.iomode) { + case IOMODE_READ: + accmode |= NFSD_MAY_READ; +@@ -1470,6 +1532,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, + struct nfs4_layout_stateid *ls; + __be32 nfserr; + ++ trace_nfsd4_layoutcommit(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_WRITE); + if (nfserr) + goto out; +@@ -1529,6 +1593,8 @@ nfsd4_layoutreturn(struct svc_rqst *rqstp, + struct svc_fh *current_fh = &cstate->current_fh; + __be32 nfserr; + ++ trace_nfsd4_layoutreturn(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_NOP); + if (nfserr) + goto out; +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c +index 3cef6bfa09d4..f87e11e2318f 100644 +--- a/fs/nfsd/nfs4state.c ++++ b/fs/nfsd/nfs4state.c +@@ -49,6 +49,7 @@ + + #include "netns.h" + #include "pnfs.h" ++#include "trace.h" + + #define NFSDDBG_FACILITY NFSDDBG_PROC + +@@ -2459,6 +2460,8 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + bool update = exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_exchange_id(rqstp); ++ + rpc_ntop(sa, addr_str, sizeof(addr_str)); + dprintk("%s rqstp=%p exid=%p clname.len=%u clname.data=%p " + "ip_addr=%s flags %x, spa_how %d\n", +@@ -2754,6 +2757,8 @@ nfsd4_create_session(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_create_session(rqstp); ++ + if (cr_ses->flags & ~SESSION4_FLAG_MASK_A) + return nfserr_inval; + status = nfsd4_check_cb_sec(&cr_ses->cb_sec); +@@ -2877,6 +2882,8 @@ __be32 nfsd4_backchannel_ctl(struct svc_rqst *rqstp, + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + __be32 status; + ++ trace_nfsd4_backchannel_ctl(rqstp); ++ + status = nfsd4_check_cb_sec(&bc->bc_cb_sec); + if (status) + return status; +@@ -2901,6 +2908,8 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_bind_conn_to_session(rqstp); ++ + if (!nfsd4_last_compound_op(rqstp)) + return nfserr_not_only_op; + spin_lock(&nn->client_lock); +@@ -2944,6 +2953,8 @@ nfsd4_destroy_session(struct svc_rqst *r, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(r); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_destroy_session(r); ++ + status = nfserr_not_only_op; + if (nfsd4_compound_in_session(cstate->session, &sessionid->sessionid)) { + if (!nfsd4_last_compound_op(r)) +@@ -3046,6 +3057,8 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_sequence(rqstp); ++ + if (resp->opcnt != 1) + return nfserr_sequence_pos; + +@@ -3178,6 +3191,8 @@ nfsd4_destroy_clientid(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_destroy_clientid(rqstp); ++ + spin_lock(&nn->client_lock); + unconf = find_unconfirmed_client(&dc->clientid, true, nn); + conf = find_confirmed_client(&dc->clientid, true, nn); +@@ -3218,6 +3233,8 @@ nfsd4_reclaim_complete(struct svc_rqst *rqstp, + struct nfsd4_reclaim_complete *rc = &u->reclaim_complete; + __be32 status = 0; + ++ trace_nfsd4_reclaim_complete(rqstp); ++ + if (rc->rca_one_fs) { + if (!cstate->current_fh.fh_dentry) + return nfserr_nofilehandle; +@@ -3262,6 +3279,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid(rqstp); ++ + new = create_client(clname, rqstp, &clverifier); + if (new == NULL) + return nfserr_jukebox; +@@ -3323,6 +3342,8 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid_confirm(rqstp); ++ + if (STALE_CLIENTID(clid, nn)) + return nfserr_stale_clientid; + +@@ -4624,6 +4645,8 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_renew(rqstp); ++ + dprintk("process_renew(%08x/%08x): starting\n", + clid->cl_boot, clid->cl_id); + status = lookup_clientid(clid, cstate, nn); +@@ -5129,6 +5152,8 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_test_stateid_id *stateid; + struct nfs4_client *cl = cstate->session->se_client; + ++ trace_nfsd4_test_stateid(rqstp); ++ + list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list) + stateid->ts_id_status = + nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); +@@ -5173,6 +5198,8 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_client *cl = cstate->session->se_client; + __be32 ret = nfserr_bad_stateid; + ++ trace_nfsd4_free_stateid(rqstp); ++ + spin_lock(&cl->cl_lock); + s = find_stateid_locked(cl, stateid); + if (!s) +@@ -5296,6 +5323,8 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_confirm(rqstp); ++ + dprintk("NFSD: nfsd4_open_confirm on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5364,6 +5393,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_downgrade(rqstp); ++ + dprintk("NFSD: nfsd4_open_downgrade on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5437,6 +5468,8 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + dprintk("NFSD: nfsd4_close on file %pd\n", + cstate->current_fh.fh_dentry); + ++ trace_nfsd4_close(rqstp); ++ + status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid, + &close->cl_stateid, + NFS4_OPEN_STID|NFS4_CLOSED_STID, +@@ -5473,6 +5506,8 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_delegreturn(rqstp); ++ + if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) + return status; + +@@ -5862,6 +5897,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_lock(rqstp); ++ + dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", + (long long) lock->lk_offset, + (long long) lock->lk_length); +@@ -6083,6 +6120,8 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_lockt(rqstp); ++ + if (locks_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + +@@ -6159,6 +6198,8 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + int err; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_locku(rqstp); ++ + dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n", + (long long) locku->lu_offset, + (long long) locku->lu_length); +@@ -6271,6 +6312,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, + struct nfs4_client *clp; + LIST_HEAD (reaplist); + ++ trace_nfsd4_release_lockowner(rqstp); ++ + dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", + clid->cl_boot, clid->cl_id); + +diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h +index 8b2f1d92c579..31be69b5b584 100644 +--- a/fs/nfsd/trace.h ++++ b/fs/nfsd/trace.h +@@ -10,6 +10,7 @@ + + #include + #include "nfsfh.h" ++#include "xdr4.h" + + DECLARE_EVENT_CLASS(nfsd_io_class, + TP_PROTO(struct svc_rqst *rqstp, +@@ -90,6 +91,166 @@ DEFINE_STATEID_EVENT(layout_recall_done); + DEFINE_STATEID_EVENT(layout_recall_fail); + DEFINE_STATEID_EVENT(layout_recall_release); + ++TRACE_EVENT(nfsd4_read, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_read *read ++ ), ++ TP_ARGS(rqstp,cstate,read), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=read->rd_offset; ++ __entry->length=read->rd_length; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++TRACE_EVENT(nfsd4_write, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_write *write ++ ), ++ TP_ARGS(rqstp,cstate,write), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=write->wr_offset; ++ __entry->length=write->wr_buflen; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++DECLARE_EVENT_CLASS(nfsd4_op_class, ++ TP_PROTO(struct svc_rqst *rqstp), ++ TP_ARGS(rqstp), ++ TP_STRUCT__entry( ++ __field( uint32_t, ipv4addr ) ++ __field( uid_t, uid ) ++ ), ++ TP_fast_assign( ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ ), ++ TP_printk("ip=0x%08x uid=%u", ++ __entry->ipv4addr,__entry->uid ++ ) ++) ++ ++/* operations defined in nfs4proc.c : nfsd4_operation nfsd4_ops[] */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_access,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_close,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_commit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_delegreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_link,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lock,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lockt,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_locku,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookup,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookupp,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_nverify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_downgrade,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* PUTPUBFH omitted - currently uses nfsd4_putrootfh op funtion */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putrootfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* READ omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readdir,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readlink,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_remove,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_rename,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_renew,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_restorefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_savefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_verify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* WRITE omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_release_lockowner,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ ++/* NFSv4.1 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_exchange_id,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_backchannel_ctl,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_bind_conn_to_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_sequence,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_clientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_reclaim_complete,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo_no_name,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_test_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_free_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#ifdef CONFIG_NFSD_PNFS ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getdeviceinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutget,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutcommit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#endif /* CONFIG_NFSD_PNFS */ ++ ++/* NFSv4.2 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_allocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_deallocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_clone,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_copy,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_seek,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ + #endif /* _NFSD_TRACE_H */ + + #undef TRACE_INCLUDE_PATH +-- +2.17.1 + diff --git a/nfsdtop/kernel-patches/linux-4.20-nfsd-Add-trace-events-for-all-v4-operations.patch b/nfsdtop/kernel-patches/linux-4.20-nfsd-Add-trace-events-for-all-v4-operations.patch new file mode 100644 index 0000000..778dd99 --- /dev/null +++ b/nfsdtop/kernel-patches/linux-4.20-nfsd-Add-trace-events-for-all-v4-operations.patch @@ -0,0 +1,720 @@ +From d4d08a30367d10d5114a818416806a1eac7b560a Mon Sep 17 00:00:00 2001 +From: Donald Buczek +Date: Wed, 9 Jan 2019 19:22:51 +0100 +Subject: [PATCH] nfsd: Add trace events for all v4 operations + +Add trace events to all v4 operations. Record client ip for ipv4 +clients. Record uid from request credentials. + +For READ and WRITE ops, additionally record offset and length request +arguments and device,inode and filename of the affected file. +--- + fs/nfsd/nfs4proc.c | 70 +++++++++++++++++++ + fs/nfsd/nfs4state.c | 43 ++++++++++++ + fs/nfsd/trace.h | 163 ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 276 insertions(+) + +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c +index d505990dac7c..06940b8452c4 100644 +--- a/fs/nfsd/nfs4proc.c ++++ b/fs/nfsd/nfs4proc.c +@@ -357,6 +357,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + bool reclaim = false; + ++ trace_nfsd4_open(rqstp); ++ + dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", + (int)open->op_fname.len, open->op_fname.data, + open->op_openowner); +@@ -493,6 +495,8 @@ static __be32 + nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_getfh(rqstp); ++ + u->getfh = &cstate->current_fh; + return nfs_ok; + } +@@ -503,6 +507,8 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_putfh *putfh = &u->putfh; + ++ trace_nfsd4_putfh(rqstp); ++ + fh_put(&cstate->current_fh); + cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; + memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, +@@ -516,6 +522,8 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_putrootfh(rqstp); ++ + fh_put(&cstate->current_fh); + status = exp_pseudoroot(rqstp, &cstate->current_fh); + return status; +@@ -525,6 +533,8 @@ static __be32 + nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_restorefh(rqstp); ++ + if (!cstate->save_fh.fh_dentry) + return nfserr_restorefh; + +@@ -540,6 +550,8 @@ static __be32 + nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_savefh(rqstp); ++ + fh_dup2(&cstate->save_fh, &cstate->current_fh); + if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG)) { + memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); +@@ -557,6 +569,8 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_access *access = &u->access; + ++ trace_nfsd4_access(rqstp); ++ + if (access->ac_req_access & ~NFS3_ACCESS_FULL) + return nfserr_inval; + +@@ -586,6 +600,8 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_commit *commit = &u->commit; + ++ trace_nfsd4_commit(rqstp); ++ + gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp)); + return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, + commit->co_count); +@@ -600,6 +616,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + dev_t rdev; + ++ trace_nfsd4_create(rqstp); ++ + fh_init(&resfh, NFS4_FHSIZE); + + status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); +@@ -691,6 +709,8 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_getattr *getattr = &u->getattr; + __be32 status; + ++ trace_nfsd4_getattr(rqstp); ++ + status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); + if (status) + return status; +@@ -713,6 +733,8 @@ nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_link *link = &u->link; + __be32 status; + ++ trace_nfsd4_link(rqstp); ++ + status = nfsd_link(rqstp, &cstate->current_fh, + link->li_name, link->li_namelen, &cstate->save_fh); + if (!status) +@@ -741,6 +763,8 @@ static __be32 + nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookupp(rqstp); ++ + return nfsd4_do_lookupp(rqstp, &cstate->current_fh); + } + +@@ -748,6 +772,8 @@ static __be32 + nfsd4_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookup(rqstp); ++ + return nfsd_lookup(rqstp, &cstate->current_fh, + u->lookup.lo_name, u->lookup.lo_len, + &cstate->current_fh); +@@ -760,6 +786,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_read *read = &u->read; + __be32 status; + ++ trace_nfsd4_read(rqstp,cstate,read); ++ + read->rd_filp = NULL; + if (read->rd_offset >= OFFSET_MAX) + return nfserr_inval; +@@ -811,6 +839,8 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + u64 cookie = readdir->rd_cookie; + static const nfs4_verifier zeroverf; + ++ trace_nfsd4_readdir(rqstp); ++ + /* no need to check permission - this will be done in nfsd_readdir() */ + + if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) +@@ -833,6 +863,8 @@ static __be32 + nfsd4_readlink(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_readlink(rqstp); ++ + u->readlink.rl_rqstp = rqstp; + u->readlink.rl_fhp = &cstate->current_fh; + return nfs_ok; +@@ -845,6 +877,8 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_remove *remove = &u->remove; + __be32 status; + ++ trace_nfsd4_remove(rqstp); ++ + if (opens_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + status = nfsd_unlink(rqstp, &cstate->current_fh, 0, +@@ -863,6 +897,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_rename *rename = &u->rename; + __be32 status; + ++ trace_nfsd4_rename(rqstp); ++ + if (opens_in_grace(SVC_NET(rqstp)) && + !(cstate->save_fh.fh_export->ex_flags & NFSEXP_NOSUBTREECHECK)) + return nfserr_grace; +@@ -885,6 +921,8 @@ nfsd4_secinfo(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct dentry *dentry; + __be32 err; + ++ trace_nfsd4_secinfo(rqstp); ++ + err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); + if (err) + return err; +@@ -912,6 +950,8 @@ nfsd4_secinfo_no_name(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstat + { + __be32 err; + ++ trace_nfsd4_secinfo_no_name(rqstp); ++ + switch (u->secinfo_no_name.sin_style) { + case NFS4_SECINFO_STYLE4_CURRENT_FH: + break; +@@ -951,6 +991,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status = nfs_ok; + int err; + ++ trace_nfsd4_setattr(rqstp); ++ + if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { + status = nfs4_preprocess_stateid_op(rqstp, cstate, + &cstate->current_fh, &setattr->sa_stateid, +@@ -998,6 +1040,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + unsigned long cnt; + int nvecs; + ++ trace_nfsd4_write(rqstp,cstate,write); ++ + if (write->wr_offset >= OFFSET_MAX) + return nfserr_inval; + +@@ -1079,6 +1123,8 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct file *src, *dst; + __be32 status; + ++ trace_nfsd4_clone(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, + &clone->cl_dst_stateid, &dst); + if (status) +@@ -1265,6 +1311,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd4_copy *async_copy = NULL; + ++ trace_nfsd4_copy(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, ©->cp_src_stateid, + ©->file_src, ©->cp_dst_stateid, + ©->file_dst); +@@ -1335,6 +1383,8 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp, + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + ++ trace_nfsd4_offload_cancel(rqstp); ++ + copy = find_async_copy(clp, &os->stateid); + if (copy) + nfsd4_stop_copy(copy); +@@ -1376,6 +1426,8 @@ nfsd4_offload_status(struct svc_rqst *rqstp, + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + ++ trace_nfsd4_offload_status(rqstp); ++ + copy = find_async_copy(clp, &os->stateid); + if (copy) { + os->count = copy->cp_res.wr_bytes_written; +@@ -1390,6 +1442,8 @@ static __be32 + nfsd4_allocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_allocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); + } + +@@ -1397,6 +1451,8 @@ static __be32 + nfsd4_deallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_deallocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->deallocate, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE); + } +@@ -1410,6 +1466,8 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct file *file; + ++ trace_nfsd4_seek(rqstp); ++ + status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, + &seek->seek_stateid, + RD_STATE, &file, NULL); +@@ -1514,6 +1572,8 @@ nfsd4_nverify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_nverify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->verify); + return status == nfserr_not_same ? nfs_ok : status; + } +@@ -1524,6 +1584,8 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_verify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->nverify); + return status == nfserr_same ? nfs_ok : status; + } +@@ -1557,6 +1619,8 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp, + struct svc_export *exp; + __be32 nfserr; + ++ trace_nfsd4_getdeviceinfo(rqstp); ++ + dprintk("%s: layout_type %u dev_id [0x%llx:0x%x] maxcnt %u\n", + __func__, + gdp->gd_layout_type, +@@ -1610,6 +1674,8 @@ nfsd4_layoutget(struct svc_rqst *rqstp, + __be32 nfserr; + int accmode = NFSD_MAY_READ_IF_EXEC; + ++ trace_nfsd4_layoutget(rqstp); ++ + switch (lgp->lg_seg.iomode) { + case IOMODE_READ: + accmode |= NFSD_MAY_READ; +@@ -1698,6 +1764,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, + struct nfs4_layout_stateid *ls; + __be32 nfserr; + ++ trace_nfsd4_layoutcommit(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_WRITE); + if (nfserr) + goto out; +@@ -1757,6 +1825,8 @@ nfsd4_layoutreturn(struct svc_rqst *rqstp, + struct svc_fh *current_fh = &cstate->current_fh; + __be32 nfserr; + ++ trace_nfsd4_layoutreturn(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_NOP); + if (nfserr) + goto out; +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c +index f093fbe47133..a3937586eb1a 100644 +--- a/fs/nfsd/nfs4state.c ++++ b/fs/nfsd/nfs4state.c +@@ -49,6 +49,7 @@ + + #include "netns.h" + #include "pnfs.h" ++#include "trace.h" + + #define NFSDDBG_FACILITY NFSDDBG_PROC + +@@ -2526,6 +2527,8 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + bool update = exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_exchange_id(rqstp); ++ + rpc_ntop(sa, addr_str, sizeof(addr_str)); + dprintk("%s rqstp=%p exid=%p clname.len=%u clname.data=%p " + "ip_addr=%s flags %x, spa_how %d\n", +@@ -2821,6 +2824,8 @@ nfsd4_create_session(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_create_session(rqstp); ++ + if (cr_ses->flags & ~SESSION4_FLAG_MASK_A) + return nfserr_inval; + status = nfsd4_check_cb_sec(&cr_ses->cb_sec); +@@ -2944,6 +2949,8 @@ __be32 nfsd4_backchannel_ctl(struct svc_rqst *rqstp, + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + __be32 status; + ++ trace_nfsd4_backchannel_ctl(rqstp); ++ + status = nfsd4_check_cb_sec(&bc->bc_cb_sec); + if (status) + return status; +@@ -2968,6 +2975,8 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_bind_conn_to_session(rqstp); ++ + if (!nfsd4_last_compound_op(rqstp)) + return nfserr_not_only_op; + spin_lock(&nn->client_lock); +@@ -3011,6 +3020,8 @@ nfsd4_destroy_session(struct svc_rqst *r, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(r); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_destroy_session(r); ++ + status = nfserr_not_only_op; + if (nfsd4_compound_in_session(cstate, sessionid)) { + if (!nfsd4_last_compound_op(r)) +@@ -3141,6 +3152,8 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_sequence(rqstp); ++ + if (resp->opcnt != 1) + return nfserr_sequence_pos; + +@@ -3276,6 +3289,8 @@ nfsd4_destroy_clientid(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_destroy_clientid(rqstp); ++ + spin_lock(&nn->client_lock); + unconf = find_unconfirmed_client(&dc->clientid, true, nn); + conf = find_confirmed_client(&dc->clientid, true, nn); +@@ -3316,6 +3331,8 @@ nfsd4_reclaim_complete(struct svc_rqst *rqstp, + struct nfsd4_reclaim_complete *rc = &u->reclaim_complete; + __be32 status = 0; + ++ trace_nfsd4_reclaim_complete(rqstp); ++ + if (rc->rca_one_fs) { + if (!cstate->current_fh.fh_dentry) + return nfserr_nofilehandle; +@@ -3360,6 +3377,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid(rqstp); ++ + new = create_client(clname, rqstp, &clverifier); + if (new == NULL) + return nfserr_jukebox; +@@ -3421,6 +3440,8 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid_confirm(rqstp); ++ + if (STALE_CLIENTID(clid, nn)) + return nfserr_stale_clientid; + +@@ -4681,6 +4702,8 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_renew(rqstp); ++ + dprintk("process_renew(%08x/%08x): starting\n", + clid->cl_boot, clid->cl_id); + status = lookup_clientid(clid, cstate, nn); +@@ -5225,6 +5248,8 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_test_stateid_id *stateid; + struct nfs4_client *cl = cstate->session->se_client; + ++ trace_nfsd4_test_stateid(rqstp); ++ + list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list) + stateid->ts_id_status = + nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); +@@ -5272,6 +5297,8 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_client *cl = cstate->session->se_client; + __be32 ret = nfserr_bad_stateid; + ++ trace_nfsd4_free_stateid(rqstp); ++ + spin_lock(&cl->cl_lock); + s = find_stateid_locked(cl, stateid); + if (!s) +@@ -5399,6 +5426,8 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_confirm(rqstp); ++ + dprintk("NFSD: nfsd4_open_confirm on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5467,6 +5496,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_downgrade(rqstp); ++ + dprintk("NFSD: nfsd4_open_downgrade on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5540,6 +5571,8 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + dprintk("NFSD: nfsd4_close on file %pd\n", + cstate->current_fh.fh_dentry); + ++ trace_nfsd4_close(rqstp); ++ + status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid, + &close->cl_stateid, + NFS4_OPEN_STID|NFS4_CLOSED_STID, +@@ -5587,6 +5620,8 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_delegreturn(rqstp); ++ + if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) + return status; + +@@ -5981,6 +6016,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_lock(rqstp); ++ + dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", + (long long) lock->lk_offset, + (long long) lock->lk_length); +@@ -6204,6 +6241,8 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_lockt(rqstp); ++ + if (locks_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + +@@ -6280,6 +6319,8 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + int err; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_locku(rqstp); ++ + dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n", + (long long) locku->lu_offset, + (long long) locku->lu_length); +@@ -6392,6 +6433,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, + struct nfs4_client *clp; + LIST_HEAD (reaplist); + ++ trace_nfsd4_release_lockowner(rqstp); ++ + dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", + clid->cl_boot, clid->cl_id); + +diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h +index 80933e4334d8..461baebe3bbe 100644 +--- a/fs/nfsd/trace.h ++++ b/fs/nfsd/trace.h +@@ -10,6 +10,7 @@ + + #include + #include "nfsfh.h" ++#include "xdr4.h" + + TRACE_EVENT(nfsd_compound, + TP_PROTO(const struct svc_rqst *rqst, +@@ -164,6 +165,168 @@ DEFINE_STATEID_EVENT(layout_recall_done); + DEFINE_STATEID_EVENT(layout_recall_fail); + DEFINE_STATEID_EVENT(layout_recall_release); + ++TRACE_EVENT(nfsd4_read, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_read *read ++ ), ++ TP_ARGS(rqstp,cstate,read), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=read->rd_offset; ++ __entry->length=read->rd_length; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++TRACE_EVENT(nfsd4_write, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_write *write ++ ), ++ TP_ARGS(rqstp,cstate,write), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=write->wr_offset; ++ __entry->length=write->wr_buflen; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++DECLARE_EVENT_CLASS(nfsd4_op_class, ++ TP_PROTO(struct svc_rqst *rqstp), ++ TP_ARGS(rqstp), ++ TP_STRUCT__entry( ++ __field( uint32_t, ipv4addr ) ++ __field( uid_t, uid ) ++ ), ++ TP_fast_assign( ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ ), ++ TP_printk("ip=0x%08x uid=%u", ++ __entry->ipv4addr,__entry->uid ++ ) ++) ++ ++/* operations defined in nfs4proc.c : nfsd4_operation nfsd4_ops[] */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_access,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_close,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_commit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_delegreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_link,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lock,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lockt,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_locku,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookup,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookupp,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_nverify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_downgrade,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* PUTPUBFH omitted - currently uses nfsd4_putrootfh op funtion */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putrootfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* READ omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readdir,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readlink,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_remove,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_rename,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_renew,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_restorefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_savefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_verify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* WRITE omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_release_lockowner,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ ++/* NFSv4.1 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_exchange_id,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_backchannel_ctl,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_bind_conn_to_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_sequence,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_clientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_reclaim_complete,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo_no_name,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_test_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_free_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#ifdef CONFIG_NFSD_PNFS ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getdeviceinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutget,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutcommit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#endif /* CONFIG_NFSD_PNFS */ ++ ++/* NFSv4.2 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_allocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_deallocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_clone,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_copy,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_seek,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_offload_status,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_offload_cancel,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ + #endif /* _NFSD_TRACE_H */ + + #undef TRACE_INCLUDE_PATH +-- +2.17.1 + diff --git a/nfsdtop/kernel-patches/linux-5.0-nfsd-Add-trace-events-for-all-v4-operations.patch b/nfsdtop/kernel-patches/linux-5.0-nfsd-Add-trace-events-for-all-v4-operations.patch new file mode 100644 index 0000000..2ec9d47 --- /dev/null +++ b/nfsdtop/kernel-patches/linux-5.0-nfsd-Add-trace-events-for-all-v4-operations.patch @@ -0,0 +1,720 @@ +From b3163d1b126f063621b04ac6c823c0527b6a02ad Mon Sep 17 00:00:00 2001 +From: Donald Buczek +Date: Wed, 9 Jan 2019 20:41:47 +0100 +Subject: [PATCH] nfsd: Add trace events for all v4 operations + +Add trace events to all v4 operations. Record client ip for ipv4 +clients. Record uid from request credentials. + +For READ and WRITE ops, additionally record offset and length request +arguments and device,inode and filename of the affected file. +--- + fs/nfsd/nfs4proc.c | 70 +++++++++++++++++++ + fs/nfsd/nfs4state.c | 43 ++++++++++++ + fs/nfsd/trace.h | 163 ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 276 insertions(+) + +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c +index 0cfd257ffdaf..2804cea6f4e6 100644 +--- a/fs/nfsd/nfs4proc.c ++++ b/fs/nfsd/nfs4proc.c +@@ -357,6 +357,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + bool reclaim = false; + ++ trace_nfsd4_open(rqstp); ++ + dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", + (int)open->op_fname.len, open->op_fname.data, + open->op_openowner); +@@ -493,6 +495,8 @@ static __be32 + nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_getfh(rqstp); ++ + u->getfh = &cstate->current_fh; + return nfs_ok; + } +@@ -503,6 +507,8 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_putfh *putfh = &u->putfh; + ++ trace_nfsd4_putfh(rqstp); ++ + fh_put(&cstate->current_fh); + cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; + memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, +@@ -516,6 +522,8 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_putrootfh(rqstp); ++ + fh_put(&cstate->current_fh); + status = exp_pseudoroot(rqstp, &cstate->current_fh); + return status; +@@ -525,6 +533,8 @@ static __be32 + nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_restorefh(rqstp); ++ + if (!cstate->save_fh.fh_dentry) + return nfserr_restorefh; + +@@ -540,6 +550,8 @@ static __be32 + nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_savefh(rqstp); ++ + fh_dup2(&cstate->save_fh, &cstate->current_fh); + if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG)) { + memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); +@@ -557,6 +569,8 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_access *access = &u->access; + ++ trace_nfsd4_access(rqstp); ++ + if (access->ac_req_access & ~NFS3_ACCESS_FULL) + return nfserr_inval; + +@@ -586,6 +600,8 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + struct nfsd4_commit *commit = &u->commit; + ++ trace_nfsd4_commit(rqstp); ++ + gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp)); + return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, + commit->co_count); +@@ -600,6 +616,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + dev_t rdev; + ++ trace_nfsd4_create(rqstp); ++ + fh_init(&resfh, NFS4_FHSIZE); + + status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); +@@ -691,6 +709,8 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_getattr *getattr = &u->getattr; + __be32 status; + ++ trace_nfsd4_getattr(rqstp); ++ + status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); + if (status) + return status; +@@ -713,6 +733,8 @@ nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_link *link = &u->link; + __be32 status; + ++ trace_nfsd4_link(rqstp); ++ + status = nfsd_link(rqstp, &cstate->current_fh, + link->li_name, link->li_namelen, &cstate->save_fh); + if (!status) +@@ -741,6 +763,8 @@ static __be32 + nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookupp(rqstp); ++ + return nfsd4_do_lookupp(rqstp, &cstate->current_fh); + } + +@@ -748,6 +772,8 @@ static __be32 + nfsd4_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_lookup(rqstp); ++ + return nfsd_lookup(rqstp, &cstate->current_fh, + u->lookup.lo_name, u->lookup.lo_len, + &cstate->current_fh); +@@ -760,6 +786,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_read *read = &u->read; + __be32 status; + ++ trace_nfsd4_read(rqstp,cstate,read); ++ + read->rd_filp = NULL; + if (read->rd_offset >= OFFSET_MAX) + return nfserr_inval; +@@ -811,6 +839,8 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + u64 cookie = readdir->rd_cookie; + static const nfs4_verifier zeroverf; + ++ trace_nfsd4_readdir(rqstp); ++ + /* no need to check permission - this will be done in nfsd_readdir() */ + + if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) +@@ -833,6 +863,8 @@ static __be32 + nfsd4_readlink(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_readlink(rqstp); ++ + u->readlink.rl_rqstp = rqstp; + u->readlink.rl_fhp = &cstate->current_fh; + return nfs_ok; +@@ -845,6 +877,8 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_remove *remove = &u->remove; + __be32 status; + ++ trace_nfsd4_remove(rqstp); ++ + if (opens_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + status = nfsd_unlink(rqstp, &cstate->current_fh, 0, +@@ -863,6 +897,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_rename *rename = &u->rename; + __be32 status; + ++ trace_nfsd4_rename(rqstp); ++ + if (opens_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, +@@ -884,6 +920,8 @@ nfsd4_secinfo(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct dentry *dentry; + __be32 err; + ++ trace_nfsd4_secinfo(rqstp); ++ + err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); + if (err) + return err; +@@ -911,6 +949,8 @@ nfsd4_secinfo_no_name(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstat + { + __be32 err; + ++ trace_nfsd4_secinfo_no_name(rqstp); ++ + switch (u->secinfo_no_name.sin_style) { + case NFS4_SECINFO_STYLE4_CURRENT_FH: + break; +@@ -950,6 +990,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status = nfs_ok; + int err; + ++ trace_nfsd4_setattr(rqstp); ++ + if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { + status = nfs4_preprocess_stateid_op(rqstp, cstate, + &cstate->current_fh, &setattr->sa_stateid, +@@ -997,6 +1039,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + unsigned long cnt; + int nvecs; + ++ trace_nfsd4_write(rqstp,cstate,write); ++ + if (write->wr_offset >= OFFSET_MAX) + return nfserr_inval; + +@@ -1076,6 +1120,8 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct file *src, *dst; + __be32 status; + ++ trace_nfsd4_clone(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, + &clone->cl_dst_stateid, &dst); + if (status) +@@ -1262,6 +1308,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd4_copy *async_copy = NULL; + ++ trace_nfsd4_copy(rqstp); ++ + status = nfsd4_verify_copy(rqstp, cstate, ©->cp_src_stateid, + ©->file_src, ©->cp_dst_stateid, + ©->file_dst); +@@ -1332,6 +1380,8 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp, + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + ++ trace_nfsd4_offload_cancel(rqstp); ++ + copy = find_async_copy(clp, &os->stateid); + if (copy) + nfsd4_stop_copy(copy); +@@ -1373,6 +1423,8 @@ nfsd4_offload_status(struct svc_rqst *rqstp, + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + ++ trace_nfsd4_offload_status(rqstp); ++ + copy = find_async_copy(clp, &os->stateid); + if (copy) { + os->count = copy->cp_res.wr_bytes_written; +@@ -1387,6 +1439,8 @@ static __be32 + nfsd4_allocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_allocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); + } + +@@ -1394,6 +1448,8 @@ static __be32 + nfsd4_deallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) + { ++ trace_nfsd4_deallocate(rqstp); ++ + return nfsd4_fallocate(rqstp, cstate, &u->deallocate, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE); + } +@@ -1407,6 +1463,8 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct file *file; + ++ trace_nfsd4_seek(rqstp); ++ + status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, + &seek->seek_stateid, + RD_STATE, &file, NULL); +@@ -1511,6 +1569,8 @@ nfsd4_nverify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_nverify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->verify); + return status == nfserr_not_same ? nfs_ok : status; + } +@@ -1521,6 +1581,8 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + { + __be32 status; + ++ trace_nfsd4_verify(rqstp); ++ + status = _nfsd4_verify(rqstp, cstate, &u->nverify); + return status == nfserr_same ? nfs_ok : status; + } +@@ -1554,6 +1616,8 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp, + struct svc_export *exp; + __be32 nfserr; + ++ trace_nfsd4_getdeviceinfo(rqstp); ++ + dprintk("%s: layout_type %u dev_id [0x%llx:0x%x] maxcnt %u\n", + __func__, + gdp->gd_layout_type, +@@ -1607,6 +1671,8 @@ nfsd4_layoutget(struct svc_rqst *rqstp, + __be32 nfserr; + int accmode = NFSD_MAY_READ_IF_EXEC; + ++ trace_nfsd4_layoutget(rqstp); ++ + switch (lgp->lg_seg.iomode) { + case IOMODE_READ: + accmode |= NFSD_MAY_READ; +@@ -1695,6 +1761,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, + struct nfs4_layout_stateid *ls; + __be32 nfserr; + ++ trace_nfsd4_layoutcommit(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_WRITE); + if (nfserr) + goto out; +@@ -1754,6 +1822,8 @@ nfsd4_layoutreturn(struct svc_rqst *rqstp, + struct svc_fh *current_fh = &cstate->current_fh; + __be32 nfserr; + ++ trace_nfsd4_layoutreturn(rqstp); ++ + nfserr = fh_verify(rqstp, current_fh, 0, NFSD_MAY_NOP); + if (nfserr) + goto out; +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c +index fb3c9844c82a..b9f3ab850e9c 100644 +--- a/fs/nfsd/nfs4state.c ++++ b/fs/nfsd/nfs4state.c +@@ -49,6 +49,7 @@ + + #include "netns.h" + #include "pnfs.h" ++#include "trace.h" + + #define NFSDDBG_FACILITY NFSDDBG_PROC + +@@ -2526,6 +2527,8 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + bool update = exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_exchange_id(rqstp); ++ + rpc_ntop(sa, addr_str, sizeof(addr_str)); + dprintk("%s rqstp=%p exid=%p clname.len=%u clname.data=%p " + "ip_addr=%s flags %x, spa_how %d\n", +@@ -2821,6 +2824,8 @@ nfsd4_create_session(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_create_session(rqstp); ++ + if (cr_ses->flags & ~SESSION4_FLAG_MASK_A) + return nfserr_inval; + status = nfsd4_check_cb_sec(&cr_ses->cb_sec); +@@ -2944,6 +2949,8 @@ __be32 nfsd4_backchannel_ctl(struct svc_rqst *rqstp, + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + __be32 status; + ++ trace_nfsd4_backchannel_ctl(rqstp); ++ + status = nfsd4_check_cb_sec(&bc->bc_cb_sec); + if (status) + return status; +@@ -2968,6 +2975,8 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_bind_conn_to_session(rqstp); ++ + if (!nfsd4_last_compound_op(rqstp)) + return nfserr_not_only_op; + spin_lock(&nn->client_lock); +@@ -3011,6 +3020,8 @@ nfsd4_destroy_session(struct svc_rqst *r, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(r); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_destroy_session(r); ++ + status = nfserr_not_only_op; + if (nfsd4_compound_in_session(cstate, sessionid)) { + if (!nfsd4_last_compound_op(r)) +@@ -3141,6 +3152,8 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_sequence(rqstp); ++ + if (resp->opcnt != 1) + return nfserr_sequence_pos; + +@@ -3276,6 +3289,8 @@ nfsd4_destroy_clientid(struct svc_rqst *rqstp, + __be32 status = 0; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_destroy_clientid(rqstp); ++ + spin_lock(&nn->client_lock); + unconf = find_unconfirmed_client(&dc->clientid, true, nn); + conf = find_confirmed_client(&dc->clientid, true, nn); +@@ -3316,6 +3331,8 @@ nfsd4_reclaim_complete(struct svc_rqst *rqstp, + struct nfsd4_reclaim_complete *rc = &u->reclaim_complete; + __be32 status = 0; + ++ trace_nfsd4_reclaim_complete(rqstp); ++ + if (rc->rca_one_fs) { + if (!cstate->current_fh.fh_dentry) + return nfserr_nofilehandle; +@@ -3360,6 +3377,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid(rqstp); ++ + new = create_client(clname, rqstp, &clverifier); + if (new == NULL) + return nfserr_jukebox; +@@ -3421,6 +3440,8 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_setclientid_confirm(rqstp); ++ + if (STALE_CLIENTID(clid, nn)) + return nfserr_stale_clientid; + +@@ -4681,6 +4702,8 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_renew(rqstp); ++ + dprintk("process_renew(%08x/%08x): starting\n", + clid->cl_boot, clid->cl_id); + status = lookup_clientid(clid, cstate, nn); +@@ -5225,6 +5248,8 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfsd4_test_stateid_id *stateid; + struct nfs4_client *cl = cstate->session->se_client; + ++ trace_nfsd4_test_stateid(rqstp); ++ + list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list) + stateid->ts_id_status = + nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); +@@ -5272,6 +5297,8 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_client *cl = cstate->session->se_client; + __be32 ret = nfserr_bad_stateid; + ++ trace_nfsd4_free_stateid(rqstp); ++ + spin_lock(&cl->cl_lock); + s = find_stateid_locked(cl, stateid); + if (!s) +@@ -5399,6 +5426,8 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_confirm(rqstp); ++ + dprintk("NFSD: nfsd4_open_confirm on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5467,6 +5496,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, + struct nfs4_ol_stateid *stp; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_open_downgrade(rqstp); ++ + dprintk("NFSD: nfsd4_open_downgrade on file %pd\n", + cstate->current_fh.fh_dentry); + +@@ -5540,6 +5571,8 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + dprintk("NFSD: nfsd4_close on file %pd\n", + cstate->current_fh.fh_dentry); + ++ trace_nfsd4_close(rqstp); ++ + status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid, + &close->cl_stateid, + NFS4_OPEN_STID|NFS4_CLOSED_STID, +@@ -5587,6 +5620,8 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_delegreturn(rqstp); ++ + if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) + return status; + +@@ -5981,6 +6016,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + struct net *net = SVC_NET(rqstp); + struct nfsd_net *nn = net_generic(net, nfsd_net_id); + ++ trace_nfsd4_lock(rqstp); ++ + dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", + (long long) lock->lk_offset, + (long long) lock->lk_length); +@@ -6204,6 +6241,8 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_lockt(rqstp); ++ + if (locks_in_grace(SVC_NET(rqstp))) + return nfserr_grace; + +@@ -6280,6 +6319,8 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, + int err; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + ++ trace_nfsd4_locku(rqstp); ++ + dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n", + (long long) locku->lu_offset, + (long long) locku->lu_length); +@@ -6392,6 +6433,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, + struct nfs4_client *clp; + LIST_HEAD (reaplist); + ++ trace_nfsd4_release_lockowner(rqstp); ++ + dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", + clid->cl_boot, clid->cl_id); + +diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h +index 80933e4334d8..461baebe3bbe 100644 +--- a/fs/nfsd/trace.h ++++ b/fs/nfsd/trace.h +@@ -10,6 +10,7 @@ + + #include + #include "nfsfh.h" ++#include "xdr4.h" + + TRACE_EVENT(nfsd_compound, + TP_PROTO(const struct svc_rqst *rqst, +@@ -164,6 +165,168 @@ DEFINE_STATEID_EVENT(layout_recall_done); + DEFINE_STATEID_EVENT(layout_recall_fail); + DEFINE_STATEID_EVENT(layout_recall_release); + ++TRACE_EVENT(nfsd4_read, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_read *read ++ ), ++ TP_ARGS(rqstp,cstate,read), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=read->rd_offset; ++ __entry->length=read->rd_length; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++TRACE_EVENT(nfsd4_write, ++ TP_PROTO( ++ struct svc_rqst *rqstp, ++ struct nfsd4_compound_state *cstate, ++ struct nfsd4_write *write ++ ), ++ TP_ARGS(rqstp,cstate,write), ++ TP_STRUCT__entry( ++ __field ( uint32_t , ipv4addr ) ++ __field ( uid_t , uid ) ++ __field ( dev_t , dev ) ++ __field ( unsigned long , ino ) ++ __field ( u64 , offset ) ++ __field ( u32 , length ) ++ __dynamic_array ( char , name , strlen(cstate->current_fh.fh_dentry->d_name.name)+1 ) ++ ), ++ TP_fast_assign( ++ struct dentry *dentry = cstate->current_fh.fh_dentry; ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ if (dentry->d_inode) { ++ __entry->ino = dentry->d_inode->i_ino; ++ __entry->dev = dentry->d_inode->i_sb->s_dev; ++ } else { ++ __entry->ino=0; ++ __entry->dev=0; ++ } ++ strcpy(__get_str(name),dentry->d_name.name); ++ __entry->offset=write->wr_offset; ++ __entry->length=write->wr_buflen; ++ ), ++ TP_printk("ip=0x%08x uid=%u dev=%u inode=%lu offset=%llu length=%u name=\"%s\"", ++ __entry->ipv4addr,__entry->uid, ++ __entry->dev,__entry->ino, ++ __entry->offset,__entry->length, ++ __get_str(name) ++ ) ++) ++ ++DECLARE_EVENT_CLASS(nfsd4_op_class, ++ TP_PROTO(struct svc_rqst *rqstp), ++ TP_ARGS(rqstp), ++ TP_STRUCT__entry( ++ __field( uint32_t, ipv4addr ) ++ __field( uid_t, uid ) ++ ), ++ TP_fast_assign( ++ __entry->ipv4addr = rqstp->rq_addr.ss_family == AF_INET ? ((struct sockaddr_in *)&rqstp->rq_addr)->sin_addr.s_addr : 0; ++ __entry->uid=rqstp->rq_cred.cr_uid.val; ++ ), ++ TP_printk("ip=0x%08x uid=%u", ++ __entry->ipv4addr,__entry->uid ++ ) ++) ++ ++/* operations defined in nfs4proc.c : nfsd4_operation nfsd4_ops[] */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_access,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_close,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_commit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_delegreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_link,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lock,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lockt,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_locku,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookup,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_lookupp,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_nverify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_open_downgrade,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* PUTPUBFH omitted - currently uses nfsd4_putrootfh op funtion */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_putrootfh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* READ omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readdir,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_readlink,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_remove,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_rename,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_renew,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_restorefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_savefh,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_setclientid_confirm,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_verify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++/* WRITE omitted - defined above */ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_release_lockowner,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ ++/* NFSv4.1 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_exchange_id,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_backchannel_ctl,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_bind_conn_to_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_create_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_session,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_sequence,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_destroy_clientid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_reclaim_complete,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_secinfo_no_name,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_test_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_free_stateid,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#ifdef CONFIG_NFSD_PNFS ++DEFINE_EVENT(nfsd4_op_class,nfsd4_getdeviceinfo,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutget,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutcommit,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_layoutreturn,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++#endif /* CONFIG_NFSD_PNFS */ ++ ++/* NFSv4.2 operations */ ++ ++DEFINE_EVENT(nfsd4_op_class,nfsd4_allocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_deallocate,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_clone,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_copy,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_seek,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_offload_status,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++DEFINE_EVENT(nfsd4_op_class,nfsd4_offload_cancel,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); ++ + #endif /* _NFSD_TRACE_H */ + + #undef TRACE_INCLUDE_PATH +-- +2.17.1 +