xref: /titanic_51/usr/src/common/zev/zev.h (revision b9710123bf6fc26197428ae089042fb387a55032)
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 */
43*b9710123SAndreas 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
73e9a5e479SAndreas Jaekel 
74*b9710123SAndreas Jaekel /* checksum block sizes */
75*b9710123SAndreas Jaekel #define ZEV_L0_SIZE	4096
76*b9710123SAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
7710874358SAndreas Jaekel 
7868a46c64SAndreas Jaekel /* zfs event records (as they are represented through the character device) */
7968a46c64SAndreas Jaekel 
80108668daSAndreas Jaekel #pragma pack(1)
8168a46c64SAndreas Jaekel typedef struct zev_inode_info_t {
8268a46c64SAndreas Jaekel 	uint64_t	ino;
8368a46c64SAndreas Jaekel 	uint64_t	gen;
8468a46c64SAndreas Jaekel 	uint64_t	mtime;
8568a46c64SAndreas Jaekel 	uint64_t	ctime;
8668a46c64SAndreas Jaekel 	uint64_t	size;
8768a46c64SAndreas Jaekel 	uint64_t	mode;
8868a46c64SAndreas Jaekel 	uint64_t	links;
89108668daSAndreas Jaekel 	uint32_t	type;
9010874358SAndreas Jaekel 	uint32_t	flags;
9168a46c64SAndreas Jaekel } zev_inode_info_t;
9268a46c64SAndreas Jaekel 
9368a46c64SAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
9468a46c64SAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
9568a46c64SAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
9668a46c64SAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
9768a46c64SAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
9868a46c64SAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
9968a46c64SAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
10001c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
1015e286361SAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
10268a46c64SAndreas Jaekel 
103108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
104108668daSAndreas Jaekel 	uint32_t		record_len;				\
105108668daSAndreas Jaekel 	uint32_t		op;					\
106108668daSAndreas Jaekel 	uint64_t		op_time;				\
107b9df2829SAndreas Jaekel 	uint64_t		guid
108108668daSAndreas Jaekel 
1095e286361SAndreas Jaekel typedef struct zev_sig_t {
1105e286361SAndreas Jaekel 	uint16_t	level;
1115e286361SAndreas Jaekel 	uint16_t	padding1;
1125e286361SAndreas Jaekel 	uint32_t	padding2;
1135e286361SAndreas Jaekel 	uint64_t	block_offset;
1145e286361SAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
1155e286361SAndreas Jaekel } zev_sig_t;
1165e286361SAndreas Jaekel 
11768a46c64SAndreas Jaekel typedef struct zev_header_t {
118108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
11968a46c64SAndreas Jaekel } zev_header_t;
12068a46c64SAndreas Jaekel 
12168a46c64SAndreas Jaekel typedef struct zev_error_t {
122108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
12368a46c64SAndreas Jaekel 	uint32_t		failed_op;
12468a46c64SAndreas Jaekel 	uint32_t		errstr_len;
12568a46c64SAndreas Jaekel 	/* error string follows */
12668a46c64SAndreas Jaekel } zev_error_t;
12768a46c64SAndreas Jaekel 
12801c2c787SAndreas Jaekel typedef struct zev_mark_t {
12901c2c787SAndreas Jaekel 	ZEV_COMMON_FIELDS;
13001c2c787SAndreas Jaekel 	uint64_t		mark_id;
13101c2c787SAndreas Jaekel 	uint32_t		payload_len;
13201c2c787SAndreas Jaekel 	uint32_t		padding;
13301c2c787SAndreas Jaekel 	/* payload follows */
13401c2c787SAndreas Jaekel } zev_mark_t;
13501c2c787SAndreas Jaekel 
13668a46c64SAndreas Jaekel typedef struct zev_zfs_mount_t {
137108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
138f66561e7SAndreas Jaekel 	zev_inode_info_t	root;
139108668daSAndreas Jaekel 	uint32_t		remount;
14068a46c64SAndreas Jaekel 	uint32_t		dataset_len;
14168a46c64SAndreas Jaekel 	uint32_t		mountpoint_len;
142108668daSAndreas Jaekel 	uint32_t		padding;
14368a46c64SAndreas Jaekel 	/* dataset follows */
14468a46c64SAndreas Jaekel 	/* mountpoint follows */
14568a46c64SAndreas Jaekel } zev_zfs_mount_t;
14668a46c64SAndreas Jaekel 
14768a46c64SAndreas Jaekel typedef struct zev_zfs_umount_t {
148108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
14968a46c64SAndreas Jaekel } zev_zfs_umount_t;
15068a46c64SAndreas Jaekel 
15168a46c64SAndreas Jaekel typedef struct zev_zvol_truncate_t {
152108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
15368a46c64SAndreas Jaekel 	uint64_t		offset;
15468a46c64SAndreas Jaekel 	uint64_t		length;
15568a46c64SAndreas Jaekel 	uint32_t		dataset_len;
156108668daSAndreas Jaekel 	uint32_t		padding;
15768a46c64SAndreas Jaekel 	/* dataset follows */
15868a46c64SAndreas Jaekel } zev_zvol_truncate_t;
15968a46c64SAndreas Jaekel 
16068a46c64SAndreas Jaekel typedef struct zev_zvol_write_t {
161108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
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_write_t;
16868a46c64SAndreas Jaekel 
16968a46c64SAndreas Jaekel typedef struct zev_znode_close_after_update_t {
170108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
17168a46c64SAndreas Jaekel 	zev_inode_info_t	file;
17268a46c64SAndreas Jaekel } zev_znode_close_after_update_t;
17368a46c64SAndreas Jaekel 
17468a46c64SAndreas Jaekel typedef struct zev_znode_create_t {
175108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
17668a46c64SAndreas Jaekel 	zev_inode_info_t	file;
17768a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
17868a46c64SAndreas Jaekel 	uint32_t		name_len;
179108668daSAndreas Jaekel 	uint32_t		padding;
18068a46c64SAndreas Jaekel 	/* name follows */
18168a46c64SAndreas Jaekel } zev_znode_create_t;
18268a46c64SAndreas Jaekel 
18368a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
18468a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
18568a46c64SAndreas Jaekel 
18668a46c64SAndreas Jaekel typedef struct zev_znode_remove_t {
187108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
1886db5d4ecSAndreas Jaekel 	zev_inode_info_t	file;
18968a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
19068a46c64SAndreas Jaekel 	uint32_t		name_len;
191108668daSAndreas Jaekel 	uint32_t		padding;
19268a46c64SAndreas Jaekel 	/* name follows */
19368a46c64SAndreas Jaekel } zev_znode_remove_t;
19468a46c64SAndreas Jaekel 
19568a46c64SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
19668a46c64SAndreas Jaekel 
19768a46c64SAndreas Jaekel typedef struct zev_znode_link_t {
198108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
19968a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
20068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
20168a46c64SAndreas Jaekel 	uint32_t		name_len;
202108668daSAndreas Jaekel 	uint32_t		padding;
20368a46c64SAndreas Jaekel 	/* new_name follows */
20468a46c64SAndreas Jaekel } zev_znode_link_t;
20568a46c64SAndreas Jaekel 
20668a46c64SAndreas Jaekel typedef struct zev_znode_symlink_t {
207108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
20868a46c64SAndreas Jaekel 	zev_inode_info_t	parent;
20968a46c64SAndreas Jaekel 	zev_inode_info_t	file;
21068a46c64SAndreas Jaekel 	uint32_t		name_len;
21168a46c64SAndreas Jaekel 	uint32_t		link_len;
21268a46c64SAndreas Jaekel 	/* name follows */
21368a46c64SAndreas Jaekel 	/* link follows */
21468a46c64SAndreas Jaekel } zev_znode_symlink_t;
21568a46c64SAndreas Jaekel 
21668a46c64SAndreas Jaekel typedef struct zev_znode_rename_t {
217108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
21868a46c64SAndreas Jaekel 	zev_inode_info_t	srcdir;
21968a46c64SAndreas Jaekel 	zev_inode_info_t	dstdir;
22068a46c64SAndreas Jaekel 	zev_inode_info_t	file;
22168a46c64SAndreas Jaekel 	uint32_t		srcname_len;
22268a46c64SAndreas Jaekel 	uint32_t		dstname_len;
22368a46c64SAndreas Jaekel 	/* srcname follows */
22468a46c64SAndreas Jaekel 	/* dstname follows */
22568a46c64SAndreas Jaekel } zev_znode_rename_t;
22668a46c64SAndreas Jaekel 
22768a46c64SAndreas Jaekel typedef struct zev_znode_write_t {
228108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
22968a46c64SAndreas Jaekel 	zev_inode_info_t	file;
23068a46c64SAndreas Jaekel 	uint64_t		offset;
23168a46c64SAndreas Jaekel 	uint64_t		length;
2325e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2335e286361SAndreas Jaekel 	/* signatures follow */
23468a46c64SAndreas Jaekel } zev_znode_write_t;
23568a46c64SAndreas Jaekel 
23668a46c64SAndreas Jaekel typedef struct zev_znode_truncate_t {
237108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
23868a46c64SAndreas Jaekel 	zev_inode_info_t	file;
23968a46c64SAndreas Jaekel 	uint64_t		offset;
24068a46c64SAndreas Jaekel 	uint64_t		length;
2415e286361SAndreas Jaekel 	uint64_t		signature_cnt;
2425e286361SAndreas Jaekel 	/* signatures follow */
24368a46c64SAndreas Jaekel } zev_znode_truncate_t;
24468a46c64SAndreas Jaekel 
24568a46c64SAndreas Jaekel typedef struct zev_znode_setattr_t {
246108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
24768a46c64SAndreas Jaekel 	zev_inode_info_t	file;
24868a46c64SAndreas Jaekel } zev_znode_setattr_t;
24968a46c64SAndreas Jaekel 
25068a46c64SAndreas Jaekel typedef struct zev_znode_acl_t {
251108668daSAndreas Jaekel 	ZEV_COMMON_FIELDS;
25268a46c64SAndreas Jaekel 	zev_inode_info_t	file;
25368a46c64SAndreas Jaekel } zev_znode_acl_t;
25468a46c64SAndreas Jaekel 
25568a46c64SAndreas Jaekel /* convenience helper definition */
25668a46c64SAndreas Jaekel typedef union {
25768a46c64SAndreas Jaekel 	zev_header_t				header;
25868a46c64SAndreas Jaekel 
25901c2c787SAndreas Jaekel 	zev_error_t				error;
26001c2c787SAndreas Jaekel 	zev_mark_t				mark;
26168a46c64SAndreas Jaekel 	union {
26268a46c64SAndreas Jaekel 		zev_zfs_mount_t			mount;
26368a46c64SAndreas Jaekel 		zev_zfs_umount_t		umount;
26468a46c64SAndreas Jaekel 	} zfs;
26568a46c64SAndreas Jaekel 	union {
26668a46c64SAndreas Jaekel 		zev_zvol_truncate_t		truncate;
26768a46c64SAndreas Jaekel 		zev_zvol_write_t		write;
26868a46c64SAndreas Jaekel 	} zvol;
26968a46c64SAndreas Jaekel 	union {
27068a46c64SAndreas Jaekel 		zev_znode_close_after_update_t	close;
27168a46c64SAndreas Jaekel 		zev_znode_create_t		create;
27268a46c64SAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
27368a46c64SAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
27468a46c64SAndreas Jaekel 		zev_znode_remove_t		remove;
27568a46c64SAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
27668a46c64SAndreas Jaekel 		zev_znode_link_t		link;
27768a46c64SAndreas Jaekel 		zev_znode_symlink_t		symlink;
27868a46c64SAndreas Jaekel 		zev_znode_rename_t		rename;
27968a46c64SAndreas Jaekel 		zev_znode_write_t		write;
28068a46c64SAndreas Jaekel 		zev_znode_truncate_t		truncate;
28168a46c64SAndreas Jaekel 		zev_znode_setattr_t		setattr;
28268a46c64SAndreas Jaekel 		zev_znode_acl_t			acl;
28368a46c64SAndreas Jaekel 	} znode;
28468a46c64SAndreas Jaekel } zev_event_t;
28568a46c64SAndreas Jaekel 
28668a46c64SAndreas Jaekel 
2872bb8e5e2SAndreas Jaekel 
2882bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t {
2892bb8e5e2SAndreas Jaekel 	uint64_t	zev_queue_len;
2902bb8e5e2SAndreas Jaekel 	uint64_t	zev_bytes_read;
291e9a5e479SAndreas Jaekel 	uint64_t	zev_bytes_discarded;
292205a9bc9SAndreas Jaekel 	/* runtime settings */
293205a9bc9SAndreas Jaekel 	uint64_t	zev_max_queue_len;
2942bb8e5e2SAndreas Jaekel 	/* counters */
2952bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
296e9a5e479SAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
2972bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_errors;
29801c2c787SAndreas Jaekel 	uint64_t	zev_cnt_marks;
2992bb8e5e2SAndreas Jaekel 	/* zfsvfs ops */
3002bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
3012bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
3022bb8e5e2SAndreas Jaekel 	/* zvol ops */
3032bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
3042bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
3052bb8e5e2SAndreas Jaekel 	/* znode ops */
3062bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
3072bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
3082bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
3092bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
3102bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
3112bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
3122bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
3132bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
3142bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
3152bb8e5e2SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
3162bb8e5e2SAndreas Jaekel } zev_statistics_t;
3172bb8e5e2SAndreas Jaekel 
318e9a5e479SAndreas Jaekel typedef struct zev_queue_name {
319e9a5e479SAndreas Jaekel 	uint64_t		zev_namelen;
320e9a5e479SAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
321e9a5e479SAndreas Jaekel } zev_queue_name_t;
322e9a5e479SAndreas Jaekel 
3232bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg {
3242bb8e5e2SAndreas Jaekel 	uint64_t	zev_poolname_len;
3252bb8e5e2SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
3262bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t;
32701c2c787SAndreas Jaekel 
32801c2c787SAndreas Jaekel typedef struct zev_ioctl_mark {
32901c2c787SAndreas Jaekel 	uint64_t	zev_mark_id;
33001c2c787SAndreas Jaekel 	uint64_t	zev_guid;
33101c2c787SAndreas Jaekel 	uint32_t	zev_payload_len;
33246c85740SAndreas Jaekel 	uint32_t	padding;
33301c2c787SAndreas Jaekel 	/* payload follows */
33401c2c787SAndreas Jaekel } zev_ioctl_mark_t;
335c035b1e8SAndreas Jaekel 
336c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen {
337c035b1e8SAndreas Jaekel 	/* input */
338c035b1e8SAndreas Jaekel 	uint64_t	inode;
339c035b1e8SAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
340c035b1e8SAndreas Jaekel 	/* noput */
341c035b1e8SAndreas Jaekel 	uint32_t	padding;
342c035b1e8SAndreas Jaekel 	/* output */
343c035b1e8SAndreas Jaekel 	uint64_t	generation;
344c035b1e8SAndreas Jaekel 	uint64_t	crtime;
345c035b1e8SAndreas Jaekel 	uint64_t	guid;
346c035b1e8SAndreas Jaekel 	char		dataset[MAXPATHLEN];
347c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t;
348e9a5e479SAndreas Jaekel 
349e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
350e9a5e479SAndreas Jaekel 	uint64_t		zev_max_queue_len;
351e9a5e479SAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
352e9a5e479SAndreas Jaekel 	uint16_t		zev_flags;
3534ca7dd5eSAndreas Jaekel 	uint16_t		padding1;
3544ca7dd5eSAndreas Jaekel 	uint32_t		padding2;
3554ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
356e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t;
357e9a5e479SAndreas Jaekel 
358e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
359e9a5e479SAndreas Jaekel 
360e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue {
361e9a5e479SAndreas Jaekel 	uint64_t	zev_max_queue_len;
362e9a5e479SAndreas Jaekel 	uint32_t	padding;
363e9a5e479SAndreas Jaekel 	uint16_t	zev_flags;
364e9a5e479SAndreas Jaekel 	uint16_t	zev_namelen;
365e9a5e479SAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
366e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t;
367e9a5e479SAndreas Jaekel 
368e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3694ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
370e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t;
371e9a5e479SAndreas Jaekel 
372e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3734ca7dd5eSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
374e9a5e479SAndreas Jaekel 	zev_statistics_t	zev_statistics;
375e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
376e9a5e479SAndreas Jaekel 
377e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info {
378e9a5e479SAndreas Jaekel 	uint64_t	zev_memory_allocated;
3795e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
3805e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
3815e286361SAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
382e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t;
383e9a5e479SAndreas Jaekel 
384e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
385e9a5e479SAndreas Jaekel 	uint64_t		zev_n_queues;
386e9a5e479SAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
387e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t;
388e9a5e479SAndreas Jaekel 
389*b9710123SAndreas Jaekel typedef struct zev_ioctl_get_signatures {
390*b9710123SAndreas Jaekel 	/* in */
391*b9710123SAndreas Jaekel 	uint64_t	zev_offset;
392*b9710123SAndreas Jaekel 	uint64_t	zev_len;
393*b9710123SAndreas Jaekel 	uint32_t	zev_fd;
394*b9710123SAndreas Jaekel 	uint32_t	zev_bufsize;
395*b9710123SAndreas Jaekel 	/* out */
396*b9710123SAndreas Jaekel 	uint64_t	zev_signature_cnt;
397*b9710123SAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
398*b9710123SAndreas Jaekel } zev_ioctl_get_signatures_t;
399*b9710123SAndreas Jaekel 
400108668daSAndreas Jaekel #pragma pack()
4012bb8e5e2SAndreas Jaekel 
4022bb8e5e2SAndreas Jaekel #ifdef _KERNEL
403e9a5e479SAndreas Jaekel 
404e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated;
405e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed;
406e9a5e479SAndreas Jaekel 
407e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
408e9a5e479SAndreas Jaekel 	do {								\
409e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
410e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
411e9a5e479SAndreas Jaekel 	} while(0)
412e9a5e479SAndreas Jaekel 
413e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
414e9a5e479SAndreas Jaekel 	do {								\
415e9a5e479SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
416e9a5e479SAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
417e9a5e479SAndreas Jaekel 	} while(0)
418e9a5e479SAndreas Jaekel 
4195e286361SAndreas Jaekel void *zev_alloc(ssize_t sz);
4205e286361SAndreas Jaekel void *zev_zalloc(ssize_t sz);
4215e286361SAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
422e9a5e479SAndreas Jaekel 
42368a46c64SAndreas Jaekel typedef struct zev_msg_t {
42468a46c64SAndreas Jaekel 	struct zev_msg_t	*next;
425e9a5e479SAndreas Jaekel 	struct zev_msg_t	*prev;
426e9a5e479SAndreas Jaekel 	uint64_t		 seq;
427e9a5e479SAndreas Jaekel 	uint16_t		 size;
428e9a5e479SAndreas Jaekel 	uint16_t		 read;
42968a46c64SAndreas Jaekel 	/* data follows */
43068a46c64SAndreas Jaekel } zev_msg_t;
43168a46c64SAndreas Jaekel 
43268a46c64SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
43368a46c64SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
43468a46c64SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
4352bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os);
43668a46c64SAndreas Jaekel 
4372bb8e5e2SAndreas Jaekel #endif
4382bb8e5e2SAndreas Jaekel 
4392bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */
4402bb8e5e2SAndreas Jaekel 
441