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-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/ndmpd/ndmp/ndmpd_mark.c
+++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_mark.c
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
|
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
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
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 +/* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
40 +
39 41 #include <sys/stat.h>
40 42 #include <sys/types.h>
43 +#include <syslog.h>
41 44 #include <cstack.h>
42 45 #include <ctype.h>
43 46 #include <dirent.h>
44 47 #include <errno.h>
45 48 #include "ndmpd.h"
46 49 #include <bitmap.h>
47 50 #include <traverse.h>
48 51 #include <limits.h>
49 52 #include <stdio.h>
50 53 #include <stdlib.h>
51 54 #include <string.h>
52 55 #include <time.h>
53 56 #include "tlm_buffers.h"
54 57
55 58
56 59 /*
57 60 * Parameter passed to traverse for marking inodes
58 61 * when traversing backup hierarchy in V2. It
59 62 * includes:
60 63 * mp_bmd: the bitmap describptor.
61 64 * mp_ddate: backup date.
62 65 * mp_session: pointer to the session structure.
63 66 * mp_nlp: pointer to the nlp.
64 67 * mp_tacl: pointer to the acl.
65 68 */
66 69 typedef struct mark_param {
67 70 int mp_bmd;
68 71 time_t mp_ddate;
69 72 ndmpd_session_t *mp_session;
70 73 ndmp_lbr_params_t *mp_nlp;
71 74 tlm_acls_t *mp_tacl;
72 75 } mark_param_t;
73 76
74 77
75 78 /*
76 79 * Set this variable to non-zero to print the inodes
77 80 * marked after traversing file system.
78 81 */
79 82 static int ndmpd_print_inodes = 0;
80 83
81 84
82 85 /*
83 86 * Flag passed to traverse_post.
84 87 */
85 88 static int ndmpd_mark_flags = 0;
86 89
87 90
88 91 /*
89 92 * Verbose traversing prints the file/dir path names
90 93 * if they are being marked.
91 94 */
92 95 static int ndmpd_verbose_traverse = 0;
93 96
94 97
95 98 /*
96 99 * Set this flag to count the number of inodes marked
97 100 * after traversing backup hierarchy.
98 101 */
99 102 static int ndmpd_mark_count_flag = 0;
100 103
101 104
102 105 /*
103 106 * Set this variable to non-zero value to force traversing
104 107 * backup hierarchy for tar format.
105 108 */
106 109 static int ndmp_tar_force_traverse = 0;
107 110
108 111
109 112 /*
110 113 * Set this variable to non-zero value to skip processing
111 114 * directories both for tar and dump.
112 115 */
113 116 static int ndmp_skip_traverse = 0;
114 117
115 118
116 119 /*
117 120 * count_bits_cb
118 121 *
119 122 * Call back for counting the set bits in the dbitmap.
120 123 *
121 124 * Parameters:
122 125 * bmd (input) - bitmap descriptor
123 126 * bn (input) - the bit number
124 127 * arg (input) - pointer to the argument
|
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
125 128 *
126 129 * Returns:
127 130 * 0: always
128 131 */
129 132 static int
130 133 count_bits_cb(int bmd, u_longlong_t bn, void *arg)
131 134 {
132 135 if (dbm_getone(bmd, bn)) {
133 136 (*(u_longlong_t *)arg)++;
134 137 if (ndmpd_print_inodes)
135 - NDMP_LOG(LOG_DEBUG, "%llu", bn);
138 + syslog(LOG_DEBUG, "%lu", bn);
136 139 }
137 140
138 141 return (0);
139 142 }
140 143
141 144
142 145 /*
143 146 * count_set_bits
144 147 *
145 148 * Count bits set in the bitmap.
146 149 *
147 150 * Parameters:
148 151 * path (input) - the backup path
149 152 * bmd (input) - bitmap descriptor
150 153 *
151 154 * Returns:
152 155 * void
153 156 */
|
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
154 157 void
155 158 count_set_bits(char *path, int bmd)
156 159 {
157 160 u_longlong_t cnt;
158 161
159 162 if (!ndmpd_mark_count_flag)
160 163 return;
161 164
162 165 cnt = 0;
163 166 (void) dbm_apply_ifset(bmd, count_bits_cb, &cnt);
164 - NDMP_LOG(LOG_DEBUG, "%s %llu inodes marked", path, cnt);
167 + syslog(LOG_DEBUG, "%s %lu inodes marked", path, cnt);
165 168 }
166 169
167 170
168 171 /*
169 172 * traverse
170 173 *
171 174 * Starts the post-traverse the backup hierarchy. Checks
172 175 * for exceptional cases, like aborting operation and if
173 176 * asked, report detailed information after traversing.
174 177 *
175 178 * Parameters:
176 179 * session (input) - pointer to the session
177 180 * nlp (input) - pointer to the nlp structure
178 181 * ftp (input) - pointer to the traverse parameters
179 182 *
180 183 * Returns:
181 184 * 0: on success
|
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
182 185 * != 0: otherwise
183 186 */
184 187 int
185 188 traverse(ndmpd_session_t *session, ndmp_lbr_params_t *nlp,
186 189 fs_traverse_t *ftp)
187 190 {
188 191 int rv;
189 192 time_t s, e;
190 193
191 194 if (!session || !nlp || !ftp) {
192 - NDMP_LOG(LOG_DEBUG, "Invalid argument");
195 + syslog(LOG_ERR, "Invalid argument in traverse");
193 196 return (-1);
194 197 }
195 - NDMP_LOG(LOG_DEBUG, "Processing directories of \"%s\"",
198 + syslog(LOG_DEBUG, "Processing directories of \"%s\"",
196 199 nlp->nlp_backup_path);
197 200
198 201 (void) time(&s);
199 202 if (traverse_post(ftp) != 0) {
200 203 rv = -1;
201 204 if (!session->ns_data.dd_abort && !NLP_ISSET(nlp,
202 205 NLPF_ABORTED)) {
203 - NDMP_LOG(LOG_DEBUG,
206 + syslog(LOG_DEBUG,
204 207 "Traversing backup path hierarchy \"%s\"",
205 208 nlp->nlp_backup_path);
206 209 }
207 210 } else {
208 211 (void) dbm_setone(nlp->nlp_bkmap, (u_longlong_t)ROOT_INODE);
209 212 rv = 0;
210 213 (void) time(&e);
211 - NDMP_LOG(LOG_DEBUG,
214 + syslog(LOG_DEBUG,
212 215 "\"%s\" traversed in %u sec", nlp->nlp_backup_path,
213 216 (uint_t)(e-s));
214 217
215 218 count_set_bits(nlp->nlp_backup_path, nlp->nlp_bkmap);
216 219 }
217 220
218 221 return (rv);
219 222 }
220 223
221 224
222 225 /*
223 226 * mark_cb
224 227 *
225 228 * The callback function, called by traverse_post to mark bits
226 229 * in the bitmap.
227 230 *
228 231 * Set the bit of the entry if it's been modified (obviously
229 232 * should be backed up) plus its parent directory.
230 233 *
231 234 * If the entry is a directory and is not modified itself,
232 235 * but it's marked, then there is something below it that
233 236 * is being backed up. It shows the the path, leads to
234 237 * an object that will be backed up. So the path should
235 238 * be marked too.
236 239 *
237 240 * The backup path itself is always marked.
238 241 *
239 242 * Parameters:
240 243 * arg (input) - pointer to the mark parameter
241 244 * pnp (input) - pointer to the path node
242 245 * enp (input) - pointer to the entry node
243 246 *
244 247 * Returns:
245 248 * 0: as long as traversing should continue
246 249 * != 0: if traversing should stop
247 250 */
248 251 int
249 252 mark_cb(void *arg, fst_node_t *pnp, fst_node_t *enp)
250 253 {
251 254 int bmd;
252 255 int rv;
253 256 u_longlong_t bl;
254 257 time_t ddate;
255 258 fs_fhandle_t *pfhp, *efhp;
|
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
256 259 struct stat64 *pstp, *estp;
257 260 mark_param_t *mpp;
258 261 ndmp_lbr_params_t *nlp;
259 262 tlm_acls_t *tacl;
260 263
261 264 rv = 0;
262 265 mpp = (mark_param_t *)arg;
263 266 tacl = mpp->mp_tacl;
264 267 nlp = ndmp_get_nlp(mpp->mp_session);
265 268 if (!mpp) {
266 - NDMP_LOG(LOG_DEBUG, "NULL argument passed");
269 + syslog(LOG_ERR, "NULL argument passed");
267 270 rv = -1;
268 271 } else if (mpp->mp_session->ns_eof) {
269 - NDMP_LOG(LOG_INFO, "Connection to the client is closed");
272 + syslog(LOG_ERR, "Connection to the client is closed");
270 273 rv = -1;
271 274 } else if (mpp->mp_session->ns_data.dd_abort ||
272 275 (nlp && NLP_ISSET(nlp, NLPF_ABORTED))) {
273 - NDMP_LOG(LOG_INFO, "Processing directories aborted.");
276 + syslog(LOG_ERR, "Processing directories aborted.");
274 277 rv = -1;
275 278 }
276 279
277 280 if (rv != 0)
278 281 return (rv);
279 282
280 283 ddate = mpp->mp_ddate;
281 284 bmd = mpp->mp_bmd;
282 285 bl = dbm_getlen(bmd);
283 286
284 287 pfhp = pnp->tn_fh;
285 288 pstp = pnp->tn_st;
286 289
287 290 /* sanity check on fh and stat of the path passed */
288 291 if (pstp->st_ino > bl) {
289 - NDMP_LOG(LOG_DEBUG, "Invalid path inode #%u",
292 + syslog(LOG_ERR, "Invalid path inode #%u",
290 293 (uint_t)pstp->st_ino);
291 294 return (-1);
292 295 }
293 296 if (pstp->st_ino != pfhp->fh_fid) {
294 - NDMP_LOG(LOG_DEBUG, "Path ino mismatch %u %u",
297 + syslog(LOG_ERR, "Path ino mismatch %u %u",
295 298 (uint_t)pstp->st_ino, (uint_t)pfhp->fh_fid);
296 299 return (-1);
297 300 }
298 301
299 302 /*
300 303 * Always mark the backup path inode number.
301 304 */
302 305 if (!enp->tn_path) {
303 306 (void) dbm_setone(bmd, pstp->st_ino);
304 307 return (0);
305 308 }
306 309
307 310 efhp = enp->tn_fh;
308 311 estp = enp->tn_st;
309 312
310 313 /* sanity check on fh and stat of the entry passed */
311 314 if (estp->st_ino > bl) {
312 - NDMP_LOG(LOG_DEBUG, "Invalid entry inode #%u",
315 + syslog(LOG_ERR, "Invalid entry inode #%u",
313 316 (uint_t)estp->st_ino);
314 317 return (-1);
315 318 }
316 319 if (estp->st_ino != efhp->fh_fid) {
317 - NDMP_LOG(LOG_DEBUG, "Entry ino mismatch %u %u", estp->st_ino,
320 + syslog(LOG_ERR, "Entry ino mismatch %u %u", estp->st_ino,
318 321 (uint_t)pfhp->fh_fid);
319 322 return (-1);
320 323 }
321 324
322 325 /* check the dates and mark the bitmap inode */
323 326 if (ddate == 0) {
324 327 /* base backup */
325 328 (void) dbm_setone(bmd, (u_longlong_t)estp->st_ino);
326 329 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
327 - if (ndmpd_verbose_traverse) {
328 - NDMP_LOG(LOG_DEBUG, "Base Backup");
329 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\"",
330 - pnp->tn_path, enp->tn_path);
331 - }
332 330
333 331 } else if (estp->st_mtime > ddate) {
334 332 (void) dbm_setone(bmd, (u_longlong_t)estp->st_ino);
335 333 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
336 334 if (ndmpd_verbose_traverse) {
337 - NDMP_LOG(LOG_DEBUG,
335 + syslog(LOG_DEBUG,
338 336 "m(%u,%u,%u,%u)", (uint_t)pstp->st_ino,
339 337 (uint_t)estp->st_ino, (uint_t)estp->st_mtime,
340 338 (uint_t)ddate);
341 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\"",
339 + syslog(LOG_DEBUG, "\"%s/%s\"",
342 340 pnp->tn_path, enp->tn_path);
343 341 }
344 342 } else if (iscreated(nlp, NULL, tacl, ddate)) {
345 343 (void) dbm_setone(bmd, (u_longlong_t)estp->st_ino);
346 344 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
347 345 if (ndmpd_verbose_traverse) {
348 - NDMP_LOG(LOG_DEBUG,
346 + syslog(LOG_DEBUG,
349 347 "cr(%u,%u,%u,%u)", (uint_t)pstp->st_ino,
350 348 (uint_t)estp->st_ino, (uint_t)estp->st_mtime,
351 349 (uint_t)ddate);
352 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\"",
350 + syslog(LOG_DEBUG, "\"%s/%s\"",
353 351 pnp->tn_path, enp->tn_path);
354 352 }
355 353 } else if (estp->st_ctime > ddate) {
356 354 if (!NLP_IGNCTIME(nlp)) {
357 355 (void) dbm_setone(bmd, (u_longlong_t)estp->st_ino);
358 356 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
359 357 }
360 358 if (ndmpd_verbose_traverse) {
361 359 if (NLP_IGNCTIME(nlp)) {
362 - NDMP_LOG(LOG_DEBUG,
360 + syslog(LOG_DEBUG,
363 361 "ign c(%u,%u,%u,%u)", (uint_t)pstp->st_ino,
364 362 (uint_t)estp->st_ino,
365 363 (uint_t)estp->st_ctime, (uint_t)ddate);
366 364 } else {
367 - NDMP_LOG(LOG_DEBUG,
365 + syslog(LOG_DEBUG,
368 366 "c(%u,%u,%u,%u)", (uint_t)pstp->st_ino,
369 367 (uint_t)estp->st_ino,
370 368 (uint_t)estp->st_ctime, (uint_t)ddate);
371 369 }
372 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\"",
370 + syslog(LOG_DEBUG, "\"%s/%s\"",
373 371 pnp->tn_path, enp->tn_path);
374 372 }
375 373 } else if (S_ISDIR(estp->st_mode) &&
376 374 dbm_getone(bmd, (u_longlong_t)estp->st_ino)) {
377 375 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
378 - if (ndmpd_verbose_traverse) {
379 - NDMP_LOG(LOG_DEBUG, "d(%u,%u)",
380 - (uint_t)pstp->st_ino, (uint_t)estp->st_ino);
381 - NDMP_LOG(LOG_DEBUG, "\"%s, %s\"",
382 - pnp->tn_path, enp->tn_path);
383 - }
384 376 }
385 377
386 378 return (0);
387 379 }
388 380
389 381
390 382 /*
391 383 * mark_inodes_v2
392 384 *
393 385 * Traverse the file system in post-order and mark
394 386 * all the modified objects and also directories leading
395 387 * to them.
396 388 *
397 389 * Parameters:
398 390 * session (input) - pointer to the session
399 391 * nlp (input) - pointer to the nlp structure
400 392 * path (input) - the physical path to traverse
401 393 *
402 394 * Returns:
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
403 395 * 0: on success.
404 396 * != 0: on error.
405 397 */
406 398 int
407 399 mark_inodes_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp, char *path)
408 400 {
409 401 fs_traverse_t ft;
410 402 mark_param_t mp;
411 403
412 404 if (!session || !nlp || !path || !*path) {
413 - NDMP_LOG(LOG_DEBUG, "Invalid argument");
405 + syslog(LOG_ERR, "Invalid argument in mark_inodes_v2");
414 406 return (-1);
415 407 }
416 408
417 - NDMP_LOG(LOG_DEBUG, "path \"%s\"", path);
409 + syslog(LOG_DEBUG, "path \"%s\"", path);
418 410
419 411 mp.mp_bmd = nlp->nlp_bkmap;
420 412 mp.mp_ddate = nlp->nlp_ldate;
421 413 mp.mp_session = session;
422 414 mp.mp_nlp = nlp;
423 415
424 416 ft.ft_path = path;
425 417 ft.ft_lpath = nlp->nlp_backup_path;
426 418 ft.ft_callbk = mark_cb;
427 419 ft.ft_arg = ∓
428 - ft.ft_logfp = (ft_log_t)ndmp_log;
420 + ft.ft_logfp = (ft_log_t)syslog;
429 421 ft.ft_flags = ndmpd_mark_flags;
430 422
431 423 return (traverse(session, nlp, &ft));
432 424 }
433 425
434 426
435 427 /*
436 428 * create_bitmap
437 429 *
438 430 * Create a dbitmap and return its descriptor.
439 431 *
440 432 * Parameters:
441 - * path (input) - path for which the bitmap should be created
433 + * nlp (input) - pointer to the nlp structure
442 434 * value (input) - the initial value for the bitmap
443 435 *
444 436 * Returns:
445 437 * the dbitmap descriptor
446 438 */
447 439 static int
448 -create_bitmap(char *path, int value)
440 +create_bitmap(ndmp_lbr_params_t *nlp, int value)
449 441 {
450 442 char bm_fname[PATH_MAX];
451 - char buf[TLM_MAX_PATH_NAME];
452 443 char *livepath;
453 444 ulong_t ninode;
454 445
455 - NDMP_LOG(LOG_DEBUG, "path \"%s\"", path);
446 + livepath = NLP_ISCHKPNTED(nlp) ?
447 + nlp->nlp_mountpoint : nlp->nlp_backup_path;
456 448
457 - if (fs_is_chkpntvol(path))
458 - livepath = (char *)tlm_remove_checkpoint(path, buf);
459 - else
460 - livepath = path;
461 449 ninode = 1024 * 1024 * 1024;
462 450 if (ninode == 0)
463 451 return (-1);
464 - (void) ndmpd_mk_temp(bm_fname);
452 + (void) ndmpd_mk_temp(nlp->nlp_job_name, bm_fname);
465 453
466 - NDMP_LOG(LOG_DEBUG, "path \"%s\"ninode %u bm_fname \"%s\"",
454 + syslog(LOG_DEBUG, "path \"%s\" ninode %u bm_fname \"%s\"",
467 455 livepath, ninode, bm_fname);
468 456
469 457 return (dbm_alloc(bm_fname, (u_longlong_t)ninode, value));
470 458 }
471 459
472 460
473 461 /*
474 462 * create_allset_bitmap
475 463 *
476 464 * A helper function to create a bitmap with all the
477 465 * values set to 1.
478 466 *
479 467 * Parameters:
|
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
480 468 * nlp (input) - pointer to the nlp structure
481 469 *
482 470 * Returns:
483 471 * the dbitmap descriptor
484 472 */
485 473 static int
486 474 create_allset_bitmap(ndmp_lbr_params_t *nlp)
487 475 {
488 476 int rv;
489 477
490 - nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 1);
491 - NDMP_LOG(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap);
478 + nlp->nlp_bkmap = create_bitmap(nlp, 1);
492 479
493 480 if (nlp->nlp_bkmap < 0) {
494 - NDMP_LOG(LOG_DEBUG, "Failed to allocate bitmap.");
481 + syslog(LOG_ERR,
482 + "Failed to allocate bitmap in create_allset_bitmap");
495 483 rv = -1;
496 484 } else
497 485 rv = 0;
498 486
499 487 return (rv);
500 488 }
501 489
502 490
503 491 /*
504 492 * mark_common_v2
505 493 *
506 494 * Create the inode bitmap. If last date of the the
507 495 * backup is epoch, then all the objects should be backed
508 496 * up; there is no need to traverse the backup hierarchy
509 497 * and mark the inodes. All the bits should be marked.
510 498 *
511 499 * Otherwise, the backup hierarchy should be traversed and
512 500 * the objects should be marked.
513 501 *
514 502 * Parameters:
515 503 * session (input) - pointer to the session
516 504 * nlp (input) - pointer to the nlp structure
517 505 *
518 506 * Returns:
519 507 * 0: on success.
520 508 * != 0: on error.
521 509 */
522 510 static int
523 511 mark_common_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
524 512 {
|
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
525 513 char buf[TLM_MAX_PATH_NAME], *chkpath;
526 514 int rv;
527 515
528 516 /*
529 517 * Everything is needed for full backup.
530 518 */
531 519 if (nlp->nlp_ldate == (time_t)0)
532 520 return (create_allset_bitmap(nlp));
533 521
534 522 rv = 0;
535 - nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 0);
536 - NDMP_LOG(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap);
523 + nlp->nlp_bkmap = create_bitmap(nlp, 0);
537 524
538 525 if (nlp->nlp_bkmap < 0) {
539 - NDMP_LOG(LOG_DEBUG, "Failed to allocate bitmap.");
526 + syslog(LOG_ERR, "Failed to allocate bitmap in mark_common_v2");
540 527 rv = -1;
541 528 } else {
542 529 if (fs_is_chkpntvol(nlp->nlp_backup_path))
543 530 chkpath = nlp->nlp_backup_path;
544 531 else
545 532 chkpath = tlm_build_snapshot_name(
546 533 nlp->nlp_backup_path, buf,
547 534 nlp->nlp_jstat->js_job_name);
548 535 rv = mark_inodes_v2(session, nlp, chkpath);
549 536 (void) dbm_setone(nlp->nlp_bkmap, (u_longlong_t)ROOT_INODE);
550 537 }
551 538
552 539 return (rv);
553 540 }
554 541
555 542
556 543 /*
557 544 * mark_tar_inodes_v2
558 545 *
559 546 * Create the bitmap for tar backup format.
560 547 *
561 548 * Parameters:
562 549 * session (input) - pointer to the session
563 550 * nlp (input) - pointer to the nlp structure
564 551 *
565 552 * Returns:
566 553 * 0: on success.
567 554 * != 0: on error.
568 555 */
569 556 static int
570 557 mark_tar_inodes_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
571 558 {
572 559 int rv;
573 560
574 561 if (ndmp_tar_force_traverse)
575 562 rv = mark_common_v2(session, nlp);
576 563 else
577 564 rv = create_allset_bitmap(nlp);
578 565
579 566 return (rv);
580 567 }
581 568
582 569
583 570 /*
584 571 * mark_dump_inodes_v2
585 572 *
586 573 * Create the bitmap for dump backup format.
587 574 *
588 575 * Parameters:
589 576 * session (input) - pointer to the session
590 577 * nlp (input) - pointer to the nlp structure
591 578 *
592 579 * Returns:
593 580 * 0: on success.
594 581 * != 0: on error.
595 582 */
596 583 static int
597 584 mark_dump_inodes_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
598 585 {
599 586 return (mark_common_v2(session, nlp));
600 587 }
601 588
602 589
603 590 /*
604 591 * ndmpd_mark_inodes_v2
605 592 *
606 593 * Mark the inodes of the backup hierarchy if necessary.
607 594 *
608 595 * Parameters:
609 596 * session (input) - pointer to the session
610 597 * nlp (input) - pointer to the nlp structure
611 598 *
|
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
612 599 * Returns:
613 600 * 0: on success.
614 601 * != 0: on error.
615 602 */
616 603 int
617 604 ndmpd_mark_inodes_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
618 605 {
619 606 int rv;
620 607
621 608 if (ndmp_skip_traverse) {
622 - NDMP_LOG(LOG_INFO, "Skip processing directories \"%s\"",
609 + syslog(LOG_INFO, "Skip processing directories \"%s\"",
623 610 nlp->nlp_backup_path);
624 611 rv = create_allset_bitmap(nlp);
625 612 } else {
626 613 if (NLP_ISTAR(nlp))
627 614 rv = mark_tar_inodes_v2(session, nlp);
628 615 else if (NLP_ISDUMP(nlp))
629 616 rv = mark_dump_inodes_v2(session, nlp);
630 617 else {
631 - NDMP_LOG(LOG_DEBUG, "Unknown backup type for \"%s\"",
618 + syslog(LOG_ERR, "Unknown backup type for \"%s\"",
632 619 nlp->nlp_backup_path);
633 620 rv = -1;
634 621 }
635 622 }
636 623
637 624 return (rv);
638 625 }
639 626
640 627
641 628 /*
642 629 * ndmpd_abort_making_v2
643 630 *
644 631 * Abort the process of marking inodes.
645 632 *
646 633 * Parameters:
647 634 * session (input) - pointer to the session
648 635 *
649 636 * Returns:
650 637 * void
651 638 */
652 639 void
653 640 ndmpd_abort_marking_v2(ndmpd_session_t *session)
654 641 {
655 642 ndmp_lbr_params_t *nlp;
656 643
657 644 nlp = ndmp_get_nlp(session);
658 645 if (nlp)
659 646 NLP_SET(nlp, NLPF_ABORTED);
660 647 }
661 648
662 649
663 650 /*
664 651 * mark_tokv3
665 652 *
666 653 * Traverse the backup hierarchy and mark the bits for the
667 654 * modified objects of directories leading to a modified
668 655 * object for the token-based backup.
669 656 *
670 657 * Parameters:
671 658 * session (input) - pointer to the session
672 659 * nlp (input) - pointer to the nlp structure
673 660 * path (input) - the physical path to traverse
674 661 *
675 662 * Returns:
|
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
676 663 * 0: on success
677 664 * != 0: otherwise
678 665 */
679 666 int
680 667 mark_tokv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp, char *path)
681 668 {
682 669 fs_traverse_t ft;
683 670 mark_param_t mp;
684 671
685 672 if (!session || !nlp || !path || !*path) {
686 - NDMP_LOG(LOG_DEBUG, "Invalid argument");
673 + syslog(LOG_ERR, "Invalid argument in mark_tokv3");
687 674 return (-1);
688 675 }
689 676 if (nlp->nlp_tokdate == (time_t)0)
690 677 return (create_allset_bitmap(nlp));
691 678
692 - nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 0);
679 + nlp->nlp_bkmap = create_bitmap(nlp, 0);
693 680 if (nlp->nlp_bkmap < 0) {
694 - NDMP_LOG(LOG_DEBUG, "Failed to allocate bitmap.");
681 + syslog(LOG_ERR, "Failed to allocate bitmap in mark_tokv3");
695 682 return (-1);
696 683 }
697 - NDMP_LOG(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap);
698 684
699 685 mp.mp_bmd = nlp->nlp_bkmap;
700 686 mp.mp_ddate = nlp->nlp_tokdate;
701 687 mp.mp_session = session;
702 688 mp.mp_nlp = nlp;
703 689
704 690 ft.ft_path = path;
705 691 ft.ft_lpath = nlp->nlp_backup_path;
706 692 ft.ft_callbk = mark_cb;
707 693 ft.ft_arg = ∓
708 - ft.ft_logfp = (ft_log_t)ndmp_log;
694 + ft.ft_logfp = (ft_log_t)syslog;
709 695 ft.ft_flags = ndmpd_mark_flags;
710 696
711 697 return (traverse(session, nlp, &ft));
712 698 }
713 699
714 700
715 701 /*
716 702 * marklbrv3_cb
717 703 *
718 704 * The callback function, called by traverse_post to mark
719 705 * bits in the bitmap.
720 706 *
721 707 * It's so much like mark_cb for time-based (token-based
722 708 * and level-type) backup types, except that it looks at
723 709 * the archive bit of the objects instead of their timestamp.
724 710 *
725 711 * Parameters:
726 712 * arg (input) - pointer to the mark parameter
727 713 * pnp (input) - pointer to the path node
728 714 * enp (input) - pointer to the entry node
729 715 *
730 716 * Returns:
731 717 * 0: as long as traversing should continue
732 718 * != 0: if traversing should stop
733 719 */
734 720 int
735 721 marklbrv3_cb(void *arg, fst_node_t *pnp, fst_node_t *enp)
|
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
736 722 {
737 723 int bmd;
738 724 u_longlong_t bl;
739 725 fs_fhandle_t *pfhp, *efhp;
740 726 struct stat64 *pstp, *estp;
741 727 mark_param_t *mpp;
742 728 ndmp_lbr_params_t *nlp;
743 729
744 730 mpp = (mark_param_t *)arg;
745 731 if (!mpp) {
746 - NDMP_LOG(LOG_DEBUG, "NULL argument passed");
732 + syslog(LOG_ERR, "NULL argument passed in marklbrv3");
747 733 return (-1);
748 734 }
749 735 nlp = ndmp_get_nlp(mpp->mp_session);
750 736 if (mpp->mp_session->ns_data.dd_abort ||
751 737 (nlp && NLP_ISSET(nlp, NLPF_ABORTED))) {
752 - NDMP_LOG(LOG_INFO, "Processing directories aborted.");
738 + syslog(LOG_ERR, "Processing directories aborted.");
753 739 return (-1);
754 740 }
755 741
756 742 bmd = mpp->mp_bmd;
757 743 bl = dbm_getlen(bmd);
758 744
759 745 pfhp = pnp->tn_fh;
760 746 pstp = pnp->tn_st;
761 747
762 748 /* sanity check on fh and stat of the path passed */
763 749 if (pstp->st_ino > bl) {
764 - NDMP_LOG(LOG_DEBUG, "Invalid path inode #%u",
750 + syslog(LOG_ERR, "Invalid path inode #%u",
765 751 (uint_t)pstp->st_ino);
766 752 return (-1);
767 753 }
768 754 if (pstp->st_ino != pfhp->fh_fid) {
769 - NDMP_LOG(LOG_DEBUG, "Path ino mismatch %u %u",
755 + syslog(LOG_ERR, "Path ino mismatch %u %u",
770 756 (uint_t)pstp->st_ino, (uint_t)pfhp->fh_fid);
771 757 return (-1);
772 758 }
773 759
774 760 /*
775 761 * Always mark the backup path inode number.
776 762 */
777 763 if (!enp->tn_path) {
778 764 (void) dbm_setone(bmd, pstp->st_ino);
779 - if (ndmpd_verbose_traverse) {
780 - NDMP_LOG(LOG_DEBUG, "d(%u)", (uint_t)pstp->st_ino);
781 - NDMP_LOG(LOG_DEBUG, "\"%s\"", pnp->tn_path);
782 - }
783 765 return (0);
784 766 }
785 767
786 768 efhp = enp->tn_fh;
787 769 estp = enp->tn_st;
788 770
789 771 /* sanity check on fh and stat of the entry passed */
790 772 if (estp->st_ino > bl) {
791 - NDMP_LOG(LOG_DEBUG, "Invalid entry inode #%u",
773 + syslog(LOG_ERR, "Invalid entry inode #%u",
792 774 (uint_t)estp->st_ino);
793 775 return (-1);
794 776 }
795 777 if (estp->st_ino != efhp->fh_fid) {
796 - NDMP_LOG(LOG_DEBUG, "Entry ino mismatch %u %u", estp->st_ino,
778 + syslog(LOG_ERR, "Entry ino mismatch %u %u", estp->st_ino,
797 779 (uint_t)pfhp->fh_fid);
798 780 return (-1);
799 781 }
800 782
801 783 if (S_ISDIR(estp->st_mode) &&
802 784 dbm_getone(bmd, (u_longlong_t)estp->st_ino)) {
803 785 (void) dbm_setone(bmd, (u_longlong_t)pstp->st_ino);
804 - if (ndmpd_verbose_traverse) {
805 - NDMP_LOG(LOG_DEBUG, "d(%u,%u)",
806 - (uint_t)pstp->st_ino, (uint_t)estp->st_ino);
807 - NDMP_LOG(LOG_DEBUG, "\"%s, %s\"",
808 - pnp->tn_path, enp->tn_path);
809 - }
810 786 }
811 787
812 788 return (0);
813 789 }
814 790
815 791
816 792 /*
817 793 * mark_lbrv3
818 794 *
819 795 * Traverse the backup hierarchy and mark the bits for the
820 796 * modified objects of directories leading to a modified
821 797 * object for the LBR-type backup.
822 798 *
823 799 * Parameters:
824 800 * session (input) - pointer to the session
825 801 * nlp (input) - pointer to the nlp structure
826 802 * path (input) - the physical path to traverse
827 803 *
828 804 * Returns:
829 805 * 0: on success
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
830 806 * != 0: otherwise
831 807 */
832 808 int
833 809 mark_lbrv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp, char *path)
834 810 {
835 811 char c;
836 812 fs_traverse_t ft;
837 813 mark_param_t mp;
838 814
839 815 if (!session || !nlp || !path || !*path) {
840 - NDMP_LOG(LOG_DEBUG, "Invalid argument");
816 + syslog(LOG_ERR, "Invalid argument in mark_lbrv3");
841 817 return (-1);
842 818 }
843 819 /* full and archive backups backup everything */
844 820 c = toupper(nlp->nlp_clevel);
845 821 if (c == 'F' || c == 'A')
846 822 return (create_allset_bitmap(nlp));
847 823
848 - nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 0);
824 + nlp->nlp_bkmap = create_bitmap(nlp, 0);
849 825 if (nlp->nlp_bkmap < 0) {
850 - NDMP_LOG(LOG_DEBUG, "Failed to allocate bitmap.");
826 + syslog(LOG_ERR, "Failed to allocate bitmap in mark_lbrv3");
851 827 return (-1);
852 828 }
853 - NDMP_LOG(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap);
854 829
855 830 mp.mp_bmd = nlp->nlp_bkmap;
856 831 mp.mp_ddate = 0;
857 832 mp.mp_session = session;
858 833 mp.mp_nlp = nlp;
859 834
860 835 ft.ft_path = path;
861 836 ft.ft_lpath = nlp->nlp_backup_path;
862 837 ft.ft_callbk = marklbrv3_cb;
863 838 ft.ft_arg = ∓
864 - ft.ft_logfp = (ft_log_t)ndmp_log;
839 + ft.ft_logfp = (ft_log_t)syslog;
865 840 ft.ft_flags = ndmpd_mark_flags;
866 841
867 842 return (traverse(session, nlp, &ft));
868 843 }
869 844
870 845
871 846 /*
872 847 * mark_levelv3
873 848 *
874 849 * Traverse the backup hierarchy and mark the bits for the
875 850 * modified objects of directories leading to a modified
876 851 * object for the level-type backup.
877 852 *
878 853 * Parameters:
879 854 * session (input) - pointer to the session
880 855 * nlp (input) - pointer to the nlp structure
881 856 * path (input) - the physical path to traverse
882 857 *
883 858 * Returns:
884 859 * 0: on success
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
885 860 * != 0: otherwise
886 861 */
887 862 int
888 863 mark_levelv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp, char *path)
889 864 {
890 865 fs_traverse_t ft;
891 866 mark_param_t mp;
892 867 tlm_acls_t traverse_acl;
893 868
894 869 if (!session || !nlp || !path || !*path) {
895 - NDMP_LOG(LOG_DEBUG, "Invalid argument");
870 + syslog(LOG_ERR, "Invalid argument in mark_levelv3");
896 871 return (-1);
897 872 }
898 873 if (nlp->nlp_ldate == (time_t)0)
899 874 return (create_allset_bitmap(nlp));
900 875
901 - nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 0);
876 + nlp->nlp_bkmap = create_bitmap(nlp, 0);
902 877 if (nlp->nlp_bkmap < 0) {
903 - NDMP_LOG(LOG_DEBUG, "Failed to allocate bitmap.");
878 + syslog(LOG_ERR, "Failed to allocate bitmap in mark_levelv3");
904 879 return (-1);
905 880 }
906 - NDMP_LOG(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap);
907 881
908 882 /*
909 883 * We do not want to allocate memory for acl every time we
910 884 * process a file.
911 885 */
912 886 (void) memset(&traverse_acl, 0, sizeof (traverse_acl));
913 887 mp.mp_tacl = &traverse_acl;
914 888
915 889 mp.mp_bmd = nlp->nlp_bkmap;
916 890 mp.mp_ddate = nlp->nlp_ldate;
917 891 mp.mp_session = session;
918 892 mp.mp_nlp = nlp;
919 893
920 894 ft.ft_path = path;
921 895 ft.ft_lpath = nlp->nlp_backup_path;
922 896 ft.ft_callbk = mark_cb;
923 897 ft.ft_arg = ∓
924 - ft.ft_logfp = (ft_log_t)ndmp_log;
898 + ft.ft_logfp = (ft_log_t)syslog;
925 899 ft.ft_flags = ndmpd_mark_flags;
926 900
927 901 return (traverse(session, nlp, &ft));
928 902 }
929 903
930 904
931 905 /*
932 906 * mark_commonv3
933 907 *
934 908 * Create the inode bitmap. If last date of the the
935 909 * backup is epoch, then all the objects should be backed
936 910 * up; there is no need to traverse the backup hierarchy
937 911 * and mark the inodes. All the bits should be marked.
938 912 *
939 913 * Otherwise, the backup hierarchy should be traversed and
940 914 * the objects should be marked.
941 915 *
942 916 * Parameters:
943 917 * session (input) - pointer to the session
944 918 * nlp (input) - pointer to the nlp structure
945 919 *
946 920 * Returns:
947 921 * 0: on success.
948 922 * != 0: on error.
949 923 */
950 924 int
951 925 mark_commonv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
952 926 {
953 927 char buf[TLM_MAX_PATH_NAME], *chkpath;
954 928 int rv;
955 929
956 930 if (NLP_ISCHKPNTED(nlp))
957 931 chkpath = nlp->nlp_backup_path;
958 932 else
959 933 chkpath = tlm_build_snapshot_name(nlp->nlp_backup_path, buf,
|
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
960 934 nlp->nlp_jstat->js_job_name);
961 935
962 936 if (NLP_ISSET(nlp, NLPF_TOKENBK))
963 937 rv = mark_tokv3(session, nlp, chkpath);
964 938 else if (NLP_ISSET(nlp, NLPF_LBRBK))
965 939 rv = mark_lbrv3(session, nlp, chkpath);
966 940 else if (NLP_ISSET(nlp, NLPF_LEVELBK)) {
967 941 rv = mark_levelv3(session, nlp, chkpath);
968 942 } else {
969 943 rv = -1;
970 - NDMP_LOG(LOG_DEBUG, "Unknown backup type for \"%s\"",
944 + syslog(LOG_ERR, "Unknown backup type for \"%s\"",
971 945 nlp->nlp_backup_path);
972 946 }
973 947
974 948 return (rv);
975 949 }
976 950
977 951
978 952 /*
979 953 * mark_tar_inodesv3
980 954 *
981 955 * Mark bits for tar backup format of V3. Normally, the
982 956 * backup hierarchy is not traversed for tar format
983 957 * unless it's forced by setting the ndmp_tar_force_traverse
984 958 * to a non-zero value.
985 959 *
986 960 * Parameters:
987 961 * session (input) - pointer to the session
988 962 * nlp (input) - pointer to the nlp structure
989 963 *
990 964 * Returns:
991 965 * 0: on success
992 966 * != 0: otherwise
993 967 */
994 968 int
995 969 mark_tar_inodesv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
996 970 {
997 971 int rv;
998 972
999 973 if (ndmp_tar_force_traverse)
1000 974 rv = mark_commonv3(session, nlp);
1001 975 else
1002 976 rv = create_allset_bitmap(nlp);
1003 977
1004 978 return (rv);
1005 979 }
1006 980
1007 981
1008 982 /*
1009 983 * ndmpd_mark_inodes_v3
1010 984 *
1011 985 * Mark the inodes of the backup hierarchy if necessary.
1012 986 *
1013 987 * Parameters:
1014 988 * session (input) - pointer to the session
1015 989 * nlp (input) - pointer to the nlp structure
1016 990 *
|
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
1017 991 * Returns:
1018 992 * 0: on success.
1019 993 * != 0: on error.
1020 994 */
1021 995 int
1022 996 ndmpd_mark_inodes_v3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp)
1023 997 {
1024 998 int rv;
1025 999
1026 1000 if (ndmp_skip_traverse) {
1027 - NDMP_LOG(LOG_INFO, "Skip processing directories \"%s\"",
1001 + syslog(LOG_INFO, "Skip processing directories \"%s\"",
1028 1002 nlp->nlp_backup_path);
1029 1003 rv = create_allset_bitmap(nlp);
1030 1004 } else {
1031 1005 if (NLP_ISTAR(nlp))
1032 1006 rv = mark_tar_inodesv3(session, nlp);
1033 1007 else if (NLP_ISDUMP(nlp)) {
1034 1008 rv = mark_commonv3(session, nlp);
1035 1009 } else {
1036 - NDMP_LOG(LOG_DEBUG, "Unknown backup type for \"%s\"",
1010 + syslog(LOG_ERR, "Unknown backup type for \"%s\"",
1037 1011 nlp->nlp_backup_path);
1038 1012 rv = -1;
1039 1013 }
1040 1014 }
1041 1015
1042 1016 return (rv);
1043 1017 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX