[PATCH][SMB3 client] dynamic tracepoints for copy_range and clone_range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Two patches that add dynamic tracepoints for copy_range and clone
range including

   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"
      "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

and

    smb3: add dynamic tracepoints for copy_file_range and reflink errors

    There are cases where debugging clone_range ("smb2_duplicate_extents"
    function) and copy_range ("smb2_copychunk_range") can be helpful.
    Add dynamic trace points for any errors in these two routines. e,g,

      "trace-cmd record -e smb3_copychunk_err -e smb3_clone_err"

See attached


-- 
Thanks,

Steve
From 26b7b2dec1d8cfca2cea2ca6ca0c21f20d0daf5a Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@xxxxxxxxxxxxx>
Date: Tue, 23 Jul 2024 18:12:40 -0500
Subject: [PATCH 1/2] smb3: add dynamic tracepoints for copy_file_range and
 reflink errors

There are cases where debugging clone_range ("smb2_duplicate_extents"
function) and copy_range ("smb2_copychunk_range") can be helpful.
Add dynamic trace points for any errors in these two routines. e,g,

  "trace-cmd record -e smb3_copychunk_err -e smb3_clone_err"

Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
---
 fs/smb/client/smb2ops.c | 13 ++++++++--
 fs/smb/client/trace.h   | 57 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 7fe59235f090..94447cde2fe0 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1899,9 +1899,13 @@ smb2_copychunk_range(const unsigned int xid,
 cchunk_out:
 	kfree(pcchunk);
 	kfree(retbuf);
-	if (rc)
+	if (rc) {
+		trace_smb3_copychunk_err(xid, srcfile->fid.volatile_fid,
+					 trgtfile->fid.volatile_fid,
+					 tcon->tid, tcon->ses->Suid, src_off,
+					 dest_off, len, rc);
 		return rc;
-	else
+	} else
 		return total_bytes_written;
 }
 
@@ -2075,6 +2079,11 @@ smb2_duplicate_extents(const unsigned int xid,
 		cifs_dbg(FYI, "Non-zero response length in duplicate extents\n");
 
 duplicate_extents_out:
+	if (rc)
+		trace_smb3_clone_err(xid, srcfile->fid.volatile_fid,
+				     trgtfile->fid.volatile_fid,
+				     tcon->tid, tcon->ses->Suid, src_off,
+				     dest_off, len, rc);
 	return rc;
 }
 
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index 36d5295c2a6f..891d6d979fad 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -206,6 +206,63 @@ DEFINE_SMB3_OTHER_ERR_EVENT(query_dir_err);
 DEFINE_SMB3_OTHER_ERR_EVENT(zero_err);
 DEFINE_SMB3_OTHER_ERR_EVENT(falloc_err);
 
+/*
+ * For logging errors in reflink and copy_range ops e.g. smb2_copychunk_range
+ * and smb2_duplicate_extents
+ */
+DECLARE_EVENT_CLASS(smb3_copy_range_err_class,
+	TP_PROTO(unsigned int xid,
+		__u64	src_fid,
+		__u64   target_fid,
+		__u32	tid,
+		__u64	sesid,
+		__u64	src_offset,
+		__u64   target_offset,
+		__u32	len,
+		int	rc),
+	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc),
+	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)
+		__field(int, rc)
+	),
+	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;
+		__entry->rc = rc;
+	),
+	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 rc=%d",
+		__entry->xid, __entry->sesid, __entry->tid, __entry->target_fid,
+		__entry->src_offset, __entry->target_fid, __entry->target_offset, __entry->len, __entry->rc)
+)
+
+#define DEFINE_SMB3_COPY_RANGE_ERR_EVENT(name)	\
+DEFINE_EVENT(smb3_copy_range_err_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,			\
+		int	rc),			\
+	TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc))
+
+DEFINE_SMB3_COPY_RANGE_ERR_EVENT(copychunk_err);
+DEFINE_SMB3_COPY_RANGE_ERR_EVENT(clone_err);
 
 /* For logging successful read or write */
 DECLARE_EVENT_CLASS(smb3_rw_done_class,
-- 
2.43.0

From 35be5f59ad26b311cd7735f9b08b8c1b22b4deb4 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@xxxxxxxxxxxxx>
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@xxxxxxxxxxxxx>
---
 fs/smb/client/smb2ops.c | 18 +++++++++++---
 fs/smb/client/trace.h   | 53 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 94447cde2fe0..0b0ceaee593f 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -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;
 }
 
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index 891d6d979fad..c1c4672f0c5e 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -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


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux