Skip to content

Commit a2f4c3f

Browse files
Trond Myklebustchucklever
authored andcommitted
nfsd: Add a tracepoint for errors in nfsd4_clone_file_range()
Since a clone error commit can cause the boot verifier to change, we should trace those errors. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> [ cel: Addressed a checkpatch.pl splat in fs/nfsd/vfs.h ]
1 parent 2c445a0 commit a2f4c3f

4 files changed

Lines changed: 69 additions & 4 deletions

File tree

fs/nfsd/nfs4proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11011101
if (status)
11021102
goto out;
11031103

1104-
status = nfsd4_clone_file_range(src, clone->cl_src_pos,
1104+
status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos,
11051105
dst, clone->cl_dst_pos, clone->cl_count,
11061106
EX_ISSYNC(cstate->current_fh.fh_export));
11071107

fs/nfsd/trace.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,56 @@ TRACE_EVENT(nfsd_dirent,
399399
)
400400
)
401401

402+
DECLARE_EVENT_CLASS(nfsd_copy_err_class,
403+
TP_PROTO(struct svc_rqst *rqstp,
404+
struct svc_fh *src_fhp,
405+
loff_t src_offset,
406+
struct svc_fh *dst_fhp,
407+
loff_t dst_offset,
408+
u64 count,
409+
int status),
410+
TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, count, status),
411+
TP_STRUCT__entry(
412+
__field(u32, xid)
413+
__field(u32, src_fh_hash)
414+
__field(loff_t, src_offset)
415+
__field(u32, dst_fh_hash)
416+
__field(loff_t, dst_offset)
417+
__field(u64, count)
418+
__field(int, status)
419+
),
420+
TP_fast_assign(
421+
__entry->xid = be32_to_cpu(rqstp->rq_xid);
422+
__entry->src_fh_hash = knfsd_fh_hash(&src_fhp->fh_handle);
423+
__entry->src_offset = src_offset;
424+
__entry->dst_fh_hash = knfsd_fh_hash(&dst_fhp->fh_handle);
425+
__entry->dst_offset = dst_offset;
426+
__entry->count = count;
427+
__entry->status = status;
428+
),
429+
TP_printk("xid=0x%08x src_fh_hash=0x%08x src_offset=%lld "
430+
"dst_fh_hash=0x%08x dst_offset=%lld "
431+
"count=%llu status=%d",
432+
__entry->xid, __entry->src_fh_hash, __entry->src_offset,
433+
__entry->dst_fh_hash, __entry->dst_offset,
434+
(unsigned long long)__entry->count,
435+
__entry->status)
436+
)
437+
438+
#define DEFINE_NFSD_COPY_ERR_EVENT(name) \
439+
DEFINE_EVENT(nfsd_copy_err_class, nfsd_##name, \
440+
TP_PROTO(struct svc_rqst *rqstp, \
441+
struct svc_fh *src_fhp, \
442+
loff_t src_offset, \
443+
struct svc_fh *dst_fhp, \
444+
loff_t dst_offset, \
445+
u64 count, \
446+
int status), \
447+
TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, \
448+
count, status))
449+
450+
DEFINE_NFSD_COPY_ERR_EVENT(clone_file_range_err);
451+
402452
#include "state.h"
403453
#include "filecache.h"
404454
#include "vfs.h"

fs/nfsd/vfs.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "../internal.h"
4141
#include "acl.h"
4242
#include "idmap.h"
43+
#include "xdr4.h"
4344
#endif /* CONFIG_NFSD_V4 */
4445

4546
#include "nfsd.h"
@@ -517,8 +518,15 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp,
517518
}
518519
#endif
519520

520-
__be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos,
521-
struct nfsd_file *nf_dst, u64 dst_pos, u64 count, bool sync)
521+
static struct nfsd4_compound_state *nfsd4_get_cstate(struct svc_rqst *rqstp)
522+
{
523+
return &((struct nfsd4_compoundres *)rqstp->rq_resp)->cstate;
524+
}
525+
526+
__be32 nfsd4_clone_file_range(struct svc_rqst *rqstp,
527+
struct nfsd_file *nf_src, u64 src_pos,
528+
struct nfsd_file *nf_dst, u64 dst_pos,
529+
u64 count, bool sync)
522530
{
523531
struct file *src = nf_src->nf_file;
524532
struct file *dst = nf_dst->nf_file;
@@ -545,6 +553,12 @@ __be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos,
545553
if (!status)
546554
status = commit_inode_metadata(file_inode(src));
547555
if (status < 0) {
556+
trace_nfsd_clone_file_range_err(rqstp,
557+
&nfsd4_get_cstate(rqstp)->save_fh,
558+
src_pos,
559+
&nfsd4_get_cstate(rqstp)->current_fh,
560+
dst_pos,
561+
count, status);
548562
nfsd_reset_boot_verifier(net_generic(nf_dst->nf_net,
549563
nfsd_net_id));
550564
ret = nfserrno(status);

fs/nfsd/vfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *, struct svc_fh *,
5757
struct xdr_netobj *);
5858
__be32 nfsd4_vfs_fallocate(struct svc_rqst *, struct svc_fh *,
5959
struct file *, loff_t, loff_t, int);
60-
__be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos,
60+
__be32 nfsd4_clone_file_range(struct svc_rqst *rqstp,
61+
struct nfsd_file *nf_src, u64 src_pos,
6162
struct nfsd_file *nf_dst, u64 dst_pos,
6263
u64 count, bool sync);
6364
#endif /* CONFIG_NFSD_V4 */

0 commit comments

Comments
 (0)