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-894 Default location of NDMP log file should be under /var/log
NEX-727 Netbackup Catalog verification hangs waiting for NDMP server
NEX-799 past last file mark returned NDMP_IO_ERR, should be NDMP_EOM_ERR (V4+)
NEX-812 NDMP backup terminate after hit the EOM in Netbackup backup
NEX-559 NDMP cannot backup/restore a file which spans multiple tapes
OS-49 Switch back to illumos' version of wcwidth()
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-426 ndmp_config_get_ext_list failed
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/ndmpd/ndmp/ndmpd.h
          +++ new/usr/src/cmd/ndmpd/ndmp/ndmpd.h
   1    1  /*
   2    2   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
   3    3   * Copyright (c) 2015 by Delphix. All rights reserved.
   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
  
    | 
      ↓ open down ↓ | 
    30 lines elided | 
    
      ↑ open up ↑ | 
  
  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   39  /* Copyright (c) 2007, The Storage Networking Industry Association. */
  40   40  /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
  41      -/* Copyright 2014 Nexenta Systems, Inc.  All rights reserved.  */
       41 +/* Copyright 2017 Nexenta Systems, Inc.  All rights reserved.  */
  42   42  
  43   43  #ifndef _NDMPD_H
  44   44  #define _NDMPD_H
  45   45  
  46   46  #include <sys/types.h>
  47   47  #include <libzfs.h>
  48   48  #include <ndmpd_door.h>
  49   49  #include <libndmp.h>
  50   50  #include "ndmpd_common.h"
  51   51  #include "tlm_buffers.h"
  52   52  #include <dirent.h>
  53   53  #include "ndmpd_prop.h"
  54   54  #include "traverse.h"
  55   55  #include <pthread.h>
  56   56  #include <libndmp.h>
  57   57  #include <atomic.h>
  58   58  
  59   59  #define MAX_RECORD_SIZE (126*512)
  60   60  #define REMOTE_RECORD_SIZE    (60*KILOBYTE)
  61   61  #define SCSI_MAX_NAME 32
  62   62  #define MD5_CHALLENGE_SIZE      64
  63   63  #define MD5_PASS_LIMIT          32
  64   64  
  65   65  /* Test unit ready */
  66   66  #define TUR_WAIT        3000000
  67   67  #define TUR_MAX_TRY     3
  68   68  
  69   69  
  70   70  /* File handler classes */
  71   71  #define HC_CLIENT       1
  72   72  #define HC_MOVER        2
  73   73  #define HC_MODULE       4
  74   74  #define HC_ALL          0xffffffff
  75   75  
  76   76  #define IN_ADDR(x) \
  77   77          (*(struct in_addr *)&x)
  78   78  
  79   79  #define FS_READONLY(fs)         (hasmntopt(fs, "ro")  ? 1 :  0)
  80   80  
  81   81  typedef void *(*funct_t)(void *);       /* function pointer */
  82   82  
  83   83  #define HOSTNAMELEN     256
  84   84  
  85   85  #define VENDOR_NAME     "Sun Microsystems"
  86   86  #define PRODUCT_NAME    "Solaris 5.11"
  87   87  
  88   88  /*
  89   89   * Calculate array length based on its size and size of
  90   90   * its elements.
  91   91   */
  92   92  #define ARRAY_LEN(a, t) (sizeof (a) / sizeof (t))
  93   93  /*
  94   94   * Default maximum permitted sequence number for the token-based backup.
  95   95   */
  96   96  #define NDMP_MAX_TOKSEQ 9
  97   97  
  98   98  /*
  99   99   * Hard-limit for the sequence number in the token-based backup.
 100  100   * It's one less than the ASCII value of 'A'.  The 'A' letter
 101  101   * can be used as level in the lbr-type backups.
 102  102   */
 103  103  #define NDMP_TOKSEQ_HLIMIT      ('A' - 1)
 104  104  
 105  105  
 106  106  /*
 107  107   * Soft-limit for the sequence number in the token-based backup.
 108  108   */
 109  109  #define NDMP_TOKSEQ_SLIMIT      (NDMP_TOKSEQ_HLIMIT - 5)
 110  110  
 111  111  
 112  112  /*
 113  113   * Root inode number of dump format in V2.
 114  114   */
 115  115  #define ROOT_INODE      2
 116  116  
 117  117  /*
 118  118   * NDMP backup image signature
 119  119   */
 120  120  #define NDMPUTF8MAGIC "NDMPUTF8MAGIC"
 121  121  
 122  122  /*
 123  123   * Supported BU types
 124  124   */
 125  125  #define NDMP_TAR_TYPE   "tar"
 126  126  #define NDMP_DUMP_TYPE  "dump"
 127  127  #define NDMP_ZFS_TYPE   "zfs"
 128  128  
 129  129  /* All 1's binary maximum mover window */
 130  130  #define MAX_WINDOW_SIZE 0xffffffffffffffffULL
 131  131  
 132  132  #define NDMP_FREE(cp)   { free((char *)(cp)); (cp) = NULL; }
 133  133  
 134  134  #define NDMP_YORN(f)    ((f) ? 'Y' : 'N')
 135  135  #define NDMP_TORF(f)    ((f) ? "TRUE" : "FALSE")
 136  136  #define NDMP_SVAL(cp)   ((cp) ? (cp) : "NULL")
 137  137  
 138  138  #define NDMP_SETENV(env, nm, val) \
 139  139          { \
 140  140                  env->name = nm; \
 141  141                  env->value = val; \
 142  142                  env++; \
 143  143          }
 144  144  
 145  145  #define NDMP_CL_ADDR_LEN        24
 146  146  #define NDMP_TCP_ADDR_SIZE      32
 147  147  #define NDMP_TAPE_DEV_NAME      256
 148  148  
 149  149  typedef struct {
 150  150          char *bk_path;
 151  151          int bk_llevel; /* last backup level */
 152  152          time_t bk_ldate; /* last backup date */
 153  153          int bk_clevel;  /* current backup level */
 154  154          time_t bk_cdate; /* current backup date */
 155  155          int bk_map;
 156  156          int bk_dirino;
 157  157          char *bk_dmpnm;
 158  158          char **bk_exl; /* exlude list */
 159  159          char **bk_inc; /* include list */
 160  160  } ndmp_backup_params_t;
 161  161  
 162  162  
  
    | 
      ↓ open down ↓ | 
    111 lines elided | 
    
      ↑ open up ↑ | 
  
 163  163  typedef struct {
 164  164          ulong_t rs_nf;  /* number of files to restore */
 165  165          char *rs_path;
 166  166          char *rs_bkpath;
 167  167          int *rs_restored;
 168  168          int rs_bm;
 169  169          int rs_lastidx;
 170  170  } ndmp_restore_params_t;
 171  171  
 172  172  /*
      173 + * Used to find latest snapshot in a dataset
      174 + */
      175 +typedef struct snap_data {
      176 +        time_t          creation_time;
      177 +        const char      *last_snapshot;
      178 +} snap_data_t;
      179 +
      180 +/*
 173  181   * Tar format archiving ops table
 174  182   */
 175  183  extern tm_ops_t tm_tar_ops;
 176  184  
 177  185  /*
 178  186   * IS_LBR_BKTYPE shows if the backup type is one of these
 179  187   * 'F' of 'f': 'Full' backup type.
 180  188   * 'A' of 'a': 'Archive' backup type.
 181  189   * 'I' of 'i': 'Incremental' backup type.
 182  190   * 'D' of 'd': 'Differntial' backup type.
 183  191   */
 184  192  #define IS_LBR_BKTYPE(t)        (((t) && strchr("FAID", toupper(t))) ? 1 : 0)
 185  193  
 186  194  
 187  195  /*
 188  196   * NLP flags.
 189  197   */
 190  198  #define NLPF_CHKPNTED_PATH      (1 << 0)
 191  199  #define NLPF_FH                 (1 << 1)
 192  200  #define NLPF_DIRECT             (1 << 2)
 193  201  #define NLPF_UPDATE             (1 << 3)
 194  202  #define NLPF_DUMP               (1 << 4)
 195  203  #define NLPF_TAR                (1 << 5)
 196  204  #define NLPF_ABORTED            (1 << 6)
 197  205  #define NLPF_TOKENBK            (1 << 8)
 198  206  #define NLPF_LBRBK              (1 << 9)
 199  207  #define NLPF_LEVELBK            (1 << 10)
 200  208  #define NLPF_IGNCTIME           (1 << 11)
 201  209  #define NLPF_INCLMTIME          (1 << 12)
 202  210  #define NLPF_RECURSIVE          (1 << 13)
 203  211  
 204  212  /*
 205  213   * Macros on NLP flags.
 206  214   */
 207  215  #define NLP_ISSET(n, f) (((n)->nlp_flags & (f)) != 0)
 208  216  #define NLP_SET(n, f)   (n)->nlp_flags |= (f)
 209  217  #define NLP_UNSET(n, f) (n)->nlp_flags &= ~(f)
 210  218  
 211  219  
 212  220  #define NLP_ISCHKPNTED(n)       NLP_ISSET(n, NLPF_CHKPNTED_PATH)
 213  221  #define NLP_SHOULD_UPDATE(n)    NLP_ISSET(n, NLPF_UPDATE)
 214  222  #define NLP_ISDUMP(n)           NLP_ISSET(n, NLPF_DUMP)
 215  223  #define NLP_ISTAR(n)            NLP_ISSET(n, NLPF_TAR)
 216  224  #define NLP_IGNCTIME(n)         NLP_ISSET(n, NLPF_IGNCTIME)
 217  225  #define NLP_INCLMTIME(n)        NLP_ISSET(n, NLPF_INCLMTIME)
 218  226  
 219  227  /*
 220  228   * NDMP statistics
 221  229   */
 222  230  #define NS_INC(s)       (atomic_inc_32((volatile uint32_t *)&ndstat.ns_##s))
 223  231  #define NS_DEC(s)       (atomic_dec_32((volatile uint32_t *)&ndstat.ns_##s))
 224  232  #define NS_ADD(s, d)    (atomic_add_64((volatile uint64_t *)&ndstat.ns_##s, \
 225  233          (uint64_t)d))
  
    | 
      ↓ open down ↓ | 
    43 lines elided | 
    
      ↑ open up ↑ | 
  
 226  234  #define NS_UPD(s, t)    { \
 227  235          atomic_inc_32((volatile uint32_t *)&ndstat.ns_##s); \
 228  236          atomic_dec_32((volatile uint32_t *)&ndstat.ns_##t); \
 229  237          }
 230  238  
 231  239  #define NLP_READY       1
 232  240  
 233  241  typedef struct ndmp_lbr_params {
 234  242          struct ndmpd_session *nlp_session;
 235  243          int nlp_flags;
      244 +        char nlp_job_name[ZFS_MAX_DATASET_NAME_LEN];
      245 +        char nlp_vol[ZFS_MAX_DATASET_NAME_LEN];
      246 +        char nlp_snapname[ZFS_MAX_DATASET_NAME_LEN];
      247 +        char nlp_clonename[ZFS_MAX_DATASET_NAME_LEN];
      248 +        char nlp_mountpoint[ZFS_MAX_DATASET_NAME_LEN];
 236  249  
 237  250          ndmp_backup_params_t bk_params;
 238  251          ndmp_restore_params_t rs_params;
 239  252  #define nlp_backup_path bk_params.bk_path
 240  253  #define nlp_llevel      bk_params.bk_llevel
 241  254  #define nlp_ldate       bk_params.bk_ldate
 242  255  #define nlp_clevel      bk_params.bk_clevel
 243  256  #define nlp_tokseq      nlp_clevel
 244  257  #define nlp_tokdate     nlp_ldate
 245  258  #define nlp_cdate       bk_params.bk_cdate
 246  259  #define nlp_bkmap       bk_params.bk_map
 247  260  #define nlp_bkdirino    bk_params.bk_dirino
 248  261  #define nlp_dmpnm       bk_params.bk_dmpnm
 249  262  #define nlp_exl         bk_params.bk_exl
 250  263  #define nlp_inc         bk_params.bk_inc
 251  264  
 252  265  #define nlp_nfiles      rs_params.rs_nf
 253  266  #define nlp_restore_path        rs_params.rs_path
 254  267  #define nlp_restore_bk_path     rs_params.rs_bkpath
 255  268  #define nlp_restored    rs_params.rs_restored
 256  269  #define nlp_rsbm        rs_params.rs_bm
 257  270  #define nlp_lastidx     rs_params.rs_lastidx
 258  271  
 259  272          ndmpd_module_params_t *nlp_params;
 260  273          tlm_job_stats_t *nlp_jstat;
 261  274          lbr_fhlog_call_backs_t *nlp_logcallbacks;
 262  275          tlm_commands_t nlp_cmds;
 263  276  
 264  277          cond_t  nlp_cv;         /* for signaling a processed request */
 265  278          mutex_t nlp_mtx;        /* mutex to synchronize access to nlp_cv */
 266  279          u_longlong_t nlp_bytes_total;
 267  280  } ndmp_lbr_params_t;
 268  281  
 269  282  
 270  283  typedef struct mem_ndmp_name_v3 {
 271  284          char *nm3_opath;
 272  285          char *nm3_dpath;
 273  286          char *nm3_newnm;
 274  287          u_longlong_t nm3_node;
 275  288          u_longlong_t nm3_fh_info;
 276  289          ndmp_error nm3_err;
 277  290  } mem_ndmp_name_v3_t;
 278  291  
 279  292  typedef struct ndmpd_file_handler {
 280  293          int fh_fd;
 281  294          ulong_t fh_mode;
 282  295          ulong_t fh_class;
 283  296          void *fh_cookie;
 284  297          ndmpd_file_handler_func_t *fh_func;
 285  298          struct ndmpd_file_handler *fh_next;
 286  299  } ndmpd_file_handler_t;
 287  300  
 288  301  typedef struct ndmpd_session_scsi_desc {
 289  302          int sd_is_open;
 290  303          int sd_devid;
 291  304          boolean_t sd_valid_target_set;
 292  305          int sd_sid;
 293  306          int sd_lun;
 294  307          char sd_adapter_name[SCSI_MAX_NAME];
 295  308  } ndmpd_session_scsi_desc_t;
 296  309  
 297  310  typedef struct ndmpd_session_tape_desc {
 298  311          int td_fd;                      /* tape device file descriptor */
 299  312          ulong_t td_record_count;        /* number of records written */
 300  313          ndmp_tape_open_mode td_mode;    /* tape device open mode */
 301  314          u_longlong_t td_pos;    /* current position on the current tape */
 302  315          int td_sid;
 303  316          int td_lun;
 304  317          char td_adapter_name[SCSI_MAX_NAME];
 305  318  } ndmpd_session_tape_desc_t;
 306  319  
 307  320  typedef struct ndmpd_session_mover_desc {
 308  321          ndmp_mover_state md_state;      /* current state */
 309  322          ndmp_mover_mode md_mode;        /* current mode */
 310  323          ndmp_mover_pause_reason md_pause_reason;        /* current reason */
 311  324          ndmp_mover_halt_reason md_halt_reason;  /* current reason */
 312  325          u_longlong_t md_data_written;   /* total written to tape */
 313  326          u_longlong_t md_seek_position;  /* current seek position */
 314  327          u_longlong_t md_bytes_left_to_read; /* #bytes to end of seek window */
 315  328          u_longlong_t md_window_offset;  /* valid data window begin */
 316  329          u_longlong_t md_window_length;  /* valid data window length */
 317  330          u_longlong_t md_position;       /* current data stream pos */
 318  331          boolean_t md_pre_cond;          /* used for precondition checks */
 319  332          ulong_t md_record_size; /* tape I/O record size */
 320  333          ulong_t md_record_num;  /* current record num */
 321  334          int md_listen_sock;             /* data conn listen socket */
 322  335          int md_sock;            /* data conn socket */
 323  336          ulong_t md_r_index;             /* buffer read  index */
 324  337          ulong_t md_w_index;             /* buffer write index */
 325  338          char *md_buf;           /* data buffer */
 326  339          /*
 327  340           * V2 fields.
 328  341           */
 329  342          ulong_t md_discard_length;      /* bytes to discard */
 330  343  
 331  344          /*
 332  345           * V3 fields.
 333  346           */
 334  347          ndmp_addr_v3 md_data_addr;
 335  348          /*
 336  349           * V4 fields.
 337  350           */
 338  351          ndmp_addr_v4 md_data_addr_v4;
 339  352  } ndmpd_session_mover_desc_t;
 340  353  
 341  354  
 342  355  typedef struct ndmpd_session_data_module {
 343  356          void *dm_module_cookie; /* sent as abort_func param */
 344  357          module_start_func_t *dm_start_func;     /* start function */
 345  358          module_abort_func_t *dm_abort_func;     /* abort function */
 346  359          ndmpd_module_stats dm_stats;    /* statistics buffer */
 347  360  } ndmpd_session_data_module_t;
 348  361  
 349  362  typedef struct ndmpd_session_data_desc {
 350  363          /*
 351  364           * Common fields.
 352  365           */
 353  366          ndmp_data_operation dd_operation;       /* current operation */
 354  367          boolean_t dd_abort;             /* abort operation flag */
 355  368          boolean_t dd_io_ready;          /* mover sock read for I/O */
 356  369          ndmp_pval *dd_env;      /* environment from backup or recover request */
 357  370          ulong_t dd_env_len;             /* environment length */
 358  371          ulong_t dd_nlist_len;   /* recover file list length */
 359  372          int dd_sock;            /* listen and data socket */
 360  373          u_longlong_t dd_read_offset;    /* data read seek offset */
 361  374          u_longlong_t dd_read_length;    /* data read length */
 362  375          u_longlong_t dd_data_size;      /* data size to be backed up */
 363  376          ndmpd_session_data_module_t dd_module;
 364  377  
 365  378          ndmp_data_state dd_state;       /* current state */
 366  379          ndmp_data_halt_reason dd_halt_reason;           /* current reason */
 367  380          /*
 368  381           * V2 fields.
 369  382           */
 370  383          ndmp_name *dd_nlist;    /* recover file list */
 371  384          ndmp_mover_addr dd_mover;       /* mover address */
 372  385          /*
 373  386           * V3 fields.
 374  387           */
 375  388          mem_ndmp_name_v3_t *dd_nlist_v3;
 376  389          ndmp_addr_v3 dd_data_addr;
 377  390          int dd_listen_sock;     /* socket for listening for remote */
 378  391                                  /* mover connections */
 379  392          u_longlong_t dd_bytes_left_to_read;
 380  393          u_longlong_t dd_position;
 381  394          u_longlong_t dd_discard_length;
 382  395          /*
 383  396           * V4 fields.
 384  397           */
 385  398          ndmp_addr_v4 dd_data_addr_v4;
 386  399  } ndmpd_session_data_desc_t;
 387  400  
 388  401  typedef struct ndmpd_session_file_history {
 389  402          ndmp_fh_unix_path *fh_path_entries;
 390  403          ndmp_fh_unix_dir *fh_dir_entries;
 391  404          ndmp_fh_unix_node *fh_node_entries;
 392  405          char *fh_path_name_buf;
 393  406          char *fh_dir_name_buf;
 394  407          ulong_t fh_path_index;
 395  408          ulong_t fh_dir_index;
 396  409          ulong_t fh_node_index;
 397  410          ulong_t fh_path_name_buf_index;
 398  411          ulong_t fh_dir_name_buf_index;
 399  412  } ndmpd_session_file_history_t;
 400  413  
 401  414  typedef struct ndmpd_session_file_history_v3 {
 402  415          ndmp_file_v3 *fh_files;
 403  416          ndmp_dir_v3 *fh_dirs;
 404  417          ndmp_node_v3 *fh_nodes;
 405  418          ndmp_file_name_v3 *fh_file_names;
 406  419          ndmp_file_name_v3 *fh_dir_names;
 407  420          ndmp_file_stat_v3 *fh_file_stats;
 408  421          ndmp_file_stat_v3 *fh_node_stats;
 409  422          char *fh_file_name_buf;
 410  423          char *fh_dir_name_buf;
 411  424          ulong_t fh_file_index;
 412  425          ulong_t fh_dir_index;
 413  426          ulong_t fh_node_index;
 414  427          ulong_t fh_file_name_buf_index;
 415  428          ulong_t fh_dir_name_buf_index;
 416  429  } ndmpd_session_file_history_v3_t;
 417  430  
 418  431  /*
 419  432   * zfs-based backup (zfs send/recv)
 420  433   */
 421  434  
 422  435  typedef enum {
 423  436          NDMPD_ZFS_MAJOR_0,
 424  437  } ndmpd_zfs_major_t;
 425  438  
 426  439  typedef enum {
 427  440          NDMPD_ZFS_MINOR_0,
 428  441  } ndmpd_zfs_minor_t;
 429  442  
 430  443  typedef enum {
 431  444          NDMPD_ZFS_PROP_MAJOR_0,
 432  445  } ndmpd_zfs_prop_major_t;
 433  446  
 434  447  typedef enum {
 435  448          NDMPD_ZFS_PROP_MINOR_0,
 436  449  } ndmpd_zfs_prop_minor_t;
 437  450  
 438  451  #define NDMPD_ZFS_MAJOR_VERSION NDMPD_ZFS_MAJOR_0
 439  452  #define NDMPD_ZFS_MINOR_VERSION NDMPD_ZFS_MINOR_0
 440  453  #define NDMPD_ZFS_PROP_MAJOR_VERSION NDMPD_ZFS_PROP_MAJOR_0
 441  454  #define NDMPD_ZFS_PROP_MINOR_VERSION NDMPD_ZFS_PROP_MINOR_0
 442  455  
 443  456  #pragma pack(1)
 444  457  typedef struct {
 445  458          char nzh_magic[14]; /* NDMPUTF8MAGIC\0 */
 446  459          uint32_t nzh_major; /* major version */
 447  460          uint32_t nzh_minor; /* minor version */
 448  461          uint32_t nzh_hdrlen; /* length of hdr in bytes including magic */
 449  462          /* future extensions */
 450  463  } ndmpd_zfs_header_t;
 451  464  #pragma pack()
 452  465  
 453  466  #define PIPE_TAPE 0
 454  467  #define PIPE_ZFS 1
 455  468  
 456  469  #define NDMPD_ZFS_DMP_NAME_MAX 32
 457  470  
 458  471  typedef struct ndmpd_zfs_args {
 459  472          zfs_type_t nz_type;                     /* type of ZFS dataset */
 460  473          char nz_dataset[ZFS_MAX_DATASET_NAME_LEN]; /* dataset name */
 461  474          char nz_snapname[ZFS_MAX_DATASET_NAME_LEN]; /* snapname (following @) */
 462  475          char nz_fromsnap[ZFS_MAX_DATASET_NAME_LEN]; /* snap of L-1 bkup */
 463  476          char nz_snapprop[ZFS_MAXPROPLEN];       /* contents of snap incr prop */
 464  477          boolean_t nz_ndmpd_snap;                /* ndmpd-generated snap? */
 465  478  
 466  479          pthread_t nz_sendrecv_thread;           /* thread for send/recv */
 467  480          pthread_t nz_tape_thread;               /* thread for tape r/w */
 468  481          int32_t nz_pipe_fd[2];                  /* pipe for above 2 threads */
 469  482          int32_t nz_bufsize;                     /* tape r/w buf size */
 470  483          int64_t nz_window_len;                  /* DMA window length */
 471  484  
 472  485          int nz_level;                           /* val of LEVEL env var */
 473  486          char nz_zfs_mode;                       /* val of ZFS_MODE env var */
 474  487          boolean_t nz_zfs_force;                 /* val of ZFS_FORCE env var */
 475  488          boolean_t nz_update;                    /* val of UPDATE env var */
 476  489          char nz_dmp_name[NDMPD_ZFS_DMP_NAME_MAX]; /* val of DMP_NAME env var */
 477  490          u_longlong_t nz_zfs_backup_size;        /* used for restore only */
 478  491  
 479  492          ndmpd_module_params_t nz_params;
 480  493          ndmp_lbr_params_t *nz_nlp;
 481  494          libzfs_handle_t *nz_zlibh;              /* session-specific lzfs hdl */
 482  495          ndmp_context_t nz_nctx;                 /* used by plugin */
 483  496  
 484  497          ndmpd_zfs_header_t nz_tape_header;      /* tape hdr for "zfs" backup */
 485  498  } ndmpd_zfs_args_t;
 486  499  
 487  500  #define ndmpd_zfs_params (&(ndmpd_zfs_args)->nz_params)
 488  501  
 489  502  typedef struct ndmpd_session {
 490  503          ndmp_connection_t *ns_connection;       /* NDMP connection to client */
 491  504          boolean_t ns_eof;               /* connection EOF flag */
 492  505          ushort_t ns_protocol_version;   /* connection protocol version */
 493  506          ndmpd_session_scsi_desc_t ns_scsi;
 494  507          ndmpd_session_tape_desc_t ns_tape;
 495  508          ndmpd_session_mover_desc_t ns_mover;
 496  509          ndmpd_session_data_desc_t ns_data;
 497  510          ndmpd_session_file_history_t ns_fh;
 498  511          ndmpd_file_handler_t *ns_file_handler_list; /* for I/O multiplexing */
 499  512          int ns_nref;
 500  513          ndmp_lbr_params_t *ns_ndmp_lbr_params;
 501  514          struct ndmpd_zfs_args ns_ndmpd_zfs_args;
 502  515          ndmpd_backup_type_t ns_butype;
 503  516          mutex_t ns_lock;
 504  517  
 505  518          /*
 506  519           * NDMP V3
 507  520           * Tape, SCSI, mover, data and file handlers will
 508  521           * be shared between V2 and V3.
 509  522           */
 510  523          ndmpd_session_file_history_v3_t ns_fh_v3;
 511  524          unsigned char ns_challenge[MD5_CHALLENGE_SIZE];  /* For MD5 */
 512  525  
 513  526          /*
 514  527           * NDMP V4 related data
 515  528           */
 516  529          boolean_t ns_get_ext_list;
 517  530          boolean_t ns_set_ext_list;
 518  531  
 519  532          /* handling of hardlink, hardlink queue head */
 520  533          struct hardlink_q *hardlink_q;
 521  534  } ndmpd_session_t;
 522  535  
 523  536  
 524  537  /*
 525  538   * NDMP request handler functions.
 526  539   */
 527  540  
 528  541  /* Config */
 529  542  ndmp_msg_handler_func_t ndmpd_config_get_host_info_v2;
 530  543  ndmp_msg_handler_func_t ndmpd_config_get_butype_attr_v2;
 531  544  ndmp_msg_handler_func_t ndmpd_config_get_mover_type_v2;
 532  545  ndmp_msg_handler_func_t ndmpd_config_get_auth_attr_v2;
 533  546  
 534  547  ndmp_msg_handler_func_t ndmpd_config_get_host_info_v3;
 535  548  ndmp_msg_handler_func_t ndmpd_config_get_butype_info_v3;
 536  549  ndmp_msg_handler_func_t ndmpd_config_get_connection_type_v3;
 537  550  ndmp_msg_handler_func_t ndmpd_config_get_auth_attr_v3;
 538  551  ndmp_msg_handler_func_t ndmpd_config_get_fs_info_v3;
 539  552  ndmp_msg_handler_func_t ndmpd_config_get_tape_info_v3;
 540  553  ndmp_msg_handler_func_t ndmpd_config_get_scsi_info_v3;
 541  554  ndmp_msg_handler_func_t ndmpd_config_get_server_info_v3;
 542  555  
 543  556  ndmp_msg_handler_func_t ndmpd_config_get_butype_info_v4;
 544  557  ndmp_msg_handler_func_t ndmpd_config_get_ext_list_v4;
 545  558  ndmp_msg_handler_func_t ndmpd_config_set_ext_list_v4;
 546  559  
 547  560  
 548  561  /* Scsi */
 549  562  ndmp_msg_handler_func_t ndmpd_scsi_open_v2;
 550  563  ndmp_msg_handler_func_t ndmpd_scsi_close_v2;
 551  564  ndmp_msg_handler_func_t ndmpd_scsi_get_state_v2;
 552  565  ndmp_msg_handler_func_t ndmpd_scsi_set_target_v2;
 553  566  ndmp_msg_handler_func_t ndmpd_scsi_reset_device_v2;
 554  567  ndmp_msg_handler_func_t ndmpd_scsi_reset_bus_v2;
 555  568  ndmp_msg_handler_func_t ndmpd_scsi_execute_cdb_v2;
 556  569  
 557  570  ndmp_msg_handler_func_t ndmpd_scsi_open_v3;
 558  571  ndmp_msg_handler_func_t ndmpd_scsi_set_target_v3;
 559  572  
 560  573  
 561  574  /* Tape */
 562  575  ndmp_msg_handler_func_t ndmpd_tape_open_v2;
 563  576  ndmp_msg_handler_func_t ndmpd_tape_close_v2;
 564  577  ndmp_msg_handler_func_t ndmpd_tape_get_state_v2;
 565  578  ndmp_msg_handler_func_t ndmpd_tape_mtio_v2;
 566  579  ndmp_msg_handler_func_t ndmpd_tape_write_v2;
 567  580  ndmp_msg_handler_func_t ndmpd_tape_read_v2;
 568  581  ndmp_msg_handler_func_t ndmpd_tape_execute_cdb_v2;
 569  582  
 570  583  ndmp_msg_handler_func_t ndmpd_tape_open_v3;
 571  584  ndmp_msg_handler_func_t ndmpd_tape_get_state_v3;
 572  585  ndmp_msg_handler_func_t ndmpd_tape_write_v3;
 573  586  ndmp_msg_handler_func_t ndmpd_tape_read_v3;
 574  587  
 575  588  
 576  589  ndmp_msg_handler_func_t ndmpd_tape_close_v4;
 577  590  /* Data */
 578  591  ndmp_msg_handler_func_t ndmpd_data_get_state_v2;
 579  592  ndmp_msg_handler_func_t ndmpd_data_start_backup_v2;
 580  593  ndmp_msg_handler_func_t ndmpd_data_start_recover_v2;
 581  594  ndmp_msg_handler_func_t ndmpd_data_get_env_v2;
 582  595  ndmp_msg_handler_func_t ndmpd_data_stop_v2;
 583  596  ndmp_msg_handler_func_t ndmpd_data_abort_v2;
 584  597  
 585  598  ndmp_msg_handler_func_t ndmpd_data_get_state_v3;
 586  599  ndmp_msg_handler_func_t ndmpd_data_connect_v3;
 587  600  ndmp_msg_handler_func_t ndmpd_data_listen_v3;
 588  601  ndmp_msg_handler_func_t ndmpd_data_stop_v3;
 589  602  ndmp_msg_handler_func_t ndmpd_data_abort_v3;
 590  603  ndmp_msg_handler_func_t ndmpd_data_start_recover_v3;
 591  604  ndmp_msg_handler_func_t ndmpd_data_start_backup_v3;
 592  605  
 593  606  ndmp_msg_handler_func_t ndmpd_data_get_env_v4;
 594  607  ndmp_msg_handler_func_t ndmpd_data_get_state_v4;
 595  608  ndmp_msg_handler_func_t ndmpd_data_connect_v4;
 596  609  ndmp_msg_handler_func_t ndmpd_data_listen_v4;
 597  610  ndmp_msg_handler_func_t ndmpd_data_start_recover_filehist_v4;
 598  611  
 599  612  
 600  613  /* Connect */
 601  614  ndmp_msg_handler_func_t ndmpd_connect_open_v2;
 602  615  ndmp_msg_handler_func_t ndmpd_connect_client_auth_v2;
 603  616  ndmp_msg_handler_func_t ndmpd_connect_server_auth_v2;
 604  617  ndmp_msg_handler_func_t ndmpd_connect_close_v2;
 605  618  
 606  619  ndmp_msg_handler_func_t ndmpd_connect_client_auth_v3;
 607  620  ndmp_msg_handler_func_t ndmpd_connect_close_v3;
 608  621  
 609  622  
 610  623  /* Mover */
 611  624  ndmp_msg_handler_func_t ndmpd_mover_get_state_v2;
 612  625  ndmp_msg_handler_func_t ndmpd_mover_listen_v2;
 613  626  ndmp_msg_handler_func_t ndmpd_mover_continue_v2;
 614  627  ndmp_msg_handler_func_t ndmpd_mover_abort_v2;
 615  628  ndmp_msg_handler_func_t ndmpd_mover_stop_v2;
 616  629  ndmp_msg_handler_func_t ndmpd_mover_set_window_v2;
 617  630  ndmp_msg_handler_func_t ndmpd_mover_read_v2;
 618  631  ndmp_msg_handler_func_t ndmpd_mover_close_v2;
 619  632  ndmp_msg_handler_func_t ndmpd_mover_set_record_size_v2;
 620  633  
 621  634  ndmp_msg_handler_func_t ndmpd_mover_get_state_v3;
 622  635  ndmp_msg_handler_func_t ndmpd_mover_listen_v3;
 623  636  ndmp_msg_handler_func_t ndmpd_mover_continue_v3;
 624  637  ndmp_msg_handler_func_t ndmpd_mover_abort_v3;
 625  638  ndmp_msg_handler_func_t ndmpd_mover_set_window_v3;
 626  639  ndmp_msg_handler_func_t ndmpd_mover_read_v3;
 627  640  ndmp_msg_handler_func_t ndmpd_mover_set_record_size_v3;
 628  641  ndmp_msg_handler_func_t ndmpd_mover_connect_v3;
 629  642  
 630  643  
 631  644  ndmp_msg_handler_func_t ndmpd_mover_get_state_v4;
 632  645  ndmp_msg_handler_func_t ndmpd_mover_listen_v4;
 633  646  ndmp_msg_handler_func_t ndmpd_mover_connect_v4;
 634  647  
 635  648  
 636  649  /*
 637  650   * Backup/recover module API functions.
 638  651   */
 639  652  ndmpd_get_env_func_t ndmpd_api_get_env;
 640  653  ndmpd_add_env_func_t ndmpd_api_add_env;
 641  654  ndmpd_add_env_func_t ndmpd_api_set_env;
 642  655  ndmpd_get_name_func_t ndmpd_api_get_name;
 643  656  ndmpd_dispatch_func_t ndmpd_api_dispatch;
 644  657  ndmpd_done_func_t ndmpd_api_done_v2;
 645  658  
 646  659  
 647  660  ndmpd_write_func_t ndmpd_api_write_v2;
 648  661  ndmpd_file_history_path_func_t ndmpd_api_file_history_path_v2;
 649  662  ndmpd_file_history_dir_func_t ndmpd_api_file_history_dir_v2;
 650  663  ndmpd_file_history_node_func_t ndmpd_api_file_history_node_v2;
 651  664  ndmpd_read_func_t ndmpd_api_read_v2;
 652  665  ndmpd_seek_func_t ndmpd_api_seek_v2;
 653  666  ndmpd_file_recovered_func_t ndmpd_api_file_recovered_v2;
 654  667  ndmpd_add_file_handler_func_t ndmpd_api_add_file_handler;
 655  668  ndmpd_remove_file_handler_func_t ndmpd_api_remove_file_handler;
 656  669  
 657  670  
 658  671  /*
 659  672   * NDMP V3
 660  673   */
 661  674  ndmpd_done_func_t ndmpd_api_done_v3;
 662  675  ndmpd_write_func_t ndmpd_api_write_v3;
 663  676  ndmpd_read_func_t ndmpd_api_read_v3;
 664  677  ndmpd_seek_func_t ndmpd_api_seek_v3;
 665  678  ndmpd_file_recovered_func_t ndmpd_api_file_recovered_v3;
 666  679  ndmpd_get_name_func_t ndmpd_api_get_name_v3;
 667  680  ndmpd_file_history_path_func_t ndmpd_api_file_history_file_v3;
 668  681  ndmpd_file_history_dir_func_t ndmpd_api_file_history_dir_v3;
 669  682  ndmpd_file_history_node_func_t ndmpd_api_file_history_node_v3;
 670  683  
 671  684  /*
 672  685   * NDMP V4
 673  686   */
 674  687  ndmpd_log_func_v3_t ndmpd_api_log_v4;
 675  688  ndmpd_file_recovered_func_t ndmpd_api_file_recovered_v4;
 676  689  
 677  690  #ifndef NO_NDMP_API_LOG_PROTOTYPES
 678  691  ndmpd_log_func_t ndmpd_api_log_v2;
 679  692  ndmpd_log_func_v3_t ndmpd_api_log_v3;
 680  693  #endif /* NO_NDMP_API_LOG_PROTOTYPES */
 681  694  
 682  695  typedef void ndmpd_func_t(ndmp_connection_t *, void *);
 683  696  
  
    | 
      ↓ open down ↓ | 
    438 lines elided | 
    
      ↑ open up ↑ | 
  
 684  697  /*
 685  698   * pthread call arg parameters
 686  699   */
 687  700  typedef struct {
 688  701          int nw_sock;
 689  702          long nw_ipaddr;
 690  703          ndmp_con_handler_func_t nw_con_handler_func;
 691  704  } ndmpd_worker_arg_t;
 692  705  
 693  706  typedef struct {
 694      -        char *br_jname;
 695  707          ndmp_lbr_params_t *br_nlp;
 696  708          tlm_commands_t *br_cmds;
 697  709          pthread_barrier_t br_barrier;
 698  710  } backup_reader_arg_t;
 699  711  
 700  712  typedef struct {
 701  713          ndmpd_session_t *tr_session;
 702  714          ndmpd_module_params_t *tr_mod_params;
 703  715          tlm_commands_t *tr_cmds;
 704  716  } ndmp_tar_reader_arg_t;
 705  717  
 706  718  typedef struct {
 707  719          ndmpd_session_t *bs_session;
  
    | 
      ↓ open down ↓ | 
    3 lines elided | 
    
      ↑ open up ↑ | 
  
 708  720          char *bs_jname;
 709  721          char *bs_path;
 710  722  } ndmp_bkup_size_arg_t;
 711  723  
 712  724  /*
 713  725   * Variables from ndmpd_comm.c
 714  726   */
 715  727  extern int ndmp_ver;
 716  728  extern int ndmp_full_restore_path;
 717  729  extern int ndmp_dar_support;
      730 +extern int ndmp_autosync_support;
      731 +extern int ndmp_hpr_support;
 718  732  extern int ndmp_port;
 719  733  extern ndmp_stat_t ndstat;
 720  734  
 721  735  extern void ndmpd_main(void);
 722  736  extern void connection_handler(ndmp_connection_t *);
 723  737  extern void ndmpd_audit_backup(ndmp_connection_t *conn, char *path,
 724  738      int dest, char *local_path, int result);
 725  739  extern void ndmpd_audit_restore(ndmp_connection_t *conn,
 726  740      char *path, int dest, char *local_path, int result);
 727  741  extern void ndmpd_audit_connect(ndmp_connection_t *conn,
 728  742      int result);
 729  743  extern void ndmpd_audit_disconnect(ndmp_connection_t *conn);
 730  744  
 731  745  /* Variables from ndmpd_main.c */
 732  746  extern  libzfs_handle_t *zlibh;
 733  747  extern  mutex_t zlib_mtx;
 734  748  
 735  749  /*
 736  750   * Utility from ndmpd_connect.c.
 737  751   */
 738  752  extern int ndmp_connect_list_add(ndmp_connection_t *, int *);
 739  753  extern int ndmp_connect_list_del(ndmp_connection_t *);
 740  754  extern int ndmpd_connect_kill_id(int);
 741  755  extern void ndmp_connect_list_get(ndmp_door_ctx_t *);
 742  756  extern void ndmpd_get_devs(ndmp_door_ctx_t *);
 743  757  
 744  758  /*
 745  759   * Utility functions form ndmpd_data.c.
 746  760   */
 747  761  extern void ndmpd_data_cleanup(ndmpd_session_t *);
 748  762  extern int ndmpd_data_init(ndmpd_session_t *);
 749  763  extern char *ndmp_data_get_mover_mode(ndmpd_session_t *);
 750  764  extern void ndmpd_data_error(ndmpd_session_t *, ndmp_data_halt_reason);
 751  765  
 752  766  
 753  767  /*
 754  768   * Utility functions from ndmpd_mover.c.
 755  769   */
 756  770  extern int ndmpd_mover_init(ndmpd_session_t *);
 757  771  extern void ndmpd_mover_cleanup(ndmpd_session_t *);
 758  772  extern ndmp_error ndmpd_mover_connect(ndmpd_session_t *,
 759  773      ndmp_mover_mode);
 760  774  extern void ndmpd_mover_error(ndmpd_session_t *,
 761  775      ndmp_mover_halt_reason);
 762  776  extern int ndmpd_mover_seek(ndmpd_session_t *,
 763  777      u_longlong_t,
 764  778      u_longlong_t);
 765  779  extern int ndmpd_local_write(ndmpd_session_t *,
 766  780      char *,
 767  781      ulong_t);
 768  782  extern int ndmpd_remote_write(ndmpd_session_t *,
 769  783      char *,
 770  784      ulong_t);
 771  785  extern int ndmpd_local_read(ndmpd_session_t *,
 772  786      char *,
 773  787      ulong_t);
 774  788  extern int ndmpd_remote_read(ndmpd_session_t *,
 775  789      char *,
 776  790      ulong_t);
 777  791  
 778  792  extern void ndmpd_mover_shut_down(ndmpd_session_t *);
 779  793  extern void ndmpd_mover_error(ndmpd_session_t *,
 780  794      ndmp_mover_halt_reason);
 781  795  extern int ndmpd_local_write_v3(ndmpd_session_t *,
 782  796      char *,
 783  797      ulong_t);
 784  798  extern int ndmpd_local_read_v3(ndmpd_session_t *,
 785  799      char *,
 786  800      ulong_t);
 787  801  extern int ndmpd_remote_read_v3(ndmpd_session_t *,
 788  802      char *,
 789  803      ulong_t);
 790  804  
 791  805  
 792  806  /*
 793  807   * Utility functions from ndmpd_file_history.c
 794  808   */
 795  809  extern void ndmpd_file_history_init(ndmpd_session_t *);
 796  810  extern void ndmpd_file_history_cleanup(ndmpd_session_t *,
 797  811      boolean_t);
 798  812  extern int ndmpd_file_history_path(lbr_fhlog_call_backs_t *,
 799  813      char *,
 800  814      struct stat64 *,
 801  815      u_longlong_t);
 802  816  extern int ndmpd_file_history_dir(lbr_fhlog_call_backs_t *,
 803  817      char *,
 804  818      struct stat64 *);
 805  819  extern int ndmpd_file_history_node(lbr_fhlog_call_backs_t *,
 806  820      char *,
 807  821      char *,
 808  822      struct stat64 *,
 809  823      u_longlong_t);
 810  824  extern int
 811  825  ndmpd_path_restored(lbr_fhlog_call_backs_t *,
 812  826      char *,
 813  827      struct stat64 *,
 814  828      u_longlong_t);
 815  829  extern int ndmpd_fhpath_v3_cb(lbr_fhlog_call_backs_t *,
 816  830      char *,
 817  831      struct stat64 *,
 818  832      u_longlong_t);
 819  833  extern int ndmpd_fhdir_v3_cb(lbr_fhlog_call_backs_t *,
 820  834      char *,
 821  835      struct stat64 *);
 822  836  extern int ndmpd_fhnode_v3_cb(lbr_fhlog_call_backs_t *,
 823  837      char *,
 824  838      char *,
 825  839      struct stat64 *,
 826  840      u_longlong_t);
 827  841  extern int ndmpd_path_restored_v3(lbr_fhlog_call_backs_t *,
 828  842      char *,
 829  843      struct stat64 *,
 830  844      u_longlong_t);
 831  845  
 832  846  extern int ndmp_send_recovery_stat_v3(ndmpd_module_params_t *,
 833  847      ndmp_lbr_params_t *,
 834  848      int,
 835  849      int);
 836  850  
 837  851  
 838  852  /*
 839  853   * Utility functions from ndmpd_dtime.c
 840  854   */
 841  855  extern int ndmpd_put_dumptime(char *, int, time_t);
 842  856  extern int ndmpd_get_dumptime(char *, int *, time_t *);
 843  857  extern int ndmpd_append_dumptime(char *, char *, int, time_t);
 844  858  
 845  859  
 846  860  /*
 847  861   * Global variables from ndmpd_tar3.c
 848  862   */
 849  863  extern char **ndmp_excl_list;
 850  864  
 851  865  
 852  866  /*
 853  867   * Global variables from ndmpd_util.c
 854  868   */
 855  869  extern int ndmp_force_bk_dirs;
 856  870  extern int ndmp_rbs;
 857  871  extern int ndmp_sbs;
 858  872  extern boolean_t ndmp_dump_path_node;
 859  873  extern boolean_t ndmp_tar_path_node;
 860  874  extern boolean_t ndmp_ignore_ctime;
 861  875  extern boolean_t ndmp_include_lmtime;
 862  876  
 863  877  
 864  878  /*
 865  879   * Utility functions from ndmpd_util.c.
 866  880   */
 867  881  extern int ndmpd_select(ndmpd_session_t *,
 868  882      boolean_t,
 869  883      ulong_t);
 870  884  
 871  885  extern ndmp_error ndmpd_save_env(ndmpd_session_t *,
 872  886      ndmp_pval *,
 873  887      ulong_t);
 874  888  
 875  889  extern void ndmpd_free_env(ndmpd_session_t *);
 876  890  extern ndmp_error ndmpd_save_nlist_v2(ndmpd_session_t *,
 877  891      ndmp_name *,
 878  892      ulong_t);
 879  893  
 880  894  extern void ndmpd_free_nlist(ndmpd_session_t *);
 881  895  extern int ndmpd_add_file_handler(ndmpd_session_t *,
 882  896      void *,
 883  897      int,
 884  898      ulong_t,
 885  899      ulong_t,
 886  900      ndmpd_file_handler_func_t *);
 887  901  
 888  902  extern int ndmpd_remove_file_handler(ndmpd_session_t *,
 889  903      int);
 890  904  
 891  905  extern void ndmp_send_reply(ndmp_connection_t *,
 892  906      void *,
 893  907      char *);
 894  908  
 895  909  extern int ndmp_mtioctl(int, int, int);
 896  910  
 897  911  extern u_longlong_t quad_to_long_long(ndmp_u_quad);
 898  912  extern ndmp_u_quad long_long_to_quad(u_longlong_t);
 899  913  
 900  914  extern void set_socket_options(int sock);
 901  915  
 902  916  extern long ndmp_buffer_get_size(ndmpd_session_t *);
 903  917  extern int ndmp_lbr_init(ndmpd_session_t *);
 904  918  extern void ndmp_lbr_cleanup(ndmpd_session_t *);
 905  919  
 906  920  extern int ndmp_wait_for_mover(ndmpd_session_t *);
 907  921  extern boolean_t is_buffer_erroneous(tlm_buffer_t *);
 908  922  extern void ndmp_execute_cdb(ndmpd_session_t *,
 909  923      char *,
 910  924      int,
 911  925      int,
 912  926      ndmp_execute_cdb_request *);
 913  927  
 914  928  extern scsi_adapter_t *scsi_get_adapter(int);
 915  929  extern boolean_t is_tape_unit_ready(char *, int);
 916  930  
 917  931  extern int ndmp_open_list_add(ndmp_connection_t *, char *, int, int, int);
  
    | 
      ↓ open down ↓ | 
    190 lines elided | 
    
      ↑ open up ↑ | 
  
 918  932  extern int ndmp_open_list_del(char *, int, int);
 919  933  extern void ndmp_open_list_release(ndmp_connection_t *);
 920  934  
 921  935  extern void ndmp_stop_buffer_worker(ndmpd_session_t *);
 922  936  extern void ndmp_stop_reader_thread(ndmpd_session_t *);
 923  937  extern void ndmp_stop_writer_thread(ndmpd_session_t *);
 924  938  extern void ndmp_free_reader_writer_ipc(ndmpd_session_t *);
 925  939  extern void ndmp_waitfor_op(ndmpd_session_t *);
 926  940  
 927  941  extern char *cctime(time_t *);
 928      -extern char *ndmp_new_job_name(char *);
 929      -extern char *ndmpd_mk_temp(char *);
      942 +extern int ndmp_new_job_name(char *, size_t);
      943 +extern char *ndmpd_mk_temp(char *, char *);
 930  944  extern char *ndmpd_make_bk_dir_path(char *, char *);
 931  945  extern boolean_t ndmp_is_chkpnt_root(char *);
 932  946  extern char **ndmpd_make_exc_list(void);
 933  947  extern void ndmp_sort_nlist_v3(ndmpd_session_t *);
 934  948  extern int ndmp_get_bk_dir_ino(ndmp_lbr_params_t *);
 935  949  extern int ndmp_write_utf8magic(tlm_cmd_t *);
 936  950  extern int ndmp_tar_writer(ndmpd_session_t *,
 937  951      ndmpd_module_params_t *,
 938  952      tlm_commands_t *);
 939  953  extern void ndmp_wait_for_reader(tlm_commands_t *);
 940  954  extern ndmp_error ndmpd_save_nlist_v3(ndmpd_session_t *,
 941  955      ndmp_name_v3 *,
  
    | 
      ↓ open down ↓ | 
    2 lines elided | 
    
      ↑ open up ↑ | 
  
 942  956      ulong_t);
 943  957  extern void ndmpd_free_nlist_v3(ndmpd_session_t *);
 944  958  extern int ndmp_create_socket(ulong_t *, ushort_t *);
 945  959  extern int ndmp_connect_sock_v3(ulong_t, ushort_t);
 946  960  extern void ndmp_copy_addr_v3(ndmp_addr_v3 *, ndmp_addr_v3 *);
 947  961  extern void ndmp_copy_addr_v4(ndmp_addr_v4 *, ndmp_addr_v4 *);
 948  962  extern char *ndmp_addr2str_v3(ndmp_addr_type);
 949  963  extern boolean_t ndmp_valid_v3addr_type(ndmp_addr_type);
 950  964  extern boolean_t ndmp_check_utf8magic(tlm_cmd_t *);
 951  965  extern int ndmp_get_cur_bk_time(ndmp_lbr_params_t *,
 952      -    time_t *, char *);
      966 +    time_t *);
 953  967  extern char *ndmp_get_relative_path(char *, char *);
 954  968  
 955  969  extern boolean_t ndmp_fhinode;
 956  970  extern void ndmp_load_params(void);
 957  971  extern void randomize(unsigned char *, int);
      972 +extern int ndmp_find_latest_autosync(zfs_handle_t *, void *);
 958  973  
 959  974  
 960  975  /*
 961  976   * Utility functions from ndmpd_tar3.c.
 962  977   */
 963  978  extern ndmp_error ndmp_restore_get_params_v3(ndmpd_session_t *,
 964  979      ndmpd_module_params_t *);
 965  980  extern ndmp_error ndmp_backup_get_params_v3(ndmpd_session_t *,
 966  981      ndmpd_module_params_t *);
 967  982  
 968  983  /*
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
 969  984   * door init and fini function from ndmpd_door_serv.c
 970  985   */
 971  986  extern int ndmp_door_init(void);
 972  987  extern void ndmp_door_fini(void);
 973  988  extern boolean_t ndmp_door_check(void);
 974  989  
 975  990  extern int ndmp_get_max_tok_seq(void);
 976  991  
 977  992  extern int get_zfsvolname(char *, int, char *);
 978  993  extern int ndmp_create_snapshot(char *, char *);
 979      -extern int ndmp_remove_snapshot(char *, char *);
      994 +extern int ndmp_remove_snapshot(ndmp_bkup_size_arg_t *);
 980  995  extern int ndmpd_mark_inodes_v2(ndmpd_session_t *, ndmp_lbr_params_t *);
 981  996  extern void ndmpd_abort_marking_v2(ndmpd_session_t *);
 982  997  extern int ndmpd_mark_inodes_v3(ndmpd_session_t *, ndmp_lbr_params_t *);
 983  998  extern ndmp_lbr_params_t *ndmp_get_nlp(void *);
      999 +extern int ndmp_clone_snapshot(ndmp_lbr_params_t *);
 984 1000  
 985 1001  module_start_func_t ndmpd_tar_backup_starter;
 986 1002  module_abort_func_t ndmpd_tar_backup_abort;
 987 1003  
 988 1004  module_start_func_t ndmpd_tar_restore_starter;
 989 1005  module_abort_func_t ndmpd_tar_restore_abort;
 990 1006  
 991 1007  module_start_func_t ndmpd_tar_backup_starter_v3;
 992 1008  module_abort_func_t ndmpd_tar_backup_abort_v3;
 993 1009  
 994 1010  module_start_func_t ndmpd_tar_restore_starter_v3;
 995 1011  module_abort_func_t ndmpd_tar_restore_abort_v3;
 996 1012  
 997 1013  extern int ndmp_backup_extract_params(ndmpd_session_t *,
 998 1014      ndmpd_module_params_t *);
 999 1015  extern int ndmp_restore_extract_params(ndmpd_session_t *,
1000 1016      ndmpd_module_params_t *);
1001 1017  extern int ndmp_tar_reader(ndmp_tar_reader_arg_t *);
1002 1018  
1003 1019  extern int tape_open(char *, int);
1004 1020  extern int tape_is_at_bot(ndmpd_session_t *);
1005 1021  extern int tape_is_at_bof(ndmpd_session_t *);
1006 1022  extern void fm_dance(ndmpd_session_t *);
1007 1023  
1008 1024  extern void ndmp_session_ref(ndmpd_session_t *);
1009 1025  extern void ndmp_session_unref(ndmpd_session_t *);
  
    | 
      ↓ open down ↓ | 
    16 lines elided | 
    
      ↑ open up ↑ | 
  
1010 1026  
1011 1027  void ndmpd_get_file_entry_type(int, ndmp_file_type *);
1012 1028  
1013 1029  extern int tcp_accept(int, unsigned int *);
1014 1030  extern int tcp_get_peer(int, unsigned int *, int *);
1015 1031  
1016 1032  extern char *gethostaddr(void);
1017 1033  extern char *get_default_nic_addr(void);
1018 1034  extern int tlm_init(void);
1019 1035  
1020      -extern int snapshot_create(char *, char *, boolean_t, boolean_t);
1021      -extern int snapshot_destroy(char *, char *, boolean_t, boolean_t, int *);
     1036 +extern int backup_dataset_create(ndmp_lbr_params_t *);
     1037 +extern int backup_dataset_destroy(ndmp_lbr_params_t *);
1022 1038  
1023 1039  extern boolean_t fs_is_chkpntvol(char *);
1024 1040  extern boolean_t fs_is_chkpnt_enabled(char *);
1025 1041  extern boolean_t fs_is_rdonly(char *);
1026 1042  extern boolean_t fs_volexist(char *);
1027 1043  extern boolean_t fs_is_valid_logvol(char *);
1028 1044  extern boolean_t rootfs_dot_or_dotdot(char *);
1029 1045  extern int dp_readdir(DIR *, unsigned long *, char *,
1030 1046      int *, unsigned long *);
1031 1047  
1032 1048  extern void scsi_find_sid_lun();
1033 1049  extern char *sasd_slink_name();
1034 1050  extern int scsi_dev_exists(char *, int, int);
1035 1051  extern int scsi_get_devtype(char *, int, int);
1036 1052  extern struct open_list *ndmp_open_list_find(char *, int, int);
1037 1053  extern int filecopy(char *, char *);
1038 1054  
1039 1055  extern void ndmp_stop_local_reader();
1040 1056  extern void ndmp_stop_remote_reader();
1041 1057  
1042 1058  extern boolean_t match(char *, char *);
1043 1059  extern char *trim_whitespace(char *);
1044 1060  extern int fs_getstat(char *, struct fs_fhandle *, struct stat64 *);
1045 1061  extern int fs_readdir(struct fs_fhandle *, char *, long *,
1046 1062      char *, int *, struct fs_fhandle *, struct stat64 *);
1047 1063  extern int iscreated(ndmp_lbr_params_t *nlp, char *name, tlm_acls_t *tacl,
1048 1064      time_t t);
1049 1065  
1050 1066  extern int sasd_dev_count(void);
1051 1067  extern struct scsi_link *sasd_dev_slink(int);
1052 1068  extern struct sasd_drive *sasd_drive(int);
1053 1069  extern void *ndmp_malloc(size_t size);
1054 1070  
1055 1071  extern ndmp_plugin_t *ndmp_pl;
1056 1072  
1057 1073  #define NDMP_APILOG(s, t, m, ...) \
1058 1074  { \
1059 1075          if (((ndmpd_session_t *)(s))->ns_protocol_version == NDMPV4) \
1060 1076                  (void) ndmpd_api_log_v4(s, t, m, __VA_ARGS__); \
1061 1077          else if (((ndmpd_session_t *)(s))->ns_protocol_version == NDMPV3) \
1062 1078                  (void) ndmpd_api_log_v3(s, t, m, __VA_ARGS__); \
1063 1079          else \
1064 1080                  (void) ndmpd_api_log_v2(s, __VA_ARGS__); \
1065 1081  }
1066 1082  
1067 1083  /*
1068 1084   * Backup path utility functions
1069 1085   */
1070 1086  extern char *get_backup_path_v3(ndmpd_module_params_t *);
1071 1087  extern char *get_backup_path_v2(ndmpd_module_params_t *);
1072 1088  
1073 1089  /*
1074 1090   * Functions for zfs-based backup
1075 1091   */
1076 1092  
1077 1093  module_start_func_t ndmpd_zfs_backup_starter;
1078 1094  module_start_func_t ndmpd_zfs_restore_starter;
1079 1095  module_abort_func_t ndmpd_zfs_abort;
1080 1096  
1081 1097  int ndmpd_zfs_init(ndmpd_session_t *);
1082 1098  void ndmpd_zfs_fini(ndmpd_zfs_args_t *);
1083 1099  
1084 1100  boolean_t ndmpd_zfs_backup_parms_valid(ndmpd_zfs_args_t *);
1085 1101  boolean_t ndmpd_zfs_restore_parms_valid(ndmpd_zfs_args_t *);
1086 1102  
1087 1103  int ndmpd_zfs_pre_backup(ndmpd_zfs_args_t *);
1088 1104  int ndmpd_zfs_pre_restore(ndmpd_zfs_args_t *);
1089 1105  int ndmpd_zfs_post_backup(ndmpd_zfs_args_t *);
1090 1106  int ndmpd_zfs_post_restore(ndmpd_zfs_args_t *);
1091 1107  
1092 1108  void ndmpd_zfs_dma_log(ndmpd_zfs_args_t *, ndmp_log_type, char *, ...);
1093 1109  
1094 1110  #endif /* _NDMPD_H */
  
    | 
      ↓ open down ↓ | 
    63 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX