xref: /titanic_44/usr/src/common/zev/zev.h (revision 42110aac12a7eb29e11eafc411d572e0ada84d12)
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 */
43*42110aacSAndreas 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
73add9520fSAndreas Jaekel 
74*42110aacSAndreas Jaekel /* checksum block sizes */
75*42110aacSAndreas Jaekel #define ZEV_L0_SIZE	4096
76*42110aacSAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
7719b08257SAndreas Jaekel 
78d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */
79d979f56cSAndreas Jaekel 
80149d0affSAndreas Jaekel #pragma pack(1)
81d979f56cSAndreas Jaekel typedef struct zev_inode_info_t {
82d979f56cSAndreas Jaekel 	uint64_t	ino;
83d979f56cSAndreas Jaekel 	uint64_t	gen;
84d979f56cSAndreas Jaekel 	uint64_t	mtime;
85d979f56cSAndreas Jaekel 	uint64_t	ctime;
86d979f56cSAndreas Jaekel 	uint64_t	size;
87d979f56cSAndreas Jaekel 	uint64_t	mode;
88d979f56cSAndreas Jaekel 	uint64_t	links;
89149d0affSAndreas Jaekel 	uint32_t	type;
9019b08257SAndreas Jaekel 	uint32_t	flags;
91d979f56cSAndreas Jaekel } zev_inode_info_t;
92d979f56cSAndreas Jaekel 
93d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
94d979f56cSAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
95d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
96d979f56cSAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
97d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
98d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
99d979f56cSAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
100888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
101205ed6bfSAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
102d979f56cSAndreas Jaekel 
103149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS						\
104149d0affSAndreas Jaekel 	uint32_t		record_len;				\
105149d0affSAndreas Jaekel 	uint32_t		op;					\
106149d0affSAndreas Jaekel 	uint64_t		op_time;				\
107da4b4c3dSAndreas Jaekel 	uint64_t		guid
108149d0affSAndreas Jaekel 
109205ed6bfSAndreas Jaekel typedef struct zev_sig_t {
110205ed6bfSAndreas Jaekel 	uint16_t	level;
111205ed6bfSAndreas Jaekel 	uint16_t	padding1;
112205ed6bfSAndreas Jaekel 	uint32_t	padding2;
113205ed6bfSAndreas Jaekel 	uint64_t	block_offset;
114205ed6bfSAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
115205ed6bfSAndreas Jaekel } zev_sig_t;
116205ed6bfSAndreas Jaekel 
117d979f56cSAndreas Jaekel typedef struct zev_header_t {
118149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
119d979f56cSAndreas Jaekel } zev_header_t;
120d979f56cSAndreas Jaekel 
121d979f56cSAndreas Jaekel typedef struct zev_error_t {
122149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
123d979f56cSAndreas Jaekel 	uint32_t		failed_op;
124d979f56cSAndreas Jaekel 	uint32_t		errstr_len;
125d979f56cSAndreas Jaekel 	/* error string follows */
126d979f56cSAndreas Jaekel } zev_error_t;
127d979f56cSAndreas Jaekel 
128888fea18SAndreas Jaekel typedef struct zev_mark_t {
129888fea18SAndreas Jaekel 	ZEV_COMMON_FIELDS;
130888fea18SAndreas Jaekel 	uint64_t		mark_id;
131888fea18SAndreas Jaekel 	uint32_t		payload_len;
132888fea18SAndreas Jaekel 	uint32_t		padding;
133888fea18SAndreas Jaekel 	/* payload follows */
134888fea18SAndreas Jaekel } zev_mark_t;
135888fea18SAndreas Jaekel 
136d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t {
137149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
13893297ba3SAndreas Jaekel 	zev_inode_info_t	root;
139149d0affSAndreas Jaekel 	uint32_t		remount;
140d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
141d979f56cSAndreas Jaekel 	uint32_t		mountpoint_len;
142149d0affSAndreas Jaekel 	uint32_t		padding;
143d979f56cSAndreas Jaekel 	/* dataset follows */
144d979f56cSAndreas Jaekel 	/* mountpoint follows */
145d979f56cSAndreas Jaekel } zev_zfs_mount_t;
146d979f56cSAndreas Jaekel 
147d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t {
148149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
149d979f56cSAndreas Jaekel } zev_zfs_umount_t;
150d979f56cSAndreas Jaekel 
151d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t {
152149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
153d979f56cSAndreas Jaekel 	uint64_t		offset;
154d979f56cSAndreas Jaekel 	uint64_t		length;
155d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
156149d0affSAndreas Jaekel 	uint32_t		padding;
157d979f56cSAndreas Jaekel 	/* dataset follows */
158d979f56cSAndreas Jaekel } zev_zvol_truncate_t;
159d979f56cSAndreas Jaekel 
160d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t {
161149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
162d979f56cSAndreas Jaekel 	uint64_t		offset;
163d979f56cSAndreas Jaekel 	uint64_t		length;
164d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
165149d0affSAndreas Jaekel 	uint32_t		padding;
166d979f56cSAndreas Jaekel 	/* dataset follows */
167d979f56cSAndreas Jaekel } zev_zvol_write_t;
168d979f56cSAndreas Jaekel 
169d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t {
170149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
171d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
172d979f56cSAndreas Jaekel } zev_znode_close_after_update_t;
173d979f56cSAndreas Jaekel 
174d979f56cSAndreas Jaekel typedef struct zev_znode_create_t {
175149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
176d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
177d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
178d979f56cSAndreas Jaekel 	uint32_t		name_len;
179149d0affSAndreas Jaekel 	uint32_t		padding;
180d979f56cSAndreas Jaekel 	/* name follows */
181d979f56cSAndreas Jaekel } zev_znode_create_t;
182d979f56cSAndreas Jaekel 
183d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
184d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
185d979f56cSAndreas Jaekel 
186d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t {
187149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
18897dcf88dSAndreas Jaekel 	zev_inode_info_t	file;
189d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
190d979f56cSAndreas Jaekel 	uint32_t		name_len;
191149d0affSAndreas Jaekel 	uint32_t		padding;
192d979f56cSAndreas Jaekel 	/* name follows */
193d979f56cSAndreas Jaekel } zev_znode_remove_t;
194d979f56cSAndreas Jaekel 
195d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
196d979f56cSAndreas Jaekel 
197d979f56cSAndreas Jaekel typedef struct zev_znode_link_t {
198149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
199d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
200d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
201d979f56cSAndreas Jaekel 	uint32_t		name_len;
202149d0affSAndreas Jaekel 	uint32_t		padding;
203d979f56cSAndreas Jaekel 	/* new_name follows */
204d979f56cSAndreas Jaekel } zev_znode_link_t;
205d979f56cSAndreas Jaekel 
206d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t {
207149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
208d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
209d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
210d979f56cSAndreas Jaekel 	uint32_t		name_len;
211d979f56cSAndreas Jaekel 	uint32_t		link_len;
212d979f56cSAndreas Jaekel 	/* name follows */
213d979f56cSAndreas Jaekel 	/* link follows */
214d979f56cSAndreas Jaekel } zev_znode_symlink_t;
215d979f56cSAndreas Jaekel 
216d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t {
217149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
218d979f56cSAndreas Jaekel 	zev_inode_info_t	srcdir;
219d979f56cSAndreas Jaekel 	zev_inode_info_t	dstdir;
220d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
221d979f56cSAndreas Jaekel 	uint32_t		srcname_len;
222d979f56cSAndreas Jaekel 	uint32_t		dstname_len;
223d979f56cSAndreas Jaekel 	/* srcname follows */
224d979f56cSAndreas Jaekel 	/* dstname follows */
225d979f56cSAndreas Jaekel } zev_znode_rename_t;
226d979f56cSAndreas Jaekel 
227d979f56cSAndreas Jaekel typedef struct zev_znode_write_t {
228149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
229d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
230d979f56cSAndreas Jaekel 	uint64_t		offset;
231d979f56cSAndreas Jaekel 	uint64_t		length;
232205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
233205ed6bfSAndreas Jaekel 	/* signatures follow */
234d979f56cSAndreas Jaekel } zev_znode_write_t;
235d979f56cSAndreas Jaekel 
236d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t {
237149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
238d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
239d979f56cSAndreas Jaekel 	uint64_t		offset;
240d979f56cSAndreas Jaekel 	uint64_t		length;
241205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
242205ed6bfSAndreas Jaekel 	/* signatures follow */
243d979f56cSAndreas Jaekel } zev_znode_truncate_t;
244d979f56cSAndreas Jaekel 
245d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t {
246149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
247d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
248d979f56cSAndreas Jaekel } zev_znode_setattr_t;
249d979f56cSAndreas Jaekel 
250d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t {
251149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
252d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
253d979f56cSAndreas Jaekel } zev_znode_acl_t;
254d979f56cSAndreas Jaekel 
255d979f56cSAndreas Jaekel /* convenience helper definition */
256d979f56cSAndreas Jaekel typedef union {
257d979f56cSAndreas Jaekel 	zev_header_t				header;
258d979f56cSAndreas Jaekel 
259888fea18SAndreas Jaekel 	zev_error_t				error;
260888fea18SAndreas Jaekel 	zev_mark_t				mark;
261d979f56cSAndreas Jaekel 	union {
262d979f56cSAndreas Jaekel 		zev_zfs_mount_t			mount;
263d979f56cSAndreas Jaekel 		zev_zfs_umount_t		umount;
264d979f56cSAndreas Jaekel 	} zfs;
265d979f56cSAndreas Jaekel 	union {
266d979f56cSAndreas Jaekel 		zev_zvol_truncate_t		truncate;
267d979f56cSAndreas Jaekel 		zev_zvol_write_t		write;
268d979f56cSAndreas Jaekel 	} zvol;
269d979f56cSAndreas Jaekel 	union {
270d979f56cSAndreas Jaekel 		zev_znode_close_after_update_t	close;
271d979f56cSAndreas Jaekel 		zev_znode_create_t		create;
272d979f56cSAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
273d979f56cSAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
274d979f56cSAndreas Jaekel 		zev_znode_remove_t		remove;
275d979f56cSAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
276d979f56cSAndreas Jaekel 		zev_znode_link_t		link;
277d979f56cSAndreas Jaekel 		zev_znode_symlink_t		symlink;
278d979f56cSAndreas Jaekel 		zev_znode_rename_t		rename;
279d979f56cSAndreas Jaekel 		zev_znode_write_t		write;
280d979f56cSAndreas Jaekel 		zev_znode_truncate_t		truncate;
281d979f56cSAndreas Jaekel 		zev_znode_setattr_t		setattr;
282d979f56cSAndreas Jaekel 		zev_znode_acl_t			acl;
283d979f56cSAndreas Jaekel 	} znode;
284d979f56cSAndreas Jaekel } zev_event_t;
285d979f56cSAndreas Jaekel 
286d979f56cSAndreas Jaekel 
287a18c35b9SAndreas Jaekel 
288a18c35b9SAndreas Jaekel typedef struct zev_statistics_t {
289a18c35b9SAndreas Jaekel 	uint64_t	zev_queue_len;
290a18c35b9SAndreas Jaekel 	uint64_t	zev_bytes_read;
291add9520fSAndreas Jaekel 	uint64_t	zev_bytes_discarded;
292fec460f8SAndreas Jaekel 	/* runtime settings */
293fec460f8SAndreas Jaekel 	uint64_t	zev_max_queue_len;
294a18c35b9SAndreas Jaekel 	/* counters */
295a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
296add9520fSAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
297a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_errors;
298888fea18SAndreas Jaekel 	uint64_t	zev_cnt_marks;
299a18c35b9SAndreas Jaekel 	/* zfsvfs ops */
300a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
301a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
302a18c35b9SAndreas Jaekel 	/* zvol ops */
303a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
304a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
305a18c35b9SAndreas Jaekel 	/* znode ops */
306a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
307a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
308a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
309a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
310a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
311a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
312a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
313a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
314a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
315a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
316a18c35b9SAndreas Jaekel } zev_statistics_t;
317a18c35b9SAndreas Jaekel 
318add9520fSAndreas Jaekel typedef struct zev_queue_name {
319add9520fSAndreas Jaekel 	uint64_t		zev_namelen;
320add9520fSAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
321add9520fSAndreas Jaekel } zev_queue_name_t;
322add9520fSAndreas Jaekel 
323a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg {
324a18c35b9SAndreas Jaekel 	uint64_t	zev_poolname_len;
325a18c35b9SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
326a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t;
327888fea18SAndreas Jaekel 
328888fea18SAndreas Jaekel typedef struct zev_ioctl_mark {
329888fea18SAndreas Jaekel 	uint64_t	zev_mark_id;
330888fea18SAndreas Jaekel 	uint64_t	zev_guid;
331888fea18SAndreas Jaekel 	uint32_t	zev_payload_len;
332808a670aSAndreas Jaekel 	uint32_t	padding;
333888fea18SAndreas Jaekel 	/* payload follows */
334888fea18SAndreas Jaekel } zev_ioctl_mark_t;
33535d4e8ddSAndreas Jaekel 
33635d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen {
33735d4e8ddSAndreas Jaekel 	/* input */
33835d4e8ddSAndreas Jaekel 	uint64_t	inode;
33935d4e8ddSAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
34035d4e8ddSAndreas Jaekel 	/* noput */
34135d4e8ddSAndreas Jaekel 	uint32_t	padding;
34235d4e8ddSAndreas Jaekel 	/* output */
34335d4e8ddSAndreas Jaekel 	uint64_t	generation;
34435d4e8ddSAndreas Jaekel 	uint64_t	crtime;
34535d4e8ddSAndreas Jaekel 	uint64_t	guid;
34635d4e8ddSAndreas Jaekel 	char		dataset[MAXPATHLEN];
34735d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t;
348add9520fSAndreas Jaekel 
349add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
350add9520fSAndreas Jaekel 	uint64_t		zev_max_queue_len;
351add9520fSAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
352add9520fSAndreas Jaekel 	uint16_t		zev_flags;
3536a6a51eeSAndreas Jaekel 	uint16_t		padding1;
3546a6a51eeSAndreas Jaekel 	uint32_t		padding2;
3556a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
356add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t;
357add9520fSAndreas Jaekel 
358add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
359add9520fSAndreas Jaekel 
360add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue {
361add9520fSAndreas Jaekel 	uint64_t	zev_max_queue_len;
362add9520fSAndreas Jaekel 	uint32_t	padding;
363add9520fSAndreas Jaekel 	uint16_t	zev_flags;
364add9520fSAndreas Jaekel 	uint16_t	zev_namelen;
365add9520fSAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
366add9520fSAndreas Jaekel } zev_ioctl_add_queue_t;
367add9520fSAndreas Jaekel 
368add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3696a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
370add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t;
371add9520fSAndreas Jaekel 
372add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3736a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
374add9520fSAndreas Jaekel 	zev_statistics_t	zev_statistics;
375add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
376add9520fSAndreas Jaekel 
377add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info {
378add9520fSAndreas Jaekel 	uint64_t	zev_memory_allocated;
379205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
380205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
381205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
382add9520fSAndreas Jaekel } zev_ioctl_debug_info_t;
383add9520fSAndreas Jaekel 
384add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
385add9520fSAndreas Jaekel 	uint64_t		zev_n_queues;
386add9520fSAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
387add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t;
388add9520fSAndreas Jaekel 
389*42110aacSAndreas Jaekel typedef struct zev_ioctl_get_signatures {
390*42110aacSAndreas Jaekel 	/* in */
391*42110aacSAndreas Jaekel 	uint64_t	zev_offset;
392*42110aacSAndreas Jaekel 	uint64_t	zev_len;
393*42110aacSAndreas Jaekel 	uint32_t	zev_fd;
394*42110aacSAndreas Jaekel 	uint32_t	zev_bufsize;
395*42110aacSAndreas Jaekel 	/* out */
396*42110aacSAndreas Jaekel 	uint64_t	zev_signature_cnt;
397*42110aacSAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
398*42110aacSAndreas Jaekel } zev_ioctl_get_signatures_t;
399*42110aacSAndreas Jaekel 
400149d0affSAndreas Jaekel #pragma pack()
401a18c35b9SAndreas Jaekel 
402a18c35b9SAndreas Jaekel #ifdef _KERNEL
403add9520fSAndreas Jaekel 
404add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated;
405add9520fSAndreas Jaekel extern uint64_t zev_memory_freed;
406add9520fSAndreas Jaekel 
407add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
408add9520fSAndreas Jaekel 	do {								\
409add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
410add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
411add9520fSAndreas Jaekel 	} while(0)
412add9520fSAndreas Jaekel 
413add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
414add9520fSAndreas Jaekel 	do {								\
415add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
416add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
417add9520fSAndreas Jaekel 	} while(0)
418add9520fSAndreas Jaekel 
419205ed6bfSAndreas Jaekel void *zev_alloc(ssize_t sz);
420205ed6bfSAndreas Jaekel void *zev_zalloc(ssize_t sz);
421205ed6bfSAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
422add9520fSAndreas Jaekel 
423d979f56cSAndreas Jaekel typedef struct zev_msg_t {
424d979f56cSAndreas Jaekel 	struct zev_msg_t	*next;
425add9520fSAndreas Jaekel 	struct zev_msg_t	*prev;
426add9520fSAndreas Jaekel 	uint64_t		 seq;
427add9520fSAndreas Jaekel 	uint16_t		 size;
428add9520fSAndreas Jaekel 	uint16_t		 read;
429d979f56cSAndreas Jaekel 	/* data follows */
430d979f56cSAndreas Jaekel } zev_msg_t;
431d979f56cSAndreas Jaekel 
432d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
433d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
434d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
435a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os);
436d979f56cSAndreas Jaekel 
437a18c35b9SAndreas Jaekel #endif
438a18c35b9SAndreas Jaekel 
439a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */
440a18c35b9SAndreas Jaekel 
441