From 35be5f59ad26b311cd7735f9b08b8c1b22b4deb4 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Tue, 23 Jul 2024 23:49:21 -0500
Subject: [PATCH 2/2] smb3: add four more dynamic tracepoints for
copy_file_range and reflink
Add more dynamic tracepoints to help debug copy_file_range (copychunk)
and clone_range ("duplicate extents"). These are tracepoints for
entering the function and completing without error. For example:
"trace-cmd record -e smb3_copychunk_enter -e smb3_copychunk_done"
or
"trace-cmd record -e smb3_clone_enter -e smb3_clone_done"
Here is sample output:
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
cp-5964 [005] ..... 2176.168977: smb3_clone_enter:
xid=17 sid=0xeb275be4 tid=0x7ffa7cdb source fid=0x1ed02e15
source offset=0x0 target fid=0x1ed02e15 target offset=0x0
len=0xa0000
cp-5964 [005] ..... 2176.170668: smb3_clone_done:
xid=17 sid=0xeb275be4 tid=0x7ffa7cdb source fid=0x1ed02e15
source offset=0x0 target fid=0x1ed02e15 target offset=0x0
len=0xa0000
Signed-off-by: Steve French <stfrench@microsoft.com>
---
fs/smb/client/smb2ops.c | 18 +++++++++++---
fs/smb/client/trace.h | 53 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 3 deletions(-)
@@ -1812,6 +1812,9 @@ smb2_copychunk_range(const unsigned int xid,
tcon = tlink_tcon(trgtfile->tlink);
+ trace_smb3_copychunk_enter(xid, srcfile->fid.volatile_fid,
+ trgtfile->fid.volatile_fid, tcon->tid,
+ tcon->ses->Suid, src_off, dest_off, len);
while (len > 0) {
pcchunk->SourceOffset = cpu_to_le64(src_off);
pcchunk->TargetOffset = cpu_to_le64(dest_off);
@@ -1905,8 +1908,11 @@ smb2_copychunk_range(const unsigned int xid,
tcon->tid, tcon->ses->Suid, src_off,
dest_off, len, rc);
return rc;
- } else
- return total_bytes_written;
+ }
+ trace_smb3_copychunk_done(xid, srcfile->fid.volatile_fid,
+ trgtfile->fid.volatile_fid, tcon->tid,
+ tcon->ses->Suid, src_off, dest_off, len);
+ return total_bytes_written;
}
static int
@@ -2050,7 +2056,9 @@ smb2_duplicate_extents(const unsigned int xid,
dup_ext_buf.ByteCount = cpu_to_le64(len);
cifs_dbg(FYI, "Duplicate extents: src off %lld dst off %lld len %lld\n",
src_off, dest_off, len);
-
+ trace_smb3_clone_enter(xid, srcfile->fid.volatile_fid,
+ trgtfile->fid.volatile_fid, tcon->tid,
+ tcon->ses->Suid, src_off, dest_off, len);
inode = d_inode(trgtfile->dentry);
if (inode->i_size < dest_off + len) {
rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
@@ -2084,6 +2092,10 @@ smb2_duplicate_extents(const unsigned int xid,
trgtfile->fid.volatile_fid,
tcon->tid, tcon->ses->Suid, src_off,
dest_off, len, rc);
+ else
+ trace_smb3_clone_done(xid, srcfile->fid.volatile_fid,
+ trgtfile->fid.volatile_fid, tcon->tid,
+ tcon->ses->Suid, src_off, dest_off, len);
return rc;
}
@@ -264,6 +264,59 @@ DEFINE_EVENT(smb3_copy_range_err_class, smb3_##name, \
DEFINE_SMB3_COPY_RANGE_ERR_EVENT(copychunk_err);
DEFINE_SMB3_COPY_RANGE_ERR_EVENT(clone_err);
+DECLARE_EVENT_CLASS(smb3_copy_range_done_class,
+ TP_PROTO(unsigned int xid,
+ __u64 src_fid,
+ __u64 target_fid,
+ __u32 tid,
+ __u64 sesid,
+ __u64 src_offset,
+ __u64 target_offset,
+ __u32 len),
+ TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len),
+ TP_STRUCT__entry(
+ __field(unsigned int, xid)
+ __field(__u64, src_fid)
+ __field(__u64, target_fid)
+ __field(__u32, tid)
+ __field(__u64, sesid)
+ __field(__u64, src_offset)
+ __field(__u64, target_offset)
+ __field(__u32, len)
+ ),
+ TP_fast_assign(
+ __entry->xid = xid;
+ __entry->src_fid = src_fid;
+ __entry->target_fid = target_fid;
+ __entry->tid = tid;
+ __entry->sesid = sesid;
+ __entry->src_offset = src_offset;
+ __entry->target_offset = target_offset;
+ __entry->len = len;
+ ),
+ TP_printk("\txid=%u sid=0x%llx tid=0x%x source fid=0x%llx source offset=0x%llx target fid=0x%llx target offset=0x%llx len=0x%x",
+ __entry->xid, __entry->sesid, __entry->tid, __entry->target_fid,
+ __entry->src_offset, __entry->target_fid, __entry->target_offset, __entry->len)
+)
+
+#define DEFINE_SMB3_COPY_RANGE_DONE_EVENT(name) \
+DEFINE_EVENT(smb3_copy_range_done_class, smb3_##name, \
+ TP_PROTO(unsigned int xid, \
+ __u64 src_fid, \
+ __u64 target_fid, \
+ __u32 tid, \
+ __u64 sesid, \
+ __u64 src_offset, \
+ __u64 target_offset, \
+ __u32 len), \
+ TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len))
+
+DEFINE_SMB3_COPY_RANGE_DONE_EVENT(copychunk_enter);
+DEFINE_SMB3_COPY_RANGE_DONE_EVENT(clone_enter);
+DEFINE_SMB3_COPY_RANGE_DONE_EVENT(copychunk_done);
+DEFINE_SMB3_COPY_RANGE_DONE_EVENT(clone_done);
+
+
/* For logging successful read or write */
DECLARE_EVENT_CLASS(smb3_rw_done_class,
TP_PROTO(unsigned int rreq_debug_id,
--
2.43.0