Skip to content

Commit

Permalink
pNFS/flexfiles: Add tracing for layout errors
Browse files Browse the repository at this point in the history
Trace layout errors for pNFS/flexfiles on read/write/commit operations.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Trond Myklebust authored and Anna Schumaker committed Jan 15, 2020
1 parent 7bdd297 commit 088f3e6
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 9 deletions.
28 changes: 19 additions & 9 deletions fs/nfs/flexfilelayout/flexfilelayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,9 +1266,10 @@ static int ff_layout_async_handle_error(struct rpc_task *task,

static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
int idx, u64 offset, u64 length,
u32 status, int opnum, int error)
u32 *op_status, int opnum, int error)
{
struct nfs4_ff_layout_mirror *mirror;
u32 status = *op_status;
int err;

if (status == 0) {
Expand All @@ -1286,10 +1287,10 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
case -ENOBUFS:
case -EPIPE:
case -EPERM:
status = NFS4ERR_NXIO;
*op_status = status = NFS4ERR_NXIO;
break;
case -EACCES:
status = NFS4ERR_ACCESS;
*op_status = status = NFS4ERR_ACCESS;
break;
default:
return;
Expand Down Expand Up @@ -1321,11 +1322,14 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
int new_idx = hdr->pgio_mirror_idx;
int err;

if (task->tk_status < 0)
if (task->tk_status < 0) {
ff_layout_io_track_ds_error(hdr->lseg, hdr->pgio_mirror_idx,
hdr->args.offset, hdr->args.count,
hdr->res.op_status, OP_READ,
&hdr->res.op_status, OP_READ,
task->tk_status);
trace_ff_layout_read_error(hdr);
}

err = ff_layout_async_handle_error(task, hdr->args.context->state,
hdr->ds_clp, hdr->lseg,
hdr->pgio_mirror_idx);
Expand Down Expand Up @@ -1494,11 +1498,14 @@ static int ff_layout_write_done_cb(struct rpc_task *task,
loff_t end_offs = 0;
int err;

if (task->tk_status < 0)
if (task->tk_status < 0) {
ff_layout_io_track_ds_error(hdr->lseg, hdr->pgio_mirror_idx,
hdr->args.offset, hdr->args.count,
hdr->res.op_status, OP_WRITE,
&hdr->res.op_status, OP_WRITE,
task->tk_status);
trace_ff_layout_write_error(hdr);
}

err = ff_layout_async_handle_error(task, hdr->args.context->state,
hdr->ds_clp, hdr->lseg,
hdr->pgio_mirror_idx);
Expand Down Expand Up @@ -1537,11 +1544,14 @@ static int ff_layout_commit_done_cb(struct rpc_task *task,
{
int err;

if (task->tk_status < 0)
if (task->tk_status < 0) {
ff_layout_io_track_ds_error(data->lseg, data->ds_commit_index,
data->args.offset, data->args.count,
data->res.op_status, OP_COMMIT,
&data->res.op_status, OP_COMMIT,
task->tk_status);
trace_ff_layout_commit_error(data);
}

err = ff_layout_async_handle_error(task, NULL, data->ds_clp,
data->lseg, data->ds_commit_index);

Expand Down
4 changes: 4 additions & 0 deletions fs/nfs/nfs4trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(pnfs_mds_fallback_read_done);
EXPORT_TRACEPOINT_SYMBOL_GPL(pnfs_mds_fallback_write_done);
EXPORT_TRACEPOINT_SYMBOL_GPL(pnfs_mds_fallback_read_pagelist);
EXPORT_TRACEPOINT_SYMBOL_GPL(pnfs_mds_fallback_write_pagelist);

EXPORT_TRACEPOINT_SYMBOL_GPL(ff_layout_read_error);
EXPORT_TRACEPOINT_SYMBOL_GPL(ff_layout_write_error);
EXPORT_TRACEPOINT_SYMBOL_GPL(ff_layout_commit_error);
#endif
109 changes: 109 additions & 0 deletions fs/nfs/nfs4trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,115 @@ DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);

DECLARE_EVENT_CLASS(nfs4_flexfiles_io_event,
TP_PROTO(
const struct nfs_pgio_header *hdr
),

TP_ARGS(hdr),

TP_STRUCT__entry(
__field(unsigned long, error)
__field(dev_t, dev)
__field(u32, fhandle)
__field(u64, fileid)
__field(loff_t, offset)
__field(u32, count)
__field(int, stateid_seq)
__field(u32, stateid_hash)
__string(dstaddr, hdr->ds_clp ?
rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
RPC_DISPLAY_ADDR) : "unknown")
),

TP_fast_assign(
const struct inode *inode = hdr->inode;

__entry->error = hdr->res.op_status;
__entry->fhandle = nfs_fhandle_hash(hdr->args.fh);
__entry->fileid = NFS_FILEID(inode);
__entry->dev = inode->i_sb->s_dev;
__entry->offset = hdr->args.offset;
__entry->count = hdr->args.count;
__entry->stateid_seq =
be32_to_cpu(hdr->args.stateid.seqid);
__entry->stateid_hash =
nfs_stateid_hash(&hdr->args.stateid);
__assign_str(dstaddr, hdr->ds_clp ?
rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
RPC_DISPLAY_ADDR) : "unknown");
),

TP_printk(
"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
"offset=%llu count=%u stateid=%d:0x%08x dstaddr=%s",
-__entry->error,
show_nfsv4_errors(__entry->error),
MAJOR(__entry->dev), MINOR(__entry->dev),
(unsigned long long)__entry->fileid,
__entry->fhandle,
__entry->offset, __entry->count,
__entry->stateid_seq, __entry->stateid_hash,
__get_str(dstaddr)
)
);

#define DEFINE_NFS4_FLEXFILES_IO_EVENT(name) \
DEFINE_EVENT(nfs4_flexfiles_io_event, name, \
TP_PROTO( \
const struct nfs_pgio_header *hdr \
), \
TP_ARGS(hdr))
DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_read_error);
DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_write_error);

TRACE_EVENT(ff_layout_commit_error,
TP_PROTO(
const struct nfs_commit_data *data
),

TP_ARGS(data),

TP_STRUCT__entry(
__field(unsigned long, error)
__field(dev_t, dev)
__field(u32, fhandle)
__field(u64, fileid)
__field(loff_t, offset)
__field(u32, count)
__string(dstaddr, data->ds_clp ?
rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
RPC_DISPLAY_ADDR) : "unknown")
),

TP_fast_assign(
const struct inode *inode = data->inode;

__entry->error = data->res.op_status;
__entry->fhandle = nfs_fhandle_hash(data->args.fh);
__entry->fileid = NFS_FILEID(inode);
__entry->dev = inode->i_sb->s_dev;
__entry->offset = data->args.offset;
__entry->count = data->args.count;
__assign_str(dstaddr, data->ds_clp ?
rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
RPC_DISPLAY_ADDR) : "unknown");
),

TP_printk(
"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
"offset=%llu count=%u dstaddr=%s",
-__entry->error,
show_nfsv4_errors(__entry->error),
MAJOR(__entry->dev), MINOR(__entry->dev),
(unsigned long long)__entry->fileid,
__entry->fhandle,
__entry->offset, __entry->count,
__get_str(dstaddr)
)
);


#endif /* CONFIG_NFS_V4_1 */

#endif /* _TRACE_NFS4_H */
Expand Down

0 comments on commit 088f3e6

Please sign in to comment.