OSDN Git Service

NFS: Add a tracepoint in nfs_fh_to_dentry()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 1 Nov 2019 19:33:55 +0000 (15:33 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 4 Nov 2019 02:28:46 +0000 (21:28 -0500)
Add a tracepoint in nfs_fh_to_dentry() for debugging issues with bad
userspace filehandles.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/export.c
fs/nfs/nfstrace.h

index deecb67..3430d68 100644 (file)
@@ -105,6 +105,7 @@ nfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
        ret = rpc_ops->getattr(NFS_SB(sb), server_fh, fattr, label, NULL);
        if (ret) {
                dprintk("%s: getattr failed %d\n", __func__, ret);
+               trace_nfs_fh_to_dentry(sb, server_fh, fattr->fileid, ret);
                dentry = ERR_PTR(ret);
                goto out_free_label;
        }
index 361cc10..f64a33d 100644 (file)
@@ -1065,6 +1065,39 @@ TRACE_EVENT(nfs_commit_done,
                )
 );
 
+TRACE_EVENT(nfs_fh_to_dentry,
+               TP_PROTO(
+                       const struct super_block *sb,
+                       const struct nfs_fh *fh,
+                       u64 fileid,
+                       int error
+               ),
+
+               TP_ARGS(sb, fh, fileid, error),
+
+               TP_STRUCT__entry(
+                       __field(int, error)
+                       __field(dev_t, dev)
+                       __field(u32, fhandle)
+                       __field(u64, fileid)
+               ),
+
+               TP_fast_assign(
+                       __entry->error = error;
+                       __entry->dev = sb->s_dev;
+                       __entry->fileid = fileid;
+                       __entry->fhandle = nfs_fhandle_hash(fh);
+               ),
+
+               TP_printk(
+                       "error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
+                       __entry->error,
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle
+               )
+);
+
 TRACE_DEFINE_ENUM(NFS_OK);
 TRACE_DEFINE_ENUM(NFSERR_PERM);
 TRACE_DEFINE_ENUM(NFSERR_NOENT);