xref: /titanic_53/usr/src/common/zev/zev.h (revision c62d83679536ddf42de5e373b54cdef18a4337c0)
12bb8e5e2SAndreas Jaekel #ifndef __ZEV_H__
22bb8e5e2SAndreas Jaekel #define __ZEV_H__
32bb8e5e2SAndreas Jaekel 
42bb8e5e2SAndreas Jaekel #include <sys/types.h>
59db22157SAndreas Jaekel #include <sys/param.h>
6e9a5e479SAndreas Jaekel #include <sys/atomic.h>
75e286361SAndreas Jaekel #include <sys/sha1.h>
82bb8e5e2SAndreas Jaekel 
92bb8e5e2SAndreas Jaekel #ifdef _KERNEL
102bb8e5e2SAndreas Jaekel #include <sys/dmu_objset.h>
112bb8e5e2SAndreas Jaekel #include <sys/dsl_dataset.h>
122bb8e5e2SAndreas Jaekel #include <sys/zfs_vfsops.h>
132bb8e5e2SAndreas Jaekel #include <sys/dsl_dir.h>
142bb8e5e2SAndreas Jaekel #include <sys/spa_impl.h>
152bb8e5e2SAndreas Jaekel #endif
162bb8e5e2SAndreas Jaekel 
17*c62d8367SAndreas Jaekel /* increased for incompatible interface and behaviour changes */
18*c62d8367SAndreas Jaekel #define ZEV_MAJOR_VERSION		1
19*c62d8367SAndreas Jaekel /* increased for compatible changes, including new ioctls(), etc. */
20*c62d8367SAndreas Jaekel #define ZEV_MINOR_VERSION		2
21*c62d8367SAndreas Jaekel 
22e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN		40
23e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUES			63
24e9a5e479SAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME		"ctrl"
25e9a5e479SAndreas Jaekel 
26e9a5e479SAndreas Jaekel /* global limit, no queue may grow larger than this. */
27e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_LEN		(1 * 1024 * 1024 * 1024)
28e9a5e479SAndreas Jaekel 
29e9a5e479SAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */
304ca7dd5eSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN	8192
31e9a5e479SAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN		65536
32e9a5e479SAndreas Jaekel 
332bb8e5e2SAndreas Jaekel #define ZEVIOC				  ('z' << 8)
34e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS	  (ZEVIOC | 1)	/* get global stats */
35205a9bc9SAndreas Jaekel #define ZEV_IOC_MUTE_POOL		  (ZEVIOC | 2)	/* no events for pool */
36205a9bc9SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL		  (ZEVIOC | 3)	/* send pool events */
37205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN	  (ZEVIOC | 4)	/* when to block ops */
38205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5)	/* poll throttle */
3901c2c787SAndreas Jaekel #define ZEV_IOC_MARK			  (ZEVIOC | 6)	/* add mark to queue */
40c035b1e8SAndreas Jaekel #define ZEV_IOC_GET_GEN			  (ZEVIOC | 7)	/* get generation no. */
41e9a5e479SAndreas Jaekel #define	ZEV_IOC_ADD_QUEUE		  (ZEVIOC | 8)  /* create new queue */
42e9a5e479SAndreas Jaekel #define	ZEV_IOC_REMOVE_QUEUE		  (ZEVIOC | 9)  /* delete queue */
43e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES	  (ZEVIOC | 10)	/* get properties */
44e9a5e479SAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES	  (ZEVIOC | 11)	/* set properties */
45e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS	  (ZEVIOC | 12)	/* get queue stats */
46e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO		  (ZEVIOC | 13)	/* get internal info */
47e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST		  (ZEVIOC | 14)	/* get queue list */
48b9710123SAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES	  (ZEVIOC | 15)	/* get beaver sigs */
49*c62d8367SAndreas Jaekel #define ZEV_IOC_GET_ZEV_VERSION		  (ZEVIOC | 16)	/* get zev version */
502bb8e5e2SAndreas Jaekel 
512bb8e5e2SAndreas Jaekel #define ZEV_OP_MIN			 1
5268a46c64SAndreas Jaekel #define ZEV_OP_ERROR			 1
5301c2c787SAndreas Jaekel #define ZEV_OP_MARK			 2
5401c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_MOUNT		 3
5501c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_UMOUNT		 4
5601c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_WRITE		 5
5701c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_TRUNCATE		 6
5801c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE	 7
5901c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CREATE		 8
6001c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MKDIR		 9
6101c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MAKE_XATTR_DIR	10
6201c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_REMOVE		11
6301c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RMDIR		12
6401c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_LINK		13
6501c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SYMLINK		14
6601c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RENAME		15
6701c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_WRITE		16
6801c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_TRUNCATE		17
6901c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SETATTR		18
7001c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_ACL		19
7101c2c787SAndreas Jaekel #define	ZEV_OP_MAX			19
7268a46c64SAndreas Jaekel 
73e9a5e479SAndreas Jaekel /* zev event flags */
74e9a5e479SAndreas Jaekel #define	ZEV_FL_XATTR			0x0001
75e9a5e479SAndreas Jaekel 
76e9a5e479SAndreas Jaekel /* zev queue flags */
77e9a5e479SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL	0x0001
78e9a5e479SAndreas Jaekel #define ZEV_FL_PERSISTENT		0x0002
79b434d29cSAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY		0x0004
80e9a5e479SAndreas Jaekel 
81b9710123SAndreas Jaekel /* checksum block sizes */
82b9710123SAndreas Jaekel #define ZEV_L0_SIZE	4096
83b9710123SAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
8410874358SAndreas Jaekel 
8568a46c64SAndreas Jaekel /* zfs event records (as they are represented through the character device) */
8668a46c64SAndreas Jaekel 
87108668daSAndreas Jaekel #pragma pack(1)
8868a46c64SAndreas Jaekel typedef struct zev_inode_info_t {
8968a46c64SAndreas Jaekel 	uint64_t	ino;
9068a46c64SAndreas Jaekel 	uint64_t	gen;
9168a46c64SAndreas Jaekel 	uint64_t	mtime;
9268a46c64SAndreas Jaekel 	uint64_t	ctime;
9368a46c64SAndreas Jaekel 	uint64_t	size;
9468a46c64SAndreas Jaekel 	uint64_t	mode;
9568a46c64SAndreas Jaekel 	uint64_t	links;
96108668daSAndreas Jaekel 	uint32_t	type;
9710874358SAndreas Jaekel 	uint32_t	flags;
9868a46c64SAndreas Jaekel } zev_inode_info_t;
9968a46c64SAndreas Jaekel 
10068a46c64SAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
10168a46c64SAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
10268a46c64SAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
10368a46c64SAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
10468a46c64SAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
10568a46c64SAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
10668a46c64SAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
10701c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
1085e286361SAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
10968a46c64SAndreas Jaekel 
110108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
111108668daSAndreas Jaekel 	uint32_t		record_len;				\
112108668daSAndreas Jaekel 	uint32_t		op;					\
113108668daSAndreas Jaekel 	uint64_t		op_time;				\
114b9df2829SAndreas Jaekel 	uint64_t		guid
115108668daSAndreas Jaekel 
1165e286361SAndreas Jaekel typedef struct zev_sig_t {
1175e286361SAndreas Jaekel 	uint16_t	level;
1185e286361SAndreas Jaekel 	uint16_t	padding1;
1195e286361SAndreas Jaekel 	uint32_t	padding2;
1205e286361SAndreas Jaekel 	uint64_t	block_offset;
1215e286361SAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
1225e286361SAndreas Jaekel } zev_sig_t;
1235e286361SAndreas Jaekel 
12468a46c64SAndreas Jaekel typedef struct zev_header_t {
125108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
12668a46c64SAndreas Jaekel } zev_header_t;
12768a46c64SAndreas Jaekel 
12868a46c64SAndreas Jaekel typedef struct zev_error_t {
129108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
13068a46c64SAndreas Jaekel 	uint32_t		failed_op;
13168a46c64SAndreas Jaekel 	uint32_t		errstr_len;
13268a46c64SAndreas Jaekel 	/* error string follows */
13368a46c64SAndreas Jaekel } zev_error_t;
13468a46c64SAndreas Jaekel 
13501c2c787SAndreas Jaekel typedef struct zev_mark_t {
13601c2c787SAndreas Jaekel 	ZEV_COMMON_FIELDS;
13701c2c787SAndreas Jaekel 	uint64_t		mark_id;
13801c2c787SAndreas Jaekel 	uint32_t		payload_len;
13901c2c787SAndreas Jaekel 	uint32_t		padding;
14001c2c787SAndreas Jaekel 	/* payload follows */
14101c2c787SAndreas Jaekel } zev_mark_t;
14201c2c787SAndreas Jaekel 
14368a46c64SAndreas Jaekel typedef struct zev_zfs_mount_t {
144108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
145f66561e7SAndreas Jaekel 	zev_inode_info_t	root;
146108668daSAndreas Jaekel 	uint32_t		remount;
14768a46c64SAndreas Jaekel 	uint32_t		dataset_len;
14868a46c64SAndreas Jaekel 	uint32_t		mountpoint_len;
149108668daSAndreas Jaekel 	uint32_t		padding;
15068a46c64SAndreas Jaekel 	/* dataset follows */
15168a46c64SAndreas Jaekel 	/* mountpoint follows */
15268a46c64SAndreas Jaekel } zev_zfs_mount_t;
15368a46c64SAndreas Jaekel 
15468a46c64SAndreas Jaekel typedef struct zev_zfs_umount_t {
155108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
156443f0cd2SAndreas Jaekel 	zev_inode_info_t	covered;
15768a46c64SAndreas Jaekel } zev_zfs_umount_t;
15868a46c64SAndreas Jaekel 
15968a46c64SAndreas Jaekel typedef struct zev_zvol_truncate_t {
160108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
161e206ace3SAndreas Jaekel 	uint64_t		txg;
16268a46c64SAndreas Jaekel 	uint64_t		offset;
16368a46c64SAndreas Jaekel 	uint64_t		length;
16468a46c64SAndreas Jaekel 	uint32_t		dataset_len;
165108668daSAndreas Jaekel 	uint32_t		padding;
16668a46c64SAndreas Jaekel 	/* dataset follows */
16768a46c64SAndreas Jaekel } zev_zvol_truncate_t;
16868a46c64SAndreas Jaekel 
16968a46c64SAndreas Jaekel typedef struct zev_zvol_write_t {
170108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
171e206ace3SAndreas Jaekel 	uint64_t		txg;
17268a46c64SAndreas Jaekel 	uint64_t		offset;
17368a46c64SAndreas Jaekel 	uint64_t		length;
17468a46c64SAndreas Jaekel 	uint32_t		dataset_len;
175108668daSAndreas Jaekel 	uint32_t		padding;
17668a46c64SAndreas Jaekel 	/* dataset follows */
17768a46c64SAndreas Jaekel } zev_zvol_write_t;
17868a46c64SAndreas Jaekel 
17968a46c64SAndreas Jaekel typedef struct zev_znode_close_after_update_t {
180108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
18168a46c64SAndreas Jaekel 	zev_inode_info_t	file;
18268a46c64SAndreas Jaekel } zev_znode_close_after_update_t;
18368a46c64SAndreas Jaekel 
18468a46c64SAndreas Jaekel typedef struct zev_znode_create_t {
185108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
186e206ace3SAndreas Jaekel 	uint64_t		txg;
18768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
18868a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
1891ca5a13bSAndreas Jaekel 	zev_sig_t		signature;
19068a46c64SAndreas Jaekel 	uint32_t		name_len;
191108668daSAndreas Jaekel 	uint32_t		padding;
19268a46c64SAndreas Jaekel 	/* name follows */
19368a46c64SAndreas Jaekel } zev_znode_create_t;
19468a46c64SAndreas Jaekel 
19568a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
19668a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
19768a46c64SAndreas Jaekel 
19868a46c64SAndreas Jaekel typedef struct zev_znode_remove_t {
199108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
200e206ace3SAndreas Jaekel 	uint64_t		txg;
2016db5d4ecSAndreas Jaekel 	zev_inode_info_t	file;
20268a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
20368a46c64SAndreas Jaekel 	uint32_t		name_len;
204108668daSAndreas Jaekel 	uint32_t		padding;
20568a46c64SAndreas Jaekel 	/* name follows */
20668a46c64SAndreas Jaekel } zev_znode_remove_t;
20768a46c64SAndreas Jaekel 
20868a46c64SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
20968a46c64SAndreas Jaekel 
21068a46c64SAndreas Jaekel typedef struct zev_znode_link_t {
211108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
212e206ace3SAndreas Jaekel 	uint64_t		txg;
21368a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
21468a46c64SAndreas Jaekel 	zev_inode_info_t	file;
21568a46c64SAndreas Jaekel 	uint32_t		name_len;
216108668daSAndreas Jaekel 	uint32_t		padding;
21768a46c64SAndreas Jaekel 	/* new_name follows */
21868a46c64SAndreas Jaekel } zev_znode_link_t;
21968a46c64SAndreas Jaekel 
22068a46c64SAndreas Jaekel typedef struct zev_znode_symlink_t {
221108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
222e206ace3SAndreas Jaekel 	uint64_t		txg;
22368a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
22468a46c64SAndreas Jaekel 	zev_inode_info_t	file;
2251ca5a13bSAndreas Jaekel 	zev_sig_t		signature;
22668a46c64SAndreas Jaekel 	uint32_t		name_len;
22768a46c64SAndreas Jaekel 	uint32_t		link_len;
22868a46c64SAndreas Jaekel 	/* name follows */
22968a46c64SAndreas Jaekel 	/* link follows */
23068a46c64SAndreas Jaekel } zev_znode_symlink_t;
23168a46c64SAndreas Jaekel 
23268a46c64SAndreas Jaekel typedef struct zev_znode_rename_t {
233108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
234e206ace3SAndreas Jaekel 	uint64_t		txg;
23568a46c64SAndreas Jaekel 	zev_inode_info_t	srcdir;
23668a46c64SAndreas Jaekel 	zev_inode_info_t	dstdir;
23768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
238f8e3fee2SAndreas Jaekel 	zev_inode_info_t	clobbered_file;
23968a46c64SAndreas Jaekel 	uint32_t		srcname_len;
24068a46c64SAndreas Jaekel 	uint32_t		dstname_len;
24168a46c64SAndreas Jaekel 	/* srcname follows */
24268a46c64SAndreas Jaekel 	/* dstname follows */
24368a46c64SAndreas Jaekel } zev_znode_rename_t;
24468a46c64SAndreas Jaekel 
24568a46c64SAndreas Jaekel typedef struct zev_znode_write_t {
246108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
247e206ace3SAndreas Jaekel 	uint64_t		txg;
24868a46c64SAndreas Jaekel 	zev_inode_info_t	file;
24968a46c64SAndreas Jaekel 	uint64_t		offset;
25068a46c64SAndreas Jaekel 	uint64_t		length;
2515e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2525e286361SAndreas Jaekel 	/* signatures follow */
25368a46c64SAndreas Jaekel } zev_znode_write_t;
25468a46c64SAndreas Jaekel 
25568a46c64SAndreas Jaekel typedef struct zev_znode_truncate_t {
256108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
257e206ace3SAndreas Jaekel 	uint64_t		txg;
25868a46c64SAndreas Jaekel 	zev_inode_info_t	file;
25968a46c64SAndreas Jaekel 	uint64_t		offset;
26068a46c64SAndreas Jaekel 	uint64_t		length;
2615e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2625e286361SAndreas Jaekel 	/* signatures follow */
26368a46c64SAndreas Jaekel } zev_znode_truncate_t;
26468a46c64SAndreas Jaekel 
26568a46c64SAndreas Jaekel typedef struct zev_znode_setattr_t {
266108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
267e206ace3SAndreas Jaekel 	uint64_t		txg;
26868a46c64SAndreas Jaekel 	zev_inode_info_t	file;
26968a46c64SAndreas Jaekel } zev_znode_setattr_t;
27068a46c64SAndreas Jaekel 
27168a46c64SAndreas Jaekel typedef struct zev_znode_acl_t {
272108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
273e206ace3SAndreas Jaekel 	uint64_t		txg;
27468a46c64SAndreas Jaekel 	zev_inode_info_t	file;
27568a46c64SAndreas Jaekel } zev_znode_acl_t;
27668a46c64SAndreas Jaekel 
27768a46c64SAndreas Jaekel /* convenience helper definition */
27868a46c64SAndreas Jaekel typedef union {
27968a46c64SAndreas Jaekel 	zev_header_t				header;
28068a46c64SAndreas Jaekel 
28101c2c787SAndreas Jaekel 	zev_error_t				error;
28201c2c787SAndreas Jaekel 	zev_mark_t				mark;
28368a46c64SAndreas Jaekel 	union {
28468a46c64SAndreas Jaekel 		zev_zfs_mount_t			mount;
28568a46c64SAndreas Jaekel 		zev_zfs_umount_t		umount;
28668a46c64SAndreas Jaekel 	} zfs;
28768a46c64SAndreas Jaekel 	union {
28868a46c64SAndreas Jaekel 		zev_zvol_truncate_t		truncate;
28968a46c64SAndreas Jaekel 		zev_zvol_write_t		write;
29068a46c64SAndreas Jaekel 	} zvol;
29168a46c64SAndreas Jaekel 	union {
29268a46c64SAndreas Jaekel 		zev_znode_close_after_update_t	close;
29368a46c64SAndreas Jaekel 		zev_znode_create_t		create;
29468a46c64SAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
29568a46c64SAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
29668a46c64SAndreas Jaekel 		zev_znode_remove_t		remove;
29768a46c64SAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
29868a46c64SAndreas Jaekel 		zev_znode_link_t		link;
29968a46c64SAndreas Jaekel 		zev_znode_symlink_t		symlink;
30068a46c64SAndreas Jaekel 		zev_znode_rename_t		rename;
30168a46c64SAndreas Jaekel 		zev_znode_write_t		write;
30268a46c64SAndreas Jaekel 		zev_znode_truncate_t		truncate;
30368a46c64SAndreas Jaekel 		zev_znode_setattr_t		setattr;
30468a46c64SAndreas Jaekel 		zev_znode_acl_t			acl;
30568a46c64SAndreas Jaekel 	} znode;
30668a46c64SAndreas Jaekel } zev_event_t;
30768a46c64SAndreas Jaekel 
30868a46c64SAndreas Jaekel 
3092bb8e5e2SAndreas Jaekel 
3102bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t {
3112bb8e5e2SAndreas Jaekel 	uint64_t	zev_queue_len;
3122bb8e5e2SAndreas Jaekel 	uint64_t	zev_bytes_read;
313e9a5e479SAndreas Jaekel 	uint64_t	zev_bytes_discarded;
314205a9bc9SAndreas Jaekel 	/* runtime settings */
315205a9bc9SAndreas Jaekel 	uint64_t	zev_max_queue_len;
3162bb8e5e2SAndreas Jaekel 	/* counters */
3172bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
318e9a5e479SAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
3192bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_errors;
32001c2c787SAndreas Jaekel 	uint64_t	zev_cnt_marks;
3212bb8e5e2SAndreas Jaekel 	/* zfsvfs ops */
3222bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
3232bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
3242bb8e5e2SAndreas Jaekel 	/* zvol ops */
3252bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
3262bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
3272bb8e5e2SAndreas Jaekel 	/* znode ops */
3282bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
3292bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
3302bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
3312bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
3322bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
3332bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
3342bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
3352bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
3362bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
3372bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
3382bb8e5e2SAndreas Jaekel } zev_statistics_t;
3392bb8e5e2SAndreas Jaekel 
340e9a5e479SAndreas Jaekel typedef struct zev_queue_name {
341e9a5e479SAndreas Jaekel 	uint64_t		zev_namelen;
342e9a5e479SAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
343e9a5e479SAndreas Jaekel } zev_queue_name_t;
344e9a5e479SAndreas Jaekel 
3452bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg {
3462bb8e5e2SAndreas Jaekel 	uint64_t	zev_poolname_len;
3472bb8e5e2SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
3482bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t;
34901c2c787SAndreas Jaekel 
35001c2c787SAndreas Jaekel typedef struct zev_ioctl_mark {
35101c2c787SAndreas Jaekel 	uint64_t	zev_mark_id;
35201c2c787SAndreas Jaekel 	uint64_t	zev_guid;
35301c2c787SAndreas Jaekel 	uint32_t	zev_payload_len;
35446c85740SAndreas Jaekel 	uint32_t	padding;
35501c2c787SAndreas Jaekel 	/* payload follows */
35601c2c787SAndreas Jaekel } zev_ioctl_mark_t;
357c035b1e8SAndreas Jaekel 
358c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen {
359c035b1e8SAndreas Jaekel 	/* input */
360c035b1e8SAndreas Jaekel 	uint64_t	inode;
361c035b1e8SAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
362c035b1e8SAndreas Jaekel 	/* noput */
363c035b1e8SAndreas Jaekel 	uint32_t	padding;
364c035b1e8SAndreas Jaekel 	/* output */
365c035b1e8SAndreas Jaekel 	uint64_t	generation;
366c035b1e8SAndreas Jaekel 	uint64_t	crtime;
367c035b1e8SAndreas Jaekel 	uint64_t	guid;
368c035b1e8SAndreas Jaekel 	char		dataset[MAXPATHLEN];
369c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t;
370e9a5e479SAndreas Jaekel 
371e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
372e9a5e479SAndreas Jaekel 	uint64_t		zev_max_queue_len;
373e9a5e479SAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
374e9a5e479SAndreas Jaekel 	uint16_t		zev_flags;
3754ca7dd5eSAndreas Jaekel 	uint16_t		padding1;
3764ca7dd5eSAndreas Jaekel 	uint32_t		padding2;
3774ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
378e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t;
379e9a5e479SAndreas Jaekel 
380e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
381e9a5e479SAndreas Jaekel 
382e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue {
383e9a5e479SAndreas Jaekel 	uint64_t	zev_max_queue_len;
384e9a5e479SAndreas Jaekel 	uint32_t	padding;
385e9a5e479SAndreas Jaekel 	uint16_t	zev_flags;
386e9a5e479SAndreas Jaekel 	uint16_t	zev_namelen;
387e9a5e479SAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
388e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t;
389e9a5e479SAndreas Jaekel 
390e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3914ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
392e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t;
393e9a5e479SAndreas Jaekel 
394e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3954ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
396e9a5e479SAndreas Jaekel 	zev_statistics_t	zev_statistics;
397e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
398e9a5e479SAndreas Jaekel 
399e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info {
400e9a5e479SAndreas Jaekel 	uint64_t	zev_memory_allocated;
4015e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
4025e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
4035e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
404e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t;
405e9a5e479SAndreas Jaekel 
406e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
407e9a5e479SAndreas Jaekel 	uint64_t		zev_n_queues;
408e9a5e479SAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
409e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t;
410e9a5e479SAndreas Jaekel 
411b9710123SAndreas Jaekel typedef struct zev_ioctl_get_signatures {
412b9710123SAndreas Jaekel 	/* in */
413b9710123SAndreas Jaekel 	uint64_t	zev_offset;
414b9710123SAndreas Jaekel 	uint64_t	zev_len;
415b9710123SAndreas Jaekel 	uint32_t	zev_fd;
416b9710123SAndreas Jaekel 	uint32_t	zev_bufsize;
417b9710123SAndreas Jaekel 	/* out */
418b9710123SAndreas Jaekel 	uint64_t	zev_signature_cnt;
419b9710123SAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
420b9710123SAndreas Jaekel } zev_ioctl_get_signatures_t;
421b9710123SAndreas Jaekel 
422*c62d8367SAndreas Jaekel typedef struct zev_ioctl_get_zev_version {
423*c62d8367SAndreas Jaekel 	uint64_t		zev_major_version;
424*c62d8367SAndreas Jaekel 	uint64_t		zev_minor_version;
425*c62d8367SAndreas Jaekel } zev_ioctl_get_zev_version;
426*c62d8367SAndreas Jaekel 
427108668daSAndreas Jaekel #pragma pack()
4282bb8e5e2SAndreas Jaekel 
4292bb8e5e2SAndreas Jaekel #ifdef _KERNEL
430e9a5e479SAndreas Jaekel 
431e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated;
432e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed;
433e9a5e479SAndreas Jaekel 
434e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
435e9a5e479SAndreas Jaekel 	do {								\
436e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
437e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
438e9a5e479SAndreas Jaekel 	} while(0)
439e9a5e479SAndreas Jaekel 
440e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
441e9a5e479SAndreas Jaekel 	do {								\
442e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
443e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
444e9a5e479SAndreas Jaekel 	} while(0)
445e9a5e479SAndreas Jaekel 
4465e286361SAndreas Jaekel void *zev_alloc(ssize_t sz);
4475e286361SAndreas Jaekel void *zev_zalloc(ssize_t sz);
4485e286361SAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
449e9a5e479SAndreas Jaekel 
45068a46c64SAndreas Jaekel typedef struct zev_msg_t {
45168a46c64SAndreas Jaekel 	struct zev_msg_t	*next;
452e9a5e479SAndreas Jaekel 	struct zev_msg_t	*prev;
453e9a5e479SAndreas Jaekel 	uint64_t		 seq;
454e9a5e479SAndreas Jaekel 	uint16_t		 size;
455e9a5e479SAndreas Jaekel 	uint16_t		 read;
45668a46c64SAndreas Jaekel 	/* data follows */
45768a46c64SAndreas Jaekel } zev_msg_t;
45868a46c64SAndreas Jaekel 
45968a46c64SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
46068a46c64SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
46168a46c64SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
4622bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os);
463*c62d8367SAndreas Jaekel int zev_skip_fs(zfsvfs_t *fs);
46468a46c64SAndreas Jaekel 
4652bb8e5e2SAndreas Jaekel #endif
4662bb8e5e2SAndreas Jaekel 
4672bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */
4682bb8e5e2SAndreas Jaekel 
469