xref: /freebsd/sys/contrib/openzfs/include/sys/dmu_recv.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
25  * Copyright (c) 2012, 2020 by Delphix. All rights reserved.
26  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
28  * Copyright (c) 2019 Datto Inc.
29  */
30 
31 #ifndef _DMU_RECV_H
32 #define	_DMU_RECV_H
33 
34 #include <sys/inttypes.h>
35 #include <sys/dsl_bookmark.h>
36 #include <sys/dsl_dataset.h>
37 #include <sys/spa.h>
38 #include <sys/objlist.h>
39 
40 extern const char *const recv_clone_name;
41 
42 typedef struct dmu_recv_cookie {
43 	struct dsl_dataset *drc_ds;
44 	struct dmu_replay_record *drc_drr_begin;
45 	struct drr_begin *drc_drrb;
46 	const char *drc_tofs;
47 	const char *drc_tosnap;
48 	boolean_t drc_newfs;
49 	boolean_t drc_byteswap;
50 	uint64_t drc_featureflags;
51 	boolean_t drc_force;
52 	boolean_t drc_heal;
53 	boolean_t drc_resumable;
54 	boolean_t drc_should_save;
55 	boolean_t drc_raw;
56 	boolean_t drc_clone;
57 	boolean_t drc_spill;
58 	nvlist_t *drc_keynvl;
59 	uint64_t drc_fromsnapobj;
60 	uint64_t drc_ivset_guid;
61 	void *drc_owner;
62 	cred_t *drc_cred;
63 	proc_t *drc_proc;
64 	nvlist_t *drc_begin_nvl;
65 
66 	objset_t *drc_os;
67 	zfs_file_t *drc_fp; /* The file to read the stream from */
68 	uint64_t drc_voff; /* The current offset in the stream */
69 	uint64_t drc_bytes_read;
70 	/*
71 	 * A record that has had its payload read in, but hasn't yet been handed
72 	 * off to the worker thread.
73 	 */
74 	struct receive_record_arg *drc_rrd;
75 	/* A record that has had its header read in, but not its payload. */
76 	struct receive_record_arg *drc_next_rrd;
77 	zio_cksum_t drc_cksum;
78 	zio_cksum_t drc_prev_cksum;
79 	/* Sorted list of objects not to issue prefetches for. */
80 	objlist_t *drc_ignore_objlist;
81 } dmu_recv_cookie_t;
82 
83 int dmu_recv_begin(const char *, const char *, dmu_replay_record_t *,
84     boolean_t, boolean_t, boolean_t, nvlist_t *, nvlist_t *, const char *,
85     dmu_recv_cookie_t *, zfs_file_t *, offset_t *);
86 int dmu_recv_stream(dmu_recv_cookie_t *, offset_t *);
87 int dmu_recv_end(dmu_recv_cookie_t *, void *);
88 boolean_t dmu_objset_is_receiving(objset_t *);
89 
90 #endif /* _DMU_RECV_H */
91