]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
NFSD: Replace dprintk() call site in fh_verify()
authorChuck Lever <chuck.lever@oracle.com>
Thu, 8 Sep 2022 22:13:42 +0000 (18:13 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 26 Sep 2022 18:02:31 +0000 (14:02 -0400)
Record permission errors in the trace log. Note that the new trace
event is conditional, so it will only record non-zero return values
from nfsd_permission().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
fs/nfsd/nfsfh.c
fs/nfsd/trace.h

index a5b71526cee0fa779b1302b1a61b9e8c1b8b65aa..d73434200df989572a95181e0bdeb3ae7b9f92c2 100644 (file)
@@ -392,13 +392,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
 skip_pseudoflavor_check:
        /* Finally, check access permissions. */
        error = nfsd_permission(rqstp, exp, dentry, access);
-
-       if (error) {
-               dprintk("fh_verify: %pd2 permission failure, "
-                       "acc=%x, error=%d\n",
-                       dentry,
-                       access, ntohl(error));
-       }
+       trace_nfsd_fh_verify_err(rqstp, fhp, type, access, error);
 out:
        if (error == nfserr_stale)
                nfsd_stats_fh_stale_inc(exp);
index 9ebd67d461f9ee51a33c305920a8bddc5f790441..1b9f5753f33656d9c7b9a74a51d4d4f441665d62 100644 (file)
@@ -195,7 +195,7 @@ TRACE_EVENT(nfsd_fh_verify,
                __sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
                __field(u32, xid)
                __field(u32, fh_hash)
-               __field(void *, inode)
+               __field(const void *, inode)
                __field(unsigned long, type)
                __field(unsigned long, access)
        ),
@@ -211,13 +211,55 @@ TRACE_EVENT(nfsd_fh_verify,
                __entry->type = type;
                __entry->access = access;
        ),
-       TP_printk("xid=0x%08x fh_hash=0x%08x inode=%p type=%s access=%s",
-               __entry->xid, __entry->fh_hash, __entry->inode,
+       TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s",
+               __entry->xid, __entry->fh_hash,
                show_fs_file_type(__entry->type),
                show_nfsd_may_flags(__entry->access)
        )
 );
 
+TRACE_EVENT_CONDITION(nfsd_fh_verify_err,
+       TP_PROTO(
+               const struct svc_rqst *rqstp,
+               const struct svc_fh *fhp,
+               umode_t type,
+               int access,
+               __be32 error
+       ),
+       TP_ARGS(rqstp, fhp, type, access, error),
+       TP_CONDITION(error),
+       TP_STRUCT__entry(
+               __field(unsigned int, netns_ino)
+               __sockaddr(server, rqstp->rq_xprt->xpt_remotelen)
+               __sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
+               __field(u32, xid)
+               __field(u32, fh_hash)
+               __field(const void *, inode)
+               __field(unsigned long, type)
+               __field(unsigned long, access)
+               __field(int, error)
+       ),
+       TP_fast_assign(
+               __entry->netns_ino = SVC_NET(rqstp)->ns.inum;
+               __assign_sockaddr(server, &rqstp->rq_xprt->xpt_local,
+                      rqstp->rq_xprt->xpt_locallen);
+               __assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote,
+                                 rqstp->rq_xprt->xpt_remotelen);
+               __entry->xid = be32_to_cpu(rqstp->rq_xid);
+               __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+               __entry->inode = d_inode(fhp->fh_dentry);
+               __entry->type = type;
+               __entry->access = access;
+               __entry->error = be32_to_cpu(error);
+       ),
+       TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s error=%d",
+               __entry->xid, __entry->fh_hash,
+               show_fs_file_type(__entry->type),
+               show_nfsd_may_flags(__entry->access),
+               __entry->error
+       )
+);
+
 DECLARE_EVENT_CLASS(nfsd_fh_err_class,
        TP_PROTO(struct svc_rqst *rqstp,
                 struct svc_fh  *fhp,