xref: /titanic_41/usr/src/common/zev/zev.h (revision e1c612e3f2af15ccdb7fdcfefe9c16f71dd315d1)
18f7d1b1aSAndreas Jaekel #ifndef __ZEV_H__
28f7d1b1aSAndreas Jaekel #define __ZEV_H__
38f7d1b1aSAndreas Jaekel 
48f7d1b1aSAndreas Jaekel #include <sys/types.h>
51941fba0SAndreas Jaekel #include <sys/param.h>
6bc16f320SAndreas Jaekel #include <sys/atomic.h>
7d8e62babSAndreas Jaekel #include <sys/sha1.h>
88f7d1b1aSAndreas Jaekel 
98f7d1b1aSAndreas Jaekel #ifdef _KERNEL
108f7d1b1aSAndreas Jaekel #include <sys/dmu_objset.h>
118f7d1b1aSAndreas Jaekel #include <sys/dsl_dataset.h>
128f7d1b1aSAndreas Jaekel #include <sys/zfs_vfsops.h>
138f7d1b1aSAndreas Jaekel #include <sys/dsl_dir.h>
148f7d1b1aSAndreas Jaekel #include <sys/spa_impl.h>
158f7d1b1aSAndreas Jaekel #endif
168f7d1b1aSAndreas Jaekel 
17f63c8e09SAndreas Jaekel /* increased for incompatible interface and behaviour changes */
18*e1c612e3SSimon Klinkert #define ZEV_MAJOR_VERSION		2
19f63c8e09SAndreas Jaekel /* increased for compatible changes, including new ioctls(), etc. */
20*e1c612e3SSimon Klinkert #define ZEV_MINOR_VERSION		0
21f63c8e09SAndreas Jaekel 
22bc16f320SAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN		40
23*e1c612e3SSimon Klinkert #define ZEV_MAX_QUEUES			60
24bc16f320SAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME		"ctrl"
25*e1c612e3SSimon Klinkert #define ZEV_TMPQUEUE_DEVICE_NAME	"tmpqueue"
26bc16f320SAndreas Jaekel 
27bc16f320SAndreas Jaekel /* global limit, no queue may grow larger than this. */
28bc16f320SAndreas Jaekel #define ZEV_MAX_QUEUE_LEN		(1 * 1024 * 1024 * 1024)
29bc16f320SAndreas Jaekel 
30bc16f320SAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */
31e4ea145cSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN	8192
32bc16f320SAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN		65536
33bc16f320SAndreas Jaekel 
348f7d1b1aSAndreas Jaekel #define ZEVIOC				  ('z' << 8)
35bc16f320SAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS	  (ZEVIOC | 1)	/* get global stats */
368816c249SAndreas Jaekel #define ZEV_IOC_MUTE_POOL		  (ZEVIOC | 2)	/* no events for pool */
378816c249SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL		  (ZEVIOC | 3)	/* send pool events */
388816c249SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN	  (ZEVIOC | 4)	/* when to block ops */
398816c249SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5)	/* poll throttle */
40d8d328edSAndreas Jaekel #define ZEV_IOC_MARK			  (ZEVIOC | 6)	/* add mark to queue */
417a84701fSAndreas Jaekel #define ZEV_IOC_GET_GEN			  (ZEVIOC | 7)	/* get generation no. */
42bc16f320SAndreas Jaekel #define	ZEV_IOC_ADD_QUEUE		  (ZEVIOC | 8)  /* create new queue */
43bc16f320SAndreas Jaekel #define	ZEV_IOC_REMOVE_QUEUE		  (ZEVIOC | 9)  /* delete queue */
44bc16f320SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES	  (ZEVIOC | 10)	/* get properties */
45bc16f320SAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES	  (ZEVIOC | 11)	/* set properties */
46bc16f320SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS	  (ZEVIOC | 12)	/* get queue stats */
47bc16f320SAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO		  (ZEVIOC | 13)	/* get internal info */
48bc16f320SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST		  (ZEVIOC | 14)	/* get queue list */
496b4c2eb9SAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES	  (ZEVIOC | 15)	/* get beaver sigs */
50f63c8e09SAndreas Jaekel #define ZEV_IOC_GET_ZEV_VERSION		  (ZEVIOC | 16)	/* get zev version */
518f7d1b1aSAndreas Jaekel 
528f7d1b1aSAndreas Jaekel #define ZEV_OP_MIN			 1
534a804719SAndreas Jaekel #define ZEV_OP_ERROR			 1
54d8d328edSAndreas Jaekel #define ZEV_OP_MARK			 2
55d8d328edSAndreas Jaekel #define	ZEV_OP_ZFS_MOUNT		 3
56d8d328edSAndreas Jaekel #define	ZEV_OP_ZFS_UMOUNT		 4
57d8d328edSAndreas Jaekel #define	ZEV_OP_ZVOL_WRITE		 5
58d8d328edSAndreas Jaekel #define	ZEV_OP_ZVOL_TRUNCATE		 6
59d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE	 7
60d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_CREATE		 8
61d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_MKDIR		 9
62d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_MAKE_XATTR_DIR	10
63d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_REMOVE		11
64d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_RMDIR		12
65d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_LINK		13
66d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_SYMLINK		14
67d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_RENAME		15
68d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_WRITE		16
69d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_TRUNCATE		17
70d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_SETATTR		18
71d8d328edSAndreas Jaekel #define	ZEV_OP_ZNODE_ACL		19
72d8d328edSAndreas Jaekel #define	ZEV_OP_MAX			19
734a804719SAndreas Jaekel 
74bc16f320SAndreas Jaekel /* zev event flags */
75bc16f320SAndreas Jaekel #define	ZEV_FL_XATTR			0x0001
76bc16f320SAndreas Jaekel 
77bc16f320SAndreas Jaekel /* zev queue flags */
78bc16f320SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL	0x0001
79bc16f320SAndreas Jaekel #define ZEV_FL_PERSISTENT		0x0002
806970b7d9SAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY		0x0004
81bc16f320SAndreas Jaekel 
826b4c2eb9SAndreas Jaekel /* checksum block sizes */
836b4c2eb9SAndreas Jaekel #define ZEV_L0_SIZE	4096
846b4c2eb9SAndreas Jaekel #define ZEV_L1_SIZE	(256 * ZEV_L0_SIZE)
855be89596SAndreas Jaekel 
864a804719SAndreas Jaekel /* zfs event records (as they are represented through the character device) */
874a804719SAndreas Jaekel 
883c715018SAndreas Jaekel #pragma pack(1)
894a804719SAndreas Jaekel typedef struct zev_inode_info_t {
904a804719SAndreas Jaekel 	uint64_t	ino;
914a804719SAndreas Jaekel 	uint64_t	gen;
924a804719SAndreas Jaekel 	uint64_t	mtime;
934a804719SAndreas Jaekel 	uint64_t	ctime;
944a804719SAndreas Jaekel 	uint64_t	size;
954a804719SAndreas Jaekel 	uint64_t	mode;
964a804719SAndreas Jaekel 	uint64_t	links;
973c715018SAndreas Jaekel 	uint32_t	type;
985be89596SAndreas Jaekel 	uint32_t	flags;
994a804719SAndreas Jaekel } zev_inode_info_t;
1004a804719SAndreas Jaekel 
1014a804719SAndreas Jaekel #define ZEV_ERRSTR(rec)		((char *)(rec + 1))
1024a804719SAndreas Jaekel #define ZEV_DATASET(rec)	((char *)(rec + 1))
1034a804719SAndreas Jaekel #define ZEV_MOUNTPOINT(rec)	(((char *)(rec + 1)) + rec->dataset_len + 1)
1044a804719SAndreas Jaekel #define ZEV_NAME(rec)		((char *)(rec + 1))
1054a804719SAndreas Jaekel #define ZEV_SRCNAME(rec)	((char *)(rec + 1))
1064a804719SAndreas Jaekel #define ZEV_DSTNAME(rec)	(((char *)(rec + 1)) + rec->srcname_len + 1)
1074a804719SAndreas Jaekel #define ZEV_LINK(rec)		(((char *)(rec + 1)) + rec->name_len + 1)
108d8d328edSAndreas Jaekel #define ZEV_PAYLOAD(rec)	((char *)(rec + 1))
109d8e62babSAndreas Jaekel #define ZEV_SIGNATURES(rec)	((char *)(rec + 1))
1104a804719SAndreas Jaekel 
1113c715018SAndreas Jaekel #define ZEV_COMMON_FIELDS						\
1123c715018SAndreas Jaekel 	uint32_t		record_len;				\
1133c715018SAndreas Jaekel 	uint32_t		op;					\
1143c715018SAndreas Jaekel 	uint64_t		op_time;				\
115e0400b41SAndreas Jaekel 	uint64_t		guid
1163c715018SAndreas Jaekel 
117d8e62babSAndreas Jaekel typedef struct zev_sig_t {
118d8e62babSAndreas Jaekel 	uint16_t	level;
119d8e62babSAndreas Jaekel 	uint16_t	padding1;
120d8e62babSAndreas Jaekel 	uint32_t	padding2;
121d8e62babSAndreas Jaekel 	uint64_t	block_offset;
122d8e62babSAndreas Jaekel 	uint8_t		value[SHA1_DIGEST_LENGTH];  /* 20 bytes -> no padding */
123d8e62babSAndreas Jaekel } zev_sig_t;
124d8e62babSAndreas Jaekel 
1254a804719SAndreas Jaekel typedef struct zev_header_t {
1263c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
1274a804719SAndreas Jaekel } zev_header_t;
1284a804719SAndreas Jaekel 
1294a804719SAndreas Jaekel typedef struct zev_error_t {
1303c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
1314a804719SAndreas Jaekel 	uint32_t		failed_op;
1324a804719SAndreas Jaekel 	uint32_t		errstr_len;
1334a804719SAndreas Jaekel 	/* error string follows */
1344a804719SAndreas Jaekel } zev_error_t;
1354a804719SAndreas Jaekel 
136d8d328edSAndreas Jaekel typedef struct zev_mark_t {
137d8d328edSAndreas Jaekel 	ZEV_COMMON_FIELDS;
138d8d328edSAndreas Jaekel 	uint64_t		mark_id;
139d8d328edSAndreas Jaekel 	uint32_t		payload_len;
140d8d328edSAndreas Jaekel 	uint32_t		padding;
141d8d328edSAndreas Jaekel 	/* payload follows */
142d8d328edSAndreas Jaekel } zev_mark_t;
143d8d328edSAndreas Jaekel 
1444a804719SAndreas Jaekel typedef struct zev_zfs_mount_t {
1453c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
1465beaf3adSAndreas Jaekel 	zev_inode_info_t	root;
147*e1c612e3SSimon Klinkert 	uint64_t		txg;
1483c715018SAndreas Jaekel 	uint32_t		remount;
1494a804719SAndreas Jaekel 	uint32_t		dataset_len;
1504a804719SAndreas Jaekel 	uint32_t		mountpoint_len;
1513c715018SAndreas Jaekel 	uint32_t		padding;
1524a804719SAndreas Jaekel 	/* dataset follows */
1534a804719SAndreas Jaekel 	/* mountpoint follows */
1544a804719SAndreas Jaekel } zev_zfs_mount_t;
1554a804719SAndreas Jaekel 
1564a804719SAndreas Jaekel typedef struct zev_zfs_umount_t {
1573c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
158*e1c612e3SSimon Klinkert 	uint64_t		txg;
159808e6c04SAndreas Jaekel 	zev_inode_info_t	covered;
1604a804719SAndreas Jaekel } zev_zfs_umount_t;
1614a804719SAndreas Jaekel 
1624a804719SAndreas Jaekel typedef struct zev_zvol_truncate_t {
1633c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
164be5f9b3cSAndreas Jaekel 	uint64_t		txg;
1654a804719SAndreas Jaekel 	uint64_t		offset;
1664a804719SAndreas Jaekel 	uint64_t		length;
1674a804719SAndreas Jaekel 	uint32_t		dataset_len;
1683c715018SAndreas Jaekel 	uint32_t		padding;
1694a804719SAndreas Jaekel 	/* dataset follows */
1704a804719SAndreas Jaekel } zev_zvol_truncate_t;
1714a804719SAndreas Jaekel 
1724a804719SAndreas Jaekel typedef struct zev_zvol_write_t {
1733c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
174be5f9b3cSAndreas Jaekel 	uint64_t		txg;
1754a804719SAndreas Jaekel 	uint64_t		offset;
1764a804719SAndreas Jaekel 	uint64_t		length;
1774a804719SAndreas Jaekel 	uint32_t		dataset_len;
1783c715018SAndreas Jaekel 	uint32_t		padding;
1794a804719SAndreas Jaekel 	/* dataset follows */
1804a804719SAndreas Jaekel } zev_zvol_write_t;
1814a804719SAndreas Jaekel 
1824a804719SAndreas Jaekel typedef struct zev_znode_close_after_update_t {
1833c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
1844a804719SAndreas Jaekel 	zev_inode_info_t	file;
1854a804719SAndreas Jaekel } zev_znode_close_after_update_t;
1864a804719SAndreas Jaekel 
1874a804719SAndreas Jaekel typedef struct zev_znode_create_t {
1883c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
189be5f9b3cSAndreas Jaekel 	uint64_t		txg;
1904a804719SAndreas Jaekel 	zev_inode_info_t	file;
1914a804719SAndreas Jaekel 	zev_inode_info_t	parent;
192d27baf23SAndreas Jaekel 	zev_sig_t		signature;
1934a804719SAndreas Jaekel 	uint32_t		name_len;
1943c715018SAndreas Jaekel 	uint32_t		padding;
1954a804719SAndreas Jaekel 	/* name follows */
1964a804719SAndreas Jaekel } zev_znode_create_t;
1974a804719SAndreas Jaekel 
1984a804719SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t;
1994a804719SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t;
2004a804719SAndreas Jaekel 
2014a804719SAndreas Jaekel typedef struct zev_znode_remove_t {
2023c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
203be5f9b3cSAndreas Jaekel 	uint64_t		txg;
204b23df438SAndreas Jaekel 	zev_inode_info_t	file;
2054a804719SAndreas Jaekel 	zev_inode_info_t	parent;
2064a804719SAndreas Jaekel 	uint32_t		name_len;
2073c715018SAndreas Jaekel 	uint32_t		padding;
2084a804719SAndreas Jaekel 	/* name follows */
2094a804719SAndreas Jaekel } zev_znode_remove_t;
2104a804719SAndreas Jaekel 
2114a804719SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t;
2124a804719SAndreas Jaekel 
2134a804719SAndreas Jaekel typedef struct zev_znode_link_t {
2143c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
215be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2164a804719SAndreas Jaekel 	zev_inode_info_t	parent;
2174a804719SAndreas Jaekel 	zev_inode_info_t	file;
2184a804719SAndreas Jaekel 	uint32_t		name_len;
2193c715018SAndreas Jaekel 	uint32_t		padding;
2204a804719SAndreas Jaekel 	/* new_name follows */
2214a804719SAndreas Jaekel } zev_znode_link_t;
2224a804719SAndreas Jaekel 
2234a804719SAndreas Jaekel typedef struct zev_znode_symlink_t {
2243c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
225be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2264a804719SAndreas Jaekel 	zev_inode_info_t	parent;
2274a804719SAndreas Jaekel 	zev_inode_info_t	file;
228d27baf23SAndreas Jaekel 	zev_sig_t		signature;
2294a804719SAndreas Jaekel 	uint32_t		name_len;
2304a804719SAndreas Jaekel 	uint32_t		link_len;
2314a804719SAndreas Jaekel 	/* name follows */
2324a804719SAndreas Jaekel 	/* link follows */
2334a804719SAndreas Jaekel } zev_znode_symlink_t;
2344a804719SAndreas Jaekel 
2354a804719SAndreas Jaekel typedef struct zev_znode_rename_t {
2363c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
237be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2384a804719SAndreas Jaekel 	zev_inode_info_t	srcdir;
2394a804719SAndreas Jaekel 	zev_inode_info_t	dstdir;
2404a804719SAndreas Jaekel 	zev_inode_info_t	file;
2419ed9bfe9SAndreas Jaekel 	zev_inode_info_t	clobbered_file;
2424a804719SAndreas Jaekel 	uint32_t		srcname_len;
2434a804719SAndreas Jaekel 	uint32_t		dstname_len;
2444a804719SAndreas Jaekel 	/* srcname follows */
2454a804719SAndreas Jaekel 	/* dstname follows */
2464a804719SAndreas Jaekel } zev_znode_rename_t;
2474a804719SAndreas Jaekel 
2484a804719SAndreas Jaekel typedef struct zev_znode_write_t {
2493c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
250be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2514a804719SAndreas Jaekel 	zev_inode_info_t	file;
2524a804719SAndreas Jaekel 	uint64_t		offset;
2534a804719SAndreas Jaekel 	uint64_t		length;
254d8e62babSAndreas Jaekel 	uint64_t		signature_cnt;
255d8e62babSAndreas Jaekel 	/* signatures follow */
2564a804719SAndreas Jaekel } zev_znode_write_t;
2574a804719SAndreas Jaekel 
2584a804719SAndreas Jaekel typedef struct zev_znode_truncate_t {
2593c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
260be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2614a804719SAndreas Jaekel 	zev_inode_info_t	file;
2624a804719SAndreas Jaekel 	uint64_t		offset;
2634a804719SAndreas Jaekel 	uint64_t		length;
264d8e62babSAndreas Jaekel 	uint64_t		signature_cnt;
265d8e62babSAndreas Jaekel 	/* signatures follow */
2664a804719SAndreas Jaekel } zev_znode_truncate_t;
2674a804719SAndreas Jaekel 
2684a804719SAndreas Jaekel typedef struct zev_znode_setattr_t {
2693c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
270be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2714a804719SAndreas Jaekel 	zev_inode_info_t	file;
2724a804719SAndreas Jaekel } zev_znode_setattr_t;
2734a804719SAndreas Jaekel 
2744a804719SAndreas Jaekel typedef struct zev_znode_acl_t {
2753c715018SAndreas Jaekel 	ZEV_COMMON_FIELDS;
276be5f9b3cSAndreas Jaekel 	uint64_t		txg;
2774a804719SAndreas Jaekel 	zev_inode_info_t	file;
2784a804719SAndreas Jaekel } zev_znode_acl_t;
2794a804719SAndreas Jaekel 
2804a804719SAndreas Jaekel /* convenience helper definition */
2814a804719SAndreas Jaekel typedef union {
2824a804719SAndreas Jaekel 	zev_header_t				header;
2834a804719SAndreas Jaekel 
284d8d328edSAndreas Jaekel 	zev_error_t				error;
285d8d328edSAndreas Jaekel 	zev_mark_t				mark;
2864a804719SAndreas Jaekel 	union {
2874a804719SAndreas Jaekel 		zev_zfs_mount_t			mount;
2884a804719SAndreas Jaekel 		zev_zfs_umount_t		umount;
2894a804719SAndreas Jaekel 	} zfs;
2904a804719SAndreas Jaekel 	union {
2914a804719SAndreas Jaekel 		zev_zvol_truncate_t		truncate;
2924a804719SAndreas Jaekel 		zev_zvol_write_t		write;
2934a804719SAndreas Jaekel 	} zvol;
2944a804719SAndreas Jaekel 	union {
2954a804719SAndreas Jaekel 		zev_znode_close_after_update_t	close;
2964a804719SAndreas Jaekel 		zev_znode_create_t		create;
2974a804719SAndreas Jaekel 		zev_znode_mkdir_t		mkdir;
2984a804719SAndreas Jaekel 		zev_znode_make_xattr_dir_t	mkxattrdir;
2994a804719SAndreas Jaekel 		zev_znode_remove_t		remove;
3004a804719SAndreas Jaekel 		zev_znode_rmdir_t		rmdir;
3014a804719SAndreas Jaekel 		zev_znode_link_t		link;
3024a804719SAndreas Jaekel 		zev_znode_symlink_t		symlink;
3034a804719SAndreas Jaekel 		zev_znode_rename_t		rename;
3044a804719SAndreas Jaekel 		zev_znode_write_t		write;
3054a804719SAndreas Jaekel 		zev_znode_truncate_t		truncate;
3064a804719SAndreas Jaekel 		zev_znode_setattr_t		setattr;
3074a804719SAndreas Jaekel 		zev_znode_acl_t			acl;
3084a804719SAndreas Jaekel 	} znode;
3094a804719SAndreas Jaekel } zev_event_t;
3104a804719SAndreas Jaekel 
3114a804719SAndreas Jaekel 
3128f7d1b1aSAndreas Jaekel 
3138f7d1b1aSAndreas Jaekel typedef struct zev_statistics_t {
3148f7d1b1aSAndreas Jaekel 	uint64_t	zev_queue_len;
3158f7d1b1aSAndreas Jaekel 	uint64_t	zev_bytes_read;
316bc16f320SAndreas Jaekel 	uint64_t	zev_bytes_discarded;
3178816c249SAndreas Jaekel 	/* runtime settings */
3188816c249SAndreas Jaekel 	uint64_t	zev_max_queue_len;
3198f7d1b1aSAndreas Jaekel 	/* counters */
3208f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_total_events;
321bc16f320SAndreas Jaekel 	uint64_t	zev_cnt_discarded_events;
3228f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_errors;
323d8d328edSAndreas Jaekel 	uint64_t	zev_cnt_marks;
3248f7d1b1aSAndreas Jaekel 	/* zfsvfs ops */
3258f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_zfs_mount;
3268f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_zfs_umount;
3278f7d1b1aSAndreas Jaekel 	/* zvol ops */
3288f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_zvol_write;
3298f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_zvol_truncate;
3308f7d1b1aSAndreas Jaekel 	/* znode ops */
3318f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_close_after_update;
3328f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_create;
3338f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_remove;
3348f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_link;
3358f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_symlink;
3368f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_rename;
3378f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_write;
3388f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_truncate;
3398f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_setattr;
3408f7d1b1aSAndreas Jaekel 	uint64_t	zev_cnt_znode_acl;
3418f7d1b1aSAndreas Jaekel } zev_statistics_t;
3428f7d1b1aSAndreas Jaekel 
343bc16f320SAndreas Jaekel typedef struct zev_queue_name {
344bc16f320SAndreas Jaekel 	uint64_t		zev_namelen;
345bc16f320SAndreas Jaekel 	char			zev_name[ZEV_MAX_QUEUE_NAME_LEN];
346bc16f320SAndreas Jaekel } zev_queue_name_t;
347bc16f320SAndreas Jaekel 
3488f7d1b1aSAndreas Jaekel typedef struct zev_ioctl_poolarg {
3498f7d1b1aSAndreas Jaekel 	uint64_t	zev_poolname_len;
3508f7d1b1aSAndreas Jaekel 	char		zev_poolname[MAXPATHLEN];
3518f7d1b1aSAndreas Jaekel } zev_ioctl_poolarg_t;
352d8d328edSAndreas Jaekel 
353d8d328edSAndreas Jaekel typedef struct zev_ioctl_mark {
354d8d328edSAndreas Jaekel 	uint64_t	zev_mark_id;
355d8d328edSAndreas Jaekel 	uint64_t	zev_guid;
356d8d328edSAndreas Jaekel 	uint32_t	zev_payload_len;
357aadc9bd9SAndreas Jaekel 	uint32_t	padding;
358d8d328edSAndreas Jaekel 	/* payload follows */
359d8d328edSAndreas Jaekel } zev_ioctl_mark_t;
3607a84701fSAndreas Jaekel 
3617a84701fSAndreas Jaekel typedef struct zev_ioctl_get_gen {
3627a84701fSAndreas Jaekel 	/* input */
3637a84701fSAndreas Jaekel 	uint64_t	inode;
3647a84701fSAndreas Jaekel 	uint32_t	fd;	/* open fd to any object on the same fs */
3657a84701fSAndreas Jaekel 	/* noput */
3667a84701fSAndreas Jaekel 	uint32_t	padding;
3677a84701fSAndreas Jaekel 	/* output */
3687a84701fSAndreas Jaekel 	uint64_t	generation;
3697a84701fSAndreas Jaekel 	uint64_t	crtime;
3707a84701fSAndreas Jaekel 	uint64_t	guid;
3717a84701fSAndreas Jaekel 	char		dataset[MAXPATHLEN];
3727a84701fSAndreas Jaekel } zev_ioctl_get_gen_t;
373bc16f320SAndreas Jaekel 
374bc16f320SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties {
375bc16f320SAndreas Jaekel 	uint64_t		zev_max_queue_len;
376bc16f320SAndreas Jaekel 	uint64_t		zev_poll_wakeup_threshold;
377bc16f320SAndreas Jaekel 	uint16_t		zev_flags;
378e4ea145cSAndreas Jaekel 	uint16_t		padding1;
379e4ea145cSAndreas Jaekel 	uint32_t		padding2;
380e4ea145cSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
381bc16f320SAndreas Jaekel } zev_ioctl_set_queue_properties_t;
382bc16f320SAndreas Jaekel 
383bc16f320SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t;
384bc16f320SAndreas Jaekel 
385bc16f320SAndreas Jaekel typedef struct zev_ioctl_add_queue {
386bc16f320SAndreas Jaekel 	uint64_t	zev_max_queue_len;
387bc16f320SAndreas Jaekel 	uint32_t	padding;
388bc16f320SAndreas Jaekel 	uint16_t	zev_flags;
389bc16f320SAndreas Jaekel 	uint16_t	zev_namelen;
390bc16f320SAndreas Jaekel 	char		zev_name[ZEV_MAX_QUEUE_NAME_LEN];
391bc16f320SAndreas Jaekel } zev_ioctl_add_queue_t;
392bc16f320SAndreas Jaekel 
393bc16f320SAndreas Jaekel typedef struct zev_ioctl_remove_queue {
394e4ea145cSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
395bc16f320SAndreas Jaekel } zev_ioctl_remove_queue_t;
396bc16f320SAndreas Jaekel 
397bc16f320SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics {
398e4ea145cSAndreas Jaekel 	zev_queue_name_t	zev_queue_name;
399bc16f320SAndreas Jaekel 	zev_statistics_t	zev_statistics;
400bc16f320SAndreas Jaekel } zev_ioctl_get_queue_statistics_t;
401bc16f320SAndreas Jaekel 
402bc16f320SAndreas Jaekel typedef struct zev_ioctl_debug_info {
403bc16f320SAndreas Jaekel 	uint64_t	zev_memory_allocated;
404d8e62babSAndreas Jaekel 	uint64_t	zev_chksum_cache_size;
405d8e62babSAndreas Jaekel 	uint64_t	zev_chksum_cache_hits;
406d8e62babSAndreas Jaekel 	uint64_t	zev_chksum_cache_misses;
407bc16f320SAndreas Jaekel } zev_ioctl_debug_info_t;
408bc16f320SAndreas Jaekel 
409bc16f320SAndreas Jaekel typedef struct zev_ioctl_get_queue_list {
410bc16f320SAndreas Jaekel 	uint64_t		zev_n_queues;
411bc16f320SAndreas Jaekel 	zev_queue_name_t	zev_queue_name[ZEV_MAX_QUEUES];
412bc16f320SAndreas Jaekel } zev_ioctl_get_queue_list_t;
413bc16f320SAndreas Jaekel 
4146b4c2eb9SAndreas Jaekel typedef struct zev_ioctl_get_signatures {
4156b4c2eb9SAndreas Jaekel 	/* in */
4166b4c2eb9SAndreas Jaekel 	uint64_t	zev_offset;
4176b4c2eb9SAndreas Jaekel 	uint64_t	zev_len;
4186b4c2eb9SAndreas Jaekel 	uint32_t	zev_fd;
4196b4c2eb9SAndreas Jaekel 	uint32_t	zev_bufsize;
4206b4c2eb9SAndreas Jaekel 	/* out */
4216b4c2eb9SAndreas Jaekel 	uint64_t	zev_signature_cnt;
4226b4c2eb9SAndreas Jaekel 	/* up to zev_bufsize bytes of checksums will be written here */
4236b4c2eb9SAndreas Jaekel } zev_ioctl_get_signatures_t;
4246b4c2eb9SAndreas Jaekel 
425f63c8e09SAndreas Jaekel typedef struct zev_ioctl_get_zev_version {
426f63c8e09SAndreas Jaekel 	uint64_t		zev_major_version;
427f63c8e09SAndreas Jaekel 	uint64_t		zev_minor_version;
428f63c8e09SAndreas Jaekel } zev_ioctl_get_zev_version;
429f63c8e09SAndreas Jaekel 
4303c715018SAndreas Jaekel #pragma pack()
4318f7d1b1aSAndreas Jaekel 
4328f7d1b1aSAndreas Jaekel #ifdef _KERNEL
433bc16f320SAndreas Jaekel 
434bc16f320SAndreas Jaekel extern uint64_t zev_memory_allocated;
435bc16f320SAndreas Jaekel extern uint64_t zev_memory_freed;
436bc16f320SAndreas Jaekel 
437bc16f320SAndreas Jaekel #define ZEV_MEM_ADD(memsize)						\
438bc16f320SAndreas Jaekel 	do {								\
439bc16f320SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
440bc16f320SAndreas Jaekel 		atomic_add_64(&zev_memory_allocated, tmp_delta);	\
441bc16f320SAndreas Jaekel 	} while(0)
442bc16f320SAndreas Jaekel 
443bc16f320SAndreas Jaekel #define ZEV_MEM_SUB(memsize)						\
444bc16f320SAndreas Jaekel 	do {								\
445bc16f320SAndreas Jaekel 		int64_t tmp_delta = (int64_t)(memsize);			\
446bc16f320SAndreas Jaekel 		atomic_add_64(&zev_memory_freed, tmp_delta);		\
447bc16f320SAndreas Jaekel 	} while(0)
448bc16f320SAndreas Jaekel 
449d8e62babSAndreas Jaekel void *zev_alloc(ssize_t sz);
450d8e62babSAndreas Jaekel void *zev_zalloc(ssize_t sz);
451d8e62babSAndreas Jaekel void zev_free(void *ptr, ssize_t sz);
452bc16f320SAndreas Jaekel 
4534a804719SAndreas Jaekel typedef struct zev_msg_t {
4544a804719SAndreas Jaekel 	struct zev_msg_t	*next;
455bc16f320SAndreas Jaekel 	struct zev_msg_t	*prev;
456bc16f320SAndreas Jaekel 	uint64_t		 seq;
457bc16f320SAndreas Jaekel 	uint16_t		 size;
458bc16f320SAndreas Jaekel 	uint16_t		 read;
4594a804719SAndreas Jaekel 	/* data follows */
4604a804719SAndreas Jaekel } zev_msg_t;
4614a804719SAndreas Jaekel 
4624a804719SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...);
4634a804719SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg);
4644a804719SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl);
4658f7d1b1aSAndreas Jaekel int zev_skip_pool(objset_t *os);
466f63c8e09SAndreas Jaekel int zev_skip_fs(zfsvfs_t *fs);
4674a804719SAndreas Jaekel 
4688f7d1b1aSAndreas Jaekel #endif
4698f7d1b1aSAndreas Jaekel 
4708f7d1b1aSAndreas Jaekel #endif /* __ZEV_H__ */
4718f7d1b1aSAndreas Jaekel 
472