NFS: Trace short NFS READs
authorChuck Lever <chuck.lever@oracle.com>
Tue, 12 May 2020 21:14:05 +0000 (17:14 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 11 Jun 2020 17:33:48 +0000 (13:33 -0400)
A short read can generate an -EIO error without there being an error
on the wire. This tracepoint acts as an eyecatcher when there is no
obvious I/O error.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfstrace.h
fs/nfs/read.c

index e906514..b35998c 100644 (file)
@@ -961,6 +961,53 @@ TRACE_EVENT(nfs_readpage_done,
                )
 );
 
+TRACE_EVENT(nfs_readpage_short,
+               TP_PROTO(
+                       const struct rpc_task *task,
+                       const struct nfs_pgio_header *hdr
+               ),
+
+               TP_ARGS(task, hdr),
+
+               TP_STRUCT__entry(
+                       __field(dev_t, dev)
+                       __field(u32, fhandle)
+                       __field(u64, fileid)
+                       __field(loff_t, offset)
+                       __field(u32, arg_count)
+                       __field(u32, res_count)
+                       __field(bool, eof)
+                       __field(int, status)
+               ),
+
+               TP_fast_assign(
+                       const struct inode *inode = hdr->inode;
+                       const struct nfs_inode *nfsi = NFS_I(inode);
+                       const struct nfs_fh *fh = hdr->args.fh ?
+                                                 hdr->args.fh : &nfsi->fh;
+
+                       __entry->status = task->tk_status;
+                       __entry->offset = hdr->args.offset;
+                       __entry->arg_count = hdr->args.count;
+                       __entry->res_count = hdr->res.count;
+                       __entry->eof = hdr->res.eof;
+                       __entry->dev = inode->i_sb->s_dev;
+                       __entry->fileid = nfsi->fileid;
+                       __entry->fhandle = nfs_fhandle_hash(fh);
+               ),
+
+               TP_printk(
+                       "fileid=%02x:%02x:%llu fhandle=0x%08x "
+                       "offset=%lld count=%u res=%u status=%d%s",
+                       MAJOR(__entry->dev), MINOR(__entry->dev),
+                       (unsigned long long)__entry->fileid,
+                       __entry->fhandle,
+                       (long long)__entry->offset, __entry->arg_count,
+                       __entry->res_count, __entry->status,
+                       __entry->eof ? " eof" : ""
+               )
+);
+
 TRACE_DEFINE_ENUM(NFS_UNSTABLE);
 TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
 TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
index 13b22e8..eb854f1 100644 (file)
@@ -264,6 +264,8 @@ static void nfs_readpage_retry(struct rpc_task *task,
 
        /* This is a short read! */
        nfs_inc_stats(hdr->inode, NFSIOS_SHORTREAD);
+       trace_nfs_readpage_short(task, hdr);
+
        /* Has the server at least made some progress? */
        if (resp->count == 0) {
                nfs_set_pgio_error(hdr, -EIO, argp->offset);