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> 75e286361SAndreas Jaekel #include <sys/sha1.h> 82bb8e5e2SAndreas Jaekel 92bb8e5e2SAndreas Jaekel #ifdef _KERNEL 102bb8e5e2SAndreas Jaekel #include <sys/dmu_objset.h> 112bb8e5e2SAndreas Jaekel #include <sys/dsl_dataset.h> 122bb8e5e2SAndreas Jaekel #include <sys/zfs_vfsops.h> 132bb8e5e2SAndreas Jaekel #include <sys/dsl_dir.h> 142bb8e5e2SAndreas Jaekel #include <sys/spa_impl.h> 152bb8e5e2SAndreas Jaekel #endif 162bb8e5e2SAndreas Jaekel 17c62d8367SAndreas Jaekel /* increased for incompatible interface and behaviour changes */ 18d3b66d30SSimon Klinkert #define ZEV_MAJOR_VERSION 2 19c62d8367SAndreas Jaekel /* increased for compatible changes, including new ioctls(), etc. */ 20*4053e902SSimon Klinkert #define ZEV_MINOR_VERSION 1 21c62d8367SAndreas Jaekel 22e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN 40 236450d95eSAndreas Jaekel #define ZEV_MAX_QUEUES 60 24e9a5e479SAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME "ctrl" 256450d95eSAndreas Jaekel #define ZEV_TMPQUEUE_DEVICE_NAME "tmpqueue" 26e9a5e479SAndreas Jaekel 27e9a5e479SAndreas Jaekel /* global limit, no queue may grow larger than this. */ 28e9a5e479SAndreas Jaekel #define ZEV_MAX_QUEUE_LEN (1 * 1024 * 1024 * 1024) 29e9a5e479SAndreas Jaekel 30e9a5e479SAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */ 314ca7dd5eSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN 8192 32e9a5e479SAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN 65536 33e9a5e479SAndreas Jaekel 342bb8e5e2SAndreas Jaekel #define ZEVIOC ('z' << 8) 35e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS (ZEVIOC | 1) /* get global stats */ 362bb8e5e2SAndreas Jaekel #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ 372bb8e5e2SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ 382bb8e5e2SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ 39205a9bc9SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ 4001c2c787SAndreas Jaekel #define ZEV_IOC_MARK (ZEVIOC | 6) /* add mark to queue */ 41c035b1e8SAndreas Jaekel #define ZEV_IOC_GET_GEN (ZEVIOC | 7) /* get generation no. */ 42e9a5e479SAndreas Jaekel #define ZEV_IOC_ADD_QUEUE (ZEVIOC | 8) /* create new queue */ 43e9a5e479SAndreas Jaekel #define ZEV_IOC_REMOVE_QUEUE (ZEVIOC | 9) /* delete queue */ 44e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES (ZEVIOC | 10) /* get properties */ 45e9a5e479SAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES (ZEVIOC | 11) /* set properties */ 46e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS (ZEVIOC | 12) /* get queue stats */ 47e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO (ZEVIOC | 13) /* get internal info */ 48e9a5e479SAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST (ZEVIOC | 14) /* get queue list */ 49b9710123SAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES (ZEVIOC | 15) /* get beaver sigs */ 50c62d8367SAndreas Jaekel #define ZEV_IOC_GET_ZEV_VERSION (ZEVIOC | 16) /* get zev version */ 512bb8e5e2SAndreas Jaekel 522bb8e5e2SAndreas Jaekel #define ZEV_OP_MIN 1 539193e9c2SAndreas Jaekel #define ZEV_OP_ERROR 1 5401c2c787SAndreas Jaekel #define ZEV_OP_MARK 2 5501c2c787SAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 3 5601c2c787SAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 4 5701c2c787SAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 5 5801c2c787SAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 6 5901c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 7 6001c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 8 6101c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 9 6201c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 10 6301c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 11 6401c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 12 6501c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_LINK 13 6601c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 14 6701c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 15 6801c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 16 6901c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 17 7001c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 18 7101c2c787SAndreas Jaekel #define ZEV_OP_ZNODE_ACL 19 7201c2c787SAndreas Jaekel #define ZEV_OP_MAX 19 732bb8e5e2SAndreas Jaekel 74e9a5e479SAndreas Jaekel /* zev event flags */ 75e9a5e479SAndreas Jaekel #define ZEV_FL_XATTR 0x0001 76e9a5e479SAndreas Jaekel 77e9a5e479SAndreas Jaekel /* zev queue flags */ 78e9a5e479SAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL 0x0001 79e9a5e479SAndreas Jaekel #define ZEV_FL_PERSISTENT 0x0002 80b434d29cSAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY 0x0004 81e9a5e479SAndreas Jaekel 82b9710123SAndreas Jaekel /* checksum block sizes */ 83b9710123SAndreas Jaekel #define ZEV_L0_SIZE 4096 84b9710123SAndreas Jaekel #define ZEV_L1_SIZE (256 * ZEV_L0_SIZE) 8510874358SAndreas Jaekel 8663aba447SAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 8763aba447SAndreas Jaekel 88108668daSAndreas Jaekel #pragma pack(1) 8963aba447SAndreas Jaekel typedef struct zev_inode_info_t { 9063aba447SAndreas Jaekel uint64_t ino; 9163aba447SAndreas Jaekel uint64_t gen; 9263aba447SAndreas Jaekel uint64_t mtime; 9363aba447SAndreas Jaekel uint64_t ctime; 9463aba447SAndreas Jaekel uint64_t size; 9563aba447SAndreas Jaekel uint64_t mode; 9663aba447SAndreas Jaekel uint64_t links; 97108668daSAndreas Jaekel uint32_t type; 9810874358SAndreas Jaekel uint32_t flags; 9963aba447SAndreas Jaekel } zev_inode_info_t; 10063aba447SAndreas Jaekel 10163aba447SAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 10263aba447SAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 10363aba447SAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 10463aba447SAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 10563aba447SAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 10663aba447SAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 10763aba447SAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 10801c2c787SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 1095e286361SAndreas Jaekel #define ZEV_SIGNATURES(rec) ((char *)(rec + 1)) 11063aba447SAndreas Jaekel 111108668daSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 112108668daSAndreas Jaekel uint32_t record_len; \ 113108668daSAndreas Jaekel uint32_t op; \ 114108668daSAndreas Jaekel uint64_t op_time; \ 115b9df2829SAndreas Jaekel uint64_t guid 116108668daSAndreas Jaekel 1175e286361SAndreas Jaekel typedef struct zev_sig_t { 1185e286361SAndreas Jaekel uint16_t level; 1195e286361SAndreas Jaekel uint16_t padding1; 1205e286361SAndreas Jaekel uint32_t padding2; 1215e286361SAndreas Jaekel uint64_t block_offset; 1225e286361SAndreas Jaekel uint8_t value[SHA1_DIGEST_LENGTH]; /* 20 bytes -> no padding */ 1235e286361SAndreas Jaekel } zev_sig_t; 1245e286361SAndreas Jaekel 12568a46c64SAndreas Jaekel typedef struct zev_header_t { 126108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 12768a46c64SAndreas Jaekel } zev_header_t; 12863aba447SAndreas Jaekel 12963aba447SAndreas Jaekel typedef struct zev_error_t { 130108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 13163aba447SAndreas Jaekel uint32_t failed_op; 13263aba447SAndreas Jaekel uint32_t errstr_len; 13363aba447SAndreas Jaekel /* error string follows */ 13463aba447SAndreas Jaekel } zev_error_t; 13563aba447SAndreas Jaekel 13601c2c787SAndreas Jaekel typedef struct zev_mark_t { 13701c2c787SAndreas Jaekel ZEV_COMMON_FIELDS; 13801c2c787SAndreas Jaekel uint64_t mark_id; 13901c2c787SAndreas Jaekel uint32_t payload_len; 14001c2c787SAndreas Jaekel uint32_t padding; 14101c2c787SAndreas Jaekel /* payload follows */ 14201c2c787SAndreas Jaekel } zev_mark_t; 14301c2c787SAndreas Jaekel 14463aba447SAndreas Jaekel typedef struct zev_zfs_mount_t { 145108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 146f66561e7SAndreas Jaekel zev_inode_info_t root; 147d3b66d30SSimon Klinkert uint64_t txg; 148108668daSAndreas Jaekel uint32_t remount; 14963aba447SAndreas Jaekel uint32_t dataset_len; 15063aba447SAndreas Jaekel uint32_t mountpoint_len; 151108668daSAndreas Jaekel uint32_t padding; 15263aba447SAndreas Jaekel /* dataset follows */ 15363aba447SAndreas Jaekel /* mountpoint follows */ 15463aba447SAndreas Jaekel } zev_zfs_mount_t; 15563aba447SAndreas Jaekel 15663aba447SAndreas Jaekel typedef struct zev_zfs_umount_t { 157108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 158d3b66d30SSimon Klinkert uint64_t txg; 159443f0cd2SAndreas Jaekel zev_inode_info_t covered; 16063aba447SAndreas Jaekel } zev_zfs_umount_t; 16163aba447SAndreas Jaekel 16263aba447SAndreas Jaekel typedef struct zev_zvol_truncate_t { 163108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 164e206ace3SAndreas Jaekel uint64_t txg; 16563aba447SAndreas Jaekel uint64_t offset; 16663aba447SAndreas Jaekel uint64_t length; 16763aba447SAndreas Jaekel uint32_t dataset_len; 168108668daSAndreas Jaekel uint32_t padding; 16963aba447SAndreas Jaekel /* dataset follows */ 17063aba447SAndreas Jaekel } zev_zvol_truncate_t; 17163aba447SAndreas Jaekel 17263aba447SAndreas Jaekel typedef struct zev_zvol_write_t { 173108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 174e206ace3SAndreas Jaekel uint64_t txg; 17563aba447SAndreas Jaekel uint64_t offset; 17663aba447SAndreas Jaekel uint64_t length; 17763aba447SAndreas Jaekel uint32_t dataset_len; 178108668daSAndreas Jaekel uint32_t padding; 17963aba447SAndreas Jaekel /* dataset follows */ 18063aba447SAndreas Jaekel } zev_zvol_write_t; 18163aba447SAndreas Jaekel 18263aba447SAndreas Jaekel typedef struct zev_znode_close_after_update_t { 183108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 18463aba447SAndreas Jaekel zev_inode_info_t file; 18563aba447SAndreas Jaekel } zev_znode_close_after_update_t; 18663aba447SAndreas Jaekel 18763aba447SAndreas Jaekel typedef struct zev_znode_create_t { 188108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 189e206ace3SAndreas Jaekel uint64_t txg; 19063aba447SAndreas Jaekel zev_inode_info_t file; 19163aba447SAndreas Jaekel zev_inode_info_t parent; 1921ca5a13bSAndreas Jaekel zev_sig_t signature; 19363aba447SAndreas Jaekel uint32_t name_len; 194108668daSAndreas Jaekel uint32_t padding; 19563aba447SAndreas Jaekel /* name follows */ 19663aba447SAndreas Jaekel } zev_znode_create_t; 19763aba447SAndreas Jaekel 19863aba447SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 19963aba447SAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 20063aba447SAndreas Jaekel 20163aba447SAndreas Jaekel typedef struct zev_znode_remove_t { 202108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 203e206ace3SAndreas Jaekel uint64_t txg; 2046db5d4ecSAndreas Jaekel zev_inode_info_t file; 20563aba447SAndreas Jaekel zev_inode_info_t parent; 20663aba447SAndreas Jaekel uint32_t name_len; 207108668daSAndreas Jaekel uint32_t padding; 20863aba447SAndreas Jaekel /* name follows */ 20963aba447SAndreas Jaekel } zev_znode_remove_t; 21063aba447SAndreas Jaekel 21163aba447SAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 21263aba447SAndreas Jaekel 21363aba447SAndreas Jaekel typedef struct zev_znode_link_t { 214108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 215e206ace3SAndreas Jaekel uint64_t txg; 21663aba447SAndreas Jaekel zev_inode_info_t parent; 21763aba447SAndreas Jaekel zev_inode_info_t file; 21863aba447SAndreas Jaekel uint32_t name_len; 219108668daSAndreas Jaekel uint32_t padding; 22063aba447SAndreas Jaekel /* new_name follows */ 22163aba447SAndreas Jaekel } zev_znode_link_t; 22263aba447SAndreas Jaekel 22363aba447SAndreas Jaekel typedef struct zev_znode_symlink_t { 224108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 225e206ace3SAndreas Jaekel uint64_t txg; 22663aba447SAndreas Jaekel zev_inode_info_t parent; 22763aba447SAndreas Jaekel zev_inode_info_t file; 2281ca5a13bSAndreas Jaekel zev_sig_t signature; 22963aba447SAndreas Jaekel uint32_t name_len; 23063aba447SAndreas Jaekel uint32_t link_len; 23163aba447SAndreas Jaekel /* name follows */ 23263aba447SAndreas Jaekel /* link follows */ 23363aba447SAndreas Jaekel } zev_znode_symlink_t; 23463aba447SAndreas Jaekel 23563aba447SAndreas Jaekel typedef struct zev_znode_rename_t { 236108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 237e206ace3SAndreas Jaekel uint64_t txg; 23863aba447SAndreas Jaekel zev_inode_info_t srcdir; 23963aba447SAndreas Jaekel zev_inode_info_t dstdir; 24063aba447SAndreas Jaekel zev_inode_info_t file; 241f8e3fee2SAndreas Jaekel zev_inode_info_t clobbered_file; 24263aba447SAndreas Jaekel uint32_t srcname_len; 24363aba447SAndreas Jaekel uint32_t dstname_len; 24463aba447SAndreas Jaekel /* srcname follows */ 24563aba447SAndreas Jaekel /* dstname follows */ 24663aba447SAndreas Jaekel } zev_znode_rename_t; 24763aba447SAndreas Jaekel 24863aba447SAndreas Jaekel typedef struct zev_znode_write_t { 249108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 250e206ace3SAndreas Jaekel uint64_t txg; 25163aba447SAndreas Jaekel zev_inode_info_t file; 25263aba447SAndreas Jaekel uint64_t offset; 25363aba447SAndreas Jaekel uint64_t length; 2545e286361SAndreas Jaekel uint64_t signature_cnt; 2555e286361SAndreas Jaekel /* signatures follow */ 25663aba447SAndreas Jaekel } zev_znode_write_t; 25763aba447SAndreas Jaekel 25863aba447SAndreas Jaekel typedef struct zev_znode_truncate_t { 259108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 260e206ace3SAndreas Jaekel uint64_t txg; 26163aba447SAndreas Jaekel zev_inode_info_t file; 26263aba447SAndreas Jaekel uint64_t offset; 26363aba447SAndreas Jaekel uint64_t length; 2645e286361SAndreas Jaekel uint64_t signature_cnt; 2655e286361SAndreas Jaekel /* signatures follow */ 26663aba447SAndreas Jaekel } zev_znode_truncate_t; 26763aba447SAndreas Jaekel 26863aba447SAndreas Jaekel typedef struct zev_znode_setattr_t { 269108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 270e206ace3SAndreas Jaekel uint64_t txg; 27163aba447SAndreas Jaekel zev_inode_info_t file; 27263aba447SAndreas Jaekel } zev_znode_setattr_t; 27363aba447SAndreas Jaekel 27463aba447SAndreas Jaekel typedef struct zev_znode_acl_t { 275108668daSAndreas Jaekel ZEV_COMMON_FIELDS; 276e206ace3SAndreas Jaekel uint64_t txg; 27763aba447SAndreas Jaekel zev_inode_info_t file; 27863aba447SAndreas Jaekel } zev_znode_acl_t; 27963aba447SAndreas Jaekel 28068a46c64SAndreas Jaekel /* convenience helper definition */ 28168a46c64SAndreas Jaekel typedef union { 28268a46c64SAndreas Jaekel zev_header_t header; 28368a46c64SAndreas Jaekel 28401c2c787SAndreas Jaekel zev_error_t error; 28501c2c787SAndreas Jaekel zev_mark_t mark; 28668a46c64SAndreas Jaekel union { 28768a46c64SAndreas Jaekel zev_zfs_mount_t mount; 28868a46c64SAndreas Jaekel zev_zfs_umount_t umount; 28968a46c64SAndreas Jaekel } zfs; 29068a46c64SAndreas Jaekel union { 29168a46c64SAndreas Jaekel zev_zvol_truncate_t truncate; 29268a46c64SAndreas Jaekel zev_zvol_write_t write; 29368a46c64SAndreas Jaekel } zvol; 29468a46c64SAndreas Jaekel union { 29568a46c64SAndreas Jaekel zev_znode_close_after_update_t close; 29668a46c64SAndreas Jaekel zev_znode_create_t create; 29768a46c64SAndreas Jaekel zev_znode_mkdir_t mkdir; 29868a46c64SAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 29968a46c64SAndreas Jaekel zev_znode_remove_t remove; 30068a46c64SAndreas Jaekel zev_znode_rmdir_t rmdir; 30168a46c64SAndreas Jaekel zev_znode_link_t link; 30268a46c64SAndreas Jaekel zev_znode_symlink_t symlink; 30368a46c64SAndreas Jaekel zev_znode_rename_t rename; 30468a46c64SAndreas Jaekel zev_znode_write_t write; 30568a46c64SAndreas Jaekel zev_znode_truncate_t truncate; 30668a46c64SAndreas Jaekel zev_znode_setattr_t setattr; 30768a46c64SAndreas Jaekel zev_znode_acl_t acl; 30868a46c64SAndreas Jaekel } znode; 30968a46c64SAndreas Jaekel } zev_event_t; 31063aba447SAndreas Jaekel 31163aba447SAndreas Jaekel 31263aba447SAndreas Jaekel 3132bb8e5e2SAndreas Jaekel typedef struct zev_statistics_t { 3142bb8e5e2SAndreas Jaekel uint64_t zev_queue_len; 3152bb8e5e2SAndreas Jaekel uint64_t zev_bytes_read; 316e9a5e479SAndreas Jaekel uint64_t zev_bytes_discarded; 317205a9bc9SAndreas Jaekel /* runtime settings */ 318205a9bc9SAndreas Jaekel uint64_t zev_max_queue_len; 3192bb8e5e2SAndreas Jaekel /* counters */ 3202bb8e5e2SAndreas Jaekel uint64_t zev_cnt_total_events; 321e9a5e479SAndreas Jaekel uint64_t zev_cnt_discarded_events; 3222bb8e5e2SAndreas Jaekel uint64_t zev_cnt_errors; 32301c2c787SAndreas Jaekel uint64_t zev_cnt_marks; 3242bb8e5e2SAndreas Jaekel /* zfsvfs ops */ 3252bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 3262bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 3272bb8e5e2SAndreas Jaekel /* zvol ops */ 3282bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zvol_write; 3292bb8e5e2SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 3302bb8e5e2SAndreas Jaekel /* znode ops */ 3312bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 3322bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_create; 3332bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_remove; 3342bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_link; 3352bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 3362bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_rename; 3372bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_write; 3382bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 3392bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 3402bb8e5e2SAndreas Jaekel uint64_t zev_cnt_znode_acl; 3412bb8e5e2SAndreas Jaekel } zev_statistics_t; 3422bb8e5e2SAndreas Jaekel 343e9a5e479SAndreas Jaekel typedef struct zev_queue_name { 344e9a5e479SAndreas Jaekel uint64_t zev_namelen; 345e9a5e479SAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 346e9a5e479SAndreas Jaekel } zev_queue_name_t; 347e9a5e479SAndreas Jaekel 3482bb8e5e2SAndreas Jaekel typedef struct zev_ioctl_poolarg { 3492bb8e5e2SAndreas Jaekel uint64_t zev_poolname_len; 3502bb8e5e2SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 3512bb8e5e2SAndreas Jaekel } zev_ioctl_poolarg_t; 35201c2c787SAndreas Jaekel 35301c2c787SAndreas Jaekel typedef struct zev_ioctl_mark { 35401c2c787SAndreas Jaekel uint64_t zev_mark_id; 35501c2c787SAndreas Jaekel uint64_t zev_guid; 35601c2c787SAndreas Jaekel uint32_t zev_payload_len; 35746c85740SAndreas Jaekel uint32_t padding; 35801c2c787SAndreas Jaekel /* payload follows */ 35901c2c787SAndreas Jaekel } zev_ioctl_mark_t; 360c035b1e8SAndreas Jaekel 361c035b1e8SAndreas Jaekel typedef struct zev_ioctl_get_gen { 362c035b1e8SAndreas Jaekel /* input */ 363c035b1e8SAndreas Jaekel uint64_t inode; 364c035b1e8SAndreas Jaekel uint32_t fd; /* open fd to any object on the same fs */ 365c035b1e8SAndreas Jaekel /* noput */ 366c035b1e8SAndreas Jaekel uint32_t padding; 367c035b1e8SAndreas Jaekel /* output */ 368c035b1e8SAndreas Jaekel uint64_t generation; 369c035b1e8SAndreas Jaekel uint64_t crtime; 370c035b1e8SAndreas Jaekel uint64_t guid; 371c035b1e8SAndreas Jaekel char dataset[MAXPATHLEN]; 372c035b1e8SAndreas Jaekel } zev_ioctl_get_gen_t; 373e9a5e479SAndreas Jaekel 374e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties { 375e9a5e479SAndreas Jaekel uint64_t zev_max_queue_len; 376e9a5e479SAndreas Jaekel uint64_t zev_poll_wakeup_threshold; 377e9a5e479SAndreas Jaekel uint16_t zev_flags; 3784ca7dd5eSAndreas Jaekel uint16_t padding1; 3794ca7dd5eSAndreas Jaekel uint32_t padding2; 3804ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 381e9a5e479SAndreas Jaekel } zev_ioctl_set_queue_properties_t; 382e9a5e479SAndreas Jaekel 383e9a5e479SAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t; 384e9a5e479SAndreas Jaekel 385e9a5e479SAndreas Jaekel typedef struct zev_ioctl_add_queue { 386e9a5e479SAndreas Jaekel uint64_t zev_max_queue_len; 387e9a5e479SAndreas Jaekel uint32_t padding; 388e9a5e479SAndreas Jaekel uint16_t zev_flags; 389e9a5e479SAndreas Jaekel uint16_t zev_namelen; 390e9a5e479SAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 391e9a5e479SAndreas Jaekel } zev_ioctl_add_queue_t; 392e9a5e479SAndreas Jaekel 393e9a5e479SAndreas Jaekel typedef struct zev_ioctl_remove_queue { 3944ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 395e9a5e479SAndreas Jaekel } zev_ioctl_remove_queue_t; 396e9a5e479SAndreas Jaekel 397e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics { 3984ca7dd5eSAndreas Jaekel zev_queue_name_t zev_queue_name; 399e9a5e479SAndreas Jaekel zev_statistics_t zev_statistics; 400e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_statistics_t; 401e9a5e479SAndreas Jaekel 402e9a5e479SAndreas Jaekel typedef struct zev_ioctl_debug_info { 403e9a5e479SAndreas Jaekel uint64_t zev_memory_allocated; 4045e286361SAndreas Jaekel uint64_t zev_chksum_cache_size; 4055e286361SAndreas Jaekel uint64_t zev_chksum_cache_hits; 4065e286361SAndreas Jaekel uint64_t zev_chksum_cache_misses; 407e9a5e479SAndreas Jaekel } zev_ioctl_debug_info_t; 408e9a5e479SAndreas Jaekel 409e9a5e479SAndreas Jaekel typedef struct zev_ioctl_get_queue_list { 410e9a5e479SAndreas Jaekel uint64_t zev_n_queues; 411e9a5e479SAndreas Jaekel zev_queue_name_t zev_queue_name[ZEV_MAX_QUEUES]; 412e9a5e479SAndreas Jaekel } zev_ioctl_get_queue_list_t; 413e9a5e479SAndreas Jaekel 414b9710123SAndreas Jaekel typedef struct zev_ioctl_get_signatures { 415b9710123SAndreas Jaekel /* in */ 416b9710123SAndreas Jaekel uint64_t zev_offset; 417b9710123SAndreas Jaekel uint64_t zev_len; 418b9710123SAndreas Jaekel uint32_t zev_fd; 419b9710123SAndreas Jaekel uint32_t zev_bufsize; 420b9710123SAndreas Jaekel /* out */ 421b9710123SAndreas Jaekel uint64_t zev_signature_cnt; 422b9710123SAndreas Jaekel /* up to zev_bufsize bytes of checksums will be written here */ 423b9710123SAndreas Jaekel } zev_ioctl_get_signatures_t; 424b9710123SAndreas Jaekel 425c62d8367SAndreas Jaekel typedef struct zev_ioctl_get_zev_version { 426c62d8367SAndreas Jaekel uint64_t zev_major_version; 427c62d8367SAndreas Jaekel uint64_t zev_minor_version; 428c62d8367SAndreas Jaekel } zev_ioctl_get_zev_version; 429c62d8367SAndreas Jaekel 430108668daSAndreas Jaekel #pragma pack() 4312bb8e5e2SAndreas Jaekel 4322bb8e5e2SAndreas Jaekel #ifdef _KERNEL 433e9a5e479SAndreas Jaekel 434e9a5e479SAndreas Jaekel extern uint64_t zev_memory_allocated; 435e9a5e479SAndreas Jaekel extern uint64_t zev_memory_freed; 436e9a5e479SAndreas Jaekel 437e9a5e479SAndreas Jaekel #define ZEV_MEM_ADD(memsize) \ 438e9a5e479SAndreas Jaekel do { \ 439e9a5e479SAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 440e9a5e479SAndreas Jaekel atomic_add_64(&zev_memory_allocated, tmp_delta); \ 441df8caf2dSSimon Klinkert /* CONSTCOND */ \ 442e9a5e479SAndreas Jaekel } while(0) 443e9a5e479SAndreas Jaekel 444e9a5e479SAndreas Jaekel #define ZEV_MEM_SUB(memsize) \ 445e9a5e479SAndreas Jaekel do { \ 446e9a5e479SAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 447e9a5e479SAndreas Jaekel atomic_add_64(&zev_memory_freed, tmp_delta); \ 448df8caf2dSSimon Klinkert /* CONSTCOND */ \ 449e9a5e479SAndreas Jaekel } while(0) 450e9a5e479SAndreas Jaekel 4515e286361SAndreas Jaekel void *zev_alloc(ssize_t sz); 4525e286361SAndreas Jaekel void *zev_zalloc(ssize_t sz); 4535e286361SAndreas Jaekel void zev_free(void *ptr, ssize_t sz); 454e9a5e479SAndreas Jaekel 45563aba447SAndreas Jaekel typedef struct zev_msg_t { 45663aba447SAndreas Jaekel struct zev_msg_t *next; 457e9a5e479SAndreas Jaekel struct zev_msg_t *prev; 458e9a5e479SAndreas Jaekel uint64_t seq; 459e9a5e479SAndreas Jaekel uint16_t size; 460e9a5e479SAndreas Jaekel uint16_t read; 46163aba447SAndreas Jaekel /* data follows */ 46263aba447SAndreas Jaekel } zev_msg_t; 46363aba447SAndreas Jaekel 4649193e9c2SAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 46563aba447SAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 46663aba447SAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 4672bb8e5e2SAndreas Jaekel int zev_skip_pool(objset_t *os); 468bdbd253bSAndreas Jaekel int zev_skip_fs(zfsvfs_t *fs); 4699193e9c2SAndreas Jaekel 4702bb8e5e2SAndreas Jaekel #endif 4712bb8e5e2SAndreas Jaekel 4722bb8e5e2SAndreas Jaekel #endif /* __ZEV_H__ */ 4732bb8e5e2SAndreas Jaekel 474