xref: /titanic_41/usr/src/uts/common/fs/zfs/sys/zfs_events.h (revision 9ed9bfe91df7eb8d10c125f9f04d3ec82010930a)
1 #ifndef	_SYS_ZFS_EVENTHOOKS_H
2 #define	_SYS_ZFS_EVENTHOOKS_H
3 
4 #include <sys/types.h>
5 #include <sys/vnode.h>
6 #include <sys/vfs.h>
7 #include <sys/zfs_znode.h>
8 #include <sys/zil.h>
9 
10 #ifdef	__cplusplus
11 extern "C" {
12 #endif
13 
14 #ifdef _KERNEL
15 
16 /* zfsvfs ops */
17 typedef void (*rz_zev_zfs_mount_cb_t)(vfs_t *vfs, vnode_t *mpt, char *dataset,
18     boolean_t remount);
19 typedef void (*rz_zev_zfs_umount_cb_t)(vfs_t *vfs);
20 /* zvol zil events */
21 typedef void (*rz_zev_zvol_truncate_cb_t)(char *dataset, objset_t *os,
22     dmu_tx_t *tx, uint64_t off, uint64_t len);
23 typedef void (*rz_zev_zvol_write_cb_t)(char *dataset, objset_t *os,
24     dmu_tx_t *tx, uint64_t off, uint64_t len);
25 /* znode zil events */
26 typedef void (*rz_zev_znode_close_after_update_cb_t)(znode_t *zp);
27 typedef void (*rz_zev_znode_create_cb_t)(znode_t *dzp, znode_t *zp,
28     dmu_tx_t *tx, char *name, uint64_t txmode);
29 typedef void (*rz_zev_znode_remove_cb_t)(znode_t *dzp, znode_t *zp,
30     dmu_tx_t *tx, char *name, uint64_t txmode);
31 typedef void (*rz_zev_znode_link_cb_t)(znode_t *dzp, znode_t *zp,
32     dmu_tx_t *tx, char *name);
33 typedef void (*rz_zev_znode_symlink_cb_t)(znode_t *dzp, znode_t *zp,
34     dmu_tx_t *tx, char *name, char *link);
35 typedef void (*rz_zev_znode_rename_cb_t)(znode_t *sdzp,
36     char *sname, znode_t *tdzp, char *tname, znode_t *szp, znode_t *tzp,
37     dmu_tx_t *tx);
38 typedef void (*rz_zev_znode_write_cb_t)(znode_t *zp,
39     dmu_tx_t *tx, uint64_t off,
40     uint64_t len);
41 typedef void (*rz_zev_znode_truncate_cb_t)(znode_t *zp, dmu_tx_t *tx,
42     uint64_t off, uint64_t len);
43 typedef void (*rz_zev_znode_setattr_cb_t)(znode_t *zp, dmu_tx_t *tx);
44 typedef void (*rz_zev_znode_acl_cb_t)(znode_t *zp, dmu_tx_t *tx);
45 
46 typedef struct rz_zev_callbacks {
47 	/* zfsvfs events */
48 	rz_zev_zfs_mount_cb_t			rz_zev_zfs_mount;
49 	rz_zev_zfs_umount_cb_t			rz_zev_zfs_umount;
50 
51 	/* zvol zil events */
52 	rz_zev_zvol_truncate_cb_t		rz_zev_zvol_truncate;
53 	rz_zev_zvol_write_cb_t			rz_zev_zvol_write;
54 
55 	/* znode zil events */
56 	rz_zev_znode_close_after_update_cb_t	rz_zev_znode_close_after_update;
57 	rz_zev_znode_create_cb_t		rz_zev_znode_create;
58 	rz_zev_znode_remove_cb_t		rz_zev_znode_remove;
59 	rz_zev_znode_link_cb_t			rz_zev_znode_link;
60 	rz_zev_znode_symlink_cb_t		rz_zev_znode_symlink;
61 	rz_zev_znode_rename_cb_t		rz_zev_znode_rename;
62 	rz_zev_znode_write_cb_t			rz_zev_znode_write;
63 	rz_zev_znode_truncate_cb_t		rz_zev_znode_truncate;
64 	rz_zev_znode_setattr_cb_t		rz_zev_znode_setattr;
65 	rz_zev_znode_acl_cb_t			rz_zev_znode_acl;
66 } rz_zev_callbacks_t;
67 
68 extern rz_zev_callbacks_t *rz_zev_callbacks;		/* in zfs_events.c */
69 extern rz_zev_callbacks_t *rz_zev_default_callbacks;	/* in zfs_events.c */
70 extern krwlock_t rz_zev_rwlock;				/* in zfs_events.c */
71 
72 void rz_zev_init(void);
73 void rz_zev_fini(void);
74 
75 boolean_t rz_zev_active(void);
76 void rz_zev_set_active(boolean_t active);
77 
78 #endif
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif	/* _SYS_ZFS_EVENTS_H */
85