linux/fs/smb/client/trace.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 *   Copyright (C) 2018, Microsoft Corporation.
 *
 *   Author(s): Steve French <[email protected]>
 *
 * Please use this 3-part article as a reference for writing new tracepoints:
 * https://lwn.net/Articles/379903/
 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM

#if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _CIFS_TRACE_H

#include <linux/tracepoint.h>
#include <linux/net.h>
#include <linux/inet.h>

/*
 * Specify enums for tracing information.
 */
#define smb3_rw_credits_traces

#define smb3_tcon_ref_traces

#undef EM
#undef E_

/*
 * Define those tracing enums.
 */
#ifndef __SMB3_DECLARE_TRACE_ENUMS_ONCE_ONLY
#define __SMB3_DECLARE_TRACE_ENUMS_ONCE_ONLY

#define EM
#define E_

enum smb3_rw_credits_trace	{} __mode();
enum smb3_tcon_ref_trace	{} __mode();

#undef EM
#undef E_
#endif

/*
 * Export enum symbols via userspace.
 */
#define EM
#define E_

smb3_rw_credits_traces;
smb3_tcon_ref_traces;

#undef EM
#undef E_

/*
 * Now redefine the EM() and E_() macros to map the enums to the strings that
 * will be printed in the output.
 */
#define EM
#define E_

/* For logging errors in read or write */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_RW_ERR_EVENT(name)

DEFINE_SMB3_RW_ERR_EVENT(read_err);

/* For logging errors in other file I/O ops */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_OTHER_ERR_EVENT(name)

DEFINE_SMB3_OTHER_ERR_EVENT(write_err);
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

#define DEFINE_SMB3_COPY_RANGE_ERR_EVENT(name)

DEFINE_SMB3_COPY_RANGE_ERR_EVENT(clone_err);
/* TODO: Add SMB3_COPY_RANGE_ERR_EVENT(copychunk_err) */

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_COPY_RANGE_DONE_EVENT(name)

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

#define DEFINE_SMB3_RW_DONE_EVENT(name)

DEFINE_SMB3_RW_DONE_EVENT(read_enter);
DEFINE_SMB3_RW_DONE_EVENT(read_done);

/* For logging successful other op */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_OTHER_DONE_EVENT(name)

DEFINE_SMB3_OTHER_DONE_EVENT(write_enter);
DEFINE_SMB3_OTHER_DONE_EVENT(query_dir_enter);
DEFINE_SMB3_OTHER_DONE_EVENT(zero_enter);
DEFINE_SMB3_OTHER_DONE_EVENT(falloc_enter);
DEFINE_SMB3_OTHER_DONE_EVENT(write_done);
DEFINE_SMB3_OTHER_DONE_EVENT(query_dir_done);
DEFINE_SMB3_OTHER_DONE_EVENT(zero_done);
DEFINE_SMB3_OTHER_DONE_EVENT(falloc_done);

/* For logging successful set EOF (truncate) */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_EOF_EVENT(name)

DEFINE_SMB3_EOF_EVENT(set_eof);

/*
 * For handle based calls other than read and write, and get/set info
 */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_FD_EVENT(name)

DEFINE_SMB3_FD_EVENT(flush_enter);
DEFINE_SMB3_FD_EVENT(flush_done);
DEFINE_SMB3_FD_EVENT(close_enter);
DEFINE_SMB3_FD_EVENT(close_done);
DEFINE_SMB3_FD_EVENT(oplock_not_found);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_FD_ERR_EVENT(name)

DEFINE_SMB3_FD_ERR_EVENT(flush_err);
DEFINE_SMB3_FD_ERR_EVENT(lock_err);
DEFINE_SMB3_FD_ERR_EVENT(close_err);

/*
 * For handle based query/set info calls
 */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_INF_ENTER_EVENT(name)

DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
DEFINE_SMB3_INF_ENTER_EVENT(notify_enter);
DEFINE_SMB3_INF_ENTER_EVENT(notify_done);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_INF_ERR_EVENT(name)

DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
DEFINE_SMB3_INF_ERR_EVENT(notify_err);
DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(name)

DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_info_compound_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(posix_query_info_compound_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_reparse_compound_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(get_reparse_compound_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter);
DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mknod_enter);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(name)

DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_info_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(posix_query_info_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_reparse_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(get_reparse_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_wsl_ea_compound_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done);
DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mknod_done);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(name)

DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_info_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(posix_query_info_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_reparse_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(get_reparse_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_wsl_ea_compound_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err);
DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mknod_err);

/*
 * For logging SMB3 Status code and Command for responses which return errors
 */
DECLARE_EVENT_CLASS

#define DEFINE_SMB3_CMD_ERR_EVENT(name)

DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_CMD_DONE_EVENT(name)

DEFINE_SMB3_CMD_DONE_EVENT(cmd_enter);
DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_MID_EVENT(name)

DEFINE_SMB3_MID_EVENT(slow_rsp);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_EXIT_ERR_EVENT(name)

DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);


DECLARE_EVENT_CLASS

#define DEFINE_SMB3_SYNC_ERR_EVENT(name)

DEFINE_SMB3_SYNC_ERR_EVENT(fsync_err);
DEFINE_SMB3_SYNC_ERR_EVENT(flush_err);


DECLARE_EVENT_CLASS

#define DEFINE_SMB3_ENTER_EXIT_EVENT(name)

DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);

/*
 * For SMB2/SMB3 tree connect
 */

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_TCON_EVENT(name)

DEFINE_SMB3_TCON_EVENT(tcon);
DEFINE_SMB3_TCON_EVENT(qfs_done);

/*
 * For smb2/smb3 open (including create and mkdir) calls
 */

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_OPEN_ENTER_EVENT(name)

DEFINE_SMB3_OPEN_ENTER_EVENT(open_enter);
DEFINE_SMB3_OPEN_ENTER_EVENT(posix_mkdir_enter);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_OPEN_ERR_EVENT(name)

DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_OPEN_DONE_EVENT(name)

DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);


DECLARE_EVENT_CLASS

#define DEFINE_SMB3_LEASE_DONE_EVENT(name)

DEFINE_SMB3_LEASE_DONE_EVENT(lease_done);
DEFINE_SMB3_LEASE_DONE_EVENT(lease_not_found);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_LEASE_ERR_EVENT(name)

DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_CONNECT_EVENT(name)

DEFINE_SMB3_CONNECT_EVENT(connect_done);
DEFINE_SMB3_CONNECT_EVENT(smbd_connect_done);
DEFINE_SMB3_CONNECT_EVENT(smbd_connect_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_CONNECT_ERR_EVENT(name)

DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_SES_SETUP_ERR_EVENT(name)

DEFINE_SMB3_SES_SETUP_ERR_EVENT(key_expired);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_RECONNECT_EVENT(name)

DEFINE_SMB3_RECONNECT_EVENT(reconnect);
DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_SES_EVENT(name)

DEFINE_SMB3_SES_EVENT(ses_not_found);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_IOCTL_EVENT(name)

DEFINE_SMB3_IOCTL_EVENT(ioctl);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_SHUTDOWN_EVENT(name)

DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_enter);
DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_done);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_SHUTDOWN_ERR_EVENT(name)

DEFINE_SMB3_SHUTDOWN_ERR_EVENT(shutdown_err);

DECLARE_EVENT_CLASS

#define DEFINE_SMB3_CREDIT_EVENT(name)

DEFINE_SMB3_CREDIT_EVENT(reconnect_with_invalid_credits);
DEFINE_SMB3_CREDIT_EVENT(reconnect_detected);
DEFINE_SMB3_CREDIT_EVENT(credit_timeout);
DEFINE_SMB3_CREDIT_EVENT(insufficient_credits);
DEFINE_SMB3_CREDIT_EVENT(too_many_credits);
DEFINE_SMB3_CREDIT_EVENT(add_credits);
DEFINE_SMB3_CREDIT_EVENT(adj_credits);
DEFINE_SMB3_CREDIT_EVENT(hdr_credits);
DEFINE_SMB3_CREDIT_EVENT(nblk_credits);
DEFINE_SMB3_CREDIT_EVENT(pend_credits);
DEFINE_SMB3_CREDIT_EVENT(wait_credits);
DEFINE_SMB3_CREDIT_EVENT(waitff_credits);
DEFINE_SMB3_CREDIT_EVENT(overflow_credits);
DEFINE_SMB3_CREDIT_EVENT(set_credits);


TRACE_EVENT(smb3_tcon_ref,
	    TP_PROTO(unsigned int tcon_debug_id, int ref,
		     enum smb3_tcon_ref_trace trace),
	    TP_ARGS(tcon_debug_id, ref, trace),
	    TP_STRUCT__entry(
		    __field(unsigned int,		tcon)
		    __field(int,			ref)
		    __field(enum smb3_tcon_ref_trace,	trace)
			     ),
	    TP_fast_assign(
		    __entry->tcon	= tcon_debug_id;
		    __entry->ref	= ref;
		    __entry->trace	= trace;
			   ),
	    TP_printk("TC=%08x %s r=%u",
		      __entry->tcon,
		      __print_symbolic(__entry->trace, smb3_tcon_ref_traces),
		      __entry->ref)
	    );

TRACE_EVENT(smb3_rw_credits,
	    TP_PROTO(unsigned int rreq_debug_id,
		     unsigned int subreq_debug_index,
		     unsigned int subreq_credits,
		     unsigned int server_credits,
		     int server_in_flight,
		     int credit_change,
		     enum smb3_rw_credits_trace trace),
	    TP_ARGS(rreq_debug_id, subreq_debug_index, subreq_credits,
		    server_credits, server_in_flight, credit_change, trace),
	    TP_STRUCT__entry(
		    __field(unsigned int, rreq_debug_id)
		    __field(unsigned int, subreq_debug_index)
		    __field(unsigned int, subreq_credits)
		    __field(unsigned int, server_credits)
		    __field(int,	  in_flight)
		    __field(int,	  credit_change)
		    __field(enum smb3_rw_credits_trace, trace)
			     ),
	    TP_fast_assign(
		    __entry->rreq_debug_id	= rreq_debug_id;
		    __entry->subreq_debug_index	= subreq_debug_index;
		    __entry->subreq_credits	= subreq_credits;
		    __entry->server_credits	= server_credits;
		    __entry->in_flight		= server_in_flight;
		    __entry->credit_change	= credit_change;
		    __entry->trace		= trace;
			   ),
	    TP_printk("R=%08x[%x] %s cred=%u chg=%d pool=%u ifl=%d",
		      __entry->rreq_debug_id, __entry->subreq_debug_index,
		      __print_symbolic(__entry->trace, smb3_rw_credits_traces),
		      __entry->subreq_credits, __entry->credit_change,
		      __entry->server_credits, __entry->in_flight)
	    );


#undef EM
#undef E_
#endif /* _CIFS_TRACE_H */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_FILE
#include <trace/define_trace.h>