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> 7a18c35b9SAndreas Jaekel 8a18c35b9SAndreas Jaekel #ifdef _KERNEL 9a18c35b9SAndreas Jaekel #include <sys/dmu_objset.h> 10a18c35b9SAndreas Jaekel #include <sys/dsl_dataset.h> 11a18c35b9SAndreas Jaekel #include <sys/zfs_vfsops.h> 12a18c35b9SAndreas Jaekel #include <sys/dsl_dir.h> 13a18c35b9SAndreas Jaekel #include <sys/spa_impl.h> 14a18c35b9SAndreas Jaekel #endif 15a18c35b9SAndreas Jaekel 16add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN 40 17add9520fSAndreas Jaekel #define ZEV_MAX_QUEUES 63 18add9520fSAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME "ctrl" 19add9520fSAndreas Jaekel 20add9520fSAndreas Jaekel /* global limit, no queue may grow larger than this. */ 21add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_LEN (1 * 1024 * 1024 * 1024) 22add9520fSAndreas Jaekel 23add9520fSAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */ 24*6a6a51eeSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN 8192 25add9520fSAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN 65536 26add9520fSAndreas Jaekel 27a18c35b9SAndreas Jaekel #define ZEVIOC ('z' << 8) 28add9520fSAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS (ZEVIOC | 1) /* get global stats */ 29fec460f8SAndreas Jaekel #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ 30fec460f8SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ 31fec460f8SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ 32fec460f8SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ 33888fea18SAndreas Jaekel #define ZEV_IOC_MARK (ZEVIOC | 6) /* add mark to queue */ 3435d4e8ddSAndreas Jaekel #define ZEV_IOC_GET_GEN (ZEVIOC | 7) /* get generation no. */ 35add9520fSAndreas Jaekel #define ZEV_IOC_ADD_QUEUE (ZEVIOC | 8) /* create new queue */ 36add9520fSAndreas Jaekel #define ZEV_IOC_REMOVE_QUEUE (ZEVIOC | 9) /* delete queue */ 37add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES (ZEVIOC | 10) /* get properties */ 38add9520fSAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES (ZEVIOC | 11) /* set properties */ 39add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS (ZEVIOC | 12) /* get queue stats */ 40add9520fSAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO (ZEVIOC | 13) /* get internal info */ 41add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST (ZEVIOC | 14) /* get queue list */ 42a18c35b9SAndreas Jaekel 43a18c35b9SAndreas Jaekel #define ZEV_OP_MIN 1 44d979f56cSAndreas Jaekel #define ZEV_OP_ERROR 1 45888fea18SAndreas Jaekel #define ZEV_OP_MARK 2 46888fea18SAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 3 47888fea18SAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 4 48888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 5 49888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 6 50888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 7 51888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 8 52888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 9 53888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 10 54888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 11 55888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 12 56888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_LINK 13 57888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 14 58888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 15 59888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 16 60888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 17 61888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 18 62888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_ACL 19 63888fea18SAndreas Jaekel #define ZEV_OP_MAX 19 64d979f56cSAndreas Jaekel 65add9520fSAndreas Jaekel /* zev event flags */ 66add9520fSAndreas Jaekel #define ZEV_FL_XATTR 0x0001 67add9520fSAndreas Jaekel 68add9520fSAndreas Jaekel /* zev queue flags */ 69add9520fSAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL 0x0001 70add9520fSAndreas Jaekel #define ZEV_FL_PERSISTENT 0x0002 71add9520fSAndreas Jaekel 7219b08257SAndreas Jaekel 73d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 74d979f56cSAndreas Jaekel 75149d0affSAndreas Jaekel #pragma pack(1) 76d979f56cSAndreas Jaekel typedef struct zev_inode_info_t { 77d979f56cSAndreas Jaekel uint64_t ino; 78d979f56cSAndreas Jaekel uint64_t gen; 79d979f56cSAndreas Jaekel uint64_t mtime; 80d979f56cSAndreas Jaekel uint64_t ctime; 81d979f56cSAndreas Jaekel uint64_t size; 82d979f56cSAndreas Jaekel uint64_t mode; 83d979f56cSAndreas Jaekel uint64_t links; 84149d0affSAndreas Jaekel uint32_t type; 8519b08257SAndreas Jaekel uint32_t flags; 86d979f56cSAndreas Jaekel } zev_inode_info_t; 87d979f56cSAndreas Jaekel 88d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 89d979f56cSAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 90d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 91d979f56cSAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 92d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 93d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 94d979f56cSAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 95888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 96d979f56cSAndreas Jaekel 97149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 98149d0affSAndreas Jaekel uint32_t record_len; \ 99149d0affSAndreas Jaekel uint32_t op; \ 100149d0affSAndreas Jaekel uint64_t op_time; \ 101da4b4c3dSAndreas Jaekel uint64_t guid 102149d0affSAndreas Jaekel 103d979f56cSAndreas Jaekel typedef struct zev_header_t { 104149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 105d979f56cSAndreas Jaekel } zev_header_t; 106d979f56cSAndreas Jaekel 107d979f56cSAndreas Jaekel typedef struct zev_error_t { 108149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 109d979f56cSAndreas Jaekel uint32_t failed_op; 110d979f56cSAndreas Jaekel uint32_t errstr_len; 111d979f56cSAndreas Jaekel /* error string follows */ 112d979f56cSAndreas Jaekel } zev_error_t; 113d979f56cSAndreas Jaekel 114888fea18SAndreas Jaekel typedef struct zev_mark_t { 115888fea18SAndreas Jaekel ZEV_COMMON_FIELDS; 116888fea18SAndreas Jaekel uint64_t mark_id; 117888fea18SAndreas Jaekel uint32_t payload_len; 118888fea18SAndreas Jaekel uint32_t padding; 119888fea18SAndreas Jaekel /* payload follows */ 120888fea18SAndreas Jaekel } zev_mark_t; 121888fea18SAndreas Jaekel 122d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t { 123149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 124d979f56cSAndreas Jaekel uint64_t root_ino; 125149d0affSAndreas Jaekel uint32_t remount; 126d979f56cSAndreas Jaekel uint32_t dataset_len; 127d979f56cSAndreas Jaekel uint32_t mountpoint_len; 128149d0affSAndreas Jaekel uint32_t padding; 129d979f56cSAndreas Jaekel /* dataset follows */ 130d979f56cSAndreas Jaekel /* mountpoint follows */ 131d979f56cSAndreas Jaekel } zev_zfs_mount_t; 132d979f56cSAndreas Jaekel 133d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t { 134149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 135d979f56cSAndreas Jaekel } zev_zfs_umount_t; 136d979f56cSAndreas Jaekel 137d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t { 138149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 139d979f56cSAndreas Jaekel uint64_t offset; 140d979f56cSAndreas Jaekel uint64_t length; 141d979f56cSAndreas Jaekel uint32_t dataset_len; 142149d0affSAndreas Jaekel uint32_t padding; 143d979f56cSAndreas Jaekel /* dataset follows */ 144d979f56cSAndreas Jaekel } zev_zvol_truncate_t; 145d979f56cSAndreas Jaekel 146d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t { 147149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 148d979f56cSAndreas Jaekel uint64_t offset; 149d979f56cSAndreas Jaekel uint64_t length; 150d979f56cSAndreas Jaekel uint32_t dataset_len; 151149d0affSAndreas Jaekel uint32_t padding; 152d979f56cSAndreas Jaekel /* dataset follows */ 153d979f56cSAndreas Jaekel } zev_zvol_write_t; 154d979f56cSAndreas Jaekel 155d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t { 156149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 157d979f56cSAndreas Jaekel zev_inode_info_t file; 158d979f56cSAndreas Jaekel } zev_znode_close_after_update_t; 159d979f56cSAndreas Jaekel 160d979f56cSAndreas Jaekel typedef struct zev_znode_create_t { 161149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 162d979f56cSAndreas Jaekel zev_inode_info_t file; 163d979f56cSAndreas Jaekel zev_inode_info_t parent; 164d979f56cSAndreas Jaekel uint32_t name_len; 165149d0affSAndreas Jaekel uint32_t padding; 166d979f56cSAndreas Jaekel /* name follows */ 167d979f56cSAndreas Jaekel } zev_znode_create_t; 168d979f56cSAndreas Jaekel 169d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 170d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 171d979f56cSAndreas Jaekel 172d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t { 173149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 17497dcf88dSAndreas Jaekel zev_inode_info_t file; 175d979f56cSAndreas Jaekel zev_inode_info_t parent; 176d979f56cSAndreas Jaekel uint32_t name_len; 177149d0affSAndreas Jaekel uint32_t padding; 178d979f56cSAndreas Jaekel /* name follows */ 179d979f56cSAndreas Jaekel } zev_znode_remove_t; 180d979f56cSAndreas Jaekel 181d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 182d979f56cSAndreas Jaekel 183d979f56cSAndreas Jaekel typedef struct zev_znode_link_t { 184149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 185d979f56cSAndreas Jaekel zev_inode_info_t parent; 186d979f56cSAndreas Jaekel zev_inode_info_t file; 187d979f56cSAndreas Jaekel uint32_t name_len; 188149d0affSAndreas Jaekel uint32_t padding; 189d979f56cSAndreas Jaekel /* new_name follows */ 190d979f56cSAndreas Jaekel } zev_znode_link_t; 191d979f56cSAndreas Jaekel 192d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t { 193149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 194d979f56cSAndreas Jaekel zev_inode_info_t parent; 195d979f56cSAndreas Jaekel zev_inode_info_t file; 196d979f56cSAndreas Jaekel uint32_t name_len; 197d979f56cSAndreas Jaekel uint32_t link_len; 198d979f56cSAndreas Jaekel /* name follows */ 199d979f56cSAndreas Jaekel /* link follows */ 200d979f56cSAndreas Jaekel } zev_znode_symlink_t; 201d979f56cSAndreas Jaekel 202d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t { 203149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 204d979f56cSAndreas Jaekel zev_inode_info_t srcdir; 205d979f56cSAndreas Jaekel zev_inode_info_t dstdir; 206d979f56cSAndreas Jaekel zev_inode_info_t file; 207d979f56cSAndreas Jaekel uint32_t srcname_len; 208d979f56cSAndreas Jaekel uint32_t dstname_len; 209d979f56cSAndreas Jaekel /* srcname follows */ 210d979f56cSAndreas Jaekel /* dstname follows */ 211d979f56cSAndreas Jaekel } zev_znode_rename_t; 212d979f56cSAndreas Jaekel 213d979f56cSAndreas Jaekel typedef struct zev_znode_write_t { 214149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 215d979f56cSAndreas Jaekel zev_inode_info_t file; 216d979f56cSAndreas Jaekel uint64_t offset; 217d979f56cSAndreas Jaekel uint64_t length; 218d979f56cSAndreas Jaekel } zev_znode_write_t; 219d979f56cSAndreas Jaekel 220d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t { 221149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 222d979f56cSAndreas Jaekel zev_inode_info_t file; 223d979f56cSAndreas Jaekel uint64_t offset; 224d979f56cSAndreas Jaekel uint64_t length; 225d979f56cSAndreas Jaekel } zev_znode_truncate_t; 226d979f56cSAndreas Jaekel 227d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t { 228149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 229d979f56cSAndreas Jaekel zev_inode_info_t file; 230d979f56cSAndreas Jaekel } zev_znode_setattr_t; 231d979f56cSAndreas Jaekel 232d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t { 233149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 234d979f56cSAndreas Jaekel zev_inode_info_t file; 235d979f56cSAndreas Jaekel } zev_znode_acl_t; 236d979f56cSAndreas Jaekel 237d979f56cSAndreas Jaekel /* convenience helper definition */ 238d979f56cSAndreas Jaekel typedef union { 239d979f56cSAndreas Jaekel zev_header_t header; 240d979f56cSAndreas Jaekel 241888fea18SAndreas Jaekel zev_error_t error; 242888fea18SAndreas Jaekel zev_mark_t mark; 243d979f56cSAndreas Jaekel union { 244d979f56cSAndreas Jaekel zev_zfs_mount_t mount; 245d979f56cSAndreas Jaekel zev_zfs_umount_t umount; 246d979f56cSAndreas Jaekel } zfs; 247d979f56cSAndreas Jaekel union { 248d979f56cSAndreas Jaekel zev_zvol_truncate_t truncate; 249d979f56cSAndreas Jaekel zev_zvol_write_t write; 250d979f56cSAndreas Jaekel } zvol; 251d979f56cSAndreas Jaekel union { 252d979f56cSAndreas Jaekel zev_znode_close_after_update_t close; 253d979f56cSAndreas Jaekel zev_znode_create_t create; 254d979f56cSAndreas Jaekel zev_znode_mkdir_t mkdir; 255d979f56cSAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 256d979f56cSAndreas Jaekel zev_znode_remove_t remove; 257d979f56cSAndreas Jaekel zev_znode_rmdir_t rmdir; 258d979f56cSAndreas Jaekel zev_znode_link_t link; 259d979f56cSAndreas Jaekel zev_znode_symlink_t symlink; 260d979f56cSAndreas Jaekel zev_znode_rename_t rename; 261d979f56cSAndreas Jaekel zev_znode_write_t write; 262d979f56cSAndreas Jaekel zev_znode_truncate_t truncate; 263d979f56cSAndreas Jaekel zev_znode_setattr_t setattr; 264d979f56cSAndreas Jaekel zev_znode_acl_t acl; 265d979f56cSAndreas Jaekel } znode; 266d979f56cSAndreas Jaekel } zev_event_t; 267d979f56cSAndreas Jaekel 268d979f56cSAndreas Jaekel 269a18c35b9SAndreas Jaekel 270a18c35b9SAndreas Jaekel typedef struct zev_statistics_t { 271a18c35b9SAndreas Jaekel uint64_t zev_queue_len; 272a18c35b9SAndreas Jaekel uint64_t zev_bytes_read; 273add9520fSAndreas Jaekel uint64_t zev_bytes_discarded; 274fec460f8SAndreas Jaekel /* runtime settings */ 275fec460f8SAndreas Jaekel uint64_t zev_max_queue_len; 276a18c35b9SAndreas Jaekel /* counters */ 277a18c35b9SAndreas Jaekel uint64_t zev_cnt_total_events; 278add9520fSAndreas Jaekel uint64_t zev_cnt_discarded_events; 279a18c35b9SAndreas Jaekel uint64_t zev_cnt_errors; 280888fea18SAndreas Jaekel uint64_t zev_cnt_marks; 281a18c35b9SAndreas Jaekel /* zfsvfs ops */ 282a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 283a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 284a18c35b9SAndreas Jaekel /* zvol ops */ 285a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_write; 286a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 287a18c35b9SAndreas Jaekel /* znode ops */ 288a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 289a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_create; 290a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_remove; 291a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_link; 292a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 293a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_rename; 294a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_write; 295a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 296a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 297a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_acl; 298a18c35b9SAndreas Jaekel } zev_statistics_t; 299a18c35b9SAndreas Jaekel 300add9520fSAndreas Jaekel typedef struct zev_queue_name { 301add9520fSAndreas Jaekel uint64_t zev_namelen; 302add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 303add9520fSAndreas Jaekel } zev_queue_name_t; 304add9520fSAndreas Jaekel 305a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg { 306a18c35b9SAndreas Jaekel uint64_t zev_poolname_len; 307a18c35b9SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 308a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t; 309888fea18SAndreas Jaekel 310888fea18SAndreas Jaekel typedef struct zev_ioctl_mark { 311888fea18SAndreas Jaekel uint64_t zev_mark_id; 312888fea18SAndreas Jaekel uint64_t zev_guid; 313888fea18SAndreas Jaekel uint32_t zev_payload_len; 314808a670aSAndreas Jaekel uint32_t padding; 315888fea18SAndreas Jaekel /* payload follows */ 316888fea18SAndreas Jaekel } zev_ioctl_mark_t; 31735d4e8ddSAndreas Jaekel 31835d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen { 31935d4e8ddSAndreas Jaekel /* input */ 32035d4e8ddSAndreas Jaekel uint64_t inode; 32135d4e8ddSAndreas Jaekel uint32_t fd; /* open fd to any object on the same fs */ 32235d4e8ddSAndreas Jaekel /* noput */ 32335d4e8ddSAndreas Jaekel uint32_t padding; 32435d4e8ddSAndreas Jaekel /* output */ 32535d4e8ddSAndreas Jaekel uint64_t generation; 32635d4e8ddSAndreas Jaekel uint64_t crtime; 32735d4e8ddSAndreas Jaekel uint64_t guid; 32835d4e8ddSAndreas Jaekel char dataset[MAXPATHLEN]; 32935d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t; 330add9520fSAndreas Jaekel 331add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties { 332add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 333add9520fSAndreas Jaekel uint64_t zev_poll_wakeup_threshold; 334add9520fSAndreas Jaekel uint16_t zev_flags; 335*6a6a51eeSAndreas Jaekel uint16_t padding1; 336*6a6a51eeSAndreas Jaekel uint32_t padding2; 337*6a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 338add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t; 339add9520fSAndreas Jaekel 340add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t; 341add9520fSAndreas Jaekel 342add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue { 343add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 344add9520fSAndreas Jaekel uint32_t padding; 345add9520fSAndreas Jaekel uint16_t zev_flags; 346add9520fSAndreas Jaekel uint16_t zev_namelen; 347add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 348add9520fSAndreas Jaekel } zev_ioctl_add_queue_t; 349add9520fSAndreas Jaekel 350add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue { 351*6a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 352add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t; 353add9520fSAndreas Jaekel 354add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics { 355*6a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 356add9520fSAndreas Jaekel zev_statistics_t zev_statistics; 357add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t; 358add9520fSAndreas Jaekel 359add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info { 360add9520fSAndreas Jaekel uint64_t zev_memory_allocated; 361add9520fSAndreas Jaekel } zev_ioctl_debug_info_t; 362add9520fSAndreas Jaekel 363add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list { 364add9520fSAndreas Jaekel uint64_t zev_n_queues; 365add9520fSAndreas Jaekel zev_queue_name_t zev_queue_name[ZEV_MAX_QUEUES]; 366add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t; 367add9520fSAndreas Jaekel 368149d0affSAndreas Jaekel #pragma pack() 369a18c35b9SAndreas Jaekel 370a18c35b9SAndreas Jaekel #ifdef _KERNEL 371add9520fSAndreas Jaekel 372add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated; 373add9520fSAndreas Jaekel extern uint64_t zev_memory_freed; 374add9520fSAndreas Jaekel 375add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize) \ 376add9520fSAndreas Jaekel do { \ 377add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 378add9520fSAndreas Jaekel atomic_add_64(&zev_memory_allocated, tmp_delta); \ 379add9520fSAndreas Jaekel } while(0) 380add9520fSAndreas Jaekel 381add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize) \ 382add9520fSAndreas Jaekel do { \ 383add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 384add9520fSAndreas Jaekel atomic_add_64(&zev_memory_freed, tmp_delta); \ 385add9520fSAndreas Jaekel } while(0) 386add9520fSAndreas Jaekel 387add9520fSAndreas Jaekel #define ZEV_ALLOC(memsize) \ 388add9520fSAndreas Jaekel kmem_alloc(memsize, KM_SLEEP); \ 389add9520fSAndreas Jaekel ZEV_MEM_ADD(memsize); 390add9520fSAndreas Jaekel 391add9520fSAndreas Jaekel #define ZEV_ZALLOC(memsize) \ 392add9520fSAndreas Jaekel kmem_zalloc(memsize, KM_SLEEP); \ 393add9520fSAndreas Jaekel ZEV_MEM_ADD(memsize); 394add9520fSAndreas Jaekel 395add9520fSAndreas Jaekel #define ZEV_FREE(p, memsize) \ 396add9520fSAndreas Jaekel ZEV_MEM_SUB(memsize); \ 397add9520fSAndreas Jaekel kmem_free(p, memsize); 398add9520fSAndreas Jaekel 399d979f56cSAndreas Jaekel typedef struct zev_msg_t { 400d979f56cSAndreas Jaekel struct zev_msg_t *next; 401add9520fSAndreas Jaekel struct zev_msg_t *prev; 402add9520fSAndreas Jaekel uint64_t seq; 403add9520fSAndreas Jaekel uint16_t size; 404add9520fSAndreas Jaekel uint16_t read; 405d979f56cSAndreas Jaekel /* data follows */ 406d979f56cSAndreas Jaekel } zev_msg_t; 407d979f56cSAndreas Jaekel 408d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 409d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 410d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 411a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os); 412d979f56cSAndreas Jaekel 413a18c35b9SAndreas Jaekel #endif 414a18c35b9SAndreas Jaekel 415a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */ 416a18c35b9SAndreas Jaekel 417