NFS: Add tracepoints for debugging NFS hard links
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 21 Aug 2013 17:54:44 +0000 (13:54 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 22 Aug 2013 12:58:20 +0000 (08:58 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/dir.c
fs/nfs/nfstrace.h

index dca7deb1609bbcab79abfe1f15b540e5d84778f7..4ce7f7696e11afa449785969bd9028e7f041ea04 100644 (file)
@@ -1860,6 +1860,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
                old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
                dentry->d_parent->d_name.name, dentry->d_name.name);
 
+       trace_nfs_link_enter(inode, dir, dentry);
        NFS_PROTO(inode)->return_delegation(inode);
 
        d_drop(dentry);
@@ -1868,6 +1869,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
                ihold(inode);
                d_add(dentry, inode);
        }
+       trace_nfs_link_exit(inode, dir, dentry, error);
        return error;
 }
 EXPORT_SYMBOL_GPL(nfs_link);
index a20f0d147cf23435dc75e9c87a10e015c4c02143..89fe741e58b1f7280f44e882f640259b8a8af144 100644 (file)
@@ -512,6 +512,76 @@ DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
 
+TRACE_EVENT(nfs_link_enter,
+               TP_PROTO(
+                       const struct inode *inode,
+                       const struct inode *dir,
+                       const struct dentry *dentry
+               ),
+
+               TP_ARGS(inode, dir, dentry),
+
+               TP_STRUCT__entry(
+                       __field(dev_t, dev)
+                       __field(u64, fileid)
+                       __field(u64, dir)
+                       __string(name, dentry->d_name.name)
+               ),
+
+               TP_fast_assign(
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->dir = NFS_FILEID(dir);
+                       __assign_str(name, dentry->d_name.name);
+               ),
+
+               TP_printk(
+                       "fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       __entry->fileid,
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->dir,
+                       __get_str(name)
+               )
+);
+
+TRACE_EVENT(nfs_link_exit,
+               TP_PROTO(
+                       const struct inode *inode,
+                       const struct inode *dir,
+                       const struct dentry *dentry,
+                       int error
+               ),
+
+               TP_ARGS(inode, dir, dentry, error),
+
+               TP_STRUCT__entry(
+                       __field(int, error)
+                       __field(dev_t, dev)
+                       __field(u64, fileid)
+                       __field(u64, dir)
+                       __string(name, dentry->d_name.name)
+               ),
+
+               TP_fast_assign(
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = NFS_FILEID(inode);
+                       __entry->dir = NFS_FILEID(dir);
+                       __entry->error = error;
+                       __assign_str(name, dentry->d_name.name);
+               ),
+
+               TP_printk(
+                       "error=%d fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
+                       __entry->error,
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       __entry->fileid,
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->dir,
+                       __get_str(name)
+               )
+);
+
 DECLARE_EVENT_CLASS(nfs_rename_event,
                TP_PROTO(
                        const struct inode *old_dir,