From 1a28f2c83767db807660f40d284fe056dd0353cc 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 | 72 +++++++++++++++++++ fs/nfsd/nfs4state.c | 42 +++++++++++ fs/nfsd/trace.h | 169 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 283 insertions(+) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 00440337efc1f..30e90d314ed72 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -359,6 +359,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); @@ -496,6 +498,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; } @@ -507,6 +511,8 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_putfh *putfh = &u->putfh; __be32 ret; + 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, @@ -527,6 +533,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; @@ -536,6 +544,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; @@ -551,6 +561,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_CSTATE_FLAG(cstate, CURRENT_STATE_ID_FLAG)) { memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); @@ -569,6 +581,8 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_access *access = &u->access; u32 access_full; + trace_nfsd4_access(rqstp); + access_full = NFS3_ACCESS_FULL; if (cstate->minorversion >= 2) access_full |= NFS4_ACCESS_XALIST | NFS4_ACCESS_XAREAD | @@ -597,6 +611,8 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, { struct nfsd4_commit *commit = &u->commit; + trace_nfsd4_commit(rqstp); + return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, commit->co_count, (__be32 *)commit->co_verf.data); @@ -611,6 +627,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); @@ -702,6 +720,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; @@ -724,6 +744,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) @@ -752,6 +774,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); } @@ -759,6 +783,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); @@ -771,6 +797,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_nf = NULL; if (read->rd_offset >= OFFSET_MAX) return nfserr_inval; @@ -822,6 +850,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) @@ -844,6 +874,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; @@ -856,6 +888,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, @@ -874,6 +908,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, @@ -895,6 +931,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; @@ -922,6 +960,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; @@ -961,6 +1001,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, @@ -1008,6 +1050,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 nfsd_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) @@ -1507,6 +1553,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, __be32 status; struct nfsd4_copy *async_copy = NULL; + trace_nfsd4_copy(rqstp); + if (!copy->cp_intra) { /* Inter server SSC */ if (!inter_copy_offload_enable || copy->cp_synchronous) { status = nfserr_notsupp; @@ -1588,6 +1636,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) { struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); @@ -1610,6 +1660,8 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfs4_cpntf_state *cps; struct nfs4_client *clp = cstate->clp; + trace_nfsd4_copy_notify(rqstp); + status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, &cn->cpn_src_stateid, RD_STATE, NULL, &stid); @@ -1675,6 +1727,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; @@ -1689,6 +1743,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); } @@ -1696,6 +1752,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); } @@ -1709,6 +1767,8 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, __be32 status; struct nfsd_file *nf; + trace_nfsd4_seek(rqstp); + status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, &seek->seek_stateid, RD_STATE, &nf, NULL); @@ -1813,6 +1873,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; } @@ -1823,6 +1885,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; } @@ -1856,6 +1920,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, @@ -1909,6 +1975,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; @@ -1997,6 +2065,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; @@ -2056,6 +2126,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 210147960c52e..8f6c00d4b9abe 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3070,6 +3070,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", @@ -3368,6 +3370,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); @@ -3491,6 +3495,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; @@ -3556,6 +3562,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); @@ -3610,6 +3618,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)) @@ -3733,6 +3743,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; @@ -3868,6 +3880,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); @@ -3908,6 +3922,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; @@ -3953,6 +3969,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; @@ -4009,6 +4027,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; @@ -5294,6 +5314,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); + trace_nfsd_clid_renew(clid); status = lookup_clientid(clid, cstate, nn, false); if (status) @@ -5918,6 +5940,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); @@ -5965,6 +5989,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) @@ -6091,6 +6117,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); @@ -6157,6 +6185,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); @@ -6227,6 +6257,8 @@ nfsd4_close(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_close(rqstp); + dprintk("NFSD: nfsd4_close on file %pd\n", cstate->current_fh.fh_dentry); @@ -6277,6 +6309,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; @@ -6674,6 +6708,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); @@ -6907,6 +6943,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; @@ -6984,6 +7022,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); @@ -7096,6 +7136,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 c8ca73d69ad04..41ed500c209fa 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -11,6 +11,7 @@ #include #include "export.h" #include "nfsfh.h" +#include "xdr4.h" TRACE_EVENT(nfsd_compound, TP_PROTO(const struct svc_rqst *rqst, @@ -748,6 +749,174 @@ TRACE_EVENT(nfsd_cb_done, __entry->status) ); +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)); +/* READ_PLUS omitted - currently uses nfsd4_read op funtion */ +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)); +DEFINE_EVENT(nfsd4_op_class,nfsd4_copy_notify,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); +DEFINE_EVENT(nfsd4_op_class,nfsd4_getxattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); +DEFINE_EVENT(nfsd4_op_class,nfsd4_setxattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); +DEFINE_EVENT(nfsd4_op_class,nfsd4_listxattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); +DEFINE_EVENT(nfsd4_op_class,nfsd4_removexattr,TP_PROTO(struct svc_rqst *rqstp),TP_ARGS(rqstp)); + #endif /* _NFSD_TRACE_H */ #undef TRACE_INCLUDE_PATH