Print this page
NEX-13374 NDMP should be able to backup unmounted ZFS filesystems
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-2990 ndmpd dumping core when used with ndmpcopy
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/ndmpd/include/tlm_buffers.h
+++ new/usr/src/cmd/ndmpd/include/tlm_buffers.h
1 1 /*
2 2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 3 * Use is subject to license terms.
4 4 */
5 5
6 6 /*
7 7 * BSD 3 Clause License
8 8 *
9 9 * Copyright (c) 2007, The Storage Networking Industry Association.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * - Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions and the following disclaimer.
16 16 *
17 17 * - Redistributions in binary form must reproduce the above copyright
18 18 * notice, this list of conditions and the following disclaimer in
19 19 * the documentation and/or other materials provided with the
20 20 * distribution.
21 21 *
22 22 * - Neither the name of The Storage Networking Industry Association (SNIA)
23 23 * nor the names of its contributors may be used to endorse or promote
24 24 * products derived from this software without specific prior written
25 25 * permission.
26 26 *
27 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
34 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 37 * POSSIBILITY OF SUCH DAMAGE.
38 38 */
39 39 /*
40 40 * This defines structures used to pass information between threads
41 41 * for both local-backup and NDMP.
42 42 *
43 43 */
44 +/* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
44 45
45 46 #ifndef _TLM_BUFFERS_H_
46 47 #define _TLM_BUFFERS_H_
47 48
48 49 #include <sys/types.h>
49 50 #include <stdlib.h>
50 51 #include <limits.h>
51 52 #include <sys/stat.h>
52 53 #include <thread.h>
53 54 #include "tlm.h"
54 55
55 56 #ifndef RECORDSIZE
56 57 #define RECORDSIZE 512
57 58 #endif /* !RECORDSIZE */
58 59
59 60 #define DOTDOT_DIR ".."
60 61 #define IS_DOTDOT(s) (strcmp(s, DOTDOT_DIR) == 0)
61 62 #define SLASH '/'
62 63
63 64 #define NDMP_MAX_SELECTIONS 64
64 65
65 66 /*
66 67 * List of files/directories to be excluded from backup list.
67 68 */
68 69 #define EXCL_PROC "/proc"
69 70 #define EXCL_TMP "/tmp"
70 71
71 72
72 73 typedef struct tlm_buffer {
73 74 char *tb_buffer_data; /* area to be used for I/O */
74 75 long tb_buffer_size; /* number of valid bytes in the buffer */
75 76 long tb_buffer_spot; /* current location in the I/O buffer */
76 77 longlong_t tb_seek_spot; /* for BACKUP */
77 78 /* where in the file this buffer stops. */
78 79 /* this is used for the Multi Volume */
79 80 /* Header record. */
80 81 longlong_t tb_file_size; /* for BACKUP */
81 82 /* how much of the file is left. */
82 83 long tb_full : 1,
83 84 tb_eot : 1,
84 85 tb_eof : 1;
85 86 int tb_errno; /* I/O error values */
86 87 } tlm_buffer_t;
87 88
88 89
89 90 /*
90 91 * Flags for tlm_buffers.
91 92 */
92 93 #define TLM_BUF_IN_READY 0x00000001
93 94 #define TLM_BUF_OUT_READY 0x00000002
94 95
95 96 typedef struct tlm_buffers {
96 97 int tbs_ref; /* number of threads using this */
97 98 short tbs_buffer_in; /* buffer to be filled */
98 99 short tbs_buffer_out; /* buffer to be emptied */
99 100 /* these are indexes into tlm_buffers */
100 101 mutex_t tbs_mtx;
101 102 cond_t tbs_in_cv;
102 103 cond_t tbs_out_cv;
103 104 uint32_t tbs_flags;
104 105 long tbs_data_transfer_size; /* max size of read/write buffer */
105 106 longlong_t tbs_offset;
106 107 tlm_buffer_t tbs_buffer[TLM_TAPE_BUFFERS];
107 108 } tlm_buffers_t;
108 109
109 110 typedef struct tlm_cmd {
110 111 int tc_ref; /* number of threads using this */
111 112 mutex_t tc_mtx;
112 113 cond_t tc_cv;
113 114 uint32_t tc_flags;
114 115 int tc_reader; /* writer to reader */
115 116 int tc_writer; /* reader to writer */
116 117 char tc_file_name[TLM_MAX_PATH_NAME]; /* name of last file */
117 118 /* for restore */
118 119 tlm_buffers_t *tc_buffers; /* reader-writer speedup buffers */
119 120 } tlm_cmd_t;
120 121
121 122 typedef struct tlm_commands {
122 123 int tcs_reader; /* commands to all readers */
123 124 int tcs_writer; /* commands to all writers */
124 125 int tcs_reader_count; /* number of active readers */
125 126 int tcs_writer_count; /* number of active writers */
126 127 int tcs_error; /* worker errors */
127 128 char tcs_message[TLM_LINE_SIZE]; /* worker message back to user */
128 129 tlm_cmd_t *tcs_command; /* IPC area between read-write */
129 130 } tlm_commands_t;
130 131
131 132
132 133 typedef struct tlm_job_stats {
133 134 char js_job_name[TLM_MAX_BACKUP_JOB_NAME];
134 135 longlong_t js_bytes_total; /* tape bytes in or out so far */
135 136 longlong_t js_bytes_in_file; /* remaining data in a file */
136 137 longlong_t js_files_so_far; /* files backed up so far */
137 138 longlong_t js_files_total; /* number of files to be backed up */
138 139 int js_errors;
139 140 time_t js_start_time; /* start time (GMT time) */
140 141 time_t js_start_ltime; /* start time (local time) */
141 142 time_t js_stop_time; /* stop time (local time) */
142 143 time_t js_chkpnt_time; /* checkpoint creation (GMT time) */
143 144 void *js_callbacks;
144 145 } tlm_job_stats_t;
145 146
146 147
147 148 struct full_dir_info {
148 149 fs_fhandle_t fd_dir_fh;
149 150 char fd_dir_name[TLM_MAX_PATH_NAME];
150 151 };
151 152
152 153 /*
153 154 * For more info please refer to
154 155 * "Functional Specification Document: Usgin new LBR engine in NDMP",
155 156 * Revision: 0.2
156 157 * Document No.: 101438.
157 158 * the "File history of backup" section
158 159 */
159 160 typedef struct lbr_fhlog_call_backs {
160 161 void *fh_cookie;
161 162 int (*fh_logpname)();
162 163 int (*fh_log_dir)();
163 164 int (*fh_log_node)();
164 165 } lbr_fhlog_call_backs_t;
165 166
166 167
167 168 typedef struct bk_selector {
168 169 void *bs_cookie;
169 170 int bs_level;
170 171 int bs_ldate;
171 172 boolean_t (*bs_fn)(struct bk_selector *bks, struct stat64 *s);
172 173 } bk_selector_t;
173 174
174 175
175 176 /*
176 177 * Call back structure to create new name for objects at restore time.
177 178 */
178 179 struct rs_name_maker;
179 180 typedef char *(*rsm_fp_t)(struct rs_name_maker *,
180 181 char *buf,
181 182 int pos,
182 183 char *path);
183 184
184 185 struct rs_name_maker {
185 186 rsm_fp_t rn_fp;
186 187 void *rn_nlp;
187 188 };
188 189
189 190
190 191 /*
191 192 * RSFLG_OVR_*: overwriting policies. Refer to LBR FSD for more info.
192 193 * RSFLG_MATCH_WCARD: should wildcards be supported in the selection list.
193 194 * RSFLG_IGNORE_CASE: should the compare be case-insensetive. NDMP needs
194 195 * case-sensetive name comparison.
195 196 */
196 197 #define RSFLG_OVR_ALWAYS 0x00000001
197 198 #define RSFLG_OVR_NEVER 0x00000002
198 199 #define RSFLG_OVR_UPDATE 0x00000004
199 200 #define RSFLG_MATCH_WCARD 0x00000008
200 201 #define RSFLG_IGNORE_CASE 0x00000010
201 202
202 203
203 204 /*
204 205 * Different cases where two paths can match with each other.
205 206 * Parent means that the current path, is parent of an entry in
206 207 * the selection list.
207 208 * Child means that the current path, is child of an entry in the
208 209 * selection list.
209 210 */
210 211 #define PM_NONE 0
211 212 #define PM_EXACT 1
212 213 #define PM_PARENT 2
213 214 #define PM_CHILD 3
214 215
215 216 extern tlm_job_stats_t *tlm_new_job_stats(char *);
216 217 extern tlm_job_stats_t *tlm_ref_job_stats(char *);
217 218 extern void tlm_un_ref_job_stats(char *);
218 219 extern boolean_t tlm_is_excluded(char *, char *, char **);
219 220 extern char *tlm_build_snapshot_name(char *, char *, char *);
220 221 extern char *tlm_remove_checkpoint(char *, char *);
221 222 extern tlm_buffers_t *tlm_allocate_buffers(boolean_t, long);
222 223 extern tlm_buffer_t *tlm_buffer_advance_in_idx(tlm_buffers_t *);
223 224 extern tlm_buffer_t *tlm_buffer_advance_out_idx(tlm_buffers_t *);
224 225 extern tlm_buffer_t *tlm_buffer_in_buf(tlm_buffers_t *, int *);
225 226 extern tlm_buffer_t *tlm_buffer_out_buf(tlm_buffers_t *, int *);
226 227 extern void tlm_buffer_mark_empty(tlm_buffer_t *);
227 228 extern void tlm_buffer_release_in_buf(tlm_buffers_t *);
228 229 extern void tlm_buffer_release_out_buf(tlm_buffers_t *);
229 230 extern void tlm_buffer_in_buf_wait(tlm_buffers_t *);
230 231 extern void tlm_buffer_out_buf_wait(tlm_buffers_t *);
231 232 extern void tlm_buffer_in_buf_timed_wait(tlm_buffers_t *, unsigned);
232 233 extern void tlm_buffer_out_buf_timed_wait(tlm_buffers_t *, unsigned);
233 234 extern char *tlm_get_write_buffer(long, long *, tlm_buffers_t *, int);
234 235 extern char *tlm_get_read_buffer(int, int *, tlm_buffers_t *, int *);
235 236 extern void tlm_unget_read_buffer(tlm_buffers_t *, int);
236 237 extern void tlm_unget_write_buffer(tlm_buffers_t *, int);
237 238 extern void tlm_release_buffers(tlm_buffers_t *);
238 239 extern tlm_cmd_t *tlm_create_reader_writer_ipc(boolean_t, long);
239 240 extern void tlm_release_reader_writer_ipc(tlm_cmd_t *);
240 241
241 242 extern void tlm_cmd_wait(tlm_cmd_t *, uint32_t);
242 243 extern void tlm_cmd_signal(tlm_cmd_t *, uint32_t);
243 244
244 245 typedef int (*path_hist_func_t)(lbr_fhlog_call_backs_t *,
245 246 char *,
246 247 struct stat64 *,
247 248 u_longlong_t);
248 249
249 250 typedef int (*dir_hist_func_t)(lbr_fhlog_call_backs_t *,
250 251 char *,
251 252 struct stat64 *);
252 253
253 254 typedef int (*node_hist_func_t)(lbr_fhlog_call_backs_t *,
254 255 char *,
255 256 char *,
256 257 struct stat64 *,
257 258 u_longlong_t);
258 259
259 260 lbr_fhlog_call_backs_t *lbrlog_callbacks_init(void *,
|
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
260 261 path_hist_func_t,
261 262 dir_hist_func_t,
262 263 node_hist_func_t);
263 264
264 265 typedef struct {
265 266 tlm_commands_t *ba_commands;
266 267 tlm_cmd_t *ba_cmd;
267 268 char *ba_job;
268 269 char *ba_dir;
269 270 char *ba_sels[NDMP_MAX_SELECTIONS];
271 + int ba_count;
270 272 pthread_barrier_t ba_barrier;
271 273 } tlm_backup_restore_arg_t;
272 274
273 275 extern void lbrlog_callbacks_done(lbr_fhlog_call_backs_t *);
274 276
275 277 extern boolean_t tlm_cat_path(char *, char *, char *);
276 278
277 279 extern char *trim_name(char *);
278 280
279 281 extern struct full_dir_info *dup_dir_info(struct full_dir_info *);
280 282 extern void write_tar_eof(tlm_cmd_t *);
281 -extern int tlm_get_chkpnt_time(char *, int, time_t *, char *);
283 +extern int tlm_get_chkpnt_time(char *, time_t *);
282 284 extern struct full_dir_info *tlm_new_dir_info(fs_fhandle_t *,
283 285 char *,
284 286 char *);
285 287 extern void tlm_release_list(char **);
286 288 extern longlong_t tlm_get_data_offset(tlm_cmd_t *);
287 289 extern int tlm_tarhdr_size(void);
288 290
289 291 #endif /* _TLM_BUFFERS_H_ */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX