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 */ 20a18c35b9SAndreas Jaekel 21a18c35b9SAndreas Jaekel #define ZEV_OP_MIN 1 22d979f56cSAndreas Jaekel #define ZEV_OP_ERROR 1 23d979f56cSAndreas Jaekel #define ZEV_OP_ZFS_MOUNT 2 24d979f56cSAndreas Jaekel #define ZEV_OP_ZFS_UMOUNT 3 25d979f56cSAndreas Jaekel #define ZEV_OP_ZVOL_WRITE 4 26d979f56cSAndreas Jaekel #define ZEV_OP_ZVOL_TRUNCATE 5 27d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 6 28d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_CREATE 7 29d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_MKDIR 8 30d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 9 31d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_REMOVE 10 32d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_RMDIR 11 33d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_LINK 12 34d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_SYMLINK 13 35d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_RENAME 14 36d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_WRITE 15 37d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_TRUNCATE 16 38d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_SETATTR 17 39d979f56cSAndreas Jaekel #define ZEV_OP_ZNODE_ACL 18 40d979f56cSAndreas Jaekel #define ZEV_OP_MAX 18 41d979f56cSAndreas Jaekel 42d979f56cSAndreas Jaekel /* zfs event records (as they are represented through the character device) */ 43d979f56cSAndreas Jaekel 44*149d0affSAndreas Jaekel #pragma pack(1) 45d979f56cSAndreas Jaekel typedef struct zev_inode_info_t { 46d979f56cSAndreas Jaekel uint64_t ino; 47d979f56cSAndreas Jaekel uint64_t gen; 48d979f56cSAndreas Jaekel uint64_t mtime; 49d979f56cSAndreas Jaekel uint64_t ctime; 50d979f56cSAndreas Jaekel uint64_t size; 51d979f56cSAndreas Jaekel uint64_t mode; 52d979f56cSAndreas Jaekel uint64_t links; 53*149d0affSAndreas Jaekel uint32_t type; 54*149d0affSAndreas Jaekel uint32_t padding; 55d979f56cSAndreas Jaekel } zev_inode_info_t; 56d979f56cSAndreas Jaekel 57d979f56cSAndreas Jaekel #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) 58d979f56cSAndreas Jaekel #define ZEV_DATASET(rec) ((char *)(rec + 1)) 59d979f56cSAndreas Jaekel #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) 60d979f56cSAndreas Jaekel #define ZEV_NAME(rec) ((char *)(rec + 1)) 61d979f56cSAndreas Jaekel #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) 62d979f56cSAndreas Jaekel #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) 63d979f56cSAndreas Jaekel #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) 64d979f56cSAndreas Jaekel 65*149d0affSAndreas Jaekel #define ZEV_COMMON_FIELDS \ 66*149d0affSAndreas Jaekel uint32_t record_len; \ 67*149d0affSAndreas Jaekel uint32_t op; \ 68*149d0affSAndreas Jaekel uint64_t op_time; \ 69*149d0affSAndreas Jaekel uint64_t guid; 70*149d0affSAndreas Jaekel 71d979f56cSAndreas Jaekel typedef struct zev_header_t { 72*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 73d979f56cSAndreas Jaekel } zev_header_t; 74d979f56cSAndreas Jaekel 75d979f56cSAndreas Jaekel typedef struct zev_error_t { 76*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 77d979f56cSAndreas Jaekel uint32_t failed_op; 78d979f56cSAndreas Jaekel uint32_t errstr_len; 79d979f56cSAndreas Jaekel /* error string follows */ 80d979f56cSAndreas Jaekel } zev_error_t; 81d979f56cSAndreas Jaekel 82d979f56cSAndreas Jaekel typedef struct zev_zfs_mount_t { 83*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 84d979f56cSAndreas Jaekel uint64_t root_ino; 85*149d0affSAndreas Jaekel uint32_t remount; 86d979f56cSAndreas Jaekel uint32_t dataset_len; 87d979f56cSAndreas Jaekel uint32_t mountpoint_len; 88*149d0affSAndreas Jaekel uint32_t padding; 89d979f56cSAndreas Jaekel /* dataset follows */ 90d979f56cSAndreas Jaekel /* mountpoint follows */ 91d979f56cSAndreas Jaekel } zev_zfs_mount_t; 92d979f56cSAndreas Jaekel 93d979f56cSAndreas Jaekel typedef struct zev_zfs_umount_t { 94*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 95d979f56cSAndreas Jaekel } zev_zfs_umount_t; 96d979f56cSAndreas Jaekel 97d979f56cSAndreas Jaekel typedef struct zev_zvol_truncate_t { 98*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 99d979f56cSAndreas Jaekel uint64_t offset; 100d979f56cSAndreas Jaekel uint64_t length; 101d979f56cSAndreas Jaekel uint32_t dataset_len; 102*149d0affSAndreas Jaekel uint32_t padding; 103d979f56cSAndreas Jaekel /* dataset follows */ 104d979f56cSAndreas Jaekel } zev_zvol_truncate_t; 105d979f56cSAndreas Jaekel 106d979f56cSAndreas Jaekel typedef struct zev_zvol_write_t { 107*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 108d979f56cSAndreas Jaekel uint64_t offset; 109d979f56cSAndreas Jaekel uint64_t length; 110d979f56cSAndreas Jaekel uint32_t dataset_len; 111*149d0affSAndreas Jaekel uint32_t padding; 112d979f56cSAndreas Jaekel /* dataset follows */ 113d979f56cSAndreas Jaekel } zev_zvol_write_t; 114d979f56cSAndreas Jaekel 115d979f56cSAndreas Jaekel typedef struct zev_znode_close_after_update_t { 116*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 117d979f56cSAndreas Jaekel zev_inode_info_t file; 118d979f56cSAndreas Jaekel } zev_znode_close_after_update_t; 119d979f56cSAndreas Jaekel 120d979f56cSAndreas Jaekel typedef struct zev_znode_create_t { 121*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 122d979f56cSAndreas Jaekel zev_inode_info_t file; 123d979f56cSAndreas Jaekel zev_inode_info_t parent; 124d979f56cSAndreas Jaekel uint32_t name_len; 125*149d0affSAndreas Jaekel uint32_t padding; 126d979f56cSAndreas Jaekel /* name follows */ 127d979f56cSAndreas Jaekel } zev_znode_create_t; 128d979f56cSAndreas Jaekel 129d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_mkdir_t; 130d979f56cSAndreas Jaekel typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; 131d979f56cSAndreas Jaekel 132d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t { 133*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 134d979f56cSAndreas Jaekel zev_inode_info_t parent; 135d979f56cSAndreas Jaekel uint32_t name_len; 136*149d0affSAndreas Jaekel uint32_t padding; 137d979f56cSAndreas Jaekel /* name follows */ 138d979f56cSAndreas Jaekel } zev_znode_remove_t; 139d979f56cSAndreas Jaekel 140d979f56cSAndreas Jaekel typedef struct zev_znode_remove_t zev_znode_rmdir_t; 141d979f56cSAndreas Jaekel 142d979f56cSAndreas Jaekel typedef struct zev_znode_link_t { 143*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 144d979f56cSAndreas Jaekel zev_inode_info_t parent; 145d979f56cSAndreas Jaekel zev_inode_info_t file; 146d979f56cSAndreas Jaekel uint32_t name_len; 147*149d0affSAndreas Jaekel uint32_t padding; 148d979f56cSAndreas Jaekel /* new_name follows */ 149d979f56cSAndreas Jaekel } zev_znode_link_t; 150d979f56cSAndreas Jaekel 151d979f56cSAndreas Jaekel typedef struct zev_znode_symlink_t { 152*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 153d979f56cSAndreas Jaekel zev_inode_info_t parent; 154d979f56cSAndreas Jaekel zev_inode_info_t file; 155d979f56cSAndreas Jaekel uint32_t name_len; 156d979f56cSAndreas Jaekel uint32_t link_len; 157d979f56cSAndreas Jaekel /* name follows */ 158d979f56cSAndreas Jaekel /* link follows */ 159d979f56cSAndreas Jaekel } zev_znode_symlink_t; 160d979f56cSAndreas Jaekel 161d979f56cSAndreas Jaekel typedef struct zev_znode_rename_t { 162*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 163d979f56cSAndreas Jaekel zev_inode_info_t srcdir; 164d979f56cSAndreas Jaekel zev_inode_info_t dstdir; 165d979f56cSAndreas Jaekel zev_inode_info_t file; 166d979f56cSAndreas Jaekel uint32_t srcname_len; 167d979f56cSAndreas Jaekel uint32_t dstname_len; 168d979f56cSAndreas Jaekel /* srcname follows */ 169d979f56cSAndreas Jaekel /* dstname follows */ 170d979f56cSAndreas Jaekel } zev_znode_rename_t; 171d979f56cSAndreas Jaekel 172d979f56cSAndreas Jaekel typedef struct zev_znode_write_t { 173*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 174d979f56cSAndreas Jaekel zev_inode_info_t file; 175d979f56cSAndreas Jaekel uint64_t offset; 176d979f56cSAndreas Jaekel uint64_t length; 177d979f56cSAndreas Jaekel } zev_znode_write_t; 178d979f56cSAndreas Jaekel 179d979f56cSAndreas Jaekel typedef struct zev_znode_truncate_t { 180*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 181d979f56cSAndreas Jaekel zev_inode_info_t file; 182d979f56cSAndreas Jaekel uint64_t offset; 183d979f56cSAndreas Jaekel uint64_t length; 184d979f56cSAndreas Jaekel } zev_znode_truncate_t; 185d979f56cSAndreas Jaekel 186d979f56cSAndreas Jaekel typedef struct zev_znode_setattr_t { 187*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 188d979f56cSAndreas Jaekel zev_inode_info_t file; 189d979f56cSAndreas Jaekel } zev_znode_setattr_t; 190d979f56cSAndreas Jaekel 191d979f56cSAndreas Jaekel typedef struct zev_znode_acl_t { 192*149d0affSAndreas Jaekel ZEV_COMMON_FIELDS; 193d979f56cSAndreas Jaekel zev_inode_info_t file; 194d979f56cSAndreas Jaekel } zev_znode_acl_t; 195d979f56cSAndreas Jaekel 196d979f56cSAndreas Jaekel /* convenience helper definition */ 197d979f56cSAndreas Jaekel typedef union { 198d979f56cSAndreas Jaekel zev_header_t header; 199d979f56cSAndreas Jaekel 200d979f56cSAndreas Jaekel union { 201d979f56cSAndreas Jaekel zev_zfs_mount_t mount; 202d979f56cSAndreas Jaekel zev_zfs_umount_t umount; 203d979f56cSAndreas Jaekel } zfs; 204d979f56cSAndreas Jaekel union { 205d979f56cSAndreas Jaekel zev_zvol_truncate_t truncate; 206d979f56cSAndreas Jaekel zev_zvol_write_t write; 207d979f56cSAndreas Jaekel } zvol; 208d979f56cSAndreas Jaekel union { 209d979f56cSAndreas Jaekel zev_znode_close_after_update_t close; 210d979f56cSAndreas Jaekel zev_znode_create_t create; 211d979f56cSAndreas Jaekel zev_znode_mkdir_t mkdir; 212d979f56cSAndreas Jaekel zev_znode_make_xattr_dir_t mkxattrdir; 213d979f56cSAndreas Jaekel zev_znode_remove_t remove; 214d979f56cSAndreas Jaekel zev_znode_rmdir_t rmdir; 215d979f56cSAndreas Jaekel zev_znode_link_t link; 216d979f56cSAndreas Jaekel zev_znode_symlink_t symlink; 217d979f56cSAndreas Jaekel zev_znode_rename_t rename; 218d979f56cSAndreas Jaekel zev_znode_write_t write; 219d979f56cSAndreas Jaekel zev_znode_truncate_t truncate; 220d979f56cSAndreas Jaekel zev_znode_setattr_t setattr; 221d979f56cSAndreas Jaekel zev_znode_acl_t acl; 222d979f56cSAndreas Jaekel } znode; 223d979f56cSAndreas Jaekel } zev_event_t; 224d979f56cSAndreas Jaekel 225d979f56cSAndreas Jaekel 226a18c35b9SAndreas Jaekel 227a18c35b9SAndreas Jaekel typedef struct zev_statistics_t { 228a18c35b9SAndreas Jaekel uint64_t zev_queue_len; 229a18c35b9SAndreas Jaekel uint64_t zev_bytes_read; 230fec460f8SAndreas Jaekel /* runtime settings */ 231fec460f8SAndreas Jaekel uint64_t zev_max_queue_len; 232fec460f8SAndreas Jaekel uint64_t zev_poll_wakeup_queue_len; 233a18c35b9SAndreas Jaekel /* counters */ 234a18c35b9SAndreas Jaekel uint64_t zev_cnt_total_events; 235a18c35b9SAndreas Jaekel uint64_t zev_cnt_errors; 236a18c35b9SAndreas Jaekel /* zfsvfs ops */ 237a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_mount; 238a18c35b9SAndreas Jaekel uint64_t zev_cnt_zfs_umount; 239a18c35b9SAndreas Jaekel /* zvol ops */ 240a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_write; 241a18c35b9SAndreas Jaekel uint64_t zev_cnt_zvol_truncate; 242a18c35b9SAndreas Jaekel /* znode ops */ 243a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_close_after_update; 244a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_create; 245a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_remove; 246a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_link; 247a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_symlink; 248a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_rename; 249a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_write; 250a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_truncate; 251a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_setattr; 252a18c35b9SAndreas Jaekel uint64_t zev_cnt_znode_acl; 253a18c35b9SAndreas Jaekel } zev_statistics_t; 254a18c35b9SAndreas Jaekel 255a18c35b9SAndreas Jaekel typedef struct zev_ioctl_poolarg { 256a18c35b9SAndreas Jaekel uint64_t zev_poolname_len; 257a18c35b9SAndreas Jaekel char zev_poolname[MAXPATHLEN]; 258a18c35b9SAndreas Jaekel } zev_ioctl_poolarg_t; 259*149d0affSAndreas Jaekel #pragma pack() 260a18c35b9SAndreas Jaekel 261a18c35b9SAndreas Jaekel #ifdef _KERNEL 262d979f56cSAndreas Jaekel typedef struct zev_msg_t { 263d979f56cSAndreas Jaekel struct zev_msg_t *next; 264d979f56cSAndreas Jaekel int size; 265d979f56cSAndreas Jaekel /* data follows */ 266d979f56cSAndreas Jaekel } zev_msg_t; 267d979f56cSAndreas Jaekel 268d979f56cSAndreas Jaekel void zev_queue_error(int op, char *fmt, ...); 269d979f56cSAndreas Jaekel void zev_queue_message(int op, zev_msg_t *msg); 270d979f56cSAndreas Jaekel void zev_queue_message_nvlist(int op, nvlist_t *nvl); 271a18c35b9SAndreas Jaekel int zev_skip_pool(objset_t *os); 272d979f56cSAndreas Jaekel 273a18c35b9SAndreas Jaekel #endif 274a18c35b9SAndreas Jaekel 275a18c35b9SAndreas Jaekel #endif /* __ZEV_H__ */ 276a18c35b9SAndreas Jaekel 277