xref: /titanic_44/usr/src/uts/common/fs/zev/zev_callbacks.c (revision 41aa6ebd93e2fff9852b1fc8361292e2c67b4410)
135d4e8ddSAndreas Jaekel #include <sys/mode.h>
2a18c35b9SAndreas Jaekel #include <sys/zfs_znode.h>
3a18c35b9SAndreas Jaekel #include <sys/fs/zfs.h>
4a18c35b9SAndreas Jaekel #include <sys/fs/zev.h>
5a18c35b9SAndreas Jaekel #include <sys/zfs_events.h>
6205ed6bfSAndreas Jaekel #include <sys/zev_checksums.h>
712119a7eSAndreas Jaekel #include <sys/dmu_tx.h>
894875cb8SAndreas Jaekel #include <sys/mntent.h>
9a18c35b9SAndreas Jaekel 
10f2dd45e5SAndreas Jaekel #define ZEV_FILL_INODE_INFO(name, znode)				\
11f2dd45e5SAndreas Jaekel 	do {								\
12f2dd45e5SAndreas Jaekel 		uint64_t mtime[2], ctime[2];				\
13f2dd45e5SAndreas Jaekel 		sa_bulk_attr_t bulk[2];					\
14f2dd45e5SAndreas Jaekel 		int count = 0;						\
15f2dd45e5SAndreas Jaekel 		timestruc_t mtime_s, ctime_s;				\
16f2dd45e5SAndreas Jaekel 		SA_ADD_BULK_ATTR(bulk, count,				\
17f2dd45e5SAndreas Jaekel 			         SA_ZPL_MTIME(znode->z_zfsvfs),		\
18f2dd45e5SAndreas Jaekel 		                 NULL, &mtime, 16);			\
19f2dd45e5SAndreas Jaekel 		SA_ADD_BULK_ATTR(bulk, count,				\
20f2dd45e5SAndreas Jaekel 			         SA_ZPL_CTIME(znode->z_zfsvfs),		\
21f2dd45e5SAndreas Jaekel 		                 NULL, &ctime, 16);			\
22f2dd45e5SAndreas Jaekel 		if ((sa_bulk_lookup(znode->z_sa_hdl, bulk, count)) != 0) { \
23f2dd45e5SAndreas Jaekel 			zev_queue_error(op, "znode write: "		\
24f2dd45e5SAndreas Jaekel 			                "mtime/ctime unavailable");	\
25f2dd45e5SAndreas Jaekel 			/* continue anyway, use fake data */		\
26f2dd45e5SAndreas Jaekel 			mtime_s.tv_sec = ctime_s.tv_sec = 0;		\
27f2dd45e5SAndreas Jaekel 		}							\
28f2dd45e5SAndreas Jaekel 		ZFS_TIME_DECODE(&mtime_s, mtime);			\
29f2dd45e5SAndreas Jaekel 		ZFS_TIME_DECODE(&ctime_s, ctime);			\
30f2dd45e5SAndreas Jaekel 		rec->name.ino = znode->z_id;				\
31f2dd45e5SAndreas Jaekel 		rec->name.gen = znode->z_gen;				\
32f2dd45e5SAndreas Jaekel 		rec->name.mtime = mtime_s.tv_sec;			\
33f2dd45e5SAndreas Jaekel 		rec->name.ctime = ctime_s.tv_sec;			\
34f2dd45e5SAndreas Jaekel 		rec->name.size = znode->z_size;				\
35f2dd45e5SAndreas Jaekel 		rec->name.type = znode->z_vnode->v_type;		\
3635d4e8ddSAndreas Jaekel 		rec->name.mode =					\
3735d4e8ddSAndreas Jaekel 			znode->z_mode | VTTOIF(znode->z_vnode->v_type);	\
38f2dd45e5SAndreas Jaekel 		rec->name.links = znode->z_links;			\
3919b08257SAndreas Jaekel 		rec->name.flags = znode->z_pflags & ZFS_XATTR ?		\
4019b08257SAndreas Jaekel 			ZEV_FL_XATTR : 0;				\
41*41aa6ebdSSimon Klinkert 	/* CONSTCOND */							\
42548c8b6eSAndreas Jaekel 	} while(0)
43f2dd45e5SAndreas Jaekel 
44a18c35b9SAndreas Jaekel void
zev_zfs_mount_cb(vfs_t * vfs,vnode_t * mpt,char * dataset,boolean_t remount)45a18c35b9SAndreas Jaekel zev_zfs_mount_cb(vfs_t *vfs, vnode_t *mpt, char *dataset, boolean_t remount)
46a18c35b9SAndreas Jaekel {
47aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZFS_MOUNT;
48aafc540fSAndreas Jaekel 	char mountpoint[MAXPATHLEN+1];
49f2dd45e5SAndreas Jaekel 	int mountpoint_len;
50f2dd45e5SAndreas Jaekel 	int dataset_len;
51f2dd45e5SAndreas Jaekel 	zev_zfs_mount_t *rec;
52f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
53f2dd45e5SAndreas Jaekel 	int msg_size;
5493297ba3SAndreas Jaekel 	znode_t *zp_root;
5503a64974SSimon Klinkert 	dmu_tx_t *tx;
5603a64974SSimon Klinkert 	int error;
5703a64974SSimon Klinkert 	uint64_t txg;
58aafc540fSAndreas Jaekel 
597894d8e6SAndreas Jaekel 	/*
607894d8e6SAndreas Jaekel 	 * workaround: this callback erronously got called for failed
617894d8e6SAndreas Jaekel 	 * mount attempts, and then crashed the system.  Detect this
627894d8e6SAndreas Jaekel 	 * from inside this callback as a workaround while the bugfix
637894d8e6SAndreas Jaekel 	 * in the zfs module is not universally available.
647894d8e6SAndreas Jaekel 	 */
657894d8e6SAndreas Jaekel 	if (vfs == NULL)
667894d8e6SAndreas Jaekel 		return;
677894d8e6SAndreas Jaekel 	if (vfs->vfs_data == NULL)
687894d8e6SAndreas Jaekel 		return;
697894d8e6SAndreas Jaekel 
70dde42681SAndreas Jaekel 	zfsvfs_t *zfsvfs = (zfsvfs_t *)vfs->vfs_data;
71d6dfd404SSimon Klinkert 	if (zfsvfs->z_os->os_dsl_dataset->ds_is_snapshot)
728f38b24dSAndreas Jaekel 		return;
73dde42681SAndreas Jaekel 	if (zev_skip_pool(zfsvfs->z_os))
74a18c35b9SAndreas Jaekel 		return;
753655089bSAndreas Jaekel 	if (zev_skip_fs(zfsvfs))
763655089bSAndreas Jaekel 		return;
77a18c35b9SAndreas Jaekel 	/* expensive, but we don't have many mount ops. */
78a18c35b9SAndreas Jaekel 	if ((vnodetopath(NULL, mpt, mountpoint, sizeof(mountpoint),
79a18c35b9SAndreas Jaekel 	    kcred)) != 0) {
80f2dd45e5SAndreas Jaekel 		zev_queue_error(op, "unresolvable mountpoint, dataset=%s",
81f2dd45e5SAndreas Jaekel 		                dataset);
82a18c35b9SAndreas Jaekel 		return;
83a18c35b9SAndreas Jaekel 	}
8493297ba3SAndreas Jaekel 	if (zfs_zget(zfsvfs, zfsvfs->z_root, &zp_root) != 0) {
8593297ba3SAndreas Jaekel 		zev_queue_error(op, "can't get root znode, dataset=%s",
8693297ba3SAndreas Jaekel 		                dataset);
8793297ba3SAndreas Jaekel 		return;
8893297ba3SAndreas Jaekel 	}
89aafc540fSAndreas Jaekel 
9003a64974SSimon Klinkert 	/* get current tgx by adding an empty tx */
9103a64974SSimon Klinkert 	tx = dmu_tx_create(zfsvfs->z_os);
9203a64974SSimon Klinkert 	error = dmu_tx_assign(tx, TXG_WAIT);
9303a64974SSimon Klinkert 	if (error) {
9403a64974SSimon Klinkert 		dmu_tx_abort(tx);
9503a64974SSimon Klinkert 		zev_queue_error(op, "can't create tx, dataset=%s", dataset);
9603a64974SSimon Klinkert 		return;
9703a64974SSimon Klinkert 	}
9803a64974SSimon Klinkert 	txg = dmu_tx_get_txg(tx);
9903a64974SSimon Klinkert 	dmu_tx_commit(tx);
10003a64974SSimon Klinkert 
101f2dd45e5SAndreas Jaekel 	dataset_len = strlen(dataset);
102f2dd45e5SAndreas Jaekel 	mountpoint_len = strlen(mountpoint);
103f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + dataset_len + 1 + mountpoint_len + 1;
104205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
105f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
106f2dd45e5SAndreas Jaekel 	rec = (zev_zfs_mount_t *)(msg + 1);
107f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
108f2dd45e5SAndreas Jaekel 	rec->op = op;
109f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
1108948de2fSSimon Klinkert 	rec->guid = dsl_dataset_phys(zfsvfs->z_os->os_dsl_dataset)->ds_guid;
11103a64974SSimon Klinkert 	rec->txg = txg;
112f2dd45e5SAndreas Jaekel 	rec->remount = remount;
113f2dd45e5SAndreas Jaekel 	rec->dataset_len = dataset_len;
114f2dd45e5SAndreas Jaekel 	rec->mountpoint_len = mountpoint_len;
11593297ba3SAndreas Jaekel 	ZEV_FILL_INODE_INFO(root, zp_root);
11693297ba3SAndreas Jaekel 	VN_RELE(ZTOV(zp_root));
117548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_DATASET(rec), dataset, dataset_len + 1);
118548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_MOUNTPOINT(rec), mountpoint, mountpoint_len + 1);
119f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
120a18c35b9SAndreas Jaekel }
121a18c35b9SAndreas Jaekel 
122a18c35b9SAndreas Jaekel void
zev_zfs_umount_cb(vfs_t * vfs)123a18c35b9SAndreas Jaekel zev_zfs_umount_cb(vfs_t *vfs)
124a18c35b9SAndreas Jaekel {
125aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZFS_UMOUNT;
126f2dd45e5SAndreas Jaekel 	zev_zfs_umount_t *rec;
127f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
128f2dd45e5SAndreas Jaekel 	int msg_size;
12994875cb8SAndreas Jaekel 	struct vnode *vp;
13094875cb8SAndreas Jaekel 	znode_t *zp;
13103a64974SSimon Klinkert 	dmu_tx_t *tx;
13203a64974SSimon Klinkert 	int error;
13303a64974SSimon Klinkert 	uint64_t txg;
134aafc540fSAndreas Jaekel 
135dde42681SAndreas Jaekel 	zfsvfs_t *zfsvfs = (zfsvfs_t *)vfs->vfs_data;
136d6dfd404SSimon Klinkert 	if (zfsvfs->z_os->os_dsl_dataset->ds_is_snapshot)
1378f38b24dSAndreas Jaekel 		return;
138dde42681SAndreas Jaekel 	if (zev_skip_pool(zfsvfs->z_os))
139a18c35b9SAndreas Jaekel 		return;
1403655089bSAndreas Jaekel 	if (zev_skip_fs(zfsvfs))
1413655089bSAndreas Jaekel 		return;
142aafc540fSAndreas Jaekel 
14303a64974SSimon Klinkert 	/* get current tgx by adding an empty tx */
14403a64974SSimon Klinkert 	tx = dmu_tx_create(zfsvfs->z_os);
14503a64974SSimon Klinkert 	error = dmu_tx_assign(tx, TXG_WAIT);
14603a64974SSimon Klinkert 	if (error) {
14703a64974SSimon Klinkert 		dmu_tx_abort(tx);
14803a64974SSimon Klinkert 		zev_queue_error(op, "can't create tx");
14903a64974SSimon Klinkert 		return;
15003a64974SSimon Klinkert 	}
15103a64974SSimon Klinkert 	txg = dmu_tx_get_txg(tx);
15203a64974SSimon Klinkert 	dmu_tx_commit(tx);
15303a64974SSimon Klinkert 
154f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec);
155205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
156f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
157f2dd45e5SAndreas Jaekel 	rec = (zev_zfs_umount_t *)(msg + 1);
158f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
159f2dd45e5SAndreas Jaekel 	rec->op = op;
160f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
1618948de2fSSimon Klinkert 	rec->guid = dsl_dataset_phys(zfsvfs->z_os->os_dsl_dataset)->ds_guid;
16203a64974SSimon Klinkert 	rec->txg = txg;
16394875cb8SAndreas Jaekel 
16494875cb8SAndreas Jaekel 	vp = vfs->vfs_vnodecovered;
16594875cb8SAndreas Jaekel 	if (strcmp(vfssw[vp->v_vfsp->vfs_fstype].vsw_name, MNTTYPE_ZFS)) {
16694875cb8SAndreas Jaekel 		cmn_err(CE_WARN, "covered inode not on zfs filesystem, "
16794875cb8SAndreas Jaekel 		        "reporting all-zero inode struct.");
16894875cb8SAndreas Jaekel 		memset(&rec->covered, 0, sizeof(rec->covered));
16994875cb8SAndreas Jaekel 	} else {
17094875cb8SAndreas Jaekel 		zp = VTOZ(vfs->vfs_vnodecovered);
17194875cb8SAndreas Jaekel 		ZEV_FILL_INODE_INFO(covered, zp);
17294875cb8SAndreas Jaekel 	}
17394875cb8SAndreas Jaekel 
174f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
175a18c35b9SAndreas Jaekel }
176a18c35b9SAndreas Jaekel 
177a18c35b9SAndreas Jaekel void
zev_zvol_truncate_cb(char * dataset,objset_t * os,dmu_tx_t * tx,uint64_t off,uint64_t len)17812119a7eSAndreas Jaekel zev_zvol_truncate_cb(char *dataset,
17912119a7eSAndreas Jaekel                      objset_t *os,
18012119a7eSAndreas Jaekel                      dmu_tx_t *tx,
18112119a7eSAndreas Jaekel                      uint64_t off,
18212119a7eSAndreas Jaekel                      uint64_t len)
183a18c35b9SAndreas Jaekel {
184aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZVOL_TRUNCATE;
185f2dd45e5SAndreas Jaekel 	zev_zvol_truncate_t *rec;
186f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
187f2dd45e5SAndreas Jaekel 	int msg_size;
188f2dd45e5SAndreas Jaekel 	int dataset_len;
189aafc540fSAndreas Jaekel 
190a18c35b9SAndreas Jaekel 	if (zev_skip_pool(os))
191a18c35b9SAndreas Jaekel 		return;
192aafc540fSAndreas Jaekel 
193f2dd45e5SAndreas Jaekel 	dataset_len = strlen(dataset);
194f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + dataset_len + 1;
195205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
196f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
197f2dd45e5SAndreas Jaekel 	rec = (zev_zvol_truncate_t *)(msg + 1);
198f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
199f2dd45e5SAndreas Jaekel 	rec->op = op;
200f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
2018948de2fSSimon Klinkert 	rec->guid = dsl_dataset_phys(os->os_dsl_dataset)->ds_guid;
20203a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
203f2dd45e5SAndreas Jaekel 	rec->offset = off;
204f2dd45e5SAndreas Jaekel 	rec->length = len;
205f2dd45e5SAndreas Jaekel 	rec->dataset_len = dataset_len;
206548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_DATASET(rec), dataset, dataset_len + 1);
207f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
208a18c35b9SAndreas Jaekel }
209a18c35b9SAndreas Jaekel 
210a18c35b9SAndreas Jaekel void
zev_zvol_write_cb(char * dataset,objset_t * os,dmu_tx_t * tx,uint64_t off,uint64_t len)21112119a7eSAndreas Jaekel zev_zvol_write_cb(char *dataset,
21212119a7eSAndreas Jaekel                   objset_t *os,
21312119a7eSAndreas Jaekel                   dmu_tx_t *tx,
21412119a7eSAndreas Jaekel                   uint64_t off,
21512119a7eSAndreas Jaekel                   uint64_t len)
216a18c35b9SAndreas Jaekel {
217aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZVOL_WRITE;
218f2dd45e5SAndreas Jaekel 	zev_zvol_write_t *rec;
219f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
220f2dd45e5SAndreas Jaekel 	int msg_size;
221f2dd45e5SAndreas Jaekel 	int dataset_len;
222aafc540fSAndreas Jaekel 
223a18c35b9SAndreas Jaekel 	if (zev_skip_pool(os))
224a18c35b9SAndreas Jaekel 		return;
225aafc540fSAndreas Jaekel 
226f2dd45e5SAndreas Jaekel 	dataset_len = strlen(dataset);
227f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + dataset_len + 1;
228205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
229f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
230f2dd45e5SAndreas Jaekel 	rec = (zev_zvol_write_t *)(msg + 1);
231f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
232f2dd45e5SAndreas Jaekel 	rec->op = op;
233f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
2348948de2fSSimon Klinkert 	rec->guid = dsl_dataset_phys(os->os_dsl_dataset)->ds_guid;
23503a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
236f2dd45e5SAndreas Jaekel 	rec->offset = off;
237f2dd45e5SAndreas Jaekel 	rec->length = len;
238f2dd45e5SAndreas Jaekel 	rec->dataset_len = dataset_len;
239548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_DATASET(rec), dataset, dataset_len + 1);
240f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
241a18c35b9SAndreas Jaekel }
242a18c35b9SAndreas Jaekel 
243a18c35b9SAndreas Jaekel void
zev_znode_close_after_update_cb(znode_t * zp)244a18c35b9SAndreas Jaekel zev_znode_close_after_update_cb(znode_t *zp)
245a18c35b9SAndreas Jaekel {
246aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_CLOSE_AFTER_UPDATE;
247f2dd45e5SAndreas Jaekel 	zev_znode_close_after_update_t *rec;
248f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
249f2dd45e5SAndreas Jaekel 	int msg_size;
250aafc540fSAndreas Jaekel 
251a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
252a18c35b9SAndreas Jaekel 		return;
2533655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
2543655089bSAndreas Jaekel 		return;
255aafc540fSAndreas Jaekel 
256f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec);
257205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
258f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
259f2dd45e5SAndreas Jaekel 	rec = (zev_znode_close_after_update_t *)(msg + 1);
260f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
261f2dd45e5SAndreas Jaekel 	rec->op = op;
262f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
2638948de2fSSimon Klinkert 	rec->guid =
2648948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
265f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
266f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
267a18c35b9SAndreas Jaekel }
268a18c35b9SAndreas Jaekel 
269a18c35b9SAndreas Jaekel void
zev_znode_create_cb(znode_t * dzp,znode_t * zp,dmu_tx_t * tx,char * name,uint64_t txtype)27012119a7eSAndreas Jaekel zev_znode_create_cb(znode_t *dzp,
27112119a7eSAndreas Jaekel                     znode_t *zp,
27212119a7eSAndreas Jaekel                     dmu_tx_t *tx,
27312119a7eSAndreas Jaekel                     char *name,
27412119a7eSAndreas Jaekel                     uint64_t txtype)
275a18c35b9SAndreas Jaekel {
276aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_CREATE;
277f2dd45e5SAndreas Jaekel 	zev_znode_create_t *rec;
278f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
279f2dd45e5SAndreas Jaekel 	int msg_size;
280f2dd45e5SAndreas Jaekel 	int name_len;
281aafc540fSAndreas Jaekel 
282a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
283a18c35b9SAndreas Jaekel 		return;
2843655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
2853655089bSAndreas Jaekel 		return;
286aafc540fSAndreas Jaekel 
287a18c35b9SAndreas Jaekel 	int type = (int)txtype;
288a18c35b9SAndreas Jaekel 	switch(type) {
289a18c35b9SAndreas Jaekel 	case TX_CREATE:
290a18c35b9SAndreas Jaekel 	case TX_CREATE_ACL:
291a18c35b9SAndreas Jaekel 	case TX_CREATE_ATTR:
292a18c35b9SAndreas Jaekel 	case TX_CREATE_ACL_ATTR:
293aafc540fSAndreas Jaekel 		op = ZEV_OP_ZNODE_CREATE;
294a18c35b9SAndreas Jaekel 		break;
295a18c35b9SAndreas Jaekel 	case TX_MKDIR:
296a18c35b9SAndreas Jaekel 	case TX_MKDIR_ACL:
297a18c35b9SAndreas Jaekel 	case TX_MKDIR_ATTR:
298a18c35b9SAndreas Jaekel 	case TX_MKDIR_ACL_ATTR:
299aafc540fSAndreas Jaekel 		op = ZEV_OP_ZNODE_MKDIR;
300a18c35b9SAndreas Jaekel 		break;
301a18c35b9SAndreas Jaekel 	case TX_MKXATTR:
302aafc540fSAndreas Jaekel 		op = ZEV_OP_ZNODE_MAKE_XATTR_DIR;
303a18c35b9SAndreas Jaekel 		break;
304a18c35b9SAndreas Jaekel 	default:
305aafc540fSAndreas Jaekel 		zev_queue_error(ZEV_OP_ZNODE_CREATE,
306a18c35b9SAndreas Jaekel 		    "ERROR: ZNODE_CREATE: unknown txtype %d "
307dde42681SAndreas Jaekel 		    "(dir_inode=%d:%d inode=%d:%d name='%s')\n",
308a18c35b9SAndreas Jaekel 		    type,
309dde42681SAndreas Jaekel 		    dzp->z_gen,
310a18c35b9SAndreas Jaekel 		    dzp->z_id,
311dde42681SAndreas Jaekel 		    zp->z_gen,
312a18c35b9SAndreas Jaekel 		    zp->z_id,
313aafc540fSAndreas Jaekel 		    name);
314a18c35b9SAndreas Jaekel 		return;
315a18c35b9SAndreas Jaekel 	}
316aafc540fSAndreas Jaekel 
317f2dd45e5SAndreas Jaekel 	/* all three types use the same struct, so this works for all types: */
318f2dd45e5SAndreas Jaekel 	name_len = strlen(name);
319f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + name_len + 1;
320205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
321f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
322f2dd45e5SAndreas Jaekel 	rec = (zev_znode_create_t *)(msg + 1);
323f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
324f2dd45e5SAndreas Jaekel 	rec->op = op;
325f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
3268948de2fSSimon Klinkert 	rec->guid =
3278948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
32803a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
329f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(parent, dzp);
330f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
331f2dd45e5SAndreas Jaekel 	rec->name_len = name_len;
332548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_NAME(rec), name, name_len + 1);
3332eabeab5SAndreas Jaekel 	zev_create_checksum(rec, zp);
334f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
335a18c35b9SAndreas Jaekel }
336a18c35b9SAndreas Jaekel 
337a18c35b9SAndreas Jaekel void
zev_znode_remove_cb(znode_t * dzp,znode_t * zp,dmu_tx_t * tx,char * name,uint64_t txtype)33812119a7eSAndreas Jaekel zev_znode_remove_cb(znode_t *dzp,
33912119a7eSAndreas Jaekel                     znode_t *zp,
34012119a7eSAndreas Jaekel                     dmu_tx_t *tx,
34112119a7eSAndreas Jaekel                     char *name,
34212119a7eSAndreas Jaekel                     uint64_t txtype)
343a18c35b9SAndreas Jaekel {
344aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_REMOVE;
345f2dd45e5SAndreas Jaekel 	zev_znode_remove_t *rec;
346f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
347f2dd45e5SAndreas Jaekel 	int msg_size;
348f2dd45e5SAndreas Jaekel 	int name_len;
349aafc540fSAndreas Jaekel 
350a18c35b9SAndreas Jaekel 	if (zev_skip_pool(dzp->z_zfsvfs->z_os))
351a18c35b9SAndreas Jaekel 		return;
3523655089bSAndreas Jaekel 	if (zev_skip_fs(dzp->z_zfsvfs))
3533655089bSAndreas Jaekel 		return;
354aafc540fSAndreas Jaekel 
355a18c35b9SAndreas Jaekel 	int type = (int)txtype;
356a18c35b9SAndreas Jaekel 	switch(type) {
357a18c35b9SAndreas Jaekel 	case TX_REMOVE:
358aafc540fSAndreas Jaekel 		op = ZEV_OP_ZNODE_REMOVE;
359a18c35b9SAndreas Jaekel 		break;
360a18c35b9SAndreas Jaekel 	case TX_RMDIR:
361aafc540fSAndreas Jaekel 		op = ZEV_OP_ZNODE_RMDIR;
362a18c35b9SAndreas Jaekel 		break;
363a18c35b9SAndreas Jaekel 	default:
364aafc540fSAndreas Jaekel 		zev_queue_error(ZEV_OP_ZNODE_REMOVE,
365a18c35b9SAndreas Jaekel 		    "ERROR: ZNODE_REMOVE: unknown txtype %d "
366dde42681SAndreas Jaekel 		    "(dir_inode=%d:%d name='%s')\n",
367a18c35b9SAndreas Jaekel 		    type,
368dde42681SAndreas Jaekel 		    dzp->z_gen,
369a18c35b9SAndreas Jaekel 		    dzp->z_id,
370aafc540fSAndreas Jaekel 		    name);
371a18c35b9SAndreas Jaekel 		return;
372a18c35b9SAndreas Jaekel 	}
373aafc540fSAndreas Jaekel 
374f2dd45e5SAndreas Jaekel 	/* both types use the same struct, so this works for all types: */
375f2dd45e5SAndreas Jaekel 	name_len = strlen(name);
376f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + name_len + 1;
377205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
378f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
379f2dd45e5SAndreas Jaekel 	rec = (zev_znode_remove_t *)(msg + 1);
380f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
381f2dd45e5SAndreas Jaekel 	rec->op = op;
382f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
3838948de2fSSimon Klinkert 	rec->guid =
3848948de2fSSimon Klinkert 		dsl_dataset_phys(dzp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
38503a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
38697dcf88dSAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
387f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(parent, dzp);
388f2dd45e5SAndreas Jaekel 	rec->name_len = name_len;
389548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_NAME(rec), name, name_len + 1);
390f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
391a18c35b9SAndreas Jaekel }
392a18c35b9SAndreas Jaekel 
393a18c35b9SAndreas Jaekel void
zev_znode_link_cb(znode_t * dzp,znode_t * zp,dmu_tx_t * tx,char * name)39412119a7eSAndreas Jaekel zev_znode_link_cb(znode_t *dzp, znode_t *zp, dmu_tx_t *tx, char *name)
395a18c35b9SAndreas Jaekel {
396aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_LINK;
397f2dd45e5SAndreas Jaekel 	zev_znode_link_t *rec;
398f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
399f2dd45e5SAndreas Jaekel 	int msg_size;
400f2dd45e5SAndreas Jaekel 	int name_len;
401aafc540fSAndreas Jaekel 
402a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
403a18c35b9SAndreas Jaekel 		return;
4043655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
4053655089bSAndreas Jaekel 		return;
406aafc540fSAndreas Jaekel 
407f2dd45e5SAndreas Jaekel 	name_len = strlen(name);
408f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + name_len + 1;
409205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
410f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
411f2dd45e5SAndreas Jaekel 	rec = (zev_znode_link_t *)(msg + 1);
412f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
413f2dd45e5SAndreas Jaekel 	rec->op = op;
414f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
4158948de2fSSimon Klinkert 	rec->guid =
4168948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
41703a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
418f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(parent, dzp);
419f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
420f2dd45e5SAndreas Jaekel 	rec->name_len = name_len;
421548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_NAME(rec), name, name_len + 1);
422f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
423a18c35b9SAndreas Jaekel }
424a18c35b9SAndreas Jaekel 
425a18c35b9SAndreas Jaekel void
zev_znode_symlink_cb(znode_t * dzp,znode_t * zp,dmu_tx_t * tx,char * name,char * link)42612119a7eSAndreas Jaekel zev_znode_symlink_cb(znode_t *dzp,
42712119a7eSAndreas Jaekel                      znode_t *zp,
42812119a7eSAndreas Jaekel                      dmu_tx_t *tx,
42912119a7eSAndreas Jaekel                      char *name,
43012119a7eSAndreas Jaekel                      char *link)
431a18c35b9SAndreas Jaekel {
432aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_SYMLINK;
433f2dd45e5SAndreas Jaekel 	zev_znode_symlink_t *rec;
434f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
435f2dd45e5SAndreas Jaekel 	int msg_size;
436f2dd45e5SAndreas Jaekel 	int name_len;
437f2dd45e5SAndreas Jaekel 	int link_len;
438aafc540fSAndreas Jaekel 
439a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
440a18c35b9SAndreas Jaekel 		return;
4413655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
4423655089bSAndreas Jaekel 		return;
443aafc540fSAndreas Jaekel 
444f2dd45e5SAndreas Jaekel 	name_len = strlen(name);
445f2dd45e5SAndreas Jaekel 	link_len = strlen(link);
446f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + name_len + 1 + link_len + 1;
447205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
448f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
449f2dd45e5SAndreas Jaekel 	rec = (zev_znode_symlink_t *)(msg + 1);
450f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
451f2dd45e5SAndreas Jaekel 	rec->op = op;
452f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
4538948de2fSSimon Klinkert 	rec->guid =
4548948de2fSSimon Klinkert 		dsl_dataset_phys(dzp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
45503a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
456f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(parent, dzp);
457f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
458f2dd45e5SAndreas Jaekel 	rec->name_len = name_len;
459f2dd45e5SAndreas Jaekel 	rec->link_len = link_len;
460548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_NAME(rec), name, name_len + 1);
461548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_LINK(rec), link, link_len + 1);
4622eabeab5SAndreas Jaekel 	zev_symlink_checksum(rec, link);
463f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
464a18c35b9SAndreas Jaekel }
465a18c35b9SAndreas Jaekel 
466a18c35b9SAndreas Jaekel void
zev_znode_rename_cb(znode_t * sdzp,char * sname,znode_t * tdzp,char * tname,znode_t * szp,znode_t * tzp,dmu_tx_t * tx)46712119a7eSAndreas Jaekel zev_znode_rename_cb(znode_t *sdzp,
46812119a7eSAndreas Jaekel                     char *sname,
46912119a7eSAndreas Jaekel                     znode_t *tdzp,
47012119a7eSAndreas Jaekel                     char *tname,
47112119a7eSAndreas Jaekel                     znode_t *szp,
4728aa47a6bSAndreas Jaekel                     znode_t *tzp,
47312119a7eSAndreas Jaekel                     dmu_tx_t *tx)
474a18c35b9SAndreas Jaekel {
475aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_RENAME;
476f2dd45e5SAndreas Jaekel 	zev_znode_rename_t *rec;
477f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
478f2dd45e5SAndreas Jaekel 	int msg_size;
479f2dd45e5SAndreas Jaekel 	int srcname_len;
480f2dd45e5SAndreas Jaekel 	int dstname_len;
481aafc540fSAndreas Jaekel 
482a18c35b9SAndreas Jaekel 	if (zev_skip_pool(szp->z_zfsvfs->z_os))
483a18c35b9SAndreas Jaekel 		return;
4843655089bSAndreas Jaekel 	if (zev_skip_fs(szp->z_zfsvfs))
4853655089bSAndreas Jaekel 		return;
486aafc540fSAndreas Jaekel 
487f2dd45e5SAndreas Jaekel 	srcname_len = strlen(sname);
488f2dd45e5SAndreas Jaekel 	dstname_len = strlen(tname);
489f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec) + srcname_len + 1 + dstname_len + 1;
490205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
491f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
492f2dd45e5SAndreas Jaekel 	rec = (zev_znode_rename_t *)(msg + 1);
493f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
494f2dd45e5SAndreas Jaekel 	rec->op = op;
495f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
4968948de2fSSimon Klinkert 	rec->guid =
4978948de2fSSimon Klinkert 		dsl_dataset_phys(szp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
49803a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
499f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(srcdir, sdzp);
500f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(dstdir, tdzp);
501f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, szp);
5028aa47a6bSAndreas Jaekel 	if (tzp) {
5038aa47a6bSAndreas Jaekel 		ZEV_FILL_INODE_INFO(clobbered_file, tzp);
5048aa47a6bSAndreas Jaekel 	} else {
5058aa47a6bSAndreas Jaekel 		memset(&rec->clobbered_file, 0, sizeof(rec->clobbered_file));
5068aa47a6bSAndreas Jaekel 	}
507f2dd45e5SAndreas Jaekel 	rec->srcname_len = srcname_len;
508f2dd45e5SAndreas Jaekel 	rec->dstname_len = dstname_len;
509548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_SRCNAME(rec), sname, srcname_len + 1);
510548c8b6eSAndreas Jaekel 	(void) memcpy(ZEV_DSTNAME(rec), tname, dstname_len + 1);
511f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
512a18c35b9SAndreas Jaekel }
513a18c35b9SAndreas Jaekel 
514a18c35b9SAndreas Jaekel void
zev_znode_write_cb(znode_t * zp,dmu_tx_t * tx,uint64_t off,uint64_t len)51512119a7eSAndreas Jaekel zev_znode_write_cb(znode_t *zp, dmu_tx_t *tx, uint64_t off, uint64_t len)
516a18c35b9SAndreas Jaekel {
517aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_WRITE;
518f2dd45e5SAndreas Jaekel 	zev_znode_write_t *rec;
519f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
520f2dd45e5SAndreas Jaekel 	int msg_size;
521205ed6bfSAndreas Jaekel 	zev_sig_t *sig_buf;
522205ed6bfSAndreas Jaekel 	uint64_t sig_buf_len;
523205ed6bfSAndreas Jaekel 	uint64_t sig_len;
524205ed6bfSAndreas Jaekel 	uint64_t sig_cnt;
525205ed6bfSAndreas Jaekel 	int ret;
526aafc540fSAndreas Jaekel 
527a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
528a18c35b9SAndreas Jaekel 		return;
5293655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
5303655089bSAndreas Jaekel 		return;
531aafc540fSAndreas Jaekel 
53242110aacSAndreas Jaekel 	ret = zev_get_checksums(&sig_buf, &sig_buf_len, &sig_cnt, 0,
533205ed6bfSAndreas Jaekel 	                        zp, off, len, zev_write);
534205ed6bfSAndreas Jaekel 	if (ret) {
535205ed6bfSAndreas Jaekel 		zev_queue_error(op,
536205ed6bfSAndreas Jaekel 		    "ERROR: ZNODE_WRITE: can't get checksum (inode=%d:%d)\n",
537205ed6bfSAndreas Jaekel 		    zp->z_gen,
538205ed6bfSAndreas Jaekel 		    zp->z_id);
539205ed6bfSAndreas Jaekel 		return;
540205ed6bfSAndreas Jaekel 	}
541205ed6bfSAndreas Jaekel 	sig_len = sig_cnt * sizeof(zev_sig_t);
542205ed6bfSAndreas Jaekel 
543205ed6bfSAndreas Jaekel 	msg_size = sizeof(*rec) + sig_len;
544205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
545f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
546f2dd45e5SAndreas Jaekel 	rec = (zev_znode_write_t *)(msg + 1);
547f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
548f2dd45e5SAndreas Jaekel 	rec->op = op;
549f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
5508948de2fSSimon Klinkert 	rec->guid =
5518948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
55203a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
553f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
554f2dd45e5SAndreas Jaekel 	rec->offset = off;
555f2dd45e5SAndreas Jaekel 	rec->length = len;
556205ed6bfSAndreas Jaekel 	rec->signature_cnt = sig_cnt;
55742110aacSAndreas Jaekel 	if (sig_cnt && sig_buf)
558205ed6bfSAndreas Jaekel 		memcpy(ZEV_SIGNATURES(rec), sig_buf, sig_len);
55942110aacSAndreas Jaekel 	if (sig_buf)
560205ed6bfSAndreas Jaekel 		zev_free(sig_buf, sig_buf_len);
561f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
562a18c35b9SAndreas Jaekel }
563a18c35b9SAndreas Jaekel 
564a18c35b9SAndreas Jaekel void
zev_znode_truncate_cb(znode_t * zp,dmu_tx_t * tx,uint64_t off,uint64_t len)56512119a7eSAndreas Jaekel zev_znode_truncate_cb(znode_t *zp, dmu_tx_t *tx, uint64_t off, uint64_t len)
566a18c35b9SAndreas Jaekel {
567aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_TRUNCATE;
568f2dd45e5SAndreas Jaekel 	zev_znode_truncate_t *rec;
569f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
570f2dd45e5SAndreas Jaekel 	int msg_size;
571205ed6bfSAndreas Jaekel 	zev_sig_t *sig_buf;
572205ed6bfSAndreas Jaekel 	uint64_t sig_buf_len;
573205ed6bfSAndreas Jaekel 	uint64_t sig_len;
574205ed6bfSAndreas Jaekel 	uint64_t sig_cnt;
575205ed6bfSAndreas Jaekel 	int ret;
576aafc540fSAndreas Jaekel 
577a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
578a18c35b9SAndreas Jaekel 		return;
5793655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
5803655089bSAndreas Jaekel 		return;
581aafc540fSAndreas Jaekel 
58242110aacSAndreas Jaekel 	ret = zev_get_checksums(&sig_buf, &sig_buf_len, &sig_cnt, 0,
583205ed6bfSAndreas Jaekel 	                        zp, off, len, zev_truncate);
584205ed6bfSAndreas Jaekel 	if (ret) {
585205ed6bfSAndreas Jaekel 		zev_queue_error(op,
586205ed6bfSAndreas Jaekel 		    "ERROR: ZNODE_TRUNCATE: can't get checksum (inode=%d:%d)\n",
587205ed6bfSAndreas Jaekel 		    zp->z_gen,
588205ed6bfSAndreas Jaekel 		    zp->z_id);
589205ed6bfSAndreas Jaekel 		return;
590205ed6bfSAndreas Jaekel 	}
591205ed6bfSAndreas Jaekel 	sig_len = sig_cnt * sizeof(zev_sig_t);
592205ed6bfSAndreas Jaekel 
593205ed6bfSAndreas Jaekel 	msg_size = sizeof(*rec) + sig_len;
594205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
595f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
596f2dd45e5SAndreas Jaekel 	rec = (zev_znode_truncate_t *)(msg + 1);
597f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
598f2dd45e5SAndreas Jaekel 	rec->op = op;
599f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
6008948de2fSSimon Klinkert 	rec->guid =
6018948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
60203a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
603f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
604f2dd45e5SAndreas Jaekel 	rec->offset = off;
605f2dd45e5SAndreas Jaekel 	rec->length = len;
606205ed6bfSAndreas Jaekel 	rec->signature_cnt = sig_cnt;
60742110aacSAndreas Jaekel 	if (sig_cnt && sig_buf)
608205ed6bfSAndreas Jaekel 		memcpy(ZEV_SIGNATURES(rec), sig_buf, sig_len);
60942110aacSAndreas Jaekel 	if (sig_buf)
610205ed6bfSAndreas Jaekel 		zev_free(sig_buf, sig_buf_len);
611f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
612a18c35b9SAndreas Jaekel }
613a18c35b9SAndreas Jaekel 
614a18c35b9SAndreas Jaekel void
zev_znode_setattr_cb(znode_t * zp,dmu_tx_t * tx)61512119a7eSAndreas Jaekel zev_znode_setattr_cb(znode_t *zp, dmu_tx_t *tx)
616a18c35b9SAndreas Jaekel {
617aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_SETATTR;
618f2dd45e5SAndreas Jaekel 	zev_znode_setattr_t *rec;
619f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
620f2dd45e5SAndreas Jaekel 	int msg_size;
621aafc540fSAndreas Jaekel 
622a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
623a18c35b9SAndreas Jaekel 		return;
6243655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
6253655089bSAndreas Jaekel 		return;
626aafc540fSAndreas Jaekel 
627f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec);
628205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
629f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
630f2dd45e5SAndreas Jaekel 	rec = (zev_znode_setattr_t *)(msg + 1);
631f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
632f2dd45e5SAndreas Jaekel 	rec->op = op;
633f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
6348948de2fSSimon Klinkert 	rec->guid =
6358948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
63603a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
637f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
638f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
639a18c35b9SAndreas Jaekel }
640a18c35b9SAndreas Jaekel 
641a18c35b9SAndreas Jaekel void
zev_znode_acl_cb(znode_t * zp,dmu_tx_t * tx)64212119a7eSAndreas Jaekel zev_znode_acl_cb(znode_t *zp, dmu_tx_t *tx)
643a18c35b9SAndreas Jaekel {
644aafc540fSAndreas Jaekel 	int op = ZEV_OP_ZNODE_ACL;
645f2dd45e5SAndreas Jaekel 	zev_znode_acl_t *rec;
646f2dd45e5SAndreas Jaekel 	zev_msg_t *msg = NULL;
647f2dd45e5SAndreas Jaekel 	int msg_size;
648aafc540fSAndreas Jaekel 
649a18c35b9SAndreas Jaekel 	if (zev_skip_pool(zp->z_zfsvfs->z_os))
650a18c35b9SAndreas Jaekel 		return;
6513655089bSAndreas Jaekel 	if (zev_skip_fs(zp->z_zfsvfs))
6523655089bSAndreas Jaekel 		return;
653aafc540fSAndreas Jaekel 
654f2dd45e5SAndreas Jaekel 	msg_size = sizeof(*rec);
655205ed6bfSAndreas Jaekel 	msg = zev_alloc(sizeof(*msg) + msg_size);
656f2dd45e5SAndreas Jaekel 	msg->size = msg_size;
657f2dd45e5SAndreas Jaekel 	rec = (zev_znode_acl_t *)(msg + 1);
658f2dd45e5SAndreas Jaekel 	rec->record_len = msg_size;
659f2dd45e5SAndreas Jaekel 	rec->op = op;
660f2dd45e5SAndreas Jaekel 	rec->op_time = ddi_get_time();
6618948de2fSSimon Klinkert 	rec->guid =
6628948de2fSSimon Klinkert 		dsl_dataset_phys(zp->z_zfsvfs->z_os->os_dsl_dataset)->ds_guid;
66303a64974SSimon Klinkert 	rec->txg = dmu_tx_get_txg(tx);
664f2dd45e5SAndreas Jaekel 	ZEV_FILL_INODE_INFO(file, zp);
665f2dd45e5SAndreas Jaekel 	zev_queue_message(op, msg);
666a18c35b9SAndreas Jaekel }
667a18c35b9SAndreas Jaekel 
668a18c35b9SAndreas Jaekel rz_zev_callbacks_t zev_callbacks = {
669a18c35b9SAndreas Jaekel 	/* zfsvfs events */
670a18c35b9SAndreas Jaekel 	.rz_zev_zfs_mount                = zev_zfs_mount_cb,
671a18c35b9SAndreas Jaekel 	.rz_zev_zfs_umount               = zev_zfs_umount_cb,
672a18c35b9SAndreas Jaekel 
673a18c35b9SAndreas Jaekel 	/* zvol zil events */
674a18c35b9SAndreas Jaekel 	.rz_zev_zvol_truncate            = zev_zvol_truncate_cb,
675a18c35b9SAndreas Jaekel 	.rz_zev_zvol_write               = zev_zvol_write_cb,
676a18c35b9SAndreas Jaekel 
677a18c35b9SAndreas Jaekel 	/* znode zil events */
678a18c35b9SAndreas Jaekel 	.rz_zev_znode_close_after_update = zev_znode_close_after_update_cb,
679a18c35b9SAndreas Jaekel 	.rz_zev_znode_create             = zev_znode_create_cb,
680a18c35b9SAndreas Jaekel 	.rz_zev_znode_remove             = zev_znode_remove_cb,
681a18c35b9SAndreas Jaekel 	.rz_zev_znode_link               = zev_znode_link_cb,
682a18c35b9SAndreas Jaekel 	.rz_zev_znode_symlink            = zev_znode_symlink_cb,
683a18c35b9SAndreas Jaekel 	.rz_zev_znode_rename             = zev_znode_rename_cb,
684a18c35b9SAndreas Jaekel 	.rz_zev_znode_write              = zev_znode_write_cb,
685a18c35b9SAndreas Jaekel 	.rz_zev_znode_truncate           = zev_znode_truncate_cb,
686a18c35b9SAndreas Jaekel 	.rz_zev_znode_setattr            = zev_znode_setattr_cb,
687a18c35b9SAndreas Jaekel 	.rz_zev_znode_acl                = zev_znode_acl_cb,
688a18c35b9SAndreas Jaekel };
689a18c35b9SAndreas Jaekel 
690