Add tracepoints for enter/exit (error or done without error) for compounded query_info and set_info Sample output (trace-cmd record -e smb3_*compound*): touch-30074 [005] .... 33989.459514: smb3_set_info_compound_enter: xid=8 sid=0xbe534a7e tid=0x82c96a43 touch-30074 [005] .N.. 33989.471834: smb3_set_info_compound_done: xid=8 sid=0xbe534a7e tid=0x82c96a43 mkdir-30076 [007] .... 33999.239926: smb3_query_info_compound_enter: xid=10 sid=0xbe534a7e tid=0x82c96a43 mkdir-30076 [007] .... 33999.247180: smb3_query_info_compound_done: xid=10 sid=0xbe534a7e tid=0x82c96a43 -- Thanks, Steve
From 7857c2f6a17851aac10232da9162b688b35dc368 Mon Sep 17 00:00:00 2001 From: Steve French <stfrench@xxxxxxxxxxxxx> Date: Wed, 27 Feb 2019 00:01:35 -0600 Subject: [PATCH] smb3: add dynamic trace points for compound query and setinfo Add tracepoints for enter/exit (error or done without error) for compounded query_info and set_info Sample output (trace-cmd record -e smb3_*compound*): touch-30074 [005] .... 33989.459514: smb3_set_info_compound_enter: xid=8 sid=0xbe534a7e tid=0x82c96a43 touch-30074 [005] .N.. 33989.471834: smb3_set_info_compound_done: xid=8 sid=0xbe534a7e tid=0x82c96a43 mkdir-30076 [007] .... 33999.239926: smb3_query_info_compound_enter: xid=10 sid=0xbe534a7e tid=0x82c96a43 mkdir-30076 [007] .... 33999.247180: smb3_query_info_compound_done: xid=10 sid=0xbe534a7e tid=0x82c96a43 Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> --- fs/cifs/smb2inode.c | 19 +++++++++++++- fs/cifs/trace.h | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index 01a76bccdb8d..b645b8626e7d 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -112,6 +112,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, PATH_MAX * 2, 0, NULL); smb2_set_next_command(tcon, &rqst[num_rqst]); smb2_set_related(&rqst[num_rqst++]); + trace_smb3_query_info_compound_enter(xid, tcon->tid, ses->Suid); break; case SMB2_OP_DELETE: break; @@ -166,6 +167,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, SMB2_O_INFO_FILE, 0, data, size); smb2_set_next_command(tcon, &rqst[num_rqst]); smb2_set_related(&rqst[num_rqst++]); + trace_smb3_set_info_compound_enter(xid, tcon->tid, ses->Suid); break; case SMB2_OP_RENAME: memset(&si_iov, 0, sizeof(si_iov)); @@ -247,7 +249,11 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, le32_to_cpu(qi_rsp->OutputBufferLength), &rsp_iov[1], sizeof(struct smb2_file_all_info), ptr); - } + trace_smb3_query_info_compound_done(xid, tcon->tid, + ses->Suid); + } else + trace_smb3_query_info_compound_err(xid, tcon->tid, + ses->Suid, rc); if (rqst[1].rq_iov) SMB2_query_info_free(&rqst[1]); if (rqst[2].rq_iov) @@ -262,11 +268,22 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, case SMB2_OP_RENAME: case SMB2_OP_RMDIR: case SMB2_OP_SET_EOF: + if (rqst[1].rq_iov) + SMB2_set_info_free(&rqst[1]); + if (rqst[2].rq_iov) + SMB2_close_free(&rqst[2]); + break; case SMB2_OP_SET_INFO: if (rqst[1].rq_iov) SMB2_set_info_free(&rqst[1]); if (rqst[2].rq_iov) SMB2_close_free(&rqst[2]); + if (rc) + trace_smb3_set_info_compound_err(xid, tcon->tid, + ses->Suid, rc); + else + trace_smb3_set_info_compound_done(xid, tcon->tid, + ses->Suid); break; } free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base); diff --git a/fs/cifs/trace.h b/fs/cifs/trace.h index d8b049afa606..a8837d6efbc0 100644 --- a/fs/cifs/trace.h +++ b/fs/cifs/trace.h @@ -242,6 +242,70 @@ DEFINE_SMB3_INF_ERR_EVENT(query_info_err); DEFINE_SMB3_INF_ERR_EVENT(set_info_err); DEFINE_SMB3_INF_ERR_EVENT(fsctl_err); +DECLARE_EVENT_CLASS(smb3_inf_compound_enter_class, + TP_PROTO(unsigned int xid, + __u32 tid, + __u64 sesid), + TP_ARGS(xid, tid, sesid), + TP_STRUCT__entry( + __field(unsigned int, xid) + __field(__u32, tid) + __field(__u64, sesid) + ), + TP_fast_assign( + __entry->xid = xid; + __entry->tid = tid; + __entry->sesid = sesid; + ), + TP_printk("xid=%u sid=0x%llx tid=0x%x", + __entry->xid, __entry->sesid, __entry->tid) +) + +#define DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(name) \ +DEFINE_EVENT(smb3_inf_compound_enter_class, smb3_##name, \ + TP_PROTO(unsigned int xid, \ + __u32 tid, \ + __u64 sesid), \ + TP_ARGS(xid, tid, sesid)) + +DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter); +DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_done); +DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter); +DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_done); + +DECLARE_EVENT_CLASS(smb3_inf_compound_err_class, + TP_PROTO(unsigned int xid, + __u32 tid, + __u64 sesid, + int rc), + TP_ARGS(xid, tid, sesid, rc), + TP_STRUCT__entry( + __field(unsigned int, xid) + __field(__u32, tid) + __field(__u64, sesid) + __field(int, rc) + ), + TP_fast_assign( + __entry->xid = xid; + __entry->tid = tid; + __entry->sesid = sesid; + __entry->rc = rc; + ), + TP_printk("xid=%u sid=0x%llx tid=0x%x rc=%d", + __entry->xid, __entry->sesid, __entry->tid, __entry->rc) +) + +#define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name) \ +DEFINE_EVENT(smb3_inf_compound_err_class, smb3_##name, \ + TP_PROTO(unsigned int xid, \ + __u32 tid, \ + __u64 sesid, \ + int rc), \ + TP_ARGS(xid, tid, sesid, rc)) + +DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err); +DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err); + /* * For logging SMB3 Status code and Command for responses which return errors */ -- 2.17.1