1a18c35b9SAndreas Jaekel #ifndef __ZEV_H__ 2a18c35b9SAndreas Jaekel #define __ZEV_H__ 3a18c35b9SAndreas Jaekel 4a18c35b9SAndreas Jaekel #include <sys/types.h> 5a18c35b9SAndreas Jaekel 6a18c35b9SAndreas Jaekel #ifdef _KERNEL 7a18c35b9SAndreas Jaekel #include <sys/dmu_objset.h> 8a18c35b9SAndreas Jaekel #include <sys/dsl_dataset.h> 9a18c35b9SAndreas Jaekel #include <sys/zfs_vfsops.h> 10a18c35b9SAndreas Jaekel #include <sys/dsl_dir.h> 11a18c35b9SAndreas Jaekel #include <sys/spa_impl.h> 12a18c35b9SAndreas Jaekel #endif 13a18c35b9SAndreas Jaekel 14a18c35b9SAndreas Jaekel #define ZEVIOC ('z' << 8) 15a18c35b9SAndreas Jaekel #define ZEV_IOC_GET_STATISTICS (ZEVIOC | 1) /* get zev statistics */ 16fec460f8SAndreas Jaekel #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ 17fec460f8SAndreas Jaekel #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ 18fec460f8SAndreas Jaekel #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ 19fec460f8SAndreas Jaekel #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ 20*888fea18SAndreas Jaekel #define ZEV_IOC_MARK (ZEVIOC | 6) /* add mark to queue */ 21a18c35b9SAndreas Jaekel 22a18c35b9SAndreas Jaekel #define ZEV_OP_MIN 1 23d979f56cSAndreas Jaekel #define ZEV_OP_ERROR 1 24*888fea18SAndreas Jaekel #define ZEV_OP_MARK 2 25*888fea18SAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 3 26*888fea18SAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 4 27*888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 5 28*888fea18SAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 6 29*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 7 30*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 8 31*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 9 32*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 10 33*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 11 34*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 12 35*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_LINK 13 36*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 14 37*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 15 38*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 16 39*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 17 40*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 18 41*888fea18SAndreas Jaekel #define ZEV_OP_ZNODE_ACL 19 42*888fea18SAndreas Jaekel #define ZEV_OP_MAX 19 43d979f56cSAndreas Jaekel 44d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 45d979f56cSAndreas Jaekel 46149d0affSAndreas Jaekel #pragma pack(1) 47d979f56cSAndreas Jaekel typedef struct zev_inode_info_t { 48d979f56cSAndreas Jaekel uint64_t ino; 49d979f56cSAndreas Jaekel uint64_t gen; 50d979f56cSAndreas Jaekel uint64_t mtime; 51d979f56cSAndreas Jaekel uint64_t ctime; 52d979f56cSAndreas Jaekel uint64_t size; 53d979f56cSAndreas Jaekel uint64_t mode; 54d979f56cSAndreas Jaekel uint64_t links; 55149d0affSAndreas Jaekel uint32_t type; 56149d0affSAndreas Jaekel uint32_t padding; 57d979f56cSAndreas Jaekel } zev_inode_info_t; 58d979f56cSAndreas Jaekel 59d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 60d979f56cSAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 61d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 62d979f56cSAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 63d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 64d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 65d979f56cSAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 66*888fea18SAndreas Jaekel #define ZEV_PAYLOAD(rec) ((char *)(rec + 1)) 67d979f56cSAndreas Jaekel 68149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 69149d0affSAndreas Jaekel uint32_t record_len; \ 70149d0affSAndreas Jaekel uint32_t op; \ 71149d0affSAndreas Jaekel uint64_t op_time; \ 72149d0affSAndreas Jaekel uint64_t guid; 73149d0affSAndreas Jaekel 74d979f56cSAndreas Jaekel typedef struct zev_header_t { 75149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 76d979f56cSAndreas Jaekel } zev_header_t; 77d979f56cSAndreas Jaekel 78d979f56cSAndreas Jaekel typedef struct zev_error_t { 79149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 80d979f56cSAndreas Jaekel uint32_t failed_op; 81d979f56cSAndreas Jaekel uint32_t errstr_len; 82d979f56cSAndreas Jaekel /* error string follows */ 83d979f56cSAndreas Jaekel } zev_error_t; 84d979f56cSAndreas Jaekel 85*888fea18SAndreas Jaekel typedef struct zev_mark_t { 86*888fea18SAndreas Jaekel ZEV_COMMON_FIELDS; 87*888fea18SAndreas Jaekel uint64_t mark_id; 88*888fea18SAndreas Jaekel uint32_t payload_len; 89*888fea18SAndreas Jaekel uint32_t padding; 90*888fea18SAndreas Jaekel /* payload follows */ 91*888fea18SAndreas Jaekel } zev_mark_t; 92*888fea18SAndreas Jaekel 93d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t { 94149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 95d979f56cSAndreas Jaekel uint64_t root_ino; 96149d0affSAndreas Jaekel uint32_t remount; 97d979f56cSAndreas Jaekel uint32_t dataset_len; 98d979f56cSAndreas Jaekel uint32_t mountpoint_len; 99149d0affSAndreas Jaekel uint32_t padding; 100d979f56cSAndreas Jaekel /* dataset follows */ 101d979f56cSAndreas Jaekel /* mountpoint follows */ 102d979f56cSAndreas Jaekel } zev_zfs_mount_t; 103d979f56cSAndreas Jaekel 104d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t { 105149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 106d979f56cSAndreas Jaekel } zev_zfs_umount_t; 107d979f56cSAndreas Jaekel 108d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t { 109149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 110d979f56cSAndreas Jaekel uint64_t offset; 111d979f56cSAndreas Jaekel uint64_t length; 112d979f56cSAndreas Jaekel uint32_t dataset_len; 113149d0affSAndreas Jaekel uint32_t padding; 114d979f56cSAndreas Jaekel /* dataset follows */ 115d979f56cSAndreas Jaekel } zev_zvol_truncate_t; 116d979f56cSAndreas Jaekel 117d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t { 118149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 119d979f56cSAndreas Jaekel uint64_t offset; 120d979f56cSAndreas Jaekel uint64_t length; 121d979f56cSAndreas Jaekel uint32_t dataset_len; 122149d0affSAndreas Jaekel uint32_t padding; 123d979f56cSAndreas Jaekel /* dataset follows */ 124d979f56cSAndreas Jaekel } zev_zvol_write_t; 125d979f56cSAndreas Jaekel 126d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t { 127149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 128d979f56cSAndreas Jaekel zev_inode_info_t file; 129d979f56cSAndreas Jaekel } zev_znode_close_after_update_t; 130d979f56cSAndreas Jaekel 131d979f56cSAndreas Jaekel typedef struct zev_znode_create_t { 132149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 133d979f56cSAndreas Jaekel zev_inode_info_t file; 134d979f56cSAndreas Jaekel zev_inode_info_t parent; 135d979f56cSAndreas Jaekel uint32_t name_len; 136149d0affSAndreas Jaekel uint32_t padding; 137d979f56cSAndreas Jaekel /* name follows */ 138d979f56cSAndreas Jaekel } zev_znode_create_t; 139d979f56cSAndreas Jaekel 140d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 141d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 142d979f56cSAndreas Jaekel 143d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t { 144149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 145d979f56cSAndreas Jaekel zev_inode_info_t parent; 146d979f56cSAndreas Jaekel uint32_t name_len; 147149d0affSAndreas Jaekel uint32_t padding; 148d979f56cSAndreas Jaekel /* name follows */ 149d979f56cSAndreas Jaekel } zev_znode_remove_t; 150d979f56cSAndreas Jaekel 151d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 152d979f56cSAndreas Jaekel 153d979f56cSAndreas Jaekel typedef struct zev_znode_link_t { 154149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 155d979f56cSAndreas Jaekel zev_inode_info_t parent; 156d979f56cSAndreas Jaekel zev_inode_info_t file; 157d979f56cSAndreas Jaekel uint32_t name_len; 158149d0affSAndreas Jaekel uint32_t padding; 159d979f56cSAndreas Jaekel /* new_name follows */ 160d979f56cSAndreas Jaekel } zev_znode_link_t; 161d979f56cSAndreas Jaekel 162d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t { 163149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 164d979f56cSAndreas Jaekel zev_inode_info_t parent; 165d979f56cSAndreas Jaekel zev_inode_info_t file; 166d979f56cSAndreas Jaekel uint32_t name_len; 167d979f56cSAndreas Jaekel uint32_t link_len; 168d979f56cSAndreas Jaekel /* name follows */ 169d979f56cSAndreas Jaekel /* link follows */ 170d979f56cSAndreas Jaekel } zev_znode_symlink_t; 171d979f56cSAndreas Jaekel 172d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t { 173149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 174d979f56cSAndreas Jaekel zev_inode_info_t srcdir; 175d979f56cSAndreas Jaekel zev_inode_info_t dstdir; 176d979f56cSAndreas Jaekel zev_inode_info_t file; 177d979f56cSAndreas Jaekel uint32_t srcname_len; 178d979f56cSAndreas Jaekel uint32_t dstname_len; 179d979f56cSAndreas Jaekel /* srcname follows */ 180d979f56cSAndreas Jaekel /* dstname follows */ 181d979f56cSAndreas Jaekel } zev_znode_rename_t; 182d979f56cSAndreas Jaekel 183d979f56cSAndreas Jaekel typedef struct zev_znode_write_t { 184149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 185d979f56cSAndreas Jaekel zev_inode_info_t file; 186d979f56cSAndreas Jaekel uint64_t offset; 187d979f56cSAndreas Jaekel uint64_t length; 188d979f56cSAndreas Jaekel } zev_znode_write_t; 189d979f56cSAndreas Jaekel 190d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t { 191149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 192d979f56cSAndreas Jaekel zev_inode_info_t file; 193d979f56cSAndreas Jaekel uint64_t offset; 194d979f56cSAndreas Jaekel uint64_t length; 195d979f56cSAndreas Jaekel } zev_znode_truncate_t; 196d979f56cSAndreas Jaekel 197d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t { 198149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 199d979f56cSAndreas Jaekel zev_inode_info_t file; 200d979f56cSAndreas Jaekel } zev_znode_setattr_t; 201d979f56cSAndreas Jaekel 202d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t { 203149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 204d979f56cSAndreas Jaekel zev_inode_info_t file; 205d979f56cSAndreas Jaekel } zev_znode_acl_t; 206d979f56cSAndreas Jaekel 207d979f56cSAndreas Jaekel /* convenience helper definition */ 208d979f56cSAndreas Jaekel typedef union { 209d979f56cSAndreas Jaekel zev_header_t header; 210d979f56cSAndreas Jaekel 211*888fea18SAndreas Jaekel zev_error_t error; 212*888fea18SAndreas Jaekel zev_mark_t mark; 213d979f56cSAndreas Jaekel union { 214d979f56cSAndreas Jaekel zev_zfs_mount_t mount; 215d979f56cSAndreas Jaekel zev_zfs_umount_t umount; 216d979f56cSAndreas Jaekel } zfs; 217d979f56cSAndreas Jaekel union { 218d979f56cSAndreas Jaekel zev_zvol_truncate_t truncate; 219d979f56cSAndreas Jaekel zev_zvol_write_t write; 220d979f56cSAndreas Jaekel } zvol; 221d979f56cSAndreas Jaekel union { 222d979f56cSAndreas Jaekel zev_znode_close_after_update_t close; 223d979f56cSAndreas Jaekel zev_znode_create_t create; 224d979f56cSAndreas Jaekel zev_znode_mkdir_t mkdir; 225d979f56cSAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 226d979f56cSAndreas Jaekel zev_znode_remove_t remove; 227d979f56cSAndreas Jaekel zev_znode_rmdir_t rmdir; 228d979f56cSAndreas Jaekel zev_znode_link_t link; 229d979f56cSAndreas Jaekel zev_znode_symlink_t symlink; 230d979f56cSAndreas Jaekel zev_znode_rename_t rename; 231d979f56cSAndreas Jaekel zev_znode_write_t write; 232d979f56cSAndreas Jaekel zev_znode_truncate_t truncate; 233d979f56cSAndreas Jaekel zev_znode_setattr_t setattr; 234d979f56cSAndreas Jaekel zev_znode_acl_t acl; 235d979f56cSAndreas Jaekel } znode; 236d979f56cSAndreas Jaekel } zev_event_t; 237d979f56cSAndreas Jaekel 238d979f56cSAndreas Jaekel 239a18c35b9SAndreas Jaekel 240a18c35b9SAndreas Jaekel typedef struct zev_statistics_t { 241a18c35b9SAndreas Jaekel uint64_t zev_queue_len; 242a18c35b9SAndreas Jaekel uint64_t zev_bytes_read; 243fec460f8SAndreas Jaekel /* runtime settings */ 244fec460f8SAndreas Jaekel uint64_t zev_max_queue_len; 245fec460f8SAndreas Jaekel uint64_t zev_poll_wakeup_queue_len; 246a18c35b9SAndreas Jaekel /* counters */ 247a18c35b9SAndreas Jaekel uint64_t zev_cnt_total_events; 248a18c35b9SAndreas Jaekel uint64_t zev_cnt_errors; 249*888fea18SAndreas Jaekel uint64_t zev_cnt_marks; 250a18c35b9SAndreas Jaekel /* zfsvfs ops */ 251a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 252a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 253a18c35b9SAndreas Jaekel /* zvol ops */ 254a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_write; 255a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 256a18c35b9SAndreas Jaekel /* znode ops */ 257a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 258a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_create; 259a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_remove; 260a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_link; 261a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 262a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_rename; 263a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_write; 264a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 265a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 266a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_acl; 267a18c35b9SAndreas Jaekel } zev_statistics_t; 268a18c35b9SAndreas Jaekel 269a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg { 270a18c35b9SAndreas Jaekel uint64_t zev_poolname_len; 271a18c35b9SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 272a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t; 273*888fea18SAndreas Jaekel 274*888fea18SAndreas Jaekel typedef struct zev_ioctl_mark { 275*888fea18SAndreas Jaekel uint64_t zev_mark_id; 276*888fea18SAndreas Jaekel uint64_t zev_guid; 277*888fea18SAndreas Jaekel uint32_t zev_payload_len; 278*888fea18SAndreas Jaekel /* payload follows */ 279*888fea18SAndreas Jaekel } zev_ioctl_mark_t; 280149d0affSAndreas Jaekel #pragma pack() 281a18c35b9SAndreas Jaekel 282a18c35b9SAndreas Jaekel #ifdef _KERNEL 283d979f56cSAndreas Jaekel typedef struct zev_msg_t { 284d979f56cSAndreas Jaekel struct zev_msg_t *next; 285d979f56cSAndreas Jaekel int size; 286d979f56cSAndreas Jaekel /* data follows */ 287d979f56cSAndreas Jaekel } zev_msg_t; 288d979f56cSAndreas Jaekel 289d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 290d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 291d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 292a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os); 293d979f56cSAndreas Jaekel 294a18c35b9SAndreas Jaekel #endif 295a18c35b9SAndreas Jaekel 296a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */ 297a18c35b9SAndreas Jaekel 298