12bb8e5e2SAndreas Jaekel #ifndef __ZEV_H__ 22bb8e5e2SAndreas Jaekel #define __ZEV_H__ 32bb8e5e2SAndreas Jaekel 42bb8e5e2SAndreas Jaekel #include <sys/types.h> 59db22157SAndreas Jaekel #include <sys/param.h> 6e9a5e479SAndreas Jaekel #include <sys/atomic.h> 72bb8e5e2SAndreas Jaekel 82bb8e5e2SAndreas Jaekel #ifdef _KERNEL 92bb8e5e2SAndreas Jaekel #include <sys/dmu_objset.h> 102bb8e5e2SAndreas Jaekel #include <sys/dsl_dataset.h> 112bb8e5e2SAndreas Jaekel #include <sys/zfs_vfsops.h> 122bb8e5e2SAndreas Jaekel #include <sys/dsl_dir.h> 132bb8e5e2SAndreas Jaekel #include <sys/spa_impl.h> 142bb8e5e2SAndreas Jaekel #endif 152bb8e5e2SAndreas Jaekel 16e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN 40 17e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUES 63 18e9a5e479SAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME "ctrl" 19e9a5e479SAndreas Jaekel 20e9a5e479SAndreas Jaekel /* global limit, no queue may grow larger than this. */ 21e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_LEN (1 * 1024 * 1024 * 1024) 22e9a5e479SAndreas Jaekel 23e9a5e479SAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */ 24*4ca7dd5eSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN 8192 25e9a5e479SAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN 65536 26e9a5e479SAndreas Jaekel 272bb8e5e2SAndreas Jaekel #define ZEVIOC ('z' << 8) 28e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS (ZEVIOC | 1) /* get global stats */ 29205a9bc9SAndreas Jaekel #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ 30205a9bc9SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ 31205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ 32205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ 3301c2c787SAndreas Jaekel #define ZEV_IOC_MARK (ZEVIOC | 6) /* add mark to queue */ 34c035b1e8SAndreas Jaekel #define ZEV_IOC_GET_GEN (ZEVIOC | 7) /* get generation no. */ 35e9a5e479SAndreas Jaekel #define ZEV_IOC_ADD_QUEUE (ZEVIOC | 8) /* create new queue */ 36e9a5e479SAndreas Jaekel #define ZEV_IOC_REMOVE_QUEUE (ZEVIOC | 9) /* delete queue */ 37e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES (ZEVIOC | 10) /* get properties */ 38e9a5e479SAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES (ZEVIOC | 11) /* set properties */ 39e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS (ZEVIOC | 12) /* get queue stats */ 40e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO (ZEVIOC | 13) /* get internal info */ 41e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST (ZEVIOC | 14) /* get queue list */ 422bb8e5e2SAndreas Jaekel 432bb8e5e2SAndreas Jaekel #define ZEV_OP_MIN 1 4468a46c64SAndreas Jaekel #define ZEV_OP_ERROR 1 4501c2c787SAndreas Jaekel #define ZEV_OP_MARK 2 4601c2c787SAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 3 4701c2c787SAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 4 4801c2c787SAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 5 4901c2c787SAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 6 5001c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 7 5101c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 8 5201c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 9 5301c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 10 5401c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 11 5501c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 12 5601c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_LINK 13 5701c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 14 5801c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 15 5901c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 16 6001c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 17 6101c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 18 6201c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_ACL 19 6301c2c787SAndreas Jaekel #define ZEV_OP_MAX 19 6468a46c64SAndreas Jaekel 65e9a5e479SAndreas Jaekel /* zev event flags */ 66e9a5e479SAndreas Jaekel #define ZEV_FL_XATTR 0x0001 67e9a5e479SAndreas Jaekel 68e9a5e479SAndreas Jaekel /* zev queue flags */ 69e9a5e479SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL 0x0001 70e9a5e479SAndreas Jaekel #define ZEV_FL_PERSISTENT 0x0002 71e9a5e479SAndreas Jaekel 7210874358SAndreas Jaekel 7368a46c64SAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 7468a46c64SAndreas Jaekel 75108668daSAndreas Jaekel #pragma pack(1) 7668a46c64SAndreas Jaekel typedef struct zev_inode_info_t { 7768a46c64SAndreas Jaekel uint64_t ino; 7868a46c64SAndreas Jaekel uint64_t gen; 7968a46c64SAndreas Jaekel uint64_t mtime; 8068a46c64SAndreas Jaekel uint64_t ctime; 8168a46c64SAndreas Jaekel uint64_t size; 8268a46c64SAndreas Jaekel uint64_t mode; 8368a46c64SAndreas Jaekel uint64_t links; 84108668daSAndreas Jaekel uint32_t type; 8510874358SAndreas Jaekel uint32_t flags; 8668a46c64SAndreas Jaekel } zev_inode_info_t; 8768a46c64SAndreas Jaekel 8868a46c64SAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 8968a46c64SAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 9068a46c64SAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 9168a46c64SAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 9268a46c64SAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 9368a46c64SAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 9468a46c64SAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 9501c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 9668a46c64SAndreas Jaekel 97108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 98108668daSAndreas Jaekel uint32_t record_len; \ 99108668daSAndreas Jaekel uint32_t op; \ 100108668daSAndreas Jaekel uint64_t op_time; \ 101b9df2829SAndreas Jaekel uint64_t guid 102108668daSAndreas Jaekel 10368a46c64SAndreas Jaekel typedef struct zev_header_t { 104108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 10568a46c64SAndreas Jaekel } zev_header_t; 10668a46c64SAndreas Jaekel 10768a46c64SAndreas Jaekel typedef struct zev_error_t { 108108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 10968a46c64SAndreas Jaekel uint32_t failed_op; 11068a46c64SAndreas Jaekel uint32_t errstr_len; 11168a46c64SAndreas Jaekel /* error string follows */ 11268a46c64SAndreas Jaekel } zev_error_t; 11368a46c64SAndreas Jaekel 11401c2c787SAndreas Jaekel typedef struct zev_mark_t { 11501c2c787SAndreas Jaekel ZEV_COMMON_FIELDS; 11601c2c787SAndreas Jaekel uint64_t mark_id; 11701c2c787SAndreas Jaekel uint32_t payload_len; 11801c2c787SAndreas Jaekel uint32_t padding; 11901c2c787SAndreas Jaekel /* payload follows */ 12001c2c787SAndreas Jaekel } zev_mark_t; 12101c2c787SAndreas Jaekel 12268a46c64SAndreas Jaekel typedef struct zev_zfs_mount_t { 123108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 12468a46c64SAndreas Jaekel uint64_t root_ino; 125108668daSAndreas Jaekel uint32_t remount; 12668a46c64SAndreas Jaekel uint32_t dataset_len; 12768a46c64SAndreas Jaekel uint32_t mountpoint_len; 128108668daSAndreas Jaekel uint32_t padding; 12968a46c64SAndreas Jaekel /* dataset follows */ 13068a46c64SAndreas Jaekel /* mountpoint follows */ 13168a46c64SAndreas Jaekel } zev_zfs_mount_t; 13268a46c64SAndreas Jaekel 13368a46c64SAndreas Jaekel typedef struct zev_zfs_umount_t { 134108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 13568a46c64SAndreas Jaekel } zev_zfs_umount_t; 13668a46c64SAndreas Jaekel 13768a46c64SAndreas Jaekel typedef struct zev_zvol_truncate_t { 138108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 13968a46c64SAndreas Jaekel uint64_t offset; 14068a46c64SAndreas Jaekel uint64_t length; 14168a46c64SAndreas Jaekel uint32_t dataset_len; 142108668daSAndreas Jaekel uint32_t padding; 14368a46c64SAndreas Jaekel /* dataset follows */ 14468a46c64SAndreas Jaekel } zev_zvol_truncate_t; 14568a46c64SAndreas Jaekel 14668a46c64SAndreas Jaekel typedef struct zev_zvol_write_t { 147108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 14868a46c64SAndreas Jaekel uint64_t offset; 14968a46c64SAndreas Jaekel uint64_t length; 15068a46c64SAndreas Jaekel uint32_t dataset_len; 151108668daSAndreas Jaekel uint32_t padding; 15268a46c64SAndreas Jaekel /* dataset follows */ 15368a46c64SAndreas Jaekel } zev_zvol_write_t; 15468a46c64SAndreas Jaekel 15568a46c64SAndreas Jaekel typedef struct zev_znode_close_after_update_t { 156108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 15768a46c64SAndreas Jaekel zev_inode_info_t file; 15868a46c64SAndreas Jaekel } zev_znode_close_after_update_t; 15968a46c64SAndreas Jaekel 16068a46c64SAndreas Jaekel typedef struct zev_znode_create_t { 161108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 16268a46c64SAndreas Jaekel zev_inode_info_t file; 16368a46c64SAndreas Jaekel zev_inode_info_t parent; 16468a46c64SAndreas Jaekel uint32_t name_len; 165108668daSAndreas Jaekel uint32_t padding; 16668a46c64SAndreas Jaekel /* name follows */ 16768a46c64SAndreas Jaekel } zev_znode_create_t; 16868a46c64SAndreas Jaekel 16968a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 17068a46c64SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 17168a46c64SAndreas Jaekel 17268a46c64SAndreas Jaekel typedef struct zev_znode_remove_t { 173108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 1746db5d4ecSAndreas Jaekel zev_inode_info_t file; 17568a46c64SAndreas Jaekel zev_inode_info_t parent; 17668a46c64SAndreas Jaekel uint32_t name_len; 177108668daSAndreas Jaekel uint32_t padding; 17868a46c64SAndreas Jaekel /* name follows */ 17968a46c64SAndreas Jaekel } zev_znode_remove_t; 18068a46c64SAndreas Jaekel 18168a46c64SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 18268a46c64SAndreas Jaekel 18368a46c64SAndreas Jaekel typedef struct zev_znode_link_t { 184108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 18568a46c64SAndreas Jaekel zev_inode_info_t parent; 18668a46c64SAndreas Jaekel zev_inode_info_t file; 18768a46c64SAndreas Jaekel uint32_t name_len; 188108668daSAndreas Jaekel uint32_t padding; 18968a46c64SAndreas Jaekel /* new_name follows */ 19068a46c64SAndreas Jaekel } zev_znode_link_t; 19168a46c64SAndreas Jaekel 19268a46c64SAndreas Jaekel typedef struct zev_znode_symlink_t { 193108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 19468a46c64SAndreas Jaekel zev_inode_info_t parent; 19568a46c64SAndreas Jaekel zev_inode_info_t file; 19668a46c64SAndreas Jaekel uint32_t name_len; 19768a46c64SAndreas Jaekel uint32_t link_len; 19868a46c64SAndreas Jaekel /* name follows */ 19968a46c64SAndreas Jaekel /* link follows */ 20068a46c64SAndreas Jaekel } zev_znode_symlink_t; 20168a46c64SAndreas Jaekel 20268a46c64SAndreas Jaekel typedef struct zev_znode_rename_t { 203108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 20468a46c64SAndreas Jaekel zev_inode_info_t srcdir; 20568a46c64SAndreas Jaekel zev_inode_info_t dstdir; 20668a46c64SAndreas Jaekel zev_inode_info_t file; 20768a46c64SAndreas Jaekel uint32_t srcname_len; 20868a46c64SAndreas Jaekel uint32_t dstname_len; 20968a46c64SAndreas Jaekel /* srcname follows */ 21068a46c64SAndreas Jaekel /* dstname follows */ 21168a46c64SAndreas Jaekel } zev_znode_rename_t; 21268a46c64SAndreas Jaekel 21368a46c64SAndreas Jaekel typedef struct zev_znode_write_t { 214108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 21568a46c64SAndreas Jaekel zev_inode_info_t file; 21668a46c64SAndreas Jaekel uint64_t offset; 21768a46c64SAndreas Jaekel uint64_t length; 21868a46c64SAndreas Jaekel } zev_znode_write_t; 21968a46c64SAndreas Jaekel 22068a46c64SAndreas Jaekel typedef struct zev_znode_truncate_t { 221108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 22268a46c64SAndreas Jaekel zev_inode_info_t file; 22368a46c64SAndreas Jaekel uint64_t offset; 22468a46c64SAndreas Jaekel uint64_t length; 22568a46c64SAndreas Jaekel } zev_znode_truncate_t; 22668a46c64SAndreas Jaekel 22768a46c64SAndreas Jaekel typedef struct zev_znode_setattr_t { 228108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 22968a46c64SAndreas Jaekel zev_inode_info_t file; 23068a46c64SAndreas Jaekel } zev_znode_setattr_t; 23168a46c64SAndreas Jaekel 23268a46c64SAndreas Jaekel typedef struct zev_znode_acl_t { 233108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 23468a46c64SAndreas Jaekel zev_inode_info_t file; 23568a46c64SAndreas Jaekel } zev_znode_acl_t; 23668a46c64SAndreas Jaekel 23768a46c64SAndreas Jaekel /* convenience helper definition */ 23868a46c64SAndreas Jaekel typedef union { 23968a46c64SAndreas Jaekel zev_header_t header; 24068a46c64SAndreas Jaekel 24101c2c787SAndreas Jaekel zev_error_t error; 24201c2c787SAndreas Jaekel zev_mark_t mark; 24368a46c64SAndreas Jaekel union { 24468a46c64SAndreas Jaekel zev_zfs_mount_t mount; 24568a46c64SAndreas Jaekel zev_zfs_umount_t umount; 24668a46c64SAndreas Jaekel } zfs; 24768a46c64SAndreas Jaekel union { 24868a46c64SAndreas Jaekel zev_zvol_truncate_t truncate; 24968a46c64SAndreas Jaekel zev_zvol_write_t write; 25068a46c64SAndreas Jaekel } zvol; 25168a46c64SAndreas Jaekel union { 25268a46c64SAndreas Jaekel zev_znode_close_after_update_t close; 25368a46c64SAndreas Jaekel zev_znode_create_t create; 25468a46c64SAndreas Jaekel zev_znode_mkdir_t mkdir; 25568a46c64SAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 25668a46c64SAndreas Jaekel zev_znode_remove_t remove; 25768a46c64SAndreas Jaekel zev_znode_rmdir_t rmdir; 25868a46c64SAndreas Jaekel zev_znode_link_t link; 25968a46c64SAndreas Jaekel zev_znode_symlink_t symlink; 26068a46c64SAndreas Jaekel zev_znode_rename_t rename; 26168a46c64SAndreas Jaekel zev_znode_write_t write; 26268a46c64SAndreas Jaekel zev_znode_truncate_t truncate; 26368a46c64SAndreas Jaekel zev_znode_setattr_t setattr; 26468a46c64SAndreas Jaekel zev_znode_acl_t acl; 26568a46c64SAndreas Jaekel } znode; 26668a46c64SAndreas Jaekel } zev_event_t; 26768a46c64SAndreas Jaekel 26868a46c64SAndreas Jaekel 2692bb8e5e2SAndreas Jaekel 2702bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t { 2712bb8e5e2SAndreas Jaekel uint64_t zev_queue_len; 2722bb8e5e2SAndreas Jaekel uint64_t zev_bytes_read; 273e9a5e479SAndreas Jaekel uint64_t zev_bytes_discarded; 274205a9bc9SAndreas Jaekel /* runtime settings */ 275205a9bc9SAndreas Jaekel uint64_t zev_max_queue_len; 2762bb8e5e2SAndreas Jaekel /* counters */ 2772bb8e5e2SAndreas Jaekel uint64_t zev_cnt_total_events; 278e9a5e479SAndreas Jaekel uint64_t zev_cnt_discarded_events; 2792bb8e5e2SAndreas Jaekel uint64_t zev_cnt_errors; 28001c2c787SAndreas Jaekel uint64_t zev_cnt_marks; 2812bb8e5e2SAndreas Jaekel /* zfsvfs ops */ 2822bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 2832bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 2842bb8e5e2SAndreas Jaekel /* zvol ops */ 2852bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zvol_write; 2862bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 2872bb8e5e2SAndreas Jaekel /* znode ops */ 2882bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 2892bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_create; 2902bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_remove; 2912bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_link; 2922bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 2932bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_rename; 2942bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_write; 2952bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 2962bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 2972bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_acl; 2982bb8e5e2SAndreas Jaekel } zev_statistics_t; 2992bb8e5e2SAndreas Jaekel 300e9a5e479SAndreas Jaekel typedef struct zev_queue_name { 301e9a5e479SAndreas Jaekel uint64_t zev_namelen; 302e9a5e479SAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 303e9a5e479SAndreas Jaekel } zev_queue_name_t; 304e9a5e479SAndreas Jaekel 3052bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg { 3062bb8e5e2SAndreas Jaekel uint64_t zev_poolname_len; 3072bb8e5e2SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 3082bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t; 30901c2c787SAndreas Jaekel 31001c2c787SAndreas Jaekel typedef struct zev_ioctl_mark { 31101c2c787SAndreas Jaekel uint64_t zev_mark_id; 31201c2c787SAndreas Jaekel uint64_t zev_guid; 31301c2c787SAndreas Jaekel uint32_t zev_payload_len; 31446c85740SAndreas Jaekel uint32_t padding; 31501c2c787SAndreas Jaekel /* payload follows */ 31601c2c787SAndreas Jaekel } zev_ioctl_mark_t; 317c035b1e8SAndreas Jaekel 318c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen { 319c035b1e8SAndreas Jaekel /* input */ 320c035b1e8SAndreas Jaekel uint64_t inode; 321c035b1e8SAndreas Jaekel uint32_t fd; /* open fd to any object on the same fs */ 322c035b1e8SAndreas Jaekel /* noput */ 323c035b1e8SAndreas Jaekel uint32_t padding; 324c035b1e8SAndreas Jaekel /* output */ 325c035b1e8SAndreas Jaekel uint64_t generation; 326c035b1e8SAndreas Jaekel uint64_t crtime; 327c035b1e8SAndreas Jaekel uint64_t guid; 328c035b1e8SAndreas Jaekel char dataset[MAXPATHLEN]; 329c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t; 330e9a5e479SAndreas Jaekel 331e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties { 332e9a5e479SAndreas Jaekel uint64_t zev_max_queue_len; 333e9a5e479SAndreas Jaekel uint64_t zev_poll_wakeup_threshold; 334e9a5e479SAndreas Jaekel uint16_t zev_flags; 335*4ca7dd5eSAndreas Jaekel uint16_t padding1; 336*4ca7dd5eSAndreas Jaekel uint32_t padding2; 337*4ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 338e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t; 339e9a5e479SAndreas Jaekel 340e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t; 341e9a5e479SAndreas Jaekel 342e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue { 343e9a5e479SAndreas Jaekel uint64_t zev_max_queue_len; 344e9a5e479SAndreas Jaekel uint32_t padding; 345e9a5e479SAndreas Jaekel uint16_t zev_flags; 346e9a5e479SAndreas Jaekel uint16_t zev_namelen; 347e9a5e479SAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 348e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t; 349e9a5e479SAndreas Jaekel 350e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue { 351*4ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 352e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t; 353e9a5e479SAndreas Jaekel 354e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics { 355*4ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 356e9a5e479SAndreas Jaekel zev_statistics_t zev_statistics; 357e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t; 358e9a5e479SAndreas Jaekel 359e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info { 360e9a5e479SAndreas Jaekel uint64_t zev_memory_allocated; 361e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t; 362e9a5e479SAndreas Jaekel 363e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list { 364e9a5e479SAndreas Jaekel uint64_t zev_n_queues; 365e9a5e479SAndreas Jaekel zev_queue_name_t zev_queue_name[ZEV_MAX_QUEUES]; 366e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t; 367e9a5e479SAndreas Jaekel 368108668daSAndreas Jaekel #pragma pack() 3692bb8e5e2SAndreas Jaekel 3702bb8e5e2SAndreas Jaekel #ifdef _KERNEL 371e9a5e479SAndreas Jaekel 372e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated; 373e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed; 374e9a5e479SAndreas Jaekel 375e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize) \ 376e9a5e479SAndreas Jaekel do { \ 377e9a5e479SAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 378e9a5e479SAndreas Jaekel atomic_add_64(&zev_memory_allocated, tmp_delta); \ 379e9a5e479SAndreas Jaekel } while(0) 380e9a5e479SAndreas Jaekel 381e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize) \ 382e9a5e479SAndreas Jaekel do { \ 383e9a5e479SAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 384e9a5e479SAndreas Jaekel atomic_add_64(&zev_memory_freed, tmp_delta); \ 385e9a5e479SAndreas Jaekel } while(0) 386e9a5e479SAndreas Jaekel 387e9a5e479SAndreas Jaekel #define ZEV_ALLOC(memsize) \ 388e9a5e479SAndreas Jaekel kmem_alloc(memsize, KM_SLEEP); \ 389e9a5e479SAndreas Jaekel ZEV_MEM_ADD(memsize); 390e9a5e479SAndreas Jaekel 391e9a5e479SAndreas Jaekel #define ZEV_ZALLOC(memsize) \ 392e9a5e479SAndreas Jaekel kmem_zalloc(memsize, KM_SLEEP); \ 393e9a5e479SAndreas Jaekel ZEV_MEM_ADD(memsize); 394e9a5e479SAndreas Jaekel 395e9a5e479SAndreas Jaekel #define ZEV_FREE(p, memsize) \ 396e9a5e479SAndreas Jaekel ZEV_MEM_SUB(memsize); \ 397e9a5e479SAndreas Jaekel kmem_free(p, memsize); 398e9a5e479SAndreas Jaekel 39968a46c64SAndreas Jaekel typedef struct zev_msg_t { 40068a46c64SAndreas Jaekel struct zev_msg_t *next; 401e9a5e479SAndreas Jaekel struct zev_msg_t *prev; 402e9a5e479SAndreas Jaekel uint64_t seq; 403e9a5e479SAndreas Jaekel uint16_t size; 404e9a5e479SAndreas Jaekel uint16_t read; 40568a46c64SAndreas Jaekel /* data follows */ 40668a46c64SAndreas Jaekel } zev_msg_t; 40768a46c64SAndreas Jaekel 40868a46c64SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 40968a46c64SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 41068a46c64SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 4112bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os); 41268a46c64SAndreas Jaekel 4132bb8e5e2SAndreas Jaekel #endif 4142bb8e5e2SAndreas Jaekel 4152bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */ 4162bb8e5e2SAndreas Jaekel 417