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 73c99a1a25SAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY 0x0004 74add9520fSAndreas Jaekel 7542110aacSAndreas Jaekel /* checksum block sizes */ 7642110aacSAndreas Jaekel #define ZEV_L0_SIZE 4096 7742110aacSAndreas Jaekel #define ZEV_L1_SIZE (256 * ZEV_L0_SIZE) 7819b08257SAndreas Jaekel 79d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 80d979f56cSAndreas Jaekel 81149d0affSAndreas Jaekel #pragma pack(1) 82d979f56cSAndreas Jaekel typedef struct zev_inode_info_t { 83d979f56cSAndreas Jaekel uint64_t ino; 84d979f56cSAndreas Jaekel uint64_t gen; 85d979f56cSAndreas Jaekel uint64_t mtime; 86d979f56cSAndreas Jaekel uint64_t ctime; 87d979f56cSAndreas Jaekel uint64_t size; 88d979f56cSAndreas Jaekel uint64_t mode; 89d979f56cSAndreas Jaekel uint64_t links; 90149d0affSAndreas Jaekel uint32_t type; 9119b08257SAndreas Jaekel uint32_t flags; 92d979f56cSAndreas Jaekel } zev_inode_info_t; 93d979f56cSAndreas Jaekel 94d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 95d979f56cSAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 96d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 97d979f56cSAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 98d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 99d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 100d979f56cSAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 101888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 102205ed6bfSAndreas Jaekel #define ZEV_SIGNATURES(rec) ((char *)(rec + 1)) 103d979f56cSAndreas Jaekel 104149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 105149d0affSAndreas Jaekel uint32_t record_len; \ 106149d0affSAndreas Jaekel uint32_t op; \ 107149d0affSAndreas Jaekel uint64_t op_time; \ 108da4b4c3dSAndreas Jaekel uint64_t guid 109149d0affSAndreas Jaekel 110205ed6bfSAndreas Jaekel typedef struct zev_sig_t { 111205ed6bfSAndreas Jaekel uint16_t level; 112205ed6bfSAndreas Jaekel uint16_t padding1; 113205ed6bfSAndreas Jaekel uint32_t padding2; 114205ed6bfSAndreas Jaekel uint64_t block_offset; 115205ed6bfSAndreas Jaekel uint8_t value[SHA1_DIGEST_LENGTH]; /* 20 bytes -> no padding */ 116205ed6bfSAndreas Jaekel } zev_sig_t; 117205ed6bfSAndreas Jaekel 118d979f56cSAndreas Jaekel typedef struct zev_header_t { 119149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 120d979f56cSAndreas Jaekel } zev_header_t; 121d979f56cSAndreas Jaekel 122d979f56cSAndreas Jaekel typedef struct zev_error_t { 123149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 124d979f56cSAndreas Jaekel uint32_t failed_op; 125d979f56cSAndreas Jaekel uint32_t errstr_len; 126d979f56cSAndreas Jaekel /* error string follows */ 127d979f56cSAndreas Jaekel } zev_error_t; 128d979f56cSAndreas Jaekel 129888fea18SAndreas Jaekel typedef struct zev_mark_t { 130888fea18SAndreas Jaekel ZEV_COMMON_FIELDS; 131888fea18SAndreas Jaekel uint64_t mark_id; 132888fea18SAndreas Jaekel uint32_t payload_len; 133888fea18SAndreas Jaekel uint32_t padding; 134888fea18SAndreas Jaekel /* payload follows */ 135888fea18SAndreas Jaekel } zev_mark_t; 136888fea18SAndreas Jaekel 137d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t { 138149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 13993297ba3SAndreas Jaekel zev_inode_info_t root; 140149d0affSAndreas Jaekel uint32_t remount; 141d979f56cSAndreas Jaekel uint32_t dataset_len; 142d979f56cSAndreas Jaekel uint32_t mountpoint_len; 143149d0affSAndreas Jaekel uint32_t padding; 144d979f56cSAndreas Jaekel /* dataset follows */ 145d979f56cSAndreas Jaekel /* mountpoint follows */ 146d979f56cSAndreas Jaekel } zev_zfs_mount_t; 147d979f56cSAndreas Jaekel 148d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t { 149149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 15094875cb8SAndreas Jaekel zev_inode_info_t covered; 151d979f56cSAndreas Jaekel } zev_zfs_umount_t; 152d979f56cSAndreas Jaekel 153d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t { 154149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 15512119a7eSAndreas Jaekel uint64_t txg; 156d979f56cSAndreas Jaekel uint64_t offset; 157d979f56cSAndreas Jaekel uint64_t length; 158d979f56cSAndreas Jaekel uint32_t dataset_len; 159149d0affSAndreas Jaekel uint32_t padding; 160d979f56cSAndreas Jaekel /* dataset follows */ 161d979f56cSAndreas Jaekel } zev_zvol_truncate_t; 162d979f56cSAndreas Jaekel 163d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t { 164149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 16512119a7eSAndreas Jaekel uint64_t txg; 166d979f56cSAndreas Jaekel uint64_t offset; 167d979f56cSAndreas Jaekel uint64_t length; 168d979f56cSAndreas Jaekel uint32_t dataset_len; 169149d0affSAndreas Jaekel uint32_t padding; 170d979f56cSAndreas Jaekel /* dataset follows */ 171d979f56cSAndreas Jaekel } zev_zvol_write_t; 172d979f56cSAndreas Jaekel 173d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t { 174149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 175d979f56cSAndreas Jaekel zev_inode_info_t file; 176d979f56cSAndreas Jaekel } zev_znode_close_after_update_t; 177d979f56cSAndreas Jaekel 178d979f56cSAndreas Jaekel typedef struct zev_znode_create_t { 179149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 18012119a7eSAndreas Jaekel uint64_t txg; 181d979f56cSAndreas Jaekel zev_inode_info_t file; 182d979f56cSAndreas Jaekel zev_inode_info_t parent; 1832eabeab5SAndreas Jaekel zev_sig_t signature; 184d979f56cSAndreas Jaekel uint32_t name_len; 185149d0affSAndreas Jaekel uint32_t padding; 186d979f56cSAndreas Jaekel /* name follows */ 187d979f56cSAndreas Jaekel } zev_znode_create_t; 188d979f56cSAndreas Jaekel 189d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 190d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 191d979f56cSAndreas Jaekel 192d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t { 193149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 19412119a7eSAndreas Jaekel uint64_t txg; 19597dcf88dSAndreas Jaekel zev_inode_info_t file; 196d979f56cSAndreas Jaekel zev_inode_info_t parent; 197d979f56cSAndreas Jaekel uint32_t name_len; 198149d0affSAndreas Jaekel uint32_t padding; 199d979f56cSAndreas Jaekel /* name follows */ 200d979f56cSAndreas Jaekel } zev_znode_remove_t; 201d979f56cSAndreas Jaekel 202d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 203d979f56cSAndreas Jaekel 204d979f56cSAndreas Jaekel typedef struct zev_znode_link_t { 205149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 20612119a7eSAndreas Jaekel uint64_t txg; 207d979f56cSAndreas Jaekel zev_inode_info_t parent; 208d979f56cSAndreas Jaekel zev_inode_info_t file; 209d979f56cSAndreas Jaekel uint32_t name_len; 210149d0affSAndreas Jaekel uint32_t padding; 211d979f56cSAndreas Jaekel /* new_name follows */ 212d979f56cSAndreas Jaekel } zev_znode_link_t; 213d979f56cSAndreas Jaekel 214d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t { 215149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 21612119a7eSAndreas Jaekel uint64_t txg; 217d979f56cSAndreas Jaekel zev_inode_info_t parent; 218d979f56cSAndreas Jaekel zev_inode_info_t file; 2192eabeab5SAndreas Jaekel zev_sig_t signature; 220d979f56cSAndreas Jaekel uint32_t name_len; 221d979f56cSAndreas Jaekel uint32_t link_len; 222d979f56cSAndreas Jaekel /* name follows */ 223d979f56cSAndreas Jaekel /* link follows */ 224d979f56cSAndreas Jaekel } zev_znode_symlink_t; 225d979f56cSAndreas Jaekel 226d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t { 227149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 22812119a7eSAndreas Jaekel uint64_t txg; 229d979f56cSAndreas Jaekel zev_inode_info_t srcdir; 230d979f56cSAndreas Jaekel zev_inode_info_t dstdir; 231d979f56cSAndreas Jaekel zev_inode_info_t file; 232*8aa47a6bSAndreas Jaekel zev_inode_info_t clobbered_file; 233d979f56cSAndreas Jaekel uint32_t srcname_len; 234d979f56cSAndreas Jaekel uint32_t dstname_len; 235d979f56cSAndreas Jaekel /* srcname follows */ 236d979f56cSAndreas Jaekel /* dstname follows */ 237d979f56cSAndreas Jaekel } zev_znode_rename_t; 238d979f56cSAndreas Jaekel 239d979f56cSAndreas Jaekel typedef struct zev_znode_write_t { 240149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 24112119a7eSAndreas Jaekel uint64_t txg; 242d979f56cSAndreas Jaekel zev_inode_info_t file; 243d979f56cSAndreas Jaekel uint64_t offset; 244d979f56cSAndreas Jaekel uint64_t length; 245205ed6bfSAndreas Jaekel uint64_t signature_cnt; 246205ed6bfSAndreas Jaekel /* signatures follow */ 247d979f56cSAndreas Jaekel } zev_znode_write_t; 248d979f56cSAndreas Jaekel 249d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t { 250149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 25112119a7eSAndreas Jaekel uint64_t txg; 252d979f56cSAndreas Jaekel zev_inode_info_t file; 253d979f56cSAndreas Jaekel uint64_t offset; 254d979f56cSAndreas Jaekel uint64_t length; 255205ed6bfSAndreas Jaekel uint64_t signature_cnt; 256205ed6bfSAndreas Jaekel /* signatures follow */ 257d979f56cSAndreas Jaekel } zev_znode_truncate_t; 258d979f56cSAndreas Jaekel 259d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t { 260149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 26112119a7eSAndreas Jaekel uint64_t txg; 262d979f56cSAndreas Jaekel zev_inode_info_t file; 263d979f56cSAndreas Jaekel } zev_znode_setattr_t; 264d979f56cSAndreas Jaekel 265d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t { 266149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 26712119a7eSAndreas Jaekel uint64_t txg; 268d979f56cSAndreas Jaekel zev_inode_info_t file; 269d979f56cSAndreas Jaekel } zev_znode_acl_t; 270d979f56cSAndreas Jaekel 271d979f56cSAndreas Jaekel /* convenience helper definition */ 272d979f56cSAndreas Jaekel typedef union { 273d979f56cSAndreas Jaekel zev_header_t header; 274d979f56cSAndreas Jaekel 275888fea18SAndreas Jaekel zev_error_t error; 276888fea18SAndreas Jaekel zev_mark_t mark; 277d979f56cSAndreas Jaekel union { 278d979f56cSAndreas Jaekel zev_zfs_mount_t mount; 279d979f56cSAndreas Jaekel zev_zfs_umount_t umount; 280d979f56cSAndreas Jaekel } zfs; 281d979f56cSAndreas Jaekel union { 282d979f56cSAndreas Jaekel zev_zvol_truncate_t truncate; 283d979f56cSAndreas Jaekel zev_zvol_write_t write; 284d979f56cSAndreas Jaekel } zvol; 285d979f56cSAndreas Jaekel union { 286d979f56cSAndreas Jaekel zev_znode_close_after_update_t close; 287d979f56cSAndreas Jaekel zev_znode_create_t create; 288d979f56cSAndreas Jaekel zev_znode_mkdir_t mkdir; 289d979f56cSAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 290d979f56cSAndreas Jaekel zev_znode_remove_t remove; 291d979f56cSAndreas Jaekel zev_znode_rmdir_t rmdir; 292d979f56cSAndreas Jaekel zev_znode_link_t link; 293d979f56cSAndreas Jaekel zev_znode_symlink_t symlink; 294d979f56cSAndreas Jaekel zev_znode_rename_t rename; 295d979f56cSAndreas Jaekel zev_znode_write_t write; 296d979f56cSAndreas Jaekel zev_znode_truncate_t truncate; 297d979f56cSAndreas Jaekel zev_znode_setattr_t setattr; 298d979f56cSAndreas Jaekel zev_znode_acl_t acl; 299d979f56cSAndreas Jaekel } znode; 300d979f56cSAndreas Jaekel } zev_event_t; 301d979f56cSAndreas Jaekel 302d979f56cSAndreas Jaekel 303a18c35b9SAndreas Jaekel 304a18c35b9SAndreas Jaekel typedef struct zev_statistics_t { 305a18c35b9SAndreas Jaekel uint64_t zev_queue_len; 306a18c35b9SAndreas Jaekel uint64_t zev_bytes_read; 307add9520fSAndreas Jaekel uint64_t zev_bytes_discarded; 308fec460f8SAndreas Jaekel /* runtime settings */ 309fec460f8SAndreas Jaekel uint64_t zev_max_queue_len; 310a18c35b9SAndreas Jaekel /* counters */ 311a18c35b9SAndreas Jaekel uint64_t zev_cnt_total_events; 312add9520fSAndreas Jaekel uint64_t zev_cnt_discarded_events; 313a18c35b9SAndreas Jaekel uint64_t zev_cnt_errors; 314888fea18SAndreas Jaekel uint64_t zev_cnt_marks; 315a18c35b9SAndreas Jaekel /* zfsvfs ops */ 316a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 317a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 318a18c35b9SAndreas Jaekel /* zvol ops */ 319a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_write; 320a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 321a18c35b9SAndreas Jaekel /* znode ops */ 322a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 323a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_create; 324a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_remove; 325a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_link; 326a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 327a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_rename; 328a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_write; 329a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 330a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 331a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_acl; 332a18c35b9SAndreas Jaekel } zev_statistics_t; 333a18c35b9SAndreas Jaekel 334add9520fSAndreas Jaekel typedef struct zev_queue_name { 335add9520fSAndreas Jaekel uint64_t zev_namelen; 336add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 337add9520fSAndreas Jaekel } zev_queue_name_t; 338add9520fSAndreas Jaekel 339a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg { 340a18c35b9SAndreas Jaekel uint64_t zev_poolname_len; 341a18c35b9SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 342a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t; 343888fea18SAndreas Jaekel 344888fea18SAndreas Jaekel typedef struct zev_ioctl_mark { 345888fea18SAndreas Jaekel uint64_t zev_mark_id; 346888fea18SAndreas Jaekel uint64_t zev_guid; 347888fea18SAndreas Jaekel uint32_t zev_payload_len; 348808a670aSAndreas Jaekel uint32_t padding; 349888fea18SAndreas Jaekel /* payload follows */ 350888fea18SAndreas Jaekel } zev_ioctl_mark_t; 35135d4e8ddSAndreas Jaekel 35235d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen { 35335d4e8ddSAndreas Jaekel /* input */ 35435d4e8ddSAndreas Jaekel uint64_t inode; 35535d4e8ddSAndreas Jaekel uint32_t fd; /* open fd to any object on the same fs */ 35635d4e8ddSAndreas Jaekel /* noput */ 35735d4e8ddSAndreas Jaekel uint32_t padding; 35835d4e8ddSAndreas Jaekel /* output */ 35935d4e8ddSAndreas Jaekel uint64_t generation; 36035d4e8ddSAndreas Jaekel uint64_t crtime; 36135d4e8ddSAndreas Jaekel uint64_t guid; 36235d4e8ddSAndreas Jaekel char dataset[MAXPATHLEN]; 36335d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t; 364add9520fSAndreas Jaekel 365add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties { 366add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 367add9520fSAndreas Jaekel uint64_t zev_poll_wakeup_threshold; 368add9520fSAndreas Jaekel uint16_t zev_flags; 3696a6a51eeSAndreas Jaekel uint16_t padding1; 3706a6a51eeSAndreas Jaekel uint32_t padding2; 3716a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 372add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t; 373add9520fSAndreas Jaekel 374add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t; 375add9520fSAndreas Jaekel 376add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue { 377add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 378add9520fSAndreas Jaekel uint32_t padding; 379add9520fSAndreas Jaekel uint16_t zev_flags; 380add9520fSAndreas Jaekel uint16_t zev_namelen; 381add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 382add9520fSAndreas Jaekel } zev_ioctl_add_queue_t; 383add9520fSAndreas Jaekel 384add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue { 3856a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 386add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t; 387add9520fSAndreas Jaekel 388add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics { 3896a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 390add9520fSAndreas Jaekel zev_statistics_t zev_statistics; 391add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t; 392add9520fSAndreas Jaekel 393add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info { 394add9520fSAndreas Jaekel uint64_t zev_memory_allocated; 395205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_size; 396205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_hits; 397205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_misses; 398add9520fSAndreas Jaekel } zev_ioctl_debug_info_t; 399add9520fSAndreas Jaekel 400add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list { 401add9520fSAndreas Jaekel uint64_t zev_n_queues; 402add9520fSAndreas Jaekel zev_queue_name_t zev_queue_name[ZEV_MAX_QUEUES]; 403add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t; 404add9520fSAndreas Jaekel 40542110aacSAndreas Jaekel typedef struct zev_ioctl_get_signatures { 40642110aacSAndreas Jaekel /* in */ 40742110aacSAndreas Jaekel uint64_t zev_offset; 40842110aacSAndreas Jaekel uint64_t zev_len; 40942110aacSAndreas Jaekel uint32_t zev_fd; 41042110aacSAndreas Jaekel uint32_t zev_bufsize; 41142110aacSAndreas Jaekel /* out */ 41242110aacSAndreas Jaekel uint64_t zev_signature_cnt; 41342110aacSAndreas Jaekel /* up to zev_bufsize bytes of checksums will be written here */ 41442110aacSAndreas Jaekel } zev_ioctl_get_signatures_t; 41542110aacSAndreas Jaekel 416149d0affSAndreas Jaekel #pragma pack() 417a18c35b9SAndreas Jaekel 418a18c35b9SAndreas Jaekel #ifdef _KERNEL 419add9520fSAndreas Jaekel 420add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated; 421add9520fSAndreas Jaekel extern uint64_t zev_memory_freed; 422add9520fSAndreas Jaekel 423add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize) \ 424add9520fSAndreas Jaekel do { \ 425add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 426add9520fSAndreas Jaekel atomic_add_64(&zev_memory_allocated, tmp_delta); \ 427add9520fSAndreas Jaekel } while(0) 428add9520fSAndreas Jaekel 429add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize) \ 430add9520fSAndreas Jaekel do { \ 431add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 432add9520fSAndreas Jaekel atomic_add_64(&zev_memory_freed, tmp_delta); \ 433add9520fSAndreas Jaekel } while(0) 434add9520fSAndreas Jaekel 435205ed6bfSAndreas Jaekel void *zev_alloc(ssize_t sz); 436205ed6bfSAndreas Jaekel void *zev_zalloc(ssize_t sz); 437205ed6bfSAndreas Jaekel void zev_free(void *ptr, ssize_t sz); 438add9520fSAndreas Jaekel 439d979f56cSAndreas Jaekel typedef struct zev_msg_t { 440d979f56cSAndreas Jaekel struct zev_msg_t *next; 441add9520fSAndreas Jaekel struct zev_msg_t *prev; 442add9520fSAndreas Jaekel uint64_t seq; 443add9520fSAndreas Jaekel uint16_t size; 444add9520fSAndreas Jaekel uint16_t read; 445d979f56cSAndreas Jaekel /* data follows */ 446d979f56cSAndreas Jaekel } zev_msg_t; 447d979f56cSAndreas Jaekel 448d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 449d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 450d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 451a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os); 452d979f56cSAndreas Jaekel 453a18c35b9SAndreas Jaekel #endif 454a18c35b9SAndreas Jaekel 455a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */ 456a18c35b9SAndreas Jaekel 457