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 17e3455c18SAndreas Jaekel /* increased for incompatible interface and behaviour changes */ 18*03a64974SSimon Klinkert #define ZEV_MAJOR_VERSION 2 19e3455c18SAndreas Jaekel /* increased for compatible changes, including new ioctls(), etc. */ 20*03a64974SSimon Klinkert #define ZEV_MINOR_VERSION 0 21e3455c18SAndreas Jaekel 22add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_NAME_LEN 40 23*03a64974SSimon Klinkert #define ZEV_MAX_QUEUES 60 24add9520fSAndreas Jaekel #define ZEV_CONTROL_DEVICE_NAME "ctrl" 25*03a64974SSimon Klinkert #define ZEV_TMPQUEUE_DEVICE_NAME "tmpqueue" 26add9520fSAndreas Jaekel 27add9520fSAndreas Jaekel /* global limit, no queue may grow larger than this. */ 28add9520fSAndreas Jaekel #define ZEV_MAX_QUEUE_LEN (1 * 1024 * 1024 * 1024) 29add9520fSAndreas Jaekel 30add9520fSAndreas Jaekel /* Don't wake up poll()ing processes for every single message. */ 316a6a51eeSAndreas Jaekel #define ZEV_DEFAULT_POLL_WAKEUP_QUEUE_LEN 8192 32add9520fSAndreas Jaekel #define ZEV_MAX_POLL_WAKEUP_QUEUE_LEN 65536 33add9520fSAndreas Jaekel 34a18c35b9SAndreas Jaekel #define ZEVIOC ('z' << 8) 35add9520fSAndreas Jaekel #define ZEV_IOC_GET_GLOBAL_STATISTICS (ZEVIOC | 1) /* get global stats */ 36fec460f8SAndreas Jaekel #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ 37fec460f8SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ 38fec460f8SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ 39fec460f8SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ 40888fea18SAndreas Jaekel #define ZEV_IOC_MARK (ZEVIOC | 6) /* add mark to queue */ 4135d4e8ddSAndreas Jaekel #define ZEV_IOC_GET_GEN (ZEVIOC | 7) /* get generation no. */ 42add9520fSAndreas Jaekel #define ZEV_IOC_ADD_QUEUE (ZEVIOC | 8) /* create new queue */ 43add9520fSAndreas Jaekel #define ZEV_IOC_REMOVE_QUEUE (ZEVIOC | 9) /* delete queue */ 44add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_PROPERTIES (ZEVIOC | 10) /* get properties */ 45add9520fSAndreas Jaekel #define ZEV_IOC_SET_QUEUE_PROPERTIES (ZEVIOC | 11) /* set properties */ 46add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_STATISTICS (ZEVIOC | 12) /* get queue stats */ 47add9520fSAndreas Jaekel #define ZEV_IOC_GET_DEBUG_INFO (ZEVIOC | 13) /* get internal info */ 48add9520fSAndreas Jaekel #define ZEV_IOC_GET_QUEUE_LIST (ZEVIOC | 14) /* get queue list */ 4942110aacSAndreas Jaekel #define ZEV_IOC_GET_FILE_SIGNATURES (ZEVIOC | 15) /* get beaver sigs */ 50e3455c18SAndreas Jaekel #define ZEV_IOC_GET_ZEV_VERSION (ZEVIOC | 16) /* get zev version */ 51a18c35b9SAndreas Jaekel 52a18c35b9SAndreas Jaekel #define ZEV_OP_MIN 1 53d979f56cSAndreas Jaekel #define ZEV_OP_ERROR 1 54888fea18SAndreas Jaekel #define ZEV_OP_MARK 2 55888fea18SAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 3 56888fea18SAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 4 57888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 5 58888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 6 59888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 7 60888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 8 61888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 9 62888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 10 63888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 11 64888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 12 65888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_LINK 13 66888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 14 67888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 15 68888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 16 69888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 17 70888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 18 71888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_ACL 19 72888fea18SAndreas Jaekel #define ZEV_OP_MAX 19 73d979f56cSAndreas Jaekel 74add9520fSAndreas Jaekel /* zev event flags */ 75add9520fSAndreas Jaekel #define ZEV_FL_XATTR 0x0001 76add9520fSAndreas Jaekel 77add9520fSAndreas Jaekel /* zev queue flags */ 78add9520fSAndreas Jaekel #define ZEV_FL_BLOCK_WHILE_QUEUE_FULL 0x0001 79add9520fSAndreas Jaekel #define ZEV_FL_PERSISTENT 0x0002 80c99a1a25SAndreas Jaekel #define ZEV_FL_INITIALLY_EMPTY 0x0004 81add9520fSAndreas Jaekel 8242110aacSAndreas Jaekel /* checksum block sizes */ 8342110aacSAndreas Jaekel #define ZEV_L0_SIZE 4096 8442110aacSAndreas Jaekel #define ZEV_L1_SIZE (256 * ZEV_L0_SIZE) 8519b08257SAndreas Jaekel 86d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 87d979f56cSAndreas Jaekel 88149d0affSAndreas Jaekel #pragma pack(1) 89d979f56cSAndreas Jaekel typedef struct zev_inode_info_t { 90d979f56cSAndreas Jaekel uint64_t ino; 91d979f56cSAndreas Jaekel uint64_t gen; 92d979f56cSAndreas Jaekel uint64_t mtime; 93d979f56cSAndreas Jaekel uint64_t ctime; 94d979f56cSAndreas Jaekel uint64_t size; 95d979f56cSAndreas Jaekel uint64_t mode; 96d979f56cSAndreas Jaekel uint64_t links; 97149d0affSAndreas Jaekel uint32_t type; 9819b08257SAndreas Jaekel uint32_t flags; 99d979f56cSAndreas Jaekel } zev_inode_info_t; 100d979f56cSAndreas Jaekel 101d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 102d979f56cSAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 103d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 104d979f56cSAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 105d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 106d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 107d979f56cSAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 108888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 109205ed6bfSAndreas Jaekel #define ZEV_SIGNATURES(rec) ((char *)(rec + 1)) 110d979f56cSAndreas Jaekel 111149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 112149d0affSAndreas Jaekel uint32_t record_len; \ 113149d0affSAndreas Jaekel uint32_t op; \ 114149d0affSAndreas Jaekel uint64_t op_time; \ 115da4b4c3dSAndreas Jaekel uint64_t guid 116149d0affSAndreas Jaekel 117205ed6bfSAndreas Jaekel typedef struct zev_sig_t { 118205ed6bfSAndreas Jaekel uint16_t level; 119205ed6bfSAndreas Jaekel uint16_t padding1; 120205ed6bfSAndreas Jaekel uint32_t padding2; 121205ed6bfSAndreas Jaekel uint64_t block_offset; 122205ed6bfSAndreas Jaekel uint8_t value[SHA1_DIGEST_LENGTH]; /* 20 bytes -> no padding */ 123205ed6bfSAndreas Jaekel } zev_sig_t; 124205ed6bfSAndreas Jaekel 125d979f56cSAndreas Jaekel typedef struct zev_header_t { 126149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 127d979f56cSAndreas Jaekel } zev_header_t; 128d979f56cSAndreas Jaekel 129d979f56cSAndreas Jaekel typedef struct zev_error_t { 130149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 131d979f56cSAndreas Jaekel uint32_t failed_op; 132d979f56cSAndreas Jaekel uint32_t errstr_len; 133d979f56cSAndreas Jaekel /* error string follows */ 134d979f56cSAndreas Jaekel } zev_error_t; 135d979f56cSAndreas Jaekel 136888fea18SAndreas Jaekel typedef struct zev_mark_t { 137888fea18SAndreas Jaekel ZEV_COMMON_FIELDS; 138888fea18SAndreas Jaekel uint64_t mark_id; 139888fea18SAndreas Jaekel uint32_t payload_len; 140888fea18SAndreas Jaekel uint32_t padding; 141888fea18SAndreas Jaekel /* payload follows */ 142888fea18SAndreas Jaekel } zev_mark_t; 143888fea18SAndreas Jaekel 144d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t { 145149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 14693297ba3SAndreas Jaekel zev_inode_info_t root; 147*03a64974SSimon Klinkert uint64_t txg; 148149d0affSAndreas Jaekel uint32_t remount; 149d979f56cSAndreas Jaekel uint32_t dataset_len; 150d979f56cSAndreas Jaekel uint32_t mountpoint_len; 151149d0affSAndreas Jaekel uint32_t padding; 152d979f56cSAndreas Jaekel /* dataset follows */ 153d979f56cSAndreas Jaekel /* mountpoint follows */ 154d979f56cSAndreas Jaekel } zev_zfs_mount_t; 155d979f56cSAndreas Jaekel 156d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t { 157149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 158*03a64974SSimon Klinkert uint64_t txg; 15994875cb8SAndreas Jaekel zev_inode_info_t covered; 160d979f56cSAndreas Jaekel } zev_zfs_umount_t; 161d979f56cSAndreas Jaekel 162d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t { 163149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 16412119a7eSAndreas Jaekel uint64_t txg; 165d979f56cSAndreas Jaekel uint64_t offset; 166d979f56cSAndreas Jaekel uint64_t length; 167d979f56cSAndreas Jaekel uint32_t dataset_len; 168149d0affSAndreas Jaekel uint32_t padding; 169d979f56cSAndreas Jaekel /* dataset follows */ 170d979f56cSAndreas Jaekel } zev_zvol_truncate_t; 171d979f56cSAndreas Jaekel 172d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t { 173149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 17412119a7eSAndreas Jaekel uint64_t txg; 175d979f56cSAndreas Jaekel uint64_t offset; 176d979f56cSAndreas Jaekel uint64_t length; 177d979f56cSAndreas Jaekel uint32_t dataset_len; 178149d0affSAndreas Jaekel uint32_t padding; 179d979f56cSAndreas Jaekel /* dataset follows */ 180d979f56cSAndreas Jaekel } zev_zvol_write_t; 181d979f56cSAndreas Jaekel 182d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t { 183149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 184d979f56cSAndreas Jaekel zev_inode_info_t file; 185d979f56cSAndreas Jaekel } zev_znode_close_after_update_t; 186d979f56cSAndreas Jaekel 187d979f56cSAndreas Jaekel typedef struct zev_znode_create_t { 188149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 18912119a7eSAndreas Jaekel uint64_t txg; 190d979f56cSAndreas Jaekel zev_inode_info_t file; 191d979f56cSAndreas Jaekel zev_inode_info_t parent; 1922eabeab5SAndreas Jaekel zev_sig_t signature; 193d979f56cSAndreas Jaekel uint32_t name_len; 194149d0affSAndreas Jaekel uint32_t padding; 195d979f56cSAndreas Jaekel /* name follows */ 196d979f56cSAndreas Jaekel } zev_znode_create_t; 197d979f56cSAndreas Jaekel 198d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 199d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 200d979f56cSAndreas Jaekel 201d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t { 202149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 20312119a7eSAndreas Jaekel uint64_t txg; 20497dcf88dSAndreas Jaekel zev_inode_info_t file; 205d979f56cSAndreas Jaekel zev_inode_info_t parent; 206d979f56cSAndreas Jaekel uint32_t name_len; 207149d0affSAndreas Jaekel uint32_t padding; 208d979f56cSAndreas Jaekel /* name follows */ 209d979f56cSAndreas Jaekel } zev_znode_remove_t; 210d979f56cSAndreas Jaekel 211d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 212d979f56cSAndreas Jaekel 213d979f56cSAndreas Jaekel typedef struct zev_znode_link_t { 214149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 21512119a7eSAndreas Jaekel uint64_t txg; 216d979f56cSAndreas Jaekel zev_inode_info_t parent; 217d979f56cSAndreas Jaekel zev_inode_info_t file; 218d979f56cSAndreas Jaekel uint32_t name_len; 219149d0affSAndreas Jaekel uint32_t padding; 220d979f56cSAndreas Jaekel /* new_name follows */ 221d979f56cSAndreas Jaekel } zev_znode_link_t; 222d979f56cSAndreas Jaekel 223d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t { 224149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 22512119a7eSAndreas Jaekel uint64_t txg; 226d979f56cSAndreas Jaekel zev_inode_info_t parent; 227d979f56cSAndreas Jaekel zev_inode_info_t file; 2282eabeab5SAndreas Jaekel zev_sig_t signature; 229d979f56cSAndreas Jaekel uint32_t name_len; 230d979f56cSAndreas Jaekel uint32_t link_len; 231d979f56cSAndreas Jaekel /* name follows */ 232d979f56cSAndreas Jaekel /* link follows */ 233d979f56cSAndreas Jaekel } zev_znode_symlink_t; 234d979f56cSAndreas Jaekel 235d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t { 236149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 23712119a7eSAndreas Jaekel uint64_t txg; 238d979f56cSAndreas Jaekel zev_inode_info_t srcdir; 239d979f56cSAndreas Jaekel zev_inode_info_t dstdir; 240d979f56cSAndreas Jaekel zev_inode_info_t file; 2418aa47a6bSAndreas Jaekel zev_inode_info_t clobbered_file; 242d979f56cSAndreas Jaekel uint32_t srcname_len; 243d979f56cSAndreas Jaekel uint32_t dstname_len; 244d979f56cSAndreas Jaekel /* srcname follows */ 245d979f56cSAndreas Jaekel /* dstname follows */ 246d979f56cSAndreas Jaekel } zev_znode_rename_t; 247d979f56cSAndreas Jaekel 248d979f56cSAndreas Jaekel typedef struct zev_znode_write_t { 249149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 25012119a7eSAndreas Jaekel uint64_t txg; 251d979f56cSAndreas Jaekel zev_inode_info_t file; 252d979f56cSAndreas Jaekel uint64_t offset; 253d979f56cSAndreas Jaekel uint64_t length; 254205ed6bfSAndreas Jaekel uint64_t signature_cnt; 255205ed6bfSAndreas Jaekel /* signatures follow */ 256d979f56cSAndreas Jaekel } zev_znode_write_t; 257d979f56cSAndreas Jaekel 258d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t { 259149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 26012119a7eSAndreas Jaekel uint64_t txg; 261d979f56cSAndreas Jaekel zev_inode_info_t file; 262d979f56cSAndreas Jaekel uint64_t offset; 263d979f56cSAndreas Jaekel uint64_t length; 264205ed6bfSAndreas Jaekel uint64_t signature_cnt; 265205ed6bfSAndreas Jaekel /* signatures follow */ 266d979f56cSAndreas Jaekel } zev_znode_truncate_t; 267d979f56cSAndreas Jaekel 268d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t { 269149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 27012119a7eSAndreas Jaekel uint64_t txg; 271d979f56cSAndreas Jaekel zev_inode_info_t file; 272d979f56cSAndreas Jaekel } zev_znode_setattr_t; 273d979f56cSAndreas Jaekel 274d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t { 275149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 27612119a7eSAndreas Jaekel uint64_t txg; 277d979f56cSAndreas Jaekel zev_inode_info_t file; 278d979f56cSAndreas Jaekel } zev_znode_acl_t; 279d979f56cSAndreas Jaekel 280d979f56cSAndreas Jaekel /* convenience helper definition */ 281d979f56cSAndreas Jaekel typedef union { 282d979f56cSAndreas Jaekel zev_header_t header; 283d979f56cSAndreas Jaekel 284888fea18SAndreas Jaekel zev_error_t error; 285888fea18SAndreas Jaekel zev_mark_t mark; 286d979f56cSAndreas Jaekel union { 287d979f56cSAndreas Jaekel zev_zfs_mount_t mount; 288d979f56cSAndreas Jaekel zev_zfs_umount_t umount; 289d979f56cSAndreas Jaekel } zfs; 290d979f56cSAndreas Jaekel union { 291d979f56cSAndreas Jaekel zev_zvol_truncate_t truncate; 292d979f56cSAndreas Jaekel zev_zvol_write_t write; 293d979f56cSAndreas Jaekel } zvol; 294d979f56cSAndreas Jaekel union { 295d979f56cSAndreas Jaekel zev_znode_close_after_update_t close; 296d979f56cSAndreas Jaekel zev_znode_create_t create; 297d979f56cSAndreas Jaekel zev_znode_mkdir_t mkdir; 298d979f56cSAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 299d979f56cSAndreas Jaekel zev_znode_remove_t remove; 300d979f56cSAndreas Jaekel zev_znode_rmdir_t rmdir; 301d979f56cSAndreas Jaekel zev_znode_link_t link; 302d979f56cSAndreas Jaekel zev_znode_symlink_t symlink; 303d979f56cSAndreas Jaekel zev_znode_rename_t rename; 304d979f56cSAndreas Jaekel zev_znode_write_t write; 305d979f56cSAndreas Jaekel zev_znode_truncate_t truncate; 306d979f56cSAndreas Jaekel zev_znode_setattr_t setattr; 307d979f56cSAndreas Jaekel zev_znode_acl_t acl; 308d979f56cSAndreas Jaekel } znode; 309d979f56cSAndreas Jaekel } zev_event_t; 310d979f56cSAndreas Jaekel 311d979f56cSAndreas Jaekel 312a18c35b9SAndreas Jaekel 313a18c35b9SAndreas Jaekel typedef struct zev_statistics_t { 314a18c35b9SAndreas Jaekel uint64_t zev_queue_len; 315a18c35b9SAndreas Jaekel uint64_t zev_bytes_read; 316add9520fSAndreas Jaekel uint64_t zev_bytes_discarded; 317fec460f8SAndreas Jaekel /* runtime settings */ 318fec460f8SAndreas Jaekel uint64_t zev_max_queue_len; 319a18c35b9SAndreas Jaekel /* counters */ 320a18c35b9SAndreas Jaekel uint64_t zev_cnt_total_events; 321add9520fSAndreas Jaekel uint64_t zev_cnt_discarded_events; 322a18c35b9SAndreas Jaekel uint64_t zev_cnt_errors; 323888fea18SAndreas Jaekel uint64_t zev_cnt_marks; 324a18c35b9SAndreas Jaekel /* zfsvfs ops */ 325a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 326a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 327a18c35b9SAndreas Jaekel /* zvol ops */ 328a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_write; 329a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 330a18c35b9SAndreas Jaekel /* znode ops */ 331a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 332a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_create; 333a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_remove; 334a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_link; 335a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 336a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_rename; 337a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_write; 338a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 339a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 340a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_acl; 341a18c35b9SAndreas Jaekel } zev_statistics_t; 342a18c35b9SAndreas Jaekel 343add9520fSAndreas Jaekel typedef struct zev_queue_name { 344add9520fSAndreas Jaekel uint64_t zev_namelen; 345add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 346add9520fSAndreas Jaekel } zev_queue_name_t; 347add9520fSAndreas Jaekel 348a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg { 349a18c35b9SAndreas Jaekel uint64_t zev_poolname_len; 350a18c35b9SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 351a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t; 352888fea18SAndreas Jaekel 353888fea18SAndreas Jaekel typedef struct zev_ioctl_mark { 354888fea18SAndreas Jaekel uint64_t zev_mark_id; 355888fea18SAndreas Jaekel uint64_t zev_guid; 356888fea18SAndreas Jaekel uint32_t zev_payload_len; 357808a670aSAndreas Jaekel uint32_t padding; 358888fea18SAndreas Jaekel /* payload follows */ 359888fea18SAndreas Jaekel } zev_ioctl_mark_t; 36035d4e8ddSAndreas Jaekel 36135d4e8ddSAndreas Jaekel typedef struct zev_ioctl_get_gen { 36235d4e8ddSAndreas Jaekel /* input */ 36335d4e8ddSAndreas Jaekel uint64_t inode; 36435d4e8ddSAndreas Jaekel uint32_t fd; /* open fd to any object on the same fs */ 36535d4e8ddSAndreas Jaekel /* noput */ 36635d4e8ddSAndreas Jaekel uint32_t padding; 36735d4e8ddSAndreas Jaekel /* output */ 36835d4e8ddSAndreas Jaekel uint64_t generation; 36935d4e8ddSAndreas Jaekel uint64_t crtime; 37035d4e8ddSAndreas Jaekel uint64_t guid; 37135d4e8ddSAndreas Jaekel char dataset[MAXPATHLEN]; 37235d4e8ddSAndreas Jaekel } zev_ioctl_get_gen_t; 373add9520fSAndreas Jaekel 374add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties { 375add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 376add9520fSAndreas Jaekel uint64_t zev_poll_wakeup_threshold; 377add9520fSAndreas Jaekel uint16_t zev_flags; 3786a6a51eeSAndreas Jaekel uint16_t padding1; 3796a6a51eeSAndreas Jaekel uint32_t padding2; 3806a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 381add9520fSAndreas Jaekel } zev_ioctl_set_queue_properties_t; 382add9520fSAndreas Jaekel 383add9520fSAndreas Jaekel typedef struct zev_ioctl_set_queue_properties zev_ioctl_get_queue_properties_t; 384add9520fSAndreas Jaekel 385add9520fSAndreas Jaekel typedef struct zev_ioctl_add_queue { 386add9520fSAndreas Jaekel uint64_t zev_max_queue_len; 387add9520fSAndreas Jaekel uint32_t padding; 388add9520fSAndreas Jaekel uint16_t zev_flags; 389add9520fSAndreas Jaekel uint16_t zev_namelen; 390add9520fSAndreas Jaekel char zev_name[ZEV_MAX_QUEUE_NAME_LEN]; 391add9520fSAndreas Jaekel } zev_ioctl_add_queue_t; 392add9520fSAndreas Jaekel 393add9520fSAndreas Jaekel typedef struct zev_ioctl_remove_queue { 3946a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 395add9520fSAndreas Jaekel } zev_ioctl_remove_queue_t; 396add9520fSAndreas Jaekel 397add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_statistics { 3986a6a51eeSAndreas Jaekel zev_queue_name_t zev_queue_name; 399add9520fSAndreas Jaekel zev_statistics_t zev_statistics; 400add9520fSAndreas Jaekel } zev_ioctl_get_queue_statistics_t; 401add9520fSAndreas Jaekel 402add9520fSAndreas Jaekel typedef struct zev_ioctl_debug_info { 403add9520fSAndreas Jaekel uint64_t zev_memory_allocated; 404205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_size; 405205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_hits; 406205ed6bfSAndreas Jaekel uint64_t zev_chksum_cache_misses; 407add9520fSAndreas Jaekel } zev_ioctl_debug_info_t; 408add9520fSAndreas Jaekel 409add9520fSAndreas Jaekel typedef struct zev_ioctl_get_queue_list { 410add9520fSAndreas Jaekel uint64_t zev_n_queues; 411add9520fSAndreas Jaekel zev_queue_name_t zev_queue_name[ZEV_MAX_QUEUES]; 412add9520fSAndreas Jaekel } zev_ioctl_get_queue_list_t; 413add9520fSAndreas Jaekel 41442110aacSAndreas Jaekel typedef struct zev_ioctl_get_signatures { 41542110aacSAndreas Jaekel /* in */ 41642110aacSAndreas Jaekel uint64_t zev_offset; 41742110aacSAndreas Jaekel uint64_t zev_len; 41842110aacSAndreas Jaekel uint32_t zev_fd; 41942110aacSAndreas Jaekel uint32_t zev_bufsize; 42042110aacSAndreas Jaekel /* out */ 42142110aacSAndreas Jaekel uint64_t zev_signature_cnt; 42242110aacSAndreas Jaekel /* up to zev_bufsize bytes of checksums will be written here */ 42342110aacSAndreas Jaekel } zev_ioctl_get_signatures_t; 42442110aacSAndreas Jaekel 425e3455c18SAndreas Jaekel typedef struct zev_ioctl_get_zev_version { 426e3455c18SAndreas Jaekel uint64_t zev_major_version; 427e3455c18SAndreas Jaekel uint64_t zev_minor_version; 428e3455c18SAndreas Jaekel } zev_ioctl_get_zev_version; 429e3455c18SAndreas Jaekel 430149d0affSAndreas Jaekel #pragma pack() 431a18c35b9SAndreas Jaekel 432a18c35b9SAndreas Jaekel #ifdef _KERNEL 433add9520fSAndreas Jaekel 434add9520fSAndreas Jaekel extern uint64_t zev_memory_allocated; 435add9520fSAndreas Jaekel extern uint64_t zev_memory_freed; 436add9520fSAndreas Jaekel 437add9520fSAndreas Jaekel #define ZEV_MEM_ADD(memsize) \ 438add9520fSAndreas Jaekel do { \ 439add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 440add9520fSAndreas Jaekel atomic_add_64(&zev_memory_allocated, tmp_delta); \ 441add9520fSAndreas Jaekel } while(0) 442add9520fSAndreas Jaekel 443add9520fSAndreas Jaekel #define ZEV_MEM_SUB(memsize) \ 444add9520fSAndreas Jaekel do { \ 445add9520fSAndreas Jaekel int64_t tmp_delta = (int64_t)(memsize); \ 446add9520fSAndreas Jaekel atomic_add_64(&zev_memory_freed, tmp_delta); \ 447add9520fSAndreas Jaekel } while(0) 448add9520fSAndreas Jaekel 449205ed6bfSAndreas Jaekel void *zev_alloc(ssize_t sz); 450205ed6bfSAndreas Jaekel void *zev_zalloc(ssize_t sz); 451205ed6bfSAndreas Jaekel void zev_free(void *ptr, ssize_t sz); 452add9520fSAndreas Jaekel 453d979f56cSAndreas Jaekel typedef struct zev_msg_t { 454d979f56cSAndreas Jaekel struct zev_msg_t *next; 455add9520fSAndreas Jaekel struct zev_msg_t *prev; 456add9520fSAndreas Jaekel uint64_t seq; 457add9520fSAndreas Jaekel uint16_t size; 458add9520fSAndreas Jaekel uint16_t read; 459d979f56cSAndreas Jaekel /* data follows */ 460d979f56cSAndreas Jaekel } zev_msg_t; 461d979f56cSAndreas Jaekel 462d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 463d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 464d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 465a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os); 466e3455c18SAndreas Jaekel int zev_skip_fs(zfsvfs_t *fs); 467d979f56cSAndreas Jaekel 468a18c35b9SAndreas Jaekel #endif 469a18c35b9SAndreas Jaekel 470a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */ 471a18c35b9SAndreas Jaekel 472