#ifndef __ZEV_H__ #define __ZEV_H__ #include #ifdef _KERNEL #include #include #include #include #include #endif #define ZEVIOC ('z' << 8) #define ZEV_IOC_GET_STATISTICS (ZEVIOC | 1) /* get zev statistics */ #define ZEV_IOC_MUTE_POOL (ZEVIOC | 2) /* no events for pool */ #define ZEV_IOC_UNMUTE_POOL (ZEVIOC | 3) /* send pool events */ #define ZEV_IOC_SET_MAX_QUEUE_LEN (ZEVIOC | 4) /* when to block ops */ #define ZEV_IOC_SET_POLL_WAKEUP_QUEUE_LEN (ZEVIOC | 5) /* poll throttle */ #define ZEV_OP_MIN 1 #define ZEV_OP_ERROR 1 #define ZEV_OP_ZFS_MOUNT 2 #define ZEV_OP_ZFS_UMOUNT 3 #define ZEV_OP_ZVOL_WRITE 4 #define ZEV_OP_ZVOL_TRUNCATE 5 #define ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE 6 #define ZEV_OP_ZNODE_CREATE 7 #define ZEV_OP_ZNODE_MKDIR 8 #define ZEV_OP_ZNODE_MAKE_XATTR_DIR 9 #define ZEV_OP_ZNODE_REMOVE 10 #define ZEV_OP_ZNODE_RMDIR 11 #define ZEV_OP_ZNODE_LINK 12 #define ZEV_OP_ZNODE_SYMLINK 13 #define ZEV_OP_ZNODE_RENAME 14 #define ZEV_OP_ZNODE_WRITE 15 #define ZEV_OP_ZNODE_TRUNCATE 16 #define ZEV_OP_ZNODE_SETATTR 17 #define ZEV_OP_ZNODE_ACL 18 #define ZEV_OP_MAX 18 /* zfs event records (as they are represented through the character device) */ typedef struct zev_inode_info_t { uint64_t ino; uint64_t gen; uint64_t mtime; uint64_t ctime; uint64_t size; uint32_t type; uint64_t mode; uint64_t links; } zev_inode_info_t; #define ZEV_ERRSTR(rec) ((char *)(rec + 1)) #define ZEV_DATASET(rec) ((char *)(rec + 1)) #define ZEV_MOUNTPOINT(rec) (((char *)(rec + 1)) + rec->dataset_len + 1) #define ZEV_NAME(rec) ((char *)(rec + 1)) #define ZEV_SRCNAME(rec) ((char *)(rec + 1)) #define ZEV_DSTNAME(rec) (((char *)(rec + 1)) + rec->srcname_len + 1) #define ZEV_LINK(rec) (((char *)(rec + 1)) + rec->name_len + 1) typedef struct zev_header_t { uint32_t record_len; uint32_t op; uint64_t op_time; } zev_header_t; typedef struct zev_error_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint32_t failed_op; uint32_t errstr_len; /* error string follows */ } zev_error_t; typedef struct zev_zfs_mount_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; uint64_t root_ino; boolean_t remount; uint32_t dataset_len; uint32_t mountpoint_len; /* dataset follows */ /* mountpoint follows */ } zev_zfs_mount_t; typedef struct zev_zfs_umount_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; } zev_zfs_umount_t; typedef struct zev_zvol_truncate_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; uint64_t offset; uint64_t length; uint32_t dataset_len; /* dataset follows */ } zev_zvol_truncate_t; typedef struct zev_zvol_write_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; uint64_t offset; uint64_t length; uint32_t dataset_len; /* dataset follows */ } zev_zvol_write_t; typedef struct zev_znode_close_after_update_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; } zev_znode_close_after_update_t; typedef struct zev_znode_create_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; zev_inode_info_t parent; uint32_t name_len; /* name follows */ } zev_znode_create_t; typedef struct zev_znode_create_t zev_znode_mkdir_t; typedef struct zev_znode_create_t zev_znode_make_xattr_dir_t; typedef struct zev_znode_remove_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t parent; uint32_t name_len; /* name follows */ } zev_znode_remove_t; typedef struct zev_znode_remove_t zev_znode_rmdir_t; typedef struct zev_znode_link_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t parent; zev_inode_info_t file; uint32_t name_len; /* new_name follows */ } zev_znode_link_t; typedef struct zev_znode_symlink_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t parent; zev_inode_info_t file; uint32_t name_len; uint32_t link_len; /* name follows */ /* link follows */ } zev_znode_symlink_t; typedef struct zev_znode_rename_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t srcdir; zev_inode_info_t dstdir; zev_inode_info_t file; uint32_t srcname_len; uint32_t dstname_len; /* srcname follows */ /* dstname follows */ } zev_znode_rename_t; typedef struct zev_znode_write_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; uint64_t offset; uint64_t length; } zev_znode_write_t; typedef struct zev_znode_truncate_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; uint64_t offset; uint64_t length; } zev_znode_truncate_t; typedef struct zev_znode_setattr_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; } zev_znode_setattr_t; typedef struct zev_znode_acl_t { uint32_t record_len; uint32_t op; uint64_t op_time; uint64_t guid; zev_inode_info_t file; } zev_znode_acl_t; /* convenience helper definition */ typedef union { zev_header_t header; union { zev_zfs_mount_t mount; zev_zfs_umount_t umount; } zfs; union { zev_zvol_truncate_t truncate; zev_zvol_write_t write; } zvol; union { zev_znode_close_after_update_t close; zev_znode_create_t create; zev_znode_mkdir_t mkdir; zev_znode_make_xattr_dir_t mkxattrdir; zev_znode_remove_t remove; zev_znode_rmdir_t rmdir; zev_znode_link_t link; zev_znode_symlink_t symlink; zev_znode_rename_t rename; zev_znode_write_t write; zev_znode_truncate_t truncate; zev_znode_setattr_t setattr; zev_znode_acl_t acl; } znode; } zev_event_t; typedef struct zev_statistics_t { uint64_t zev_queue_len; uint64_t zev_bytes_read; /* runtime settings */ uint64_t zev_max_queue_len; uint64_t zev_poll_wakeup_queue_len; /* counters */ uint64_t zev_cnt_total_events; uint64_t zev_cnt_errors; /* zfsvfs ops */ uint64_t zev_cnt_zfs_mount; uint64_t zev_cnt_zfs_umount; /* zvol ops */ uint64_t zev_cnt_zvol_write; uint64_t zev_cnt_zvol_truncate; /* znode ops */ uint64_t zev_cnt_znode_close_after_update; uint64_t zev_cnt_znode_create; uint64_t zev_cnt_znode_remove; uint64_t zev_cnt_znode_link; uint64_t zev_cnt_znode_symlink; uint64_t zev_cnt_znode_rename; uint64_t zev_cnt_znode_write; uint64_t zev_cnt_znode_truncate; uint64_t zev_cnt_znode_setattr; uint64_t zev_cnt_znode_acl; } zev_statistics_t; typedef struct zev_ioctl_poolarg { uint64_t zev_poolname_len; char zev_poolname[MAXPATHLEN]; } zev_ioctl_poolarg_t; #ifdef _KERNEL typedef struct zev_msg_t { struct zev_msg_t *next; int size; /* data follows */ } zev_msg_t; void zev_queue_error(int op, char *fmt, ...); void zev_queue_message(int op, zev_msg_t *msg); void zev_queue_message_nvlist(int op, nvlist_t *nvl); int zev_skip_pool(objset_t *os); #endif #endif /* __ZEV_H__ */