xref: /titanic_44/usr/src/common/zev/zev.h (revision c99a1a257f8a5ec43b8896d8e5e51b50c7f09883)
1a18c35b9SAndreas Jaekel #ifndef __ZEV_H__
2a18c35b9SAndreas Jaekel #define __ZEV_H__
3a18c35b9SAndreas Jaekel 
4a18c35b9SAndreas Jaekel #include <sys/types.h>
557691ffeSAndreas Jaekel #include <sys/param.h>
6add9520fSAndreas Jaekel #include <sys/atomic.h>
7205ed6bfSAndreas Jaekel #include <sys/sha1.h>
8a18c35b9SAndreas Jaekel 
9a18c35b9SAndreas Jaekel #ifdef _KERNEL
10a18c35b9SAndreas Jaekel #include <sys/dmu_objset.h>
11a18c35b9SAndreas Jaekel #include <sys/dsl_dataset.h>
12a18c35b9SAndreas Jaekel #include <sys/zfs_vfsops.h>
13a18c35b9SAndreas Jaekel #include <sys/dsl_dir.h>
14a18c35b9SAndreas Jaekel #include <sys/spa_impl.h>
15a18c35b9SAndreas Jaekel #endif
16a18c35b9SAndreas Jaekel 
17add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN		40
18add9520fSAndreas Jaekel #define ZEV_MAX_QUEUES			63
19add9520fSAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME		"ctrl"
20add9520fSAndreas Jaekel 
21add9520fSAndreas Jaekel /* global limit, no queue may grow larger than this. */
22add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_LEN		(1 * 1024 * 1024 * 1024)
23add9520fSAndreas Jaekel 
24add9520fSAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */
256a6a51eeSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN	8192
26add9520fSAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN		65536
27add9520fSAndreas Jaekel 
28a18c35b9SAndreas Jaekel #define ZEVIOC				  ('z' << 8)
29add9520fSAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS	  (ZEVIOC | 1)	/* get global stats */
30fec460f8SAndreas Jaekel #define ZEV_IOC_MUTE_POOL		  (ZEVIOC | 2)	/* no events for pool */
31fec460f8SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL		  (ZEVIOC | 3)	/* send pool events */
32fec460f8SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN	  (ZEVIOC | 4)	/* when to block ops */
33fec460f8SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5)	/* poll throttle */
34888fea18SAndreas Jaekel #define ZEV_IOC_MARK			  (ZEVIOC | 6)	/* add mark to queue */
3535d4e8ddSAndreas Jaekel #define ZEV_IOC_GET_GEN			  (ZEVIOC | 7)	/* get generation no. */
36add9520fSAndreas Jaekel #define	ZEV_IOC_ADD_QUEUE		  (ZEVIOC | 8)  /* create new queue */
37add9520fSAndreas Jaekel #define	ZEV_IOC_REMOVE_QUEUE		  (ZEVIOC | 9)  /* delete queue */
38add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES	  (ZEVIOC | 10)	/* get properties */
39add9520fSAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES	  (ZEVIOC | 11)	/* set properties */
40add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS	  (ZEVIOC | 12)	/* get queue stats */
41add9520fSAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO		  (ZEVIOC | 13)	/* get internal info */
42add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST		  (ZEVIOC | 14)	/* get queue list */
4342110aacSAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES	  (ZEVIOC | 15)	/* get beaver sigs */
44a18c35b9SAndreas Jaekel 
45a18c35b9SAndreas Jaekel #define ZEV_OP_MIN			 1
46d979f56cSAndreas Jaekel #define ZEV_OP_ERROR			 1
47888fea18SAndreas Jaekel #define ZEV_OP_MARK			 2
48888fea18SAndreas Jaekel #define	ZEV_OP_ZFS_MOUNT		 3
49888fea18SAndreas Jaekel #define	ZEV_OP_ZFS_UMOUNT		 4
50888fea18SAndreas Jaekel #define	ZEV_OP_ZVOL_WRITE		 5
51888fea18SAndreas Jaekel #define	ZEV_OP_ZVOL_TRUNCATE		 6
52888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE	 7
53888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_CREATE		 8
54888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_MKDIR		 9
55888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_MAKE_XATTR_DIR	10
56888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_REMOVE		11
57888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_RMDIR		12
58888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_LINK		13
59888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_SYMLINK		14
60888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_RENAME		15
61888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_WRITE		16
62888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_TRUNCATE		17
63888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_SETATTR		18
64888fea18SAndreas Jaekel #define	ZEV_OP_ZNODE_ACL		19
65888fea18SAndreas Jaekel #define	ZEV_OP_MAX			19
66d979f56cSAndreas Jaekel 
67add9520fSAndreas Jaekel /* zev event flags */
68add9520fSAndreas Jaekel #define	ZEV_FL_XATTR			0x0001
69add9520fSAndreas Jaekel 
70add9520fSAndreas Jaekel /* zev queue flags */
71add9520fSAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL	0x0001
72add9520fSAndreas Jaekel #define ZEV_FL_PERSISTENT		0x0002
73*c99a1a25SAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY		0x0004
74add9520fSAndreas Jaekel 
7542110aacSAndreas Jaekel /* checksum block sizes */
7642110aacSAndreas Jaekel #define ZEV_L0_SIZE	4096
7742110aacSAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
7819b08257SAndreas Jaekel 
79d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */
80d979f56cSAndreas Jaekel 
81149d0affSAndreas Jaekel #pragma pack(1)
82d979f56cSAndreas Jaekel typedef struct zev_inode_info_t {
83d979f56cSAndreas Jaekel 	uint64_t	ino;
84d979f56cSAndreas Jaekel 	uint64_t	gen;
85d979f56cSAndreas Jaekel 	uint64_t	mtime;
86d979f56cSAndreas Jaekel 	uint64_t	ctime;
87d979f56cSAndreas Jaekel 	uint64_t	size;
88d979f56cSAndreas Jaekel 	uint64_t	mode;
89d979f56cSAndreas Jaekel 	uint64_t	links;
90149d0affSAndreas Jaekel 	uint32_t	type;
9119b08257SAndreas Jaekel 	uint32_t	flags;
92d979f56cSAndreas Jaekel } zev_inode_info_t;
93d979f56cSAndreas Jaekel 
94d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
95d979f56cSAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
96d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
97d979f56cSAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
98d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
99d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
100d979f56cSAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
101888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
102205ed6bfSAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
103d979f56cSAndreas Jaekel 
104149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
105149d0affSAndreas Jaekel 	uint32_t		record_len;				\
106149d0affSAndreas Jaekel 	uint32_t		op;					\
107149d0affSAndreas Jaekel 	uint64_t		op_time;				\
108da4b4c3dSAndreas Jaekel 	uint64_t		guid
109149d0affSAndreas Jaekel 
110205ed6bfSAndreas Jaekel typedef struct zev_sig_t {
111205ed6bfSAndreas Jaekel 	uint16_t	level;
112205ed6bfSAndreas Jaekel 	uint16_t	padding1;
113205ed6bfSAndreas Jaekel 	uint32_t	padding2;
114205ed6bfSAndreas Jaekel 	uint64_t	block_offset;
115205ed6bfSAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
116205ed6bfSAndreas Jaekel } zev_sig_t;
117205ed6bfSAndreas Jaekel 
118d979f56cSAndreas Jaekel typedef struct zev_header_t {
119149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
120d979f56cSAndreas Jaekel } zev_header_t;
121d979f56cSAndreas Jaekel 
122d979f56cSAndreas Jaekel typedef struct zev_error_t {
123149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
124d979f56cSAndreas Jaekel 	uint32_t		failed_op;
125d979f56cSAndreas Jaekel 	uint32_t		errstr_len;
126d979f56cSAndreas Jaekel 	/* error string follows */
127d979f56cSAndreas Jaekel } zev_error_t;
128d979f56cSAndreas Jaekel 
129888fea18SAndreas Jaekel typedef struct zev_mark_t {
130888fea18SAndreas Jaekel 	ZEV_COMMON_FIELDS;
131888fea18SAndreas Jaekel 	uint64_t		mark_id;
132888fea18SAndreas Jaekel 	uint32_t		payload_len;
133888fea18SAndreas Jaekel 	uint32_t		padding;
134888fea18SAndreas Jaekel 	/* payload follows */
135888fea18SAndreas Jaekel } zev_mark_t;
136888fea18SAndreas Jaekel 
137d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t {
138149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
13993297ba3SAndreas Jaekel 	zev_inode_info_t	root;
140149d0affSAndreas Jaekel 	uint32_t		remount;
141d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
142d979f56cSAndreas Jaekel 	uint32_t		mountpoint_len;
143149d0affSAndreas Jaekel 	uint32_t		padding;
144d979f56cSAndreas Jaekel 	/* dataset follows */
145d979f56cSAndreas Jaekel 	/* mountpoint follows */
146d979f56cSAndreas Jaekel } zev_zfs_mount_t;
147d979f56cSAndreas Jaekel 
148d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t {
149149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
150d979f56cSAndreas Jaekel } zev_zfs_umount_t;
151d979f56cSAndreas Jaekel 
152d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t {
153149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
15412119a7eSAndreas Jaekel 	uint64_t		txg;
155d979f56cSAndreas Jaekel 	uint64_t		offset;
156d979f56cSAndreas Jaekel 	uint64_t		length;
157d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
158149d0affSAndreas Jaekel 	uint32_t		padding;
159d979f56cSAndreas Jaekel 	/* dataset follows */
160d979f56cSAndreas Jaekel } zev_zvol_truncate_t;
161d979f56cSAndreas Jaekel 
162d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t {
163149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
16412119a7eSAndreas Jaekel 	uint64_t		txg;
165d979f56cSAndreas Jaekel 	uint64_t		offset;
166d979f56cSAndreas Jaekel 	uint64_t		length;
167d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
168149d0affSAndreas Jaekel 	uint32_t		padding;
169d979f56cSAndreas Jaekel 	/* dataset follows */
170d979f56cSAndreas Jaekel } zev_zvol_write_t;
171d979f56cSAndreas Jaekel 
172d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t {
173149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
174d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
175d979f56cSAndreas Jaekel } zev_znode_close_after_update_t;
176d979f56cSAndreas Jaekel 
177d979f56cSAndreas Jaekel typedef struct zev_znode_create_t {
178149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
17912119a7eSAndreas Jaekel 	uint64_t		txg;
180d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
181d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
1822eabeab5SAndreas Jaekel 	zev_sig_t		signature;
183d979f56cSAndreas Jaekel 	uint32_t		name_len;
184149d0affSAndreas Jaekel 	uint32_t		padding;
185d979f56cSAndreas Jaekel 	/* name follows */
186d979f56cSAndreas Jaekel } zev_znode_create_t;
187d979f56cSAndreas Jaekel 
188d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
189d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
190d979f56cSAndreas Jaekel 
191d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t {
192149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
19312119a7eSAndreas Jaekel 	uint64_t		txg;
19497dcf88dSAndreas Jaekel 	zev_inode_info_t	file;
195d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
196d979f56cSAndreas Jaekel 	uint32_t		name_len;
197149d0affSAndreas Jaekel 	uint32_t		padding;
198d979f56cSAndreas Jaekel 	/* name follows */
199d979f56cSAndreas Jaekel } zev_znode_remove_t;
200d979f56cSAndreas Jaekel 
201d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
202d979f56cSAndreas Jaekel 
203d979f56cSAndreas Jaekel typedef struct zev_znode_link_t {
204149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
20512119a7eSAndreas Jaekel 	uint64_t		txg;
206d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
207d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
208d979f56cSAndreas Jaekel 	uint32_t		name_len;
209149d0affSAndreas Jaekel 	uint32_t		padding;
210d979f56cSAndreas Jaekel 	/* new_name follows */
211d979f56cSAndreas Jaekel } zev_znode_link_t;
212d979f56cSAndreas Jaekel 
213d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t {
214149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
21512119a7eSAndreas Jaekel 	uint64_t		txg;
216d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
217d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
2182eabeab5SAndreas Jaekel 	zev_sig_t		signature;
219d979f56cSAndreas Jaekel 	uint32_t		name_len;
220d979f56cSAndreas Jaekel 	uint32_t		link_len;
221d979f56cSAndreas Jaekel 	/* name follows */
222d979f56cSAndreas Jaekel 	/* link follows */
223d979f56cSAndreas Jaekel } zev_znode_symlink_t;
224d979f56cSAndreas Jaekel 
225d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t {
226149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
22712119a7eSAndreas Jaekel 	uint64_t		txg;
228d979f56cSAndreas Jaekel 	zev_inode_info_t	srcdir;
229d979f56cSAndreas Jaekel 	zev_inode_info_t	dstdir;
230d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
231d979f56cSAndreas Jaekel 	uint32_t		srcname_len;
232d979f56cSAndreas Jaekel 	uint32_t		dstname_len;
233d979f56cSAndreas Jaekel 	/* srcname follows */
234d979f56cSAndreas Jaekel 	/* dstname follows */
235d979f56cSAndreas Jaekel } zev_znode_rename_t;
236d979f56cSAndreas Jaekel 
237d979f56cSAndreas Jaekel typedef struct zev_znode_write_t {
238149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
23912119a7eSAndreas Jaekel 	uint64_t		txg;
240d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
241d979f56cSAndreas Jaekel 	uint64_t		offset;
242d979f56cSAndreas Jaekel 	uint64_t		length;
243205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
244205ed6bfSAndreas Jaekel 	/* signatures follow */
245d979f56cSAndreas Jaekel } zev_znode_write_t;
246d979f56cSAndreas Jaekel 
247d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t {
248149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
24912119a7eSAndreas Jaekel 	uint64_t		txg;
250d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
251d979f56cSAndreas Jaekel 	uint64_t		offset;
252d979f56cSAndreas Jaekel 	uint64_t		length;
253205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
254205ed6bfSAndreas Jaekel 	/* signatures follow */
255d979f56cSAndreas Jaekel } zev_znode_truncate_t;
256d979f56cSAndreas Jaekel 
257d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t {
258149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
25912119a7eSAndreas Jaekel 	uint64_t		txg;
260d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
261d979f56cSAndreas Jaekel } zev_znode_setattr_t;
262d979f56cSAndreas Jaekel 
263d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t {
264149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
26512119a7eSAndreas Jaekel 	uint64_t		txg;
266d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
267d979f56cSAndreas Jaekel } zev_znode_acl_t;
268d979f56cSAndreas Jaekel 
269d979f56cSAndreas Jaekel /* convenience helper definition */
270d979f56cSAndreas Jaekel typedef union {
271d979f56cSAndreas Jaekel 	zev_header_t				header;
272d979f56cSAndreas Jaekel 
273888fea18SAndreas Jaekel 	zev_error_t				error;
274888fea18SAndreas Jaekel 	zev_mark_t				mark;
275d979f56cSAndreas Jaekel 	union {
276d979f56cSAndreas Jaekel 		zev_zfs_mount_t			mount;
277d979f56cSAndreas Jaekel 		zev_zfs_umount_t		umount;
278d979f56cSAndreas Jaekel 	} zfs;
279d979f56cSAndreas Jaekel 	union {
280d979f56cSAndreas Jaekel 		zev_zvol_truncate_t		truncate;
281d979f56cSAndreas Jaekel 		zev_zvol_write_t		write;
282d979f56cSAndreas Jaekel 	} zvol;
283d979f56cSAndreas Jaekel 	union {
284d979f56cSAndreas Jaekel 		zev_znode_close_after_update_t	close;
285d979f56cSAndreas Jaekel 		zev_znode_create_t		create;
286d979f56cSAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
287d979f56cSAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
288d979f56cSAndreas Jaekel 		zev_znode_remove_t		remove;
289d979f56cSAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
290d979f56cSAndreas Jaekel 		zev_znode_link_t		link;
291d979f56cSAndreas Jaekel 		zev_znode_symlink_t		symlink;
292d979f56cSAndreas Jaekel 		zev_znode_rename_t		rename;
293d979f56cSAndreas Jaekel 		zev_znode_write_t		write;
294d979f56cSAndreas Jaekel 		zev_znode_truncate_t		truncate;
295d979f56cSAndreas Jaekel 		zev_znode_setattr_t		setattr;
296d979f56cSAndreas Jaekel 		zev_znode_acl_t			acl;
297d979f56cSAndreas Jaekel 	} znode;
298d979f56cSAndreas Jaekel } zev_event_t;
299d979f56cSAndreas Jaekel 
300d979f56cSAndreas Jaekel 
301a18c35b9SAndreas Jaekel 
302a18c35b9SAndreas Jaekel typedef struct zev_statistics_t {
303a18c35b9SAndreas Jaekel 	uint64_t	zev_queue_len;
304a18c35b9SAndreas Jaekel 	uint64_t	zev_bytes_read;
305add9520fSAndreas Jaekel 	uint64_t	zev_bytes_discarded;
306fec460f8SAndreas Jaekel 	/* runtime settings */
307fec460f8SAndreas Jaekel 	uint64_t	zev_max_queue_len;
308a18c35b9SAndreas Jaekel 	/* counters */
309a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
310add9520fSAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
311a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_errors;
312888fea18SAndreas Jaekel 	uint64_t	zev_cnt_marks;
313a18c35b9SAndreas Jaekel 	/* zfsvfs ops */
314a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
315a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
316a18c35b9SAndreas Jaekel 	/* zvol ops */
317a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
318a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
319a18c35b9SAndreas Jaekel 	/* znode ops */
320a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
321a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
322a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
323a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
324a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
325a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
326a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
327a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
328a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
329a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
330a18c35b9SAndreas Jaekel } zev_statistics_t;
331a18c35b9SAndreas Jaekel 
332add9520fSAndreas Jaekel typedef struct zev_queue_name {
333add9520fSAndreas Jaekel 	uint64_t		zev_namelen;
334add9520fSAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
335add9520fSAndreas Jaekel } zev_queue_name_t;
336add9520fSAndreas Jaekel 
337a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg {
338a18c35b9SAndreas Jaekel 	uint64_t	zev_poolname_len;
339a18c35b9SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
340a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t;
341888fea18SAndreas Jaekel 
342888fea18SAndreas Jaekel typedef struct zev_ioctl_mark {
343888fea18SAndreas Jaekel 	uint64_t	zev_mark_id;
344888fea18SAndreas Jaekel 	uint64_t	zev_guid;
345888fea18SAndreas Jaekel 	uint32_t	zev_payload_len;
346808a670aSAndreas Jaekel 	uint32_t	padding;
347888fea18SAndreas Jaekel 	/* payload follows */
348888fea18SAndreas Jaekel } zev_ioctl_mark_t;
34935d4e8ddSAndreas Jaekel 
35035d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen {
35135d4e8ddSAndreas Jaekel 	/* input */
35235d4e8ddSAndreas Jaekel 	uint64_t	inode;
35335d4e8ddSAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
35435d4e8ddSAndreas Jaekel 	/* noput */
35535d4e8ddSAndreas Jaekel 	uint32_t	padding;
35635d4e8ddSAndreas Jaekel 	/* output */
35735d4e8ddSAndreas Jaekel 	uint64_t	generation;
35835d4e8ddSAndreas Jaekel 	uint64_t	crtime;
35935d4e8ddSAndreas Jaekel 	uint64_t	guid;
36035d4e8ddSAndreas Jaekel 	char		dataset[MAXPATHLEN];
36135d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t;
362add9520fSAndreas Jaekel 
363add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
364add9520fSAndreas Jaekel 	uint64_t		zev_max_queue_len;
365add9520fSAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
366add9520fSAndreas Jaekel 	uint16_t		zev_flags;
3676a6a51eeSAndreas Jaekel 	uint16_t		padding1;
3686a6a51eeSAndreas Jaekel 	uint32_t		padding2;
3696a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
370add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t;
371add9520fSAndreas Jaekel 
372add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
373add9520fSAndreas Jaekel 
374add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue {
375add9520fSAndreas Jaekel 	uint64_t	zev_max_queue_len;
376add9520fSAndreas Jaekel 	uint32_t	padding;
377add9520fSAndreas Jaekel 	uint16_t	zev_flags;
378add9520fSAndreas Jaekel 	uint16_t	zev_namelen;
379add9520fSAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
380add9520fSAndreas Jaekel } zev_ioctl_add_queue_t;
381add9520fSAndreas Jaekel 
382add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3836a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
384add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t;
385add9520fSAndreas Jaekel 
386add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3876a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
388add9520fSAndreas Jaekel 	zev_statistics_t	zev_statistics;
389add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
390add9520fSAndreas Jaekel 
391add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info {
392add9520fSAndreas Jaekel 	uint64_t	zev_memory_allocated;
393205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
394205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
395205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
396add9520fSAndreas Jaekel } zev_ioctl_debug_info_t;
397add9520fSAndreas Jaekel 
398add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
399add9520fSAndreas Jaekel 	uint64_t		zev_n_queues;
400add9520fSAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
401add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t;
402add9520fSAndreas Jaekel 
40342110aacSAndreas Jaekel typedef struct zev_ioctl_get_signatures {
40442110aacSAndreas Jaekel 	/* in */
40542110aacSAndreas Jaekel 	uint64_t	zev_offset;
40642110aacSAndreas Jaekel 	uint64_t	zev_len;
40742110aacSAndreas Jaekel 	uint32_t	zev_fd;
40842110aacSAndreas Jaekel 	uint32_t	zev_bufsize;
40942110aacSAndreas Jaekel 	/* out */
41042110aacSAndreas Jaekel 	uint64_t	zev_signature_cnt;
41142110aacSAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
41242110aacSAndreas Jaekel } zev_ioctl_get_signatures_t;
41342110aacSAndreas Jaekel 
414149d0affSAndreas Jaekel #pragma pack()
415a18c35b9SAndreas Jaekel 
416a18c35b9SAndreas Jaekel #ifdef _KERNEL
417add9520fSAndreas Jaekel 
418add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated;
419add9520fSAndreas Jaekel extern uint64_t zev_memory_freed;
420add9520fSAndreas Jaekel 
421add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
422add9520fSAndreas Jaekel 	do {								\
423add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
424add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
425add9520fSAndreas Jaekel 	} while(0)
426add9520fSAndreas Jaekel 
427add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
428add9520fSAndreas Jaekel 	do {								\
429add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
430add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
431add9520fSAndreas Jaekel 	} while(0)
432add9520fSAndreas Jaekel 
433205ed6bfSAndreas Jaekel void *zev_alloc(ssize_t sz);
434205ed6bfSAndreas Jaekel void *zev_zalloc(ssize_t sz);
435205ed6bfSAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
436add9520fSAndreas Jaekel 
437d979f56cSAndreas Jaekel typedef struct zev_msg_t {
438d979f56cSAndreas Jaekel 	struct zev_msg_t	*next;
439add9520fSAndreas Jaekel 	struct zev_msg_t	*prev;
440add9520fSAndreas Jaekel 	uint64_t		 seq;
441add9520fSAndreas Jaekel 	uint16_t		 size;
442add9520fSAndreas Jaekel 	uint16_t		 read;
443d979f56cSAndreas Jaekel 	/* data follows */
444d979f56cSAndreas Jaekel } zev_msg_t;
445d979f56cSAndreas Jaekel 
446d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
447d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
448d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
449a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os);
450d979f56cSAndreas Jaekel 
451a18c35b9SAndreas Jaekel #endif
452a18c35b9SAndreas Jaekel 
453a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */
454a18c35b9SAndreas Jaekel 
455