xref: /titanic_53/usr/src/common/zev/zev.h (revision b434d29ccaa1213de5b6e829a10cc5d82d786795)
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 
17e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN		40
18e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUES			63
19e9a5e479SAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME		"ctrl"
20e9a5e479SAndreas Jaekel 
21e9a5e479SAndreas Jaekel /* global limit, no queue may grow larger than this. */
22e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_LEN		(1 * 1024 * 1024 * 1024)
23e9a5e479SAndreas Jaekel 
24e9a5e479SAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */
254ca7dd5eSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN	8192
26e9a5e479SAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN		65536
27e9a5e479SAndreas Jaekel 
282bb8e5e2SAndreas Jaekel #define ZEVIOC				  ('z' << 8)
29e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS	  (ZEVIOC | 1)	/* get global stats */
30205a9bc9SAndreas Jaekel #define ZEV_IOC_MUTE_POOL		  (ZEVIOC | 2)	/* no events for pool */
31205a9bc9SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL		  (ZEVIOC | 3)	/* send pool events */
32205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN	  (ZEVIOC | 4)	/* when to block ops */
33205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5)	/* poll throttle */
3401c2c787SAndreas Jaekel #define ZEV_IOC_MARK			  (ZEVIOC | 6)	/* add mark to queue */
35c035b1e8SAndreas Jaekel #define ZEV_IOC_GET_GEN			  (ZEVIOC | 7)	/* get generation no. */
36e9a5e479SAndreas Jaekel #define	ZEV_IOC_ADD_QUEUE		  (ZEVIOC | 8)  /* create new queue */
37e9a5e479SAndreas Jaekel #define	ZEV_IOC_REMOVE_QUEUE		  (ZEVIOC | 9)  /* delete queue */
38e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES	  (ZEVIOC | 10)	/* get properties */
39e9a5e479SAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES	  (ZEVIOC | 11)	/* set properties */
40e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS	  (ZEVIOC | 12)	/* get queue stats */
41e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO		  (ZEVIOC | 13)	/* get internal info */
42e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST		  (ZEVIOC | 14)	/* get queue list */
43b9710123SAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES	  (ZEVIOC | 15)	/* get beaver sigs */
442bb8e5e2SAndreas Jaekel 
452bb8e5e2SAndreas Jaekel #define ZEV_OP_MIN			 1
4668a46c64SAndreas Jaekel #define ZEV_OP_ERROR			 1
4701c2c787SAndreas Jaekel #define ZEV_OP_MARK			 2
4801c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_MOUNT		 3
4901c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_UMOUNT		 4
5001c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_WRITE		 5
5101c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_TRUNCATE		 6
5201c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE	 7
5301c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CREATE		 8
5401c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MKDIR		 9
5501c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MAKE_XATTR_DIR	10
5601c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_REMOVE		11
5701c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RMDIR		12
5801c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_LINK		13
5901c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SYMLINK		14
6001c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RENAME		15
6101c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_WRITE		16
6201c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_TRUNCATE		17
6301c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SETATTR		18
6401c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_ACL		19
6501c2c787SAndreas Jaekel #define	ZEV_OP_MAX			19
6668a46c64SAndreas Jaekel 
67e9a5e479SAndreas Jaekel /* zev event flags */
68e9a5e479SAndreas Jaekel #define	ZEV_FL_XATTR			0x0001
69e9a5e479SAndreas Jaekel 
70e9a5e479SAndreas Jaekel /* zev queue flags */
71e9a5e479SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL	0x0001
72e9a5e479SAndreas Jaekel #define ZEV_FL_PERSISTENT		0x0002
73*b434d29cSAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY		0x0004
74e9a5e479SAndreas Jaekel 
75b9710123SAndreas Jaekel /* checksum block sizes */
76b9710123SAndreas Jaekel #define ZEV_L0_SIZE	4096
77b9710123SAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
7810874358SAndreas Jaekel 
7968a46c64SAndreas Jaekel /* zfs event records (as they are represented through the character device) */
8068a46c64SAndreas Jaekel 
81108668daSAndreas Jaekel #pragma pack(1)
8268a46c64SAndreas Jaekel typedef struct zev_inode_info_t {
8368a46c64SAndreas Jaekel 	uint64_t	ino;
8468a46c64SAndreas Jaekel 	uint64_t	gen;
8568a46c64SAndreas Jaekel 	uint64_t	mtime;
8668a46c64SAndreas Jaekel 	uint64_t	ctime;
8768a46c64SAndreas Jaekel 	uint64_t	size;
8868a46c64SAndreas Jaekel 	uint64_t	mode;
8968a46c64SAndreas Jaekel 	uint64_t	links;
90108668daSAndreas Jaekel 	uint32_t	type;
9110874358SAndreas Jaekel 	uint32_t	flags;
9268a46c64SAndreas Jaekel } zev_inode_info_t;
9368a46c64SAndreas Jaekel 
9468a46c64SAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
9568a46c64SAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
9668a46c64SAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
9768a46c64SAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
9868a46c64SAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
9968a46c64SAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
10068a46c64SAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
10101c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
1025e286361SAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
10368a46c64SAndreas Jaekel 
104108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
105108668daSAndreas Jaekel 	uint32_t		record_len;				\
106108668daSAndreas Jaekel 	uint32_t		op;					\
107108668daSAndreas Jaekel 	uint64_t		op_time;				\
108b9df2829SAndreas Jaekel 	uint64_t		guid
109108668daSAndreas Jaekel 
1105e286361SAndreas Jaekel typedef struct zev_sig_t {
1115e286361SAndreas Jaekel 	uint16_t	level;
1125e286361SAndreas Jaekel 	uint16_t	padding1;
1135e286361SAndreas Jaekel 	uint32_t	padding2;
1145e286361SAndreas Jaekel 	uint64_t	block_offset;
1155e286361SAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
1165e286361SAndreas Jaekel } zev_sig_t;
1175e286361SAndreas Jaekel 
11868a46c64SAndreas Jaekel typedef struct zev_header_t {
119108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
12068a46c64SAndreas Jaekel } zev_header_t;
12168a46c64SAndreas Jaekel 
12268a46c64SAndreas Jaekel typedef struct zev_error_t {
123108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
12468a46c64SAndreas Jaekel 	uint32_t		failed_op;
12568a46c64SAndreas Jaekel 	uint32_t		errstr_len;
12668a46c64SAndreas Jaekel 	/* error string follows */
12768a46c64SAndreas Jaekel } zev_error_t;
12868a46c64SAndreas Jaekel 
12901c2c787SAndreas Jaekel typedef struct zev_mark_t {
13001c2c787SAndreas Jaekel 	ZEV_COMMON_FIELDS;
13101c2c787SAndreas Jaekel 	uint64_t		mark_id;
13201c2c787SAndreas Jaekel 	uint32_t		payload_len;
13301c2c787SAndreas Jaekel 	uint32_t		padding;
13401c2c787SAndreas Jaekel 	/* payload follows */
13501c2c787SAndreas Jaekel } zev_mark_t;
13601c2c787SAndreas Jaekel 
13768a46c64SAndreas Jaekel typedef struct zev_zfs_mount_t {
138108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
139f66561e7SAndreas Jaekel 	zev_inode_info_t	root;
140108668daSAndreas Jaekel 	uint32_t		remount;
14168a46c64SAndreas Jaekel 	uint32_t		dataset_len;
14268a46c64SAndreas Jaekel 	uint32_t		mountpoint_len;
143108668daSAndreas Jaekel 	uint32_t		padding;
14468a46c64SAndreas Jaekel 	/* dataset follows */
14568a46c64SAndreas Jaekel 	/* mountpoint follows */
14668a46c64SAndreas Jaekel } zev_zfs_mount_t;
14768a46c64SAndreas Jaekel 
14868a46c64SAndreas Jaekel typedef struct zev_zfs_umount_t {
149108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
15068a46c64SAndreas Jaekel } zev_zfs_umount_t;
15168a46c64SAndreas Jaekel 
15268a46c64SAndreas Jaekel typedef struct zev_zvol_truncate_t {
153108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
154e206ace3SAndreas Jaekel 	uint64_t		txg;
15568a46c64SAndreas Jaekel 	uint64_t		offset;
15668a46c64SAndreas Jaekel 	uint64_t		length;
15768a46c64SAndreas Jaekel 	uint32_t		dataset_len;
158108668daSAndreas Jaekel 	uint32_t		padding;
15968a46c64SAndreas Jaekel 	/* dataset follows */
16068a46c64SAndreas Jaekel } zev_zvol_truncate_t;
16168a46c64SAndreas Jaekel 
16268a46c64SAndreas Jaekel typedef struct zev_zvol_write_t {
163108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
164e206ace3SAndreas Jaekel 	uint64_t		txg;
16568a46c64SAndreas Jaekel 	uint64_t		offset;
16668a46c64SAndreas Jaekel 	uint64_t		length;
16768a46c64SAndreas Jaekel 	uint32_t		dataset_len;
168108668daSAndreas Jaekel 	uint32_t		padding;
16968a46c64SAndreas Jaekel 	/* dataset follows */
17068a46c64SAndreas Jaekel } zev_zvol_write_t;
17168a46c64SAndreas Jaekel 
17268a46c64SAndreas Jaekel typedef struct zev_znode_close_after_update_t {
173108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
17468a46c64SAndreas Jaekel 	zev_inode_info_t	file;
17568a46c64SAndreas Jaekel } zev_znode_close_after_update_t;
17668a46c64SAndreas Jaekel 
17768a46c64SAndreas Jaekel typedef struct zev_znode_create_t {
178108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
179e206ace3SAndreas Jaekel 	uint64_t		txg;
18068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
18168a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
1821ca5a13bSAndreas Jaekel 	zev_sig_t		signature;
18368a46c64SAndreas Jaekel 	uint32_t		name_len;
184108668daSAndreas Jaekel 	uint32_t		padding;
18568a46c64SAndreas Jaekel 	/* name follows */
18668a46c64SAndreas Jaekel } zev_znode_create_t;
18768a46c64SAndreas Jaekel 
18868a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
18968a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
19068a46c64SAndreas Jaekel 
19168a46c64SAndreas Jaekel typedef struct zev_znode_remove_t {
192108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
193e206ace3SAndreas Jaekel 	uint64_t		txg;
1946db5d4ecSAndreas Jaekel 	zev_inode_info_t	file;
19568a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
19668a46c64SAndreas Jaekel 	uint32_t		name_len;
197108668daSAndreas Jaekel 	uint32_t		padding;
19868a46c64SAndreas Jaekel 	/* name follows */
19968a46c64SAndreas Jaekel } zev_znode_remove_t;
20068a46c64SAndreas Jaekel 
20168a46c64SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
20268a46c64SAndreas Jaekel 
20368a46c64SAndreas Jaekel typedef struct zev_znode_link_t {
204108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
205e206ace3SAndreas Jaekel 	uint64_t		txg;
20668a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
20768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
20868a46c64SAndreas Jaekel 	uint32_t		name_len;
209108668daSAndreas Jaekel 	uint32_t		padding;
21068a46c64SAndreas Jaekel 	/* new_name follows */
21168a46c64SAndreas Jaekel } zev_znode_link_t;
21268a46c64SAndreas Jaekel 
21368a46c64SAndreas Jaekel typedef struct zev_znode_symlink_t {
214108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
215e206ace3SAndreas Jaekel 	uint64_t		txg;
21668a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
21768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
2181ca5a13bSAndreas Jaekel 	zev_sig_t		signature;
21968a46c64SAndreas Jaekel 	uint32_t		name_len;
22068a46c64SAndreas Jaekel 	uint32_t		link_len;
22168a46c64SAndreas Jaekel 	/* name follows */
22268a46c64SAndreas Jaekel 	/* link follows */
22368a46c64SAndreas Jaekel } zev_znode_symlink_t;
22468a46c64SAndreas Jaekel 
22568a46c64SAndreas Jaekel typedef struct zev_znode_rename_t {
226108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
227e206ace3SAndreas Jaekel 	uint64_t		txg;
22868a46c64SAndreas Jaekel 	zev_inode_info_t	srcdir;
22968a46c64SAndreas Jaekel 	zev_inode_info_t	dstdir;
23068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
23168a46c64SAndreas Jaekel 	uint32_t		srcname_len;
23268a46c64SAndreas Jaekel 	uint32_t		dstname_len;
23368a46c64SAndreas Jaekel 	/* srcname follows */
23468a46c64SAndreas Jaekel 	/* dstname follows */
23568a46c64SAndreas Jaekel } zev_znode_rename_t;
23668a46c64SAndreas Jaekel 
23768a46c64SAndreas Jaekel typedef struct zev_znode_write_t {
238108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
239e206ace3SAndreas Jaekel 	uint64_t		txg;
24068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
24168a46c64SAndreas Jaekel 	uint64_t		offset;
24268a46c64SAndreas Jaekel 	uint64_t		length;
2435e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2445e286361SAndreas Jaekel 	/* signatures follow */
24568a46c64SAndreas Jaekel } zev_znode_write_t;
24668a46c64SAndreas Jaekel 
24768a46c64SAndreas Jaekel typedef struct zev_znode_truncate_t {
248108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
249e206ace3SAndreas Jaekel 	uint64_t		txg;
25068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
25168a46c64SAndreas Jaekel 	uint64_t		offset;
25268a46c64SAndreas Jaekel 	uint64_t		length;
2535e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2545e286361SAndreas Jaekel 	/* signatures follow */
25568a46c64SAndreas Jaekel } zev_znode_truncate_t;
25668a46c64SAndreas Jaekel 
25768a46c64SAndreas Jaekel typedef struct zev_znode_setattr_t {
258108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
259e206ace3SAndreas Jaekel 	uint64_t		txg;
26068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
26168a46c64SAndreas Jaekel } zev_znode_setattr_t;
26268a46c64SAndreas Jaekel 
26368a46c64SAndreas Jaekel typedef struct zev_znode_acl_t {
264108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
265e206ace3SAndreas Jaekel 	uint64_t		txg;
26668a46c64SAndreas Jaekel 	zev_inode_info_t	file;
26768a46c64SAndreas Jaekel } zev_znode_acl_t;
26868a46c64SAndreas Jaekel 
26968a46c64SAndreas Jaekel /* convenience helper definition */
27068a46c64SAndreas Jaekel typedef union {
27168a46c64SAndreas Jaekel 	zev_header_t				header;
27268a46c64SAndreas Jaekel 
27301c2c787SAndreas Jaekel 	zev_error_t				error;
27401c2c787SAndreas Jaekel 	zev_mark_t				mark;
27568a46c64SAndreas Jaekel 	union {
27668a46c64SAndreas Jaekel 		zev_zfs_mount_t			mount;
27768a46c64SAndreas Jaekel 		zev_zfs_umount_t		umount;
27868a46c64SAndreas Jaekel 	} zfs;
27968a46c64SAndreas Jaekel 	union {
28068a46c64SAndreas Jaekel 		zev_zvol_truncate_t		truncate;
28168a46c64SAndreas Jaekel 		zev_zvol_write_t		write;
28268a46c64SAndreas Jaekel 	} zvol;
28368a46c64SAndreas Jaekel 	union {
28468a46c64SAndreas Jaekel 		zev_znode_close_after_update_t	close;
28568a46c64SAndreas Jaekel 		zev_znode_create_t		create;
28668a46c64SAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
28768a46c64SAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
28868a46c64SAndreas Jaekel 		zev_znode_remove_t		remove;
28968a46c64SAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
29068a46c64SAndreas Jaekel 		zev_znode_link_t		link;
29168a46c64SAndreas Jaekel 		zev_znode_symlink_t		symlink;
29268a46c64SAndreas Jaekel 		zev_znode_rename_t		rename;
29368a46c64SAndreas Jaekel 		zev_znode_write_t		write;
29468a46c64SAndreas Jaekel 		zev_znode_truncate_t		truncate;
29568a46c64SAndreas Jaekel 		zev_znode_setattr_t		setattr;
29668a46c64SAndreas Jaekel 		zev_znode_acl_t			acl;
29768a46c64SAndreas Jaekel 	} znode;
29868a46c64SAndreas Jaekel } zev_event_t;
29968a46c64SAndreas Jaekel 
30068a46c64SAndreas Jaekel 
3012bb8e5e2SAndreas Jaekel 
3022bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t {
3032bb8e5e2SAndreas Jaekel 	uint64_t	zev_queue_len;
3042bb8e5e2SAndreas Jaekel 	uint64_t	zev_bytes_read;
305e9a5e479SAndreas Jaekel 	uint64_t	zev_bytes_discarded;
306205a9bc9SAndreas Jaekel 	/* runtime settings */
307205a9bc9SAndreas Jaekel 	uint64_t	zev_max_queue_len;
3082bb8e5e2SAndreas Jaekel 	/* counters */
3092bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
310e9a5e479SAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
3112bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_errors;
31201c2c787SAndreas Jaekel 	uint64_t	zev_cnt_marks;
3132bb8e5e2SAndreas Jaekel 	/* zfsvfs ops */
3142bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
3152bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
3162bb8e5e2SAndreas Jaekel 	/* zvol ops */
3172bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
3182bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
3192bb8e5e2SAndreas Jaekel 	/* znode ops */
3202bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
3212bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
3222bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
3232bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
3242bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
3252bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
3262bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
3272bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
3282bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
3292bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
3302bb8e5e2SAndreas Jaekel } zev_statistics_t;
3312bb8e5e2SAndreas Jaekel 
332e9a5e479SAndreas Jaekel typedef struct zev_queue_name {
333e9a5e479SAndreas Jaekel 	uint64_t		zev_namelen;
334e9a5e479SAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
335e9a5e479SAndreas Jaekel } zev_queue_name_t;
336e9a5e479SAndreas Jaekel 
3372bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg {
3382bb8e5e2SAndreas Jaekel 	uint64_t	zev_poolname_len;
3392bb8e5e2SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
3402bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t;
34101c2c787SAndreas Jaekel 
34201c2c787SAndreas Jaekel typedef struct zev_ioctl_mark {
34301c2c787SAndreas Jaekel 	uint64_t	zev_mark_id;
34401c2c787SAndreas Jaekel 	uint64_t	zev_guid;
34501c2c787SAndreas Jaekel 	uint32_t	zev_payload_len;
34646c85740SAndreas Jaekel 	uint32_t	padding;
34701c2c787SAndreas Jaekel 	/* payload follows */
34801c2c787SAndreas Jaekel } zev_ioctl_mark_t;
349c035b1e8SAndreas Jaekel 
350c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen {
351c035b1e8SAndreas Jaekel 	/* input */
352c035b1e8SAndreas Jaekel 	uint64_t	inode;
353c035b1e8SAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
354c035b1e8SAndreas Jaekel 	/* noput */
355c035b1e8SAndreas Jaekel 	uint32_t	padding;
356c035b1e8SAndreas Jaekel 	/* output */
357c035b1e8SAndreas Jaekel 	uint64_t	generation;
358c035b1e8SAndreas Jaekel 	uint64_t	crtime;
359c035b1e8SAndreas Jaekel 	uint64_t	guid;
360c035b1e8SAndreas Jaekel 	char		dataset[MAXPATHLEN];
361c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t;
362e9a5e479SAndreas Jaekel 
363e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
364e9a5e479SAndreas Jaekel 	uint64_t		zev_max_queue_len;
365e9a5e479SAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
366e9a5e479SAndreas Jaekel 	uint16_t		zev_flags;
3674ca7dd5eSAndreas Jaekel 	uint16_t		padding1;
3684ca7dd5eSAndreas Jaekel 	uint32_t		padding2;
3694ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
370e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t;
371e9a5e479SAndreas Jaekel 
372e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
373e9a5e479SAndreas Jaekel 
374e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue {
375e9a5e479SAndreas Jaekel 	uint64_t	zev_max_queue_len;
376e9a5e479SAndreas Jaekel 	uint32_t	padding;
377e9a5e479SAndreas Jaekel 	uint16_t	zev_flags;
378e9a5e479SAndreas Jaekel 	uint16_t	zev_namelen;
379e9a5e479SAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
380e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t;
381e9a5e479SAndreas Jaekel 
382e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3834ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
384e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t;
385e9a5e479SAndreas Jaekel 
386e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3874ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
388e9a5e479SAndreas Jaekel 	zev_statistics_t	zev_statistics;
389e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
390e9a5e479SAndreas Jaekel 
391e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info {
392e9a5e479SAndreas Jaekel 	uint64_t	zev_memory_allocated;
3935e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
3945e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
3955e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
396e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t;
397e9a5e479SAndreas Jaekel 
398e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
399e9a5e479SAndreas Jaekel 	uint64_t		zev_n_queues;
400e9a5e479SAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
401e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t;
402e9a5e479SAndreas Jaekel 
403b9710123SAndreas Jaekel typedef struct zev_ioctl_get_signatures {
404b9710123SAndreas Jaekel 	/* in */
405b9710123SAndreas Jaekel 	uint64_t	zev_offset;
406b9710123SAndreas Jaekel 	uint64_t	zev_len;
407b9710123SAndreas Jaekel 	uint32_t	zev_fd;
408b9710123SAndreas Jaekel 	uint32_t	zev_bufsize;
409b9710123SAndreas Jaekel 	/* out */
410b9710123SAndreas Jaekel 	uint64_t	zev_signature_cnt;
411b9710123SAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
412b9710123SAndreas Jaekel } zev_ioctl_get_signatures_t;
413b9710123SAndreas Jaekel 
414108668daSAndreas Jaekel #pragma pack()
4152bb8e5e2SAndreas Jaekel 
4162bb8e5e2SAndreas Jaekel #ifdef _KERNEL
417e9a5e479SAndreas Jaekel 
418e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated;
419e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed;
420e9a5e479SAndreas Jaekel 
421e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
422e9a5e479SAndreas Jaekel 	do {								\
423e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
424e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
425e9a5e479SAndreas Jaekel 	} while(0)
426e9a5e479SAndreas Jaekel 
427e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
428e9a5e479SAndreas Jaekel 	do {								\
429e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
430e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
431e9a5e479SAndreas Jaekel 	} while(0)
432e9a5e479SAndreas Jaekel 
4335e286361SAndreas Jaekel void *zev_alloc(ssize_t sz);
4345e286361SAndreas Jaekel void *zev_zalloc(ssize_t sz);
4355e286361SAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
436e9a5e479SAndreas Jaekel 
43768a46c64SAndreas Jaekel typedef struct zev_msg_t {
43868a46c64SAndreas Jaekel 	struct zev_msg_t	*next;
439e9a5e479SAndreas Jaekel 	struct zev_msg_t	*prev;
440e9a5e479SAndreas Jaekel 	uint64_t		 seq;
441e9a5e479SAndreas Jaekel 	uint16_t		 size;
442e9a5e479SAndreas Jaekel 	uint16_t		 read;
44368a46c64SAndreas Jaekel 	/* data follows */
44468a46c64SAndreas Jaekel } zev_msg_t;
44568a46c64SAndreas Jaekel 
44668a46c64SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
44768a46c64SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
44868a46c64SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
4492bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os);
45068a46c64SAndreas Jaekel 
4512bb8e5e2SAndreas Jaekel #endif
4522bb8e5e2SAndreas Jaekel 
4532bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */
4542bb8e5e2SAndreas Jaekel 
455