1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2018, Microsoft Corporation.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU General Public License for more details.
18 #define TRACE_SYSTEM cifs
20 #if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
23 #include <linux/tracepoint.h>
25 /* For logging errors in read or write */
26 DECLARE_EVENT_CLASS(smb3_rw_err_class,
27 TP_PROTO(unsigned int xid,
34 TP_ARGS(xid, fid, tid, sesid, offset, len, rc),
36 __field(unsigned int, xid)
40 __field(__u64, offset)
48 __entry->sesid = sesid;
49 __entry->offset = offset;
53 TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
54 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
55 __entry->offset, __entry->len, __entry->rc)
58 #define DEFINE_SMB3_RW_ERR_EVENT(name) \
59 DEFINE_EVENT(smb3_rw_err_class, smb3_##name, \
60 TP_PROTO(unsigned int xid, \
67 TP_ARGS(xid, fid, tid, sesid, offset, len, rc))
69 DEFINE_SMB3_RW_ERR_EVENT(write_err);
70 DEFINE_SMB3_RW_ERR_EVENT(read_err);
73 /* For logging successful read or write */
74 DECLARE_EVENT_CLASS(smb3_rw_done_class,
75 TP_PROTO(unsigned int xid,
81 TP_ARGS(xid, fid, tid, sesid, offset, len),
83 __field(unsigned int, xid)
87 __field(__u64, offset)
94 __entry->sesid = sesid;
95 __entry->offset = offset;
98 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
99 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
100 __entry->offset, __entry->len)
103 #define DEFINE_SMB3_RW_DONE_EVENT(name) \
104 DEFINE_EVENT(smb3_rw_done_class, smb3_##name, \
105 TP_PROTO(unsigned int xid, \
111 TP_ARGS(xid, fid, tid, sesid, offset, len))
113 DEFINE_SMB3_RW_DONE_EVENT(write_done);
114 DEFINE_SMB3_RW_DONE_EVENT(read_done);
117 * For handle based calls other than read and write, and get/set info
119 DECLARE_EVENT_CLASS(smb3_fd_err_class,
120 TP_PROTO(unsigned int xid,
125 TP_ARGS(xid, fid, tid, sesid, rc),
127 __field(unsigned int, xid)
130 __field(__u64, sesid)
137 __entry->sesid = sesid;
140 TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx rc=%d",
141 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
145 #define DEFINE_SMB3_FD_ERR_EVENT(name) \
146 DEFINE_EVENT(smb3_fd_err_class, smb3_##name, \
147 TP_PROTO(unsigned int xid, \
152 TP_ARGS(xid, fid, tid, sesid, rc))
154 DEFINE_SMB3_FD_ERR_EVENT(flush_err);
155 DEFINE_SMB3_FD_ERR_EVENT(lock_err);
156 DEFINE_SMB3_FD_ERR_EVENT(close_err);
159 * For handle based query/set info calls
161 DECLARE_EVENT_CLASS(smb3_inf_err_class,
162 TP_PROTO(unsigned int xid,
169 TP_ARGS(xid, fid, tid, sesid, infclass, type, rc),
171 __field(unsigned int, xid)
174 __field(__u64, sesid)
175 __field(__u8, infclass)
183 __entry->sesid = sesid;
184 __entry->infclass = infclass;
185 __entry->type = type;
188 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x rc=%d",
189 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
190 __entry->infclass, __entry->type, __entry->rc)
193 #define DEFINE_SMB3_INF_ERR_EVENT(name) \
194 DEFINE_EVENT(smb3_inf_err_class, smb3_##name, \
195 TP_PROTO(unsigned int xid, \
202 TP_ARGS(xid, fid, tid, sesid, infclass, type, rc))
204 DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
205 DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
206 DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
209 * For logging SMB3 Status code and Command for responses which return errors
211 DECLARE_EVENT_CLASS(smb3_cmd_err_class,
218 TP_ARGS(tid, sesid, cmd, mid, status, rc),
221 __field(__u64, sesid)
224 __field(__u32, status)
229 __entry->sesid = sesid;
232 __entry->status = status;
235 TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
236 __entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
237 __entry->status, __entry->rc)
240 #define DEFINE_SMB3_CMD_ERR_EVENT(name) \
241 DEFINE_EVENT(smb3_cmd_err_class, smb3_##name, \
242 TP_PROTO(__u32 tid, \
248 TP_ARGS(tid, sesid, cmd, mid, status, rc))
250 DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
252 DECLARE_EVENT_CLASS(smb3_cmd_done_class,
257 TP_ARGS(tid, sesid, cmd, mid),
260 __field(__u64, sesid)
266 __entry->sesid = sesid;
270 TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
271 __entry->sesid, __entry->tid,
272 __entry->cmd, __entry->mid)
275 #define DEFINE_SMB3_CMD_DONE_EVENT(name) \
276 DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \
277 TP_PROTO(__u32 tid, \
281 TP_ARGS(tid, sesid, cmd, mid))
283 DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
284 DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
286 DECLARE_EVENT_CLASS(smb3_mid_class,
290 unsigned long when_sent,
291 unsigned long when_received),
292 TP_ARGS(cmd, mid, pid, when_sent, when_received),
297 __field(unsigned long, when_sent)
298 __field(unsigned long, when_received)
304 __entry->when_sent = when_sent;
305 __entry->when_received = when_received;
307 TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
308 __entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
309 __entry->when_received)
312 #define DEFINE_SMB3_MID_EVENT(name) \
313 DEFINE_EVENT(smb3_mid_class, smb3_##name, \
314 TP_PROTO(__u16 cmd, \
317 unsigned long when_sent, \
318 unsigned long when_received), \
319 TP_ARGS(cmd, mid, pid, when_sent, when_received))
321 DEFINE_SMB3_MID_EVENT(slow_rsp);
323 DECLARE_EVENT_CLASS(smb3_exit_err_class,
324 TP_PROTO(unsigned int xid,
325 const char *func_name,
327 TP_ARGS(xid, func_name, rc),
329 __field(unsigned int, xid)
330 __field(const char *, func_name)
335 __entry->func_name = func_name;
338 TP_printk("\t%s: xid=%u rc=%d",
339 __entry->func_name, __entry->xid, __entry->rc)
342 #define DEFINE_SMB3_EXIT_ERR_EVENT(name) \
343 DEFINE_EVENT(smb3_exit_err_class, smb3_##name, \
344 TP_PROTO(unsigned int xid, \
345 const char *func_name, \
347 TP_ARGS(xid, func_name, rc))
349 DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
351 DECLARE_EVENT_CLASS(smb3_enter_exit_class,
352 TP_PROTO(unsigned int xid,
353 const char *func_name),
354 TP_ARGS(xid, func_name),
356 __field(unsigned int, xid)
357 __field(const char *, func_name)
361 __entry->func_name = func_name;
363 TP_printk("\t%s: xid=%u",
364 __entry->func_name, __entry->xid)
367 #define DEFINE_SMB3_ENTER_EXIT_EVENT(name) \
368 DEFINE_EVENT(smb3_enter_exit_class, smb3_##name, \
369 TP_PROTO(unsigned int xid, \
370 const char *func_name), \
371 TP_ARGS(xid, func_name))
373 DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
374 DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
377 * For SMB2/SMB3 tree connect
380 DECLARE_EVENT_CLASS(smb3_tcon_class,
381 TP_PROTO(unsigned int xid,
384 const char *unc_name,
386 TP_ARGS(xid, tid, sesid, unc_name, rc),
388 __field(unsigned int, xid)
390 __field(__u64, sesid)
391 __field(const char *, unc_name)
397 __entry->sesid = sesid;
398 __entry->unc_name = unc_name;
401 TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d",
402 __entry->xid, __entry->sesid, __entry->tid,
403 __entry->unc_name, __entry->rc)
406 #define DEFINE_SMB3_TCON_EVENT(name) \
407 DEFINE_EVENT(smb3_tcon_class, smb3_##name, \
408 TP_PROTO(unsigned int xid, \
411 const char *unc_name, \
413 TP_ARGS(xid, tid, sesid, unc_name, rc))
415 DEFINE_SMB3_TCON_EVENT(tcon);
419 * For smb2/smb3 open call
421 DECLARE_EVENT_CLASS(smb3_open_err_class,
422 TP_PROTO(unsigned int xid,
428 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
430 __field(unsigned int, xid)
432 __field(__u64, sesid)
433 __field(int, create_options)
434 __field(int, desired_access)
440 __entry->sesid = sesid;
441 __entry->create_options = create_options;
442 __entry->desired_access = desired_access;
445 TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
446 __entry->xid, __entry->sesid, __entry->tid,
447 __entry->create_options, __entry->desired_access, __entry->rc)
450 #define DEFINE_SMB3_OPEN_ERR_EVENT(name) \
451 DEFINE_EVENT(smb3_open_err_class, smb3_##name, \
452 TP_PROTO(unsigned int xid, \
455 int create_options, \
456 int desired_access, \
458 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
460 DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
461 DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
463 DECLARE_EVENT_CLASS(smb3_open_done_class,
464 TP_PROTO(unsigned int xid,
470 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
472 __field(unsigned int, xid)
475 __field(__u64, sesid)
476 __field(int, create_options)
477 __field(int, desired_access)
483 __entry->sesid = sesid;
484 __entry->create_options = create_options;
485 __entry->desired_access = desired_access;
487 TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
488 __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
489 __entry->create_options, __entry->desired_access)
492 #define DEFINE_SMB3_OPEN_DONE_EVENT(name) \
493 DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
494 TP_PROTO(unsigned int xid, \
498 int create_options, \
499 int desired_access), \
500 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
502 DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
503 DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
506 DECLARE_EVENT_CLASS(smb3_lease_done_class,
507 TP_PROTO(__u32 lease_state,
511 __u64 lease_key_high),
512 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high),
514 __field(__u32, lease_state)
516 __field(__u64, sesid)
517 __field(__u64, lease_key_low)
518 __field(__u64, lease_key_high)
521 __entry->lease_state = lease_state;
523 __entry->sesid = sesid;
524 __entry->lease_key_low = lease_key_low;
525 __entry->lease_key_high = lease_key_high;
527 TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x",
528 __entry->sesid, __entry->tid, __entry->lease_key_high,
529 __entry->lease_key_low, __entry->lease_state)
532 #define DEFINE_SMB3_LEASE_DONE_EVENT(name) \
533 DEFINE_EVENT(smb3_lease_done_class, smb3_##name, \
534 TP_PROTO(__u32 lease_state, \
537 __u64 lease_key_low, \
538 __u64 lease_key_high), \
539 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high))
541 DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
543 DECLARE_EVENT_CLASS(smb3_lease_err_class,
544 TP_PROTO(__u32 lease_state,
548 __u64 lease_key_high,
550 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc),
552 __field(__u32, lease_state)
554 __field(__u64, sesid)
555 __field(__u64, lease_key_low)
556 __field(__u64, lease_key_high)
560 __entry->lease_state = lease_state;
562 __entry->sesid = sesid;
563 __entry->lease_key_low = lease_key_low;
564 __entry->lease_key_high = lease_key_high;
567 TP_printk("sid=0x%llx tid=0x%x lease_key=0x%llx%llx lease_state=0x%x rc=%d",
568 __entry->sesid, __entry->tid, __entry->lease_key_high,
569 __entry->lease_key_low, __entry->lease_state, __entry->rc)
572 #define DEFINE_SMB3_LEASE_ERR_EVENT(name) \
573 DEFINE_EVENT(smb3_lease_err_class, smb3_##name, \
574 TP_PROTO(__u32 lease_state, \
577 __u64 lease_key_low, \
578 __u64 lease_key_high, \
580 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc))
582 DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
584 DECLARE_EVENT_CLASS(smb3_reconnect_class,
585 TP_PROTO(__u64 currmid,
587 TP_ARGS(currmid, hostname),
589 __field(__u64, currmid)
590 __field(char *, hostname)
593 __entry->currmid = currmid;
594 __entry->hostname = hostname;
596 TP_printk("server=%s current_mid=0x%llx",
601 #define DEFINE_SMB3_RECONNECT_EVENT(name) \
602 DEFINE_EVENT(smb3_reconnect_class, smb3_##name, \
603 TP_PROTO(__u64 currmid, \
605 TP_ARGS(currmid, hostname))
607 DEFINE_SMB3_RECONNECT_EVENT(reconnect);
608 DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
610 DECLARE_EVENT_CLASS(smb3_credit_class,
611 TP_PROTO(__u64 currmid,
614 TP_ARGS(currmid, hostname, credits),
616 __field(__u64, currmid)
617 __field(char *, hostname)
618 __field(int, credits)
621 __entry->currmid = currmid;
622 __entry->hostname = hostname;
623 __entry->credits = credits;
625 TP_printk("server=%s current_mid=0x%llx credits=%d",
631 #define DEFINE_SMB3_CREDIT_EVENT(name) \
632 DEFINE_EVENT(smb3_credit_class, smb3_##name, \
633 TP_PROTO(__u64 currmid, \
636 TP_ARGS(currmid, hostname, credits))
638 DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
640 #endif /* _CIFS_TRACE_H */
642 #undef TRACE_INCLUDE_PATH
643 #define TRACE_INCLUDE_PATH .
644 #define TRACE_INCLUDE_FILE trace
645 #include <trace/define_trace.h>