xref: /titanic_53/usr/src/common/zev/zev.h (revision 5e28636192c7a7f235ea1e835192fe00d17757cb)
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>
7*5e286361SAndreas 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 */
432bb8e5e2SAndreas Jaekel 
442bb8e5e2SAndreas Jaekel #define ZEV_OP_MIN			 1
4568a46c64SAndreas Jaekel #define ZEV_OP_ERROR			 1
4601c2c787SAndreas Jaekel #define ZEV_OP_MARK			 2
4701c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_MOUNT		 3
4801c2c787SAndreas Jaekel #define	ZEV_OP_ZFS_UMOUNT		 4
4901c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_WRITE		 5
5001c2c787SAndreas Jaekel #define	ZEV_OP_ZVOL_TRUNCATE		 6
5101c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE	 7
5201c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_CREATE		 8
5301c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MKDIR		 9
5401c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_MAKE_XATTR_DIR	10
5501c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_REMOVE		11
5601c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RMDIR		12
5701c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_LINK		13
5801c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SYMLINK		14
5901c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_RENAME		15
6001c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_WRITE		16
6101c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_TRUNCATE		17
6201c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_SETATTR		18
6301c2c787SAndreas Jaekel #define	ZEV_OP_ZNODE_ACL		19
6401c2c787SAndreas Jaekel #define	ZEV_OP_MAX			19
6568a46c64SAndreas Jaekel 
66e9a5e479SAndreas Jaekel /* zev event flags */
67e9a5e479SAndreas Jaekel #define	ZEV_FL_XATTR			0x0001
68e9a5e479SAndreas Jaekel 
69e9a5e479SAndreas Jaekel /* zev queue flags */
70e9a5e479SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL	0x0001
71e9a5e479SAndreas Jaekel #define ZEV_FL_PERSISTENT		0x0002
72e9a5e479SAndreas Jaekel 
7310874358SAndreas Jaekel 
7468a46c64SAndreas Jaekel /* zfs event records (as they are represented through the character device) */
7568a46c64SAndreas Jaekel 
76108668daSAndreas Jaekel #pragma pack(1)
7768a46c64SAndreas Jaekel typedef struct zev_inode_info_t {
7868a46c64SAndreas Jaekel 	uint64_t	ino;
7968a46c64SAndreas Jaekel 	uint64_t	gen;
8068a46c64SAndreas Jaekel 	uint64_t	mtime;
8168a46c64SAndreas Jaekel 	uint64_t	ctime;
8268a46c64SAndreas Jaekel 	uint64_t	size;
8368a46c64SAndreas Jaekel 	uint64_t	mode;
8468a46c64SAndreas Jaekel 	uint64_t	links;
85108668daSAndreas Jaekel 	uint32_t	type;
8610874358SAndreas Jaekel 	uint32_t	flags;
8768a46c64SAndreas Jaekel } zev_inode_info_t;
8868a46c64SAndreas Jaekel 
8968a46c64SAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
9068a46c64SAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
9168a46c64SAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
9268a46c64SAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
9368a46c64SAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
9468a46c64SAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
9568a46c64SAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
9601c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
97*5e286361SAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
9868a46c64SAndreas Jaekel 
99108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
100108668daSAndreas Jaekel 	uint32_t		record_len;				\
101108668daSAndreas Jaekel 	uint32_t		op;					\
102108668daSAndreas Jaekel 	uint64_t		op_time;				\
103b9df2829SAndreas Jaekel 	uint64_t		guid
104108668daSAndreas Jaekel 
105*5e286361SAndreas Jaekel typedef struct zev_sig_t {
106*5e286361SAndreas Jaekel 	uint16_t	level;
107*5e286361SAndreas Jaekel 	uint16_t	padding1;
108*5e286361SAndreas Jaekel 	uint32_t	padding2;
109*5e286361SAndreas Jaekel 	uint64_t	block_offset;
110*5e286361SAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
111*5e286361SAndreas Jaekel } zev_sig_t;
112*5e286361SAndreas Jaekel 
11368a46c64SAndreas Jaekel typedef struct zev_header_t {
114108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
11568a46c64SAndreas Jaekel } zev_header_t;
11668a46c64SAndreas Jaekel 
11768a46c64SAndreas Jaekel typedef struct zev_error_t {
118108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
11968a46c64SAndreas Jaekel 	uint32_t		failed_op;
12068a46c64SAndreas Jaekel 	uint32_t		errstr_len;
12168a46c64SAndreas Jaekel 	/* error string follows */
12268a46c64SAndreas Jaekel } zev_error_t;
12368a46c64SAndreas Jaekel 
12401c2c787SAndreas Jaekel typedef struct zev_mark_t {
12501c2c787SAndreas Jaekel 	ZEV_COMMON_FIELDS;
12601c2c787SAndreas Jaekel 	uint64_t		mark_id;
12701c2c787SAndreas Jaekel 	uint32_t		payload_len;
12801c2c787SAndreas Jaekel 	uint32_t		padding;
12901c2c787SAndreas Jaekel 	/* payload follows */
13001c2c787SAndreas Jaekel } zev_mark_t;
13101c2c787SAndreas Jaekel 
13268a46c64SAndreas Jaekel typedef struct zev_zfs_mount_t {
133108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
134f66561e7SAndreas Jaekel 	zev_inode_info_t	root;
135108668daSAndreas Jaekel 	uint32_t		remount;
13668a46c64SAndreas Jaekel 	uint32_t		dataset_len;
13768a46c64SAndreas Jaekel 	uint32_t		mountpoint_len;
138108668daSAndreas Jaekel 	uint32_t		padding;
13968a46c64SAndreas Jaekel 	/* dataset follows */
14068a46c64SAndreas Jaekel 	/* mountpoint follows */
14168a46c64SAndreas Jaekel } zev_zfs_mount_t;
14268a46c64SAndreas Jaekel 
14368a46c64SAndreas Jaekel typedef struct zev_zfs_umount_t {
144108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
14568a46c64SAndreas Jaekel } zev_zfs_umount_t;
14668a46c64SAndreas Jaekel 
14768a46c64SAndreas Jaekel typedef struct zev_zvol_truncate_t {
148108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
14968a46c64SAndreas Jaekel 	uint64_t		offset;
15068a46c64SAndreas Jaekel 	uint64_t		length;
15168a46c64SAndreas Jaekel 	uint32_t		dataset_len;
152108668daSAndreas Jaekel 	uint32_t		padding;
15368a46c64SAndreas Jaekel 	/* dataset follows */
15468a46c64SAndreas Jaekel } zev_zvol_truncate_t;
15568a46c64SAndreas Jaekel 
15668a46c64SAndreas Jaekel typedef struct zev_zvol_write_t {
157108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
15868a46c64SAndreas Jaekel 	uint64_t		offset;
15968a46c64SAndreas Jaekel 	uint64_t		length;
16068a46c64SAndreas Jaekel 	uint32_t		dataset_len;
161108668daSAndreas Jaekel 	uint32_t		padding;
16268a46c64SAndreas Jaekel 	/* dataset follows */
16368a46c64SAndreas Jaekel } zev_zvol_write_t;
16468a46c64SAndreas Jaekel 
16568a46c64SAndreas Jaekel typedef struct zev_znode_close_after_update_t {
166108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
16768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
16868a46c64SAndreas Jaekel } zev_znode_close_after_update_t;
16968a46c64SAndreas Jaekel 
17068a46c64SAndreas Jaekel typedef struct zev_znode_create_t {
171108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
17268a46c64SAndreas Jaekel 	zev_inode_info_t	file;
17368a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
17468a46c64SAndreas Jaekel 	uint32_t		name_len;
175108668daSAndreas Jaekel 	uint32_t		padding;
17668a46c64SAndreas Jaekel 	/* name follows */
17768a46c64SAndreas Jaekel } zev_znode_create_t;
17868a46c64SAndreas Jaekel 
17968a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
18068a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
18168a46c64SAndreas Jaekel 
18268a46c64SAndreas Jaekel typedef struct zev_znode_remove_t {
183108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
1846db5d4ecSAndreas Jaekel 	zev_inode_info_t	file;
18568a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
18668a46c64SAndreas Jaekel 	uint32_t		name_len;
187108668daSAndreas Jaekel 	uint32_t		padding;
18868a46c64SAndreas Jaekel 	/* name follows */
18968a46c64SAndreas Jaekel } zev_znode_remove_t;
19068a46c64SAndreas Jaekel 
19168a46c64SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
19268a46c64SAndreas Jaekel 
19368a46c64SAndreas Jaekel typedef struct zev_znode_link_t {
194108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
19568a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
19668a46c64SAndreas Jaekel 	zev_inode_info_t	file;
19768a46c64SAndreas Jaekel 	uint32_t		name_len;
198108668daSAndreas Jaekel 	uint32_t		padding;
19968a46c64SAndreas Jaekel 	/* new_name follows */
20068a46c64SAndreas Jaekel } zev_znode_link_t;
20168a46c64SAndreas Jaekel 
20268a46c64SAndreas Jaekel typedef struct zev_znode_symlink_t {
203108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
20468a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
20568a46c64SAndreas Jaekel 	zev_inode_info_t	file;
20668a46c64SAndreas Jaekel 	uint32_t		name_len;
20768a46c64SAndreas Jaekel 	uint32_t		link_len;
20868a46c64SAndreas Jaekel 	/* name follows */
20968a46c64SAndreas Jaekel 	/* link follows */
21068a46c64SAndreas Jaekel } zev_znode_symlink_t;
21168a46c64SAndreas Jaekel 
21268a46c64SAndreas Jaekel typedef struct zev_znode_rename_t {
213108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
21468a46c64SAndreas Jaekel 	zev_inode_info_t	srcdir;
21568a46c64SAndreas Jaekel 	zev_inode_info_t	dstdir;
21668a46c64SAndreas Jaekel 	zev_inode_info_t	file;
21768a46c64SAndreas Jaekel 	uint32_t		srcname_len;
21868a46c64SAndreas Jaekel 	uint32_t		dstname_len;
21968a46c64SAndreas Jaekel 	/* srcname follows */
22068a46c64SAndreas Jaekel 	/* dstname follows */
22168a46c64SAndreas Jaekel } zev_znode_rename_t;
22268a46c64SAndreas Jaekel 
22368a46c64SAndreas Jaekel typedef struct zev_znode_write_t {
224108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
22568a46c64SAndreas Jaekel 	zev_inode_info_t	file;
22668a46c64SAndreas Jaekel 	uint64_t		offset;
22768a46c64SAndreas Jaekel 	uint64_t		length;
228*5e286361SAndreas Jaekel 	uint64_t		signature_cnt;
229*5e286361SAndreas Jaekel 	/* signatures follow */
23068a46c64SAndreas Jaekel } zev_znode_write_t;
23168a46c64SAndreas Jaekel 
23268a46c64SAndreas Jaekel typedef struct zev_znode_truncate_t {
233108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
23468a46c64SAndreas Jaekel 	zev_inode_info_t	file;
23568a46c64SAndreas Jaekel 	uint64_t		offset;
23668a46c64SAndreas Jaekel 	uint64_t		length;
237*5e286361SAndreas Jaekel 	uint64_t		signature_cnt;
238*5e286361SAndreas Jaekel 	/* signatures follow */
23968a46c64SAndreas Jaekel } zev_znode_truncate_t;
24068a46c64SAndreas Jaekel 
24168a46c64SAndreas Jaekel typedef struct zev_znode_setattr_t {
242108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
24368a46c64SAndreas Jaekel 	zev_inode_info_t	file;
24468a46c64SAndreas Jaekel } zev_znode_setattr_t;
24568a46c64SAndreas Jaekel 
24668a46c64SAndreas Jaekel typedef struct zev_znode_acl_t {
247108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
24868a46c64SAndreas Jaekel 	zev_inode_info_t	file;
24968a46c64SAndreas Jaekel } zev_znode_acl_t;
25068a46c64SAndreas Jaekel 
25168a46c64SAndreas Jaekel /* convenience helper definition */
25268a46c64SAndreas Jaekel typedef union {
25368a46c64SAndreas Jaekel 	zev_header_t				header;
25468a46c64SAndreas Jaekel 
25501c2c787SAndreas Jaekel 	zev_error_t				error;
25601c2c787SAndreas Jaekel 	zev_mark_t				mark;
25768a46c64SAndreas Jaekel 	union {
25868a46c64SAndreas Jaekel 		zev_zfs_mount_t			mount;
25968a46c64SAndreas Jaekel 		zev_zfs_umount_t		umount;
26068a46c64SAndreas Jaekel 	} zfs;
26168a46c64SAndreas Jaekel 	union {
26268a46c64SAndreas Jaekel 		zev_zvol_truncate_t		truncate;
26368a46c64SAndreas Jaekel 		zev_zvol_write_t		write;
26468a46c64SAndreas Jaekel 	} zvol;
26568a46c64SAndreas Jaekel 	union {
26668a46c64SAndreas Jaekel 		zev_znode_close_after_update_t	close;
26768a46c64SAndreas Jaekel 		zev_znode_create_t		create;
26868a46c64SAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
26968a46c64SAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
27068a46c64SAndreas Jaekel 		zev_znode_remove_t		remove;
27168a46c64SAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
27268a46c64SAndreas Jaekel 		zev_znode_link_t		link;
27368a46c64SAndreas Jaekel 		zev_znode_symlink_t		symlink;
27468a46c64SAndreas Jaekel 		zev_znode_rename_t		rename;
27568a46c64SAndreas Jaekel 		zev_znode_write_t		write;
27668a46c64SAndreas Jaekel 		zev_znode_truncate_t		truncate;
27768a46c64SAndreas Jaekel 		zev_znode_setattr_t		setattr;
27868a46c64SAndreas Jaekel 		zev_znode_acl_t			acl;
27968a46c64SAndreas Jaekel 	} znode;
28068a46c64SAndreas Jaekel } zev_event_t;
28168a46c64SAndreas Jaekel 
28268a46c64SAndreas Jaekel 
2832bb8e5e2SAndreas Jaekel 
2842bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t {
2852bb8e5e2SAndreas Jaekel 	uint64_t	zev_queue_len;
2862bb8e5e2SAndreas Jaekel 	uint64_t	zev_bytes_read;
287e9a5e479SAndreas Jaekel 	uint64_t	zev_bytes_discarded;
288205a9bc9SAndreas Jaekel 	/* runtime settings */
289205a9bc9SAndreas Jaekel 	uint64_t	zev_max_queue_len;
2902bb8e5e2SAndreas Jaekel 	/* counters */
2912bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
292e9a5e479SAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
2932bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_errors;
29401c2c787SAndreas Jaekel 	uint64_t	zev_cnt_marks;
2952bb8e5e2SAndreas Jaekel 	/* zfsvfs ops */
2962bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
2972bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
2982bb8e5e2SAndreas Jaekel 	/* zvol ops */
2992bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
3002bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
3012bb8e5e2SAndreas Jaekel 	/* znode ops */
3022bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
3032bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
3042bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
3052bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
3062bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
3072bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
3082bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
3092bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
3102bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
3112bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
3122bb8e5e2SAndreas Jaekel } zev_statistics_t;
3132bb8e5e2SAndreas Jaekel 
314e9a5e479SAndreas Jaekel typedef struct zev_queue_name {
315e9a5e479SAndreas Jaekel 	uint64_t		zev_namelen;
316e9a5e479SAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
317e9a5e479SAndreas Jaekel } zev_queue_name_t;
318e9a5e479SAndreas Jaekel 
3192bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg {
3202bb8e5e2SAndreas Jaekel 	uint64_t	zev_poolname_len;
3212bb8e5e2SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
3222bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t;
32301c2c787SAndreas Jaekel 
32401c2c787SAndreas Jaekel typedef struct zev_ioctl_mark {
32501c2c787SAndreas Jaekel 	uint64_t	zev_mark_id;
32601c2c787SAndreas Jaekel 	uint64_t	zev_guid;
32701c2c787SAndreas Jaekel 	uint32_t	zev_payload_len;
32846c85740SAndreas Jaekel 	uint32_t	padding;
32901c2c787SAndreas Jaekel 	/* payload follows */
33001c2c787SAndreas Jaekel } zev_ioctl_mark_t;
331c035b1e8SAndreas Jaekel 
332c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen {
333c035b1e8SAndreas Jaekel 	/* input */
334c035b1e8SAndreas Jaekel 	uint64_t	inode;
335c035b1e8SAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
336c035b1e8SAndreas Jaekel 	/* noput */
337c035b1e8SAndreas Jaekel 	uint32_t	padding;
338c035b1e8SAndreas Jaekel 	/* output */
339c035b1e8SAndreas Jaekel 	uint64_t	generation;
340c035b1e8SAndreas Jaekel 	uint64_t	crtime;
341c035b1e8SAndreas Jaekel 	uint64_t	guid;
342c035b1e8SAndreas Jaekel 	char		dataset[MAXPATHLEN];
343c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t;
344e9a5e479SAndreas Jaekel 
345e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
346e9a5e479SAndreas Jaekel 	uint64_t		zev_max_queue_len;
347e9a5e479SAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
348e9a5e479SAndreas Jaekel 	uint16_t		zev_flags;
3494ca7dd5eSAndreas Jaekel 	uint16_t		padding1;
3504ca7dd5eSAndreas Jaekel 	uint32_t		padding2;
3514ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
352e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t;
353e9a5e479SAndreas Jaekel 
354e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
355e9a5e479SAndreas Jaekel 
356e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue {
357e9a5e479SAndreas Jaekel 	uint64_t	zev_max_queue_len;
358e9a5e479SAndreas Jaekel 	uint32_t	padding;
359e9a5e479SAndreas Jaekel 	uint16_t	zev_flags;
360e9a5e479SAndreas Jaekel 	uint16_t	zev_namelen;
361e9a5e479SAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
362e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t;
363e9a5e479SAndreas Jaekel 
364e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3654ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
366e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t;
367e9a5e479SAndreas Jaekel 
368e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3694ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
370e9a5e479SAndreas Jaekel 	zev_statistics_t	zev_statistics;
371e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
372e9a5e479SAndreas Jaekel 
373e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info {
374e9a5e479SAndreas Jaekel 	uint64_t	zev_memory_allocated;
375*5e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
376*5e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
377*5e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
378e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t;
379e9a5e479SAndreas Jaekel 
380e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
381e9a5e479SAndreas Jaekel 	uint64_t		zev_n_queues;
382e9a5e479SAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
383e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t;
384e9a5e479SAndreas Jaekel 
385108668daSAndreas Jaekel #pragma pack()
3862bb8e5e2SAndreas Jaekel 
3872bb8e5e2SAndreas Jaekel #ifdef _KERNEL
388e9a5e479SAndreas Jaekel 
389e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated;
390e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed;
391e9a5e479SAndreas Jaekel 
392e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
393e9a5e479SAndreas Jaekel 	do {								\
394e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
395e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
396e9a5e479SAndreas Jaekel 	} while(0)
397e9a5e479SAndreas Jaekel 
398e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
399e9a5e479SAndreas Jaekel 	do {								\
400e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
401e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
402e9a5e479SAndreas Jaekel 	} while(0)
403e9a5e479SAndreas Jaekel 
404*5e286361SAndreas Jaekel void *zev_alloc(ssize_t sz);
405*5e286361SAndreas Jaekel void *zev_zalloc(ssize_t sz);
406*5e286361SAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
407e9a5e479SAndreas Jaekel 
40868a46c64SAndreas Jaekel typedef struct zev_msg_t {
40968a46c64SAndreas Jaekel 	struct zev_msg_t	*next;
410e9a5e479SAndreas Jaekel 	struct zev_msg_t	*prev;
411e9a5e479SAndreas Jaekel 	uint64_t		 seq;
412e9a5e479SAndreas Jaekel 	uint16_t		 size;
413e9a5e479SAndreas Jaekel 	uint16_t		 read;
41468a46c64SAndreas Jaekel 	/* data follows */
41568a46c64SAndreas Jaekel } zev_msg_t;
41668a46c64SAndreas Jaekel 
41768a46c64SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
41868a46c64SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
41968a46c64SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
4202bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os);
42168a46c64SAndreas Jaekel 
4222bb8e5e2SAndreas Jaekel #endif
4232bb8e5e2SAndreas Jaekel 
4242bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */
4252bb8e5e2SAndreas Jaekel 
426