xref: /titanic_44/usr/src/common/zev/zev.h (revision 12119a7ecb15c0fc9740c9331d2800dc932c8060)
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
73add9520fSAndreas Jaekel 
7442110aacSAndreas Jaekel /* checksum block sizes */
7542110aacSAndreas Jaekel #define ZEV_L0_SIZE	4096
7642110aacSAndreas 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;
153*12119a7eSAndreas Jaekel 	uint64_t		txg;
154d979f56cSAndreas Jaekel 	uint64_t		offset;
155d979f56cSAndreas Jaekel 	uint64_t		length;
156d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
157149d0affSAndreas Jaekel 	uint32_t		padding;
158d979f56cSAndreas Jaekel 	/* dataset follows */
159d979f56cSAndreas Jaekel } zev_zvol_truncate_t;
160d979f56cSAndreas Jaekel 
161d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t {
162149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
163*12119a7eSAndreas Jaekel 	uint64_t		txg;
164d979f56cSAndreas Jaekel 	uint64_t		offset;
165d979f56cSAndreas Jaekel 	uint64_t		length;
166d979f56cSAndreas Jaekel 	uint32_t		dataset_len;
167149d0affSAndreas Jaekel 	uint32_t		padding;
168d979f56cSAndreas Jaekel 	/* dataset follows */
169d979f56cSAndreas Jaekel } zev_zvol_write_t;
170d979f56cSAndreas Jaekel 
171d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t {
172149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
173d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
174d979f56cSAndreas Jaekel } zev_znode_close_after_update_t;
175d979f56cSAndreas Jaekel 
176d979f56cSAndreas Jaekel typedef struct zev_znode_create_t {
177149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
178*12119a7eSAndreas Jaekel 	uint64_t		txg;
179d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
180d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
181d979f56cSAndreas Jaekel 	uint32_t		name_len;
182149d0affSAndreas Jaekel 	uint32_t		padding;
183d979f56cSAndreas Jaekel 	/* name follows */
184d979f56cSAndreas Jaekel } zev_znode_create_t;
185d979f56cSAndreas Jaekel 
186d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
187d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
188d979f56cSAndreas Jaekel 
189d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t {
190149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
191*12119a7eSAndreas Jaekel 	uint64_t		txg;
19297dcf88dSAndreas Jaekel 	zev_inode_info_t	file;
193d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
194d979f56cSAndreas Jaekel 	uint32_t		name_len;
195149d0affSAndreas Jaekel 	uint32_t		padding;
196d979f56cSAndreas Jaekel 	/* name follows */
197d979f56cSAndreas Jaekel } zev_znode_remove_t;
198d979f56cSAndreas Jaekel 
199d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
200d979f56cSAndreas Jaekel 
201d979f56cSAndreas Jaekel typedef struct zev_znode_link_t {
202149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
203*12119a7eSAndreas Jaekel 	uint64_t		txg;
204d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
205d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
206d979f56cSAndreas Jaekel 	uint32_t		name_len;
207149d0affSAndreas Jaekel 	uint32_t		padding;
208d979f56cSAndreas Jaekel 	/* new_name follows */
209d979f56cSAndreas Jaekel } zev_znode_link_t;
210d979f56cSAndreas Jaekel 
211d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t {
212149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
213*12119a7eSAndreas Jaekel 	uint64_t		txg;
214d979f56cSAndreas Jaekel 	zev_inode_info_t	parent;
215d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
216d979f56cSAndreas Jaekel 	uint32_t		name_len;
217d979f56cSAndreas Jaekel 	uint32_t		link_len;
218d979f56cSAndreas Jaekel 	/* name follows */
219d979f56cSAndreas Jaekel 	/* link follows */
220d979f56cSAndreas Jaekel } zev_znode_symlink_t;
221d979f56cSAndreas Jaekel 
222d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t {
223149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
224*12119a7eSAndreas Jaekel 	uint64_t		txg;
225d979f56cSAndreas Jaekel 	zev_inode_info_t	srcdir;
226d979f56cSAndreas Jaekel 	zev_inode_info_t	dstdir;
227d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
228d979f56cSAndreas Jaekel 	uint32_t		srcname_len;
229d979f56cSAndreas Jaekel 	uint32_t		dstname_len;
230d979f56cSAndreas Jaekel 	/* srcname follows */
231d979f56cSAndreas Jaekel 	/* dstname follows */
232d979f56cSAndreas Jaekel } zev_znode_rename_t;
233d979f56cSAndreas Jaekel 
234d979f56cSAndreas Jaekel typedef struct zev_znode_write_t {
235149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
236*12119a7eSAndreas Jaekel 	uint64_t		txg;
237d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
238d979f56cSAndreas Jaekel 	uint64_t		offset;
239d979f56cSAndreas Jaekel 	uint64_t		length;
240205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
241205ed6bfSAndreas Jaekel 	/* signatures follow */
242d979f56cSAndreas Jaekel } zev_znode_write_t;
243d979f56cSAndreas Jaekel 
244d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t {
245149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
246*12119a7eSAndreas Jaekel 	uint64_t		txg;
247d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
248d979f56cSAndreas Jaekel 	uint64_t		offset;
249d979f56cSAndreas Jaekel 	uint64_t		length;
250205ed6bfSAndreas Jaekel 	uint64_t		signature_cnt;
251205ed6bfSAndreas Jaekel 	/* signatures follow */
252d979f56cSAndreas Jaekel } zev_znode_truncate_t;
253d979f56cSAndreas Jaekel 
254d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t {
255149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
256*12119a7eSAndreas Jaekel 	uint64_t		txg;
257d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
258d979f56cSAndreas Jaekel } zev_znode_setattr_t;
259d979f56cSAndreas Jaekel 
260d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t {
261149d0affSAndreas Jaekel 	ZEV_COMMON_FIELDS;
262*12119a7eSAndreas Jaekel 	uint64_t		txg;
263d979f56cSAndreas Jaekel 	zev_inode_info_t	file;
264d979f56cSAndreas Jaekel } zev_znode_acl_t;
265d979f56cSAndreas Jaekel 
266d979f56cSAndreas Jaekel /* convenience helper definition */
267d979f56cSAndreas Jaekel typedef union {
268d979f56cSAndreas Jaekel 	zev_header_t				header;
269d979f56cSAndreas Jaekel 
270888fea18SAndreas Jaekel 	zev_error_t				error;
271888fea18SAndreas Jaekel 	zev_mark_t				mark;
272d979f56cSAndreas Jaekel 	union {
273d979f56cSAndreas Jaekel 		zev_zfs_mount_t			mount;
274d979f56cSAndreas Jaekel 		zev_zfs_umount_t		umount;
275d979f56cSAndreas Jaekel 	} zfs;
276d979f56cSAndreas Jaekel 	union {
277d979f56cSAndreas Jaekel 		zev_zvol_truncate_t		truncate;
278d979f56cSAndreas Jaekel 		zev_zvol_write_t		write;
279d979f56cSAndreas Jaekel 	} zvol;
280d979f56cSAndreas Jaekel 	union {
281d979f56cSAndreas Jaekel 		zev_znode_close_after_update_t	close;
282d979f56cSAndreas Jaekel 		zev_znode_create_t		create;
283d979f56cSAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
284d979f56cSAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
285d979f56cSAndreas Jaekel 		zev_znode_remove_t		remove;
286d979f56cSAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
287d979f56cSAndreas Jaekel 		zev_znode_link_t		link;
288d979f56cSAndreas Jaekel 		zev_znode_symlink_t		symlink;
289d979f56cSAndreas Jaekel 		zev_znode_rename_t		rename;
290d979f56cSAndreas Jaekel 		zev_znode_write_t		write;
291d979f56cSAndreas Jaekel 		zev_znode_truncate_t		truncate;
292d979f56cSAndreas Jaekel 		zev_znode_setattr_t		setattr;
293d979f56cSAndreas Jaekel 		zev_znode_acl_t			acl;
294d979f56cSAndreas Jaekel 	} znode;
295d979f56cSAndreas Jaekel } zev_event_t;
296d979f56cSAndreas Jaekel 
297d979f56cSAndreas Jaekel 
298a18c35b9SAndreas Jaekel 
299a18c35b9SAndreas Jaekel typedef struct zev_statistics_t {
300a18c35b9SAndreas Jaekel 	uint64_t	zev_queue_len;
301a18c35b9SAndreas Jaekel 	uint64_t	zev_bytes_read;
302add9520fSAndreas Jaekel 	uint64_t	zev_bytes_discarded;
303fec460f8SAndreas Jaekel 	/* runtime settings */
304fec460f8SAndreas Jaekel 	uint64_t	zev_max_queue_len;
305a18c35b9SAndreas Jaekel 	/* counters */
306a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_total_events;
307add9520fSAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
308a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_errors;
309888fea18SAndreas Jaekel 	uint64_t	zev_cnt_marks;
310a18c35b9SAndreas Jaekel 	/* zfsvfs ops */
311a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
312a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
313a18c35b9SAndreas Jaekel 	/* zvol ops */
314a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
315a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
316a18c35b9SAndreas Jaekel 	/* znode ops */
317a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
318a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
319a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
320a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
321a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
322a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
323a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
324a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
325a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
326a18c35b9SAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
327a18c35b9SAndreas Jaekel } zev_statistics_t;
328a18c35b9SAndreas Jaekel 
329add9520fSAndreas Jaekel typedef struct zev_queue_name {
330add9520fSAndreas Jaekel 	uint64_t		zev_namelen;
331add9520fSAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
332add9520fSAndreas Jaekel } zev_queue_name_t;
333add9520fSAndreas Jaekel 
334a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg {
335a18c35b9SAndreas Jaekel 	uint64_t	zev_poolname_len;
336a18c35b9SAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
337a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t;
338888fea18SAndreas Jaekel 
339888fea18SAndreas Jaekel typedef struct zev_ioctl_mark {
340888fea18SAndreas Jaekel 	uint64_t	zev_mark_id;
341888fea18SAndreas Jaekel 	uint64_t	zev_guid;
342888fea18SAndreas Jaekel 	uint32_t	zev_payload_len;
343808a670aSAndreas Jaekel 	uint32_t	padding;
344888fea18SAndreas Jaekel 	/* payload follows */
345888fea18SAndreas Jaekel } zev_ioctl_mark_t;
34635d4e8ddSAndreas Jaekel 
34735d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen {
34835d4e8ddSAndreas Jaekel 	/* input */
34935d4e8ddSAndreas Jaekel 	uint64_t	inode;
35035d4e8ddSAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
35135d4e8ddSAndreas Jaekel 	/* noput */
35235d4e8ddSAndreas Jaekel 	uint32_t	padding;
35335d4e8ddSAndreas Jaekel 	/* output */
35435d4e8ddSAndreas Jaekel 	uint64_t	generation;
35535d4e8ddSAndreas Jaekel 	uint64_t	crtime;
35635d4e8ddSAndreas Jaekel 	uint64_t	guid;
35735d4e8ddSAndreas Jaekel 	char		dataset[MAXPATHLEN];
35835d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t;
359add9520fSAndreas Jaekel 
360add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
361add9520fSAndreas Jaekel 	uint64_t		zev_max_queue_len;
362add9520fSAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
363add9520fSAndreas Jaekel 	uint16_t		zev_flags;
3646a6a51eeSAndreas Jaekel 	uint16_t		padding1;
3656a6a51eeSAndreas Jaekel 	uint32_t		padding2;
3666a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
367add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t;
368add9520fSAndreas Jaekel 
369add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
370add9520fSAndreas Jaekel 
371add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue {
372add9520fSAndreas Jaekel 	uint64_t	zev_max_queue_len;
373add9520fSAndreas Jaekel 	uint32_t	padding;
374add9520fSAndreas Jaekel 	uint16_t	zev_flags;
375add9520fSAndreas Jaekel 	uint16_t	zev_namelen;
376add9520fSAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
377add9520fSAndreas Jaekel } zev_ioctl_add_queue_t;
378add9520fSAndreas Jaekel 
379add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue {
3806a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
381add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t;
382add9520fSAndreas Jaekel 
383add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
3846a6a51eeSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
385add9520fSAndreas Jaekel 	zev_statistics_t	zev_statistics;
386add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
387add9520fSAndreas Jaekel 
388add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info {
389add9520fSAndreas Jaekel 	uint64_t	zev_memory_allocated;
390205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
391205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
392205ed6bfSAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
393add9520fSAndreas Jaekel } zev_ioctl_debug_info_t;
394add9520fSAndreas Jaekel 
395add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
396add9520fSAndreas Jaekel 	uint64_t		zev_n_queues;
397add9520fSAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
398add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t;
399add9520fSAndreas Jaekel 
40042110aacSAndreas Jaekel typedef struct zev_ioctl_get_signatures {
40142110aacSAndreas Jaekel 	/* in */
40242110aacSAndreas Jaekel 	uint64_t	zev_offset;
40342110aacSAndreas Jaekel 	uint64_t	zev_len;
40442110aacSAndreas Jaekel 	uint32_t	zev_fd;
40542110aacSAndreas Jaekel 	uint32_t	zev_bufsize;
40642110aacSAndreas Jaekel 	/* out */
40742110aacSAndreas Jaekel 	uint64_t	zev_signature_cnt;
40842110aacSAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
40942110aacSAndreas Jaekel } zev_ioctl_get_signatures_t;
41042110aacSAndreas Jaekel 
411149d0affSAndreas Jaekel #pragma pack()
412a18c35b9SAndreas Jaekel 
413a18c35b9SAndreas Jaekel #ifdef _KERNEL
414add9520fSAndreas Jaekel 
415add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated;
416add9520fSAndreas Jaekel extern uint64_t zev_memory_freed;
417add9520fSAndreas Jaekel 
418add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
419add9520fSAndreas Jaekel 	do {								\
420add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
421add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
422add9520fSAndreas Jaekel 	} while(0)
423add9520fSAndreas Jaekel 
424add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
425add9520fSAndreas Jaekel 	do {								\
426add9520fSAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
427add9520fSAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
428add9520fSAndreas Jaekel 	} while(0)
429add9520fSAndreas Jaekel 
430205ed6bfSAndreas Jaekel void *zev_alloc(ssize_t sz);
431205ed6bfSAndreas Jaekel void *zev_zalloc(ssize_t sz);
432205ed6bfSAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
433add9520fSAndreas Jaekel 
434d979f56cSAndreas Jaekel typedef struct zev_msg_t {
435d979f56cSAndreas Jaekel 	struct zev_msg_t	*next;
436add9520fSAndreas Jaekel 	struct zev_msg_t	*prev;
437add9520fSAndreas Jaekel 	uint64_t		 seq;
438add9520fSAndreas Jaekel 	uint16_t		 size;
439add9520fSAndreas Jaekel 	uint16_t		 read;
440d979f56cSAndreas Jaekel 	/* data follows */
441d979f56cSAndreas Jaekel } zev_msg_t;
442d979f56cSAndreas Jaekel 
443d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
444d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
445d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
446a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os);
447d979f56cSAndreas Jaekel 
448a18c35b9SAndreas Jaekel #endif
449a18c35b9SAndreas Jaekel 
450a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */
451a18c35b9SAndreas Jaekel 
452