1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2018, Microsoft Corporation.
8 #define TRACE_SYSTEM cifs
10 #if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
13 #include <linux/tracepoint.h>
15 /* For logging errors in read or write */
16 DECLARE_EVENT_CLASS(smb3_rw_err_class,
17 TP_PROTO(unsigned int xid,
24 TP_ARGS(xid, fid, tid, sesid, offset, len, rc),
26 __field(unsigned int, xid)
30 __field(__u64, offset)
38 __entry->sesid = sesid;
39 __entry->offset = offset;
43 TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
44 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
45 __entry->offset, __entry->len, __entry->rc)
48 #define DEFINE_SMB3_RW_ERR_EVENT(name) \
49 DEFINE_EVENT(smb3_rw_err_class, smb3_##name, \
50 TP_PROTO(unsigned int xid, \
57 TP_ARGS(xid, fid, tid, sesid, offset, len, rc))
59 DEFINE_SMB3_RW_ERR_EVENT(write_err);
60 DEFINE_SMB3_RW_ERR_EVENT(read_err);
61 DEFINE_SMB3_RW_ERR_EVENT(query_dir_err);
62 DEFINE_SMB3_RW_ERR_EVENT(zero_err);
63 DEFINE_SMB3_RW_ERR_EVENT(falloc_err);
66 /* For logging successful read or write */
67 DECLARE_EVENT_CLASS(smb3_rw_done_class,
68 TP_PROTO(unsigned int xid,
74 TP_ARGS(xid, fid, tid, sesid, offset, len),
76 __field(unsigned int, xid)
80 __field(__u64, offset)
87 __entry->sesid = sesid;
88 __entry->offset = offset;
91 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
92 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
93 __entry->offset, __entry->len)
96 #define DEFINE_SMB3_RW_DONE_EVENT(name) \
97 DEFINE_EVENT(smb3_rw_done_class, smb3_##name, \
98 TP_PROTO(unsigned int xid, \
104 TP_ARGS(xid, fid, tid, sesid, offset, len))
106 DEFINE_SMB3_RW_DONE_EVENT(write_enter);
107 DEFINE_SMB3_RW_DONE_EVENT(read_enter);
108 DEFINE_SMB3_RW_DONE_EVENT(query_dir_enter);
109 DEFINE_SMB3_RW_DONE_EVENT(zero_enter);
110 DEFINE_SMB3_RW_DONE_EVENT(falloc_enter);
111 DEFINE_SMB3_RW_DONE_EVENT(write_done);
112 DEFINE_SMB3_RW_DONE_EVENT(read_done);
113 DEFINE_SMB3_RW_DONE_EVENT(query_dir_done);
114 DEFINE_SMB3_RW_DONE_EVENT(zero_done);
115 DEFINE_SMB3_RW_DONE_EVENT(falloc_done);
118 * For handle based calls other than read and write, and get/set info
120 DECLARE_EVENT_CLASS(smb3_fd_err_class,
121 TP_PROTO(unsigned int xid,
126 TP_ARGS(xid, fid, tid, sesid, rc),
128 __field(unsigned int, xid)
131 __field(__u64, sesid)
138 __entry->sesid = sesid;
141 TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx rc=%d",
142 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
146 #define DEFINE_SMB3_FD_ERR_EVENT(name) \
147 DEFINE_EVENT(smb3_fd_err_class, smb3_##name, \
148 TP_PROTO(unsigned int xid, \
153 TP_ARGS(xid, fid, tid, sesid, rc))
155 DEFINE_SMB3_FD_ERR_EVENT(flush_err);
156 DEFINE_SMB3_FD_ERR_EVENT(lock_err);
157 DEFINE_SMB3_FD_ERR_EVENT(close_err);
160 * For handle based query/set info calls
162 DECLARE_EVENT_CLASS(smb3_inf_enter_class,
163 TP_PROTO(unsigned int xid,
169 TP_ARGS(xid, fid, tid, sesid, infclass, type),
171 __field(unsigned int, xid)
174 __field(__u64, sesid)
175 __field(__u8, infclass)
182 __entry->sesid = sesid;
183 __entry->infclass = infclass;
184 __entry->type = type;
186 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x",
187 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
188 __entry->infclass, __entry->type)
191 #define DEFINE_SMB3_INF_ENTER_EVENT(name) \
192 DEFINE_EVENT(smb3_inf_enter_class, smb3_##name, \
193 TP_PROTO(unsigned int xid, \
199 TP_ARGS(xid, fid, tid, sesid, infclass, type))
201 DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
202 DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
204 DECLARE_EVENT_CLASS(smb3_inf_err_class,
205 TP_PROTO(unsigned int xid,
212 TP_ARGS(xid, fid, tid, sesid, infclass, type, rc),
214 __field(unsigned int, xid)
217 __field(__u64, sesid)
218 __field(__u8, infclass)
226 __entry->sesid = sesid;
227 __entry->infclass = infclass;
228 __entry->type = type;
231 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x rc=%d",
232 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
233 __entry->infclass, __entry->type, __entry->rc)
236 #define DEFINE_SMB3_INF_ERR_EVENT(name) \
237 DEFINE_EVENT(smb3_inf_err_class, smb3_##name, \
238 TP_PROTO(unsigned int xid, \
245 TP_ARGS(xid, fid, tid, sesid, infclass, type, rc))
247 DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
248 DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
249 DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
251 DECLARE_EVENT_CLASS(smb3_inf_compound_enter_class,
252 TP_PROTO(unsigned int xid,
255 const char *full_path),
256 TP_ARGS(xid, tid, sesid, full_path),
258 __field(unsigned int, xid)
260 __field(__u64, sesid)
261 __string(path, full_path)
266 __entry->sesid = sesid;
267 __assign_str(path, full_path);
269 TP_printk("xid=%u sid=0x%llx tid=0x%x path=%s",
270 __entry->xid, __entry->sesid, __entry->tid,
274 #define DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(name) \
275 DEFINE_EVENT(smb3_inf_compound_enter_class, smb3_##name, \
276 TP_PROTO(unsigned int xid, \
279 const char *full_path), \
280 TP_ARGS(xid, tid, sesid, full_path))
282 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter);
283 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter);
284 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter);
285 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter);
286 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
287 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
288 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
289 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
292 DECLARE_EVENT_CLASS(smb3_inf_compound_done_class,
293 TP_PROTO(unsigned int xid,
296 TP_ARGS(xid, tid, sesid),
298 __field(unsigned int, xid)
300 __field(__u64, sesid)
305 __entry->sesid = sesid;
307 TP_printk("xid=%u sid=0x%llx tid=0x%x",
308 __entry->xid, __entry->sesid, __entry->tid)
311 #define DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(name) \
312 DEFINE_EVENT(smb3_inf_compound_done_class, smb3_##name, \
313 TP_PROTO(unsigned int xid, \
316 TP_ARGS(xid, tid, sesid))
318 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_info_compound_done);
319 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done);
320 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done);
321 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done);
322 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
323 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
324 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
325 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
328 DECLARE_EVENT_CLASS(smb3_inf_compound_err_class,
329 TP_PROTO(unsigned int xid,
333 TP_ARGS(xid, tid, sesid, rc),
335 __field(unsigned int, xid)
337 __field(__u64, sesid)
343 __entry->sesid = sesid;
346 TP_printk("xid=%u sid=0x%llx tid=0x%x rc=%d",
347 __entry->xid, __entry->sesid, __entry->tid,
351 #define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name) \
352 DEFINE_EVENT(smb3_inf_compound_err_class, smb3_##name, \
353 TP_PROTO(unsigned int xid, \
357 TP_ARGS(xid, tid, sesid, rc))
359 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err);
360 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err);
361 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err);
362 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err);
363 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
364 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
365 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
366 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
369 * For logging SMB3 Status code and Command for responses which return errors
371 DECLARE_EVENT_CLASS(smb3_cmd_err_class,
378 TP_ARGS(tid, sesid, cmd, mid, status, rc),
381 __field(__u64, sesid)
384 __field(__u32, status)
389 __entry->sesid = sesid;
392 __entry->status = status;
395 TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
396 __entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
397 __entry->status, __entry->rc)
400 #define DEFINE_SMB3_CMD_ERR_EVENT(name) \
401 DEFINE_EVENT(smb3_cmd_err_class, smb3_##name, \
402 TP_PROTO(__u32 tid, \
408 TP_ARGS(tid, sesid, cmd, mid, status, rc))
410 DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
412 DECLARE_EVENT_CLASS(smb3_cmd_done_class,
417 TP_ARGS(tid, sesid, cmd, mid),
420 __field(__u64, sesid)
426 __entry->sesid = sesid;
430 TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
431 __entry->sesid, __entry->tid,
432 __entry->cmd, __entry->mid)
435 #define DEFINE_SMB3_CMD_DONE_EVENT(name) \
436 DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \
437 TP_PROTO(__u32 tid, \
441 TP_ARGS(tid, sesid, cmd, mid))
443 DEFINE_SMB3_CMD_DONE_EVENT(cmd_enter);
444 DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
445 DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
447 DECLARE_EVENT_CLASS(smb3_mid_class,
451 unsigned long when_sent,
452 unsigned long when_received),
453 TP_ARGS(cmd, mid, pid, when_sent, when_received),
458 __field(unsigned long, when_sent)
459 __field(unsigned long, when_received)
465 __entry->when_sent = when_sent;
466 __entry->when_received = when_received;
468 TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
469 __entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
470 __entry->when_received)
473 #define DEFINE_SMB3_MID_EVENT(name) \
474 DEFINE_EVENT(smb3_mid_class, smb3_##name, \
475 TP_PROTO(__u16 cmd, \
478 unsigned long when_sent, \
479 unsigned long when_received), \
480 TP_ARGS(cmd, mid, pid, when_sent, when_received))
482 DEFINE_SMB3_MID_EVENT(slow_rsp);
484 DECLARE_EVENT_CLASS(smb3_exit_err_class,
485 TP_PROTO(unsigned int xid,
486 const char *func_name,
488 TP_ARGS(xid, func_name, rc),
490 __field(unsigned int, xid)
491 __field(const char *, func_name)
496 __entry->func_name = func_name;
499 TP_printk("\t%s: xid=%u rc=%d",
500 __entry->func_name, __entry->xid, __entry->rc)
503 #define DEFINE_SMB3_EXIT_ERR_EVENT(name) \
504 DEFINE_EVENT(smb3_exit_err_class, smb3_##name, \
505 TP_PROTO(unsigned int xid, \
506 const char *func_name, \
508 TP_ARGS(xid, func_name, rc))
510 DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
512 DECLARE_EVENT_CLASS(smb3_enter_exit_class,
513 TP_PROTO(unsigned int xid,
514 const char *func_name),
515 TP_ARGS(xid, func_name),
517 __field(unsigned int, xid)
518 __field(const char *, func_name)
522 __entry->func_name = func_name;
524 TP_printk("\t%s: xid=%u",
525 __entry->func_name, __entry->xid)
528 #define DEFINE_SMB3_ENTER_EXIT_EVENT(name) \
529 DEFINE_EVENT(smb3_enter_exit_class, smb3_##name, \
530 TP_PROTO(unsigned int xid, \
531 const char *func_name), \
532 TP_ARGS(xid, func_name))
534 DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
535 DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
538 * For SMB2/SMB3 tree connect
541 DECLARE_EVENT_CLASS(smb3_tcon_class,
542 TP_PROTO(unsigned int xid,
545 const char *unc_name,
547 TP_ARGS(xid, tid, sesid, unc_name, rc),
549 __field(unsigned int, xid)
551 __field(__u64, sesid)
552 __string(name, unc_name)
558 __entry->sesid = sesid;
559 __assign_str(name, unc_name);
562 TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d",
563 __entry->xid, __entry->sesid, __entry->tid,
564 __get_str(name), __entry->rc)
567 #define DEFINE_SMB3_TCON_EVENT(name) \
568 DEFINE_EVENT(smb3_tcon_class, smb3_##name, \
569 TP_PROTO(unsigned int xid, \
572 const char *unc_name, \
574 TP_ARGS(xid, tid, sesid, unc_name, rc))
576 DEFINE_SMB3_TCON_EVENT(tcon);
580 * For smb2/smb3 open (including create and mkdir) calls
583 DECLARE_EVENT_CLASS(smb3_open_enter_class,
584 TP_PROTO(unsigned int xid,
589 TP_ARGS(xid, tid, sesid, create_options, desired_access),
591 __field(unsigned int, xid)
593 __field(__u64, sesid)
594 __field(int, create_options)
595 __field(int, desired_access)
600 __entry->sesid = sesid;
601 __entry->create_options = create_options;
602 __entry->desired_access = desired_access;
604 TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x",
605 __entry->xid, __entry->sesid, __entry->tid,
606 __entry->create_options, __entry->desired_access)
609 #define DEFINE_SMB3_OPEN_ENTER_EVENT(name) \
610 DEFINE_EVENT(smb3_open_enter_class, smb3_##name, \
611 TP_PROTO(unsigned int xid, \
614 int create_options, \
615 int desired_access), \
616 TP_ARGS(xid, tid, sesid, create_options, desired_access))
618 DEFINE_SMB3_OPEN_ENTER_EVENT(open_enter);
619 DEFINE_SMB3_OPEN_ENTER_EVENT(posix_mkdir_enter);
621 DECLARE_EVENT_CLASS(smb3_open_err_class,
622 TP_PROTO(unsigned int xid,
628 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
630 __field(unsigned int, xid)
632 __field(__u64, sesid)
633 __field(int, create_options)
634 __field(int, desired_access)
640 __entry->sesid = sesid;
641 __entry->create_options = create_options;
642 __entry->desired_access = desired_access;
645 TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
646 __entry->xid, __entry->sesid, __entry->tid,
647 __entry->create_options, __entry->desired_access, __entry->rc)
650 #define DEFINE_SMB3_OPEN_ERR_EVENT(name) \
651 DEFINE_EVENT(smb3_open_err_class, smb3_##name, \
652 TP_PROTO(unsigned int xid, \
655 int create_options, \
656 int desired_access, \
658 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
660 DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
661 DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
663 DECLARE_EVENT_CLASS(smb3_open_done_class,
664 TP_PROTO(unsigned int xid,
670 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
672 __field(unsigned int, xid)
675 __field(__u64, sesid)
676 __field(int, create_options)
677 __field(int, desired_access)
683 __entry->sesid = sesid;
684 __entry->create_options = create_options;
685 __entry->desired_access = desired_access;
687 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
688 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
689 __entry->create_options, __entry->desired_access)
692 #define DEFINE_SMB3_OPEN_DONE_EVENT(name) \
693 DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
694 TP_PROTO(unsigned int xid, \
698 int create_options, \
699 int desired_access), \
700 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
702 DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
703 DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
706 DECLARE_EVENT_CLASS(smb3_lease_done_class,
707 TP_PROTO(__u32 lease_state,
711 __u64 lease_key_high),
712 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high),
714 __field(__u32, lease_state)
716 __field(__u64, sesid)
717 __field(__u64, lease_key_low)
718 __field(__u64, lease_key_high)
721 __entry->lease_state = lease_state;
723 __entry->sesid = sesid;
724 __entry->lease_key_low = lease_key_low;
725 __entry->lease_key_high = lease_key_high;
727 TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x",
728 __entry->sesid, __entry->tid, __entry->lease_key_high,
729 __entry->lease_key_low, __entry->lease_state)
732 #define DEFINE_SMB3_LEASE_DONE_EVENT(name) \
733 DEFINE_EVENT(smb3_lease_done_class, smb3_##name, \
734 TP_PROTO(__u32 lease_state, \
737 __u64 lease_key_low, \
738 __u64 lease_key_high), \
739 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high))
741 DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
743 DECLARE_EVENT_CLASS(smb3_lease_err_class,
744 TP_PROTO(__u32 lease_state,
748 __u64 lease_key_high,
750 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc),
752 __field(__u32, lease_state)
754 __field(__u64, sesid)
755 __field(__u64, lease_key_low)
756 __field(__u64, lease_key_high)
760 __entry->lease_state = lease_state;
762 __entry->sesid = sesid;
763 __entry->lease_key_low = lease_key_low;
764 __entry->lease_key_high = lease_key_high;
767 TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x rc=%d",
768 __entry->sesid, __entry->tid, __entry->lease_key_high,
769 __entry->lease_key_low, __entry->lease_state, __entry->rc)
772 #define DEFINE_SMB3_LEASE_ERR_EVENT(name) \
773 DEFINE_EVENT(smb3_lease_err_class, smb3_##name, \
774 TP_PROTO(__u32 lease_state, \
777 __u64 lease_key_low, \
778 __u64 lease_key_high, \
780 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc))
782 DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
784 DECLARE_EVENT_CLASS(smb3_reconnect_class,
785 TP_PROTO(__u64 currmid,
787 TP_ARGS(currmid, hostname),
789 __field(__u64, currmid)
790 __field(char *, hostname)
793 __entry->currmid = currmid;
794 __entry->hostname = hostname;
796 TP_printk("server=%s current_mid=0x%llx",
801 #define DEFINE_SMB3_RECONNECT_EVENT(name) \
802 DEFINE_EVENT(smb3_reconnect_class, smb3_##name, \
803 TP_PROTO(__u64 currmid, \
805 TP_ARGS(currmid, hostname))
807 DEFINE_SMB3_RECONNECT_EVENT(reconnect);
808 DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
810 DECLARE_EVENT_CLASS(smb3_credit_class,
811 TP_PROTO(__u64 currmid,
814 TP_ARGS(currmid, hostname, credits),
816 __field(__u64, currmid)
817 __field(char *, hostname)
818 __field(int, credits)
821 __entry->currmid = currmid;
822 __entry->hostname = hostname;
823 __entry->credits = credits;
825 TP_printk("server=%s current_mid=0x%llx credits=%d",
831 #define DEFINE_SMB3_CREDIT_EVENT(name) \
832 DEFINE_EVENT(smb3_credit_class, smb3_##name, \
833 TP_PROTO(__u64 currmid, \
836 TP_ARGS(currmid, hostname, credits))
838 DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
839 DEFINE_SMB3_CREDIT_EVENT(credit_timeout);
841 #endif /* _CIFS_TRACE_H */
843 #undef TRACE_INCLUDE_PATH
844 #define TRACE_INCLUDE_PATH .
845 #define TRACE_INCLUDE_FILE trace
846 #include <trace/define_trace.h>