summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReza Sabdar <Reza.Sabdar@Sun.COM>2010-07-24 18:42:21 -0400
committerReza Sabdar <Reza.Sabdar@Sun.COM>2010-07-24 18:42:21 -0400
commit876b86efac620aaabc70ad2ed4bfb715ce714875 (patch)
treef0fd3a60218566a5242da220d4cd97aed6f0a003
parent940fff4ba2ecee47f4762cbfc616f0990446a09a (diff)
downloadillumos-joyent-876b86efac620aaabc70ad2ed4bfb715ce714875.tar.gz
6947180 ndmp snapshots not getting deleted after concurrent backups
6906014 NDMP: removing snapshot during backup causes problem
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd.h14
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_chkpnt.c330
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_tar.c9
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c17
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c10
-rw-r--r--usr/src/cmd/ndmpd/tlm/tlm_lib.c105
-rw-r--r--usr/src/cmd/ndmpd/tlm/tlm_proto.h5
7 files changed, 209 insertions, 281 deletions
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd.h b/usr/src/cmd/ndmpd/ndmp/ndmpd.h
index 46991911ba..b13ae883c6 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd.h
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd.h
@@ -995,15 +995,9 @@ extern int ndmp_get_max_tok_seq(void);
extern boolean_t set_debug_level(boolean_t);
extern boolean_t get_debug_level(void);
-typedef struct ndmp_chkpnt_vol {
- char cv_vol_name[64];
- unsigned int cv_count;
- void *cv_next;
-} ndmp_chkpnt_vol_t;
-
extern int get_zfsvolname(char *, int, char *);
-extern int ndmp_start_check_point(char *, char *);
-extern int ndmp_release_check_point(char *, char *);
+extern int ndmp_create_snapshot(char *, char *);
+extern int ndmp_remove_snapshot(char *, char *);
extern int ndmpd_mark_inodes_v2(ndmpd_session_t *, ndmp_lbr_params_t *);
extern void ndmpd_abort_marking_v2(ndmpd_session_t *);
extern int ndmpd_mark_inodes_v3(ndmpd_session_t *, ndmp_lbr_params_t *);
@@ -1040,8 +1034,8 @@ extern int tcp_get_peer(int, unsigned int *, int *);
extern char *gethostaddr(void);
extern int tlm_init(void);
-extern int chkpnt_backup_successful(char *, char *, boolean_t, int *);
-extern int chkpnt_backup_prepare(char *, char *, boolean_t);
+extern int snapshot_create(char *, char *, boolean_t, boolean_t);
+extern int snapshot_destroy(char *, char *, boolean_t, boolean_t, int *);
extern boolean_t fs_is_chkpntvol(char *);
extern boolean_t fs_is_chkpnt_enabled(char *);
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_chkpnt.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_chkpnt.c
index d47bc38d25..a029cdae93 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_chkpnt.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_chkpnt.c
@@ -41,12 +41,12 @@
#include "ndmpd.h"
#include <libzfs.h>
-ndmp_chkpnt_vol_t *chkpnt_vols = NULL;
+typedef struct snap_param {
+ char *snp_name;
+ boolean_t snp_found;
+} snap_param_t;
-typedef struct chkpnt_param {
- char *chp_name;
- boolean_t chp_found;
-} chkpnt_param_t;
+static int cleanup_fd = -1;
/*
* ndmp_has_backup
@@ -67,23 +67,23 @@ static int
ndmp_has_backup(zfs_handle_t *zhp, void *data)
{
const char *name;
- chkpnt_param_t *chp = (chkpnt_param_t *)data;
+ snap_param_t *chp = (snap_param_t *)data;
name = zfs_get_name(zhp);
if (name == NULL ||
- strstr(name, chp->chp_name) == NULL) {
+ strstr(name, chp->snp_name) == NULL) {
zfs_close(zhp);
return (-1);
}
- chp->chp_found = 1;
+ chp->snp_found = 1;
zfs_close(zhp);
return (0);
}
/*
- * ndmp_has_backup_chkpnt
+ * ndmp_has_backup_snapshot
*
* Returns TRUE if the volume has an active backup snapshot, otherwise,
* returns FALSE.
@@ -96,201 +96,251 @@ ndmp_has_backup(zfs_handle_t *zhp, void *data)
* -1: otherwise
*/
static int
-ndmp_has_backup_chkpnt(char *volname, char *jobname)
+ndmp_has_backup_snapshot(char *volname, char *jobname)
{
zfs_handle_t *zhp;
- chkpnt_param_t chkp;
+ snap_param_t snp;
char chname[ZFS_MAXNAMELEN];
(void) mutex_lock(&zlib_mtx);
if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
- NDMP_LOG(LOG_ERR, "Cannot open checkpoint %s.", volname);
+ NDMP_LOG(LOG_ERR, "Cannot open snapshot %s.", volname);
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
- chkp.chp_found = 0;
+ snp.snp_found = 0;
(void) snprintf(chname, ZFS_MAXNAMELEN, "@%s", jobname);
- chkp.chp_name = chname;
+ snp.snp_name = chname;
- (void) zfs_iter_snapshots(zhp, ndmp_has_backup, &chkp);
+ (void) zfs_iter_snapshots(zhp, ndmp_has_backup, &snp);
zfs_close(zhp);
(void) mutex_unlock(&zlib_mtx);
- return (chkp.chp_found);
+ return (snp.snp_found);
}
-
/*
- * ndmp_add_chk_pnt_vol
+ * ndmp_create_snapshot
*
- * This function keep track of check points created by NDMP. Whenever the
- * NDMP check points need to be created, this function should be called.
- * If the value returned is bigger than 1, it indicates that the check point
- * has already exists and should not be created.
+ * This function will parse the path to get the real volume name.
+ * It will then create a snapshot based on volume and job name.
+ * This function should be called before the NDMP backup is started.
*
* Parameters:
* vol_name (input) - name of the volume
*
* Returns:
- * The number of existing snapshots
+ * 0: on success
+ * -1: otherwise
*/
-static unsigned int
-ndmp_add_chk_pnt_vol(char *vol_name)
+int
+ndmp_create_snapshot(char *vol_name, char *jname)
{
- ndmp_chkpnt_vol_t *new_chkpnt_vol;
-
- for (new_chkpnt_vol = chkpnt_vols; new_chkpnt_vol != NULL;
- new_chkpnt_vol = new_chkpnt_vol->cv_next) {
- if (strcmp(new_chkpnt_vol->cv_vol_name, vol_name) == 0) {
- new_chkpnt_vol->cv_count++;
- return (new_chkpnt_vol->cv_count);
- }
- }
+ char vol[ZFS_MAXNAMELEN];
- new_chkpnt_vol = ndmp_malloc(sizeof (ndmp_chkpnt_vol_t));
- if (new_chkpnt_vol == NULL)
+ if (vol_name == 0 ||
+ get_zfsvolname(vol, sizeof (vol), vol_name) == -1)
return (0);
- (void) memset(new_chkpnt_vol, 0, sizeof (ndmp_chkpnt_vol_t));
- (void) strlcpy(new_chkpnt_vol->cv_vol_name, vol_name,
- sizeof (new_chkpnt_vol->cv_vol_name));
-
- new_chkpnt_vol->cv_count++;
-
- if (chkpnt_vols == NULL) {
- chkpnt_vols = new_chkpnt_vol;
- } else {
- new_chkpnt_vol->cv_next = chkpnt_vols;
- chkpnt_vols = new_chkpnt_vol;
- }
+ /*
+ * If there is an old snapshot left from the previous
+ * backup it could be stale one and it must be
+ * removed before using it.
+ */
+ if (ndmp_has_backup_snapshot(vol, jname))
+ (void) snapshot_destroy(vol, jname, B_FALSE, B_TRUE, NULL);
- return (new_chkpnt_vol->cv_count);
+ return (snapshot_create(vol, jname, B_FALSE, B_TRUE));
}
-
/*
- * ndmp_remove_chk_pnt_vol
+ * ndmp_remove_snapshot
*
- * This function will decrement the usage counter belongs to the check point.
- * Whenever a check point needs to be removed, this function should be
- * called. When the return value is greater than zero, it indicates someone
- * else is still using the check point and the check point should not be
- * removed.
+ * This function will parse the path to get the real volume name.
+ * It will then remove the snapshot for that volume and job name.
+ * This function should be called after NDMP backup is finished.
*
* Parameters:
* vol_name (input) - name of the volume
*
* Returns:
- * The number of existing snapshots
+ * 0: on success
+ * -1: otherwise
*/
-static unsigned int
-ndmp_remove_chk_pnt_vol(char *vol_name)
+int
+ndmp_remove_snapshot(char *vol_name, char *jname)
{
- ndmp_chkpnt_vol_t *new_chkpnt_vol, *pre_chkpnt_vol;
-
- pre_chkpnt_vol = chkpnt_vols;
- for (new_chkpnt_vol = chkpnt_vols; new_chkpnt_vol != NULL;
- new_chkpnt_vol = new_chkpnt_vol->cv_next) {
- if (strcmp(new_chkpnt_vol->cv_vol_name, vol_name) == 0) {
- new_chkpnt_vol->cv_count--;
-
- if (new_chkpnt_vol->cv_count == 0) {
- if (pre_chkpnt_vol == new_chkpnt_vol &&
- new_chkpnt_vol->cv_next == NULL)
- chkpnt_vols = NULL;
- else if (pre_chkpnt_vol == new_chkpnt_vol)
- chkpnt_vols = new_chkpnt_vol->cv_next;
- else
- pre_chkpnt_vol->cv_next =
- new_chkpnt_vol->cv_next;
-
- free(new_chkpnt_vol);
- return (0);
- }
- return (new_chkpnt_vol->cv_count);
- }
- if (new_chkpnt_vol != chkpnt_vols)
- pre_chkpnt_vol = pre_chkpnt_vol->cv_next;
+ char vol[ZFS_MAXNAMELEN];
+
+ if (vol_name == 0 ||
+ get_zfsvolname(vol, sizeof (vol), vol_name) == -1)
+ return (0);
+
+ return (snapshot_destroy(vol, jname, B_FALSE, B_TRUE, NULL));
+}
+
+/*
+ * Put a hold on snapshot
+ */
+int
+snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
+{
+ zfs_handle_t *zhp;
+ char *p;
+
+ if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
+ NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
+ return (-1);
}
+ if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
+ O_RDWR|O_EXCL)) < 0) {
+ NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
+ zfs_close(zhp);
+ return (-1);
+ }
+
+ p = strchr(snapname, '@') + 1;
+ if (zfs_hold(zhp, p, jname, recursive, B_TRUE, B_FALSE,
+ cleanup_fd, 0, 0) != 0) {
+ NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
+ zfs_close(zhp);
+ return (-1);
+ }
+ zfs_close(zhp);
return (0);
}
+int
+snapshot_release(char *volname, char *snapname, char *jname,
+ boolean_t recursive)
+{
+ zfs_handle_t *zhp;
+ char *p;
+ int rv = 0;
+ if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
+ NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
+ return (-1);
+ }
+ p = strchr(snapname, '@') + 1;
+ if (zfs_release(zhp, p, jname, recursive) != 0) {
+ NDMP_LOG(LOG_DEBUG, "Cannot release snapshot %s", p);
+ rv = -1;
+ }
+ if (cleanup_fd != -1) {
+ (void) close(cleanup_fd);
+ cleanup_fd = -1;
+ }
+ zfs_close(zhp);
+ return (rv);
+}
/*
- * ndmp_start_check_point
- *
- * This function will parse the path, vol_name, to get the real volume name.
- * It will then check via ndmp_add_chk_pnt_vol to see if creating a check point
- * for the volume is necessary. If it is, a checkpoint is created.
- * This function should be called before the NDMP backup is started.
- *
- * Parameters:
- * vol_name (input) - name of the volume
- *
- * Returns:
- * 0: on success
- * -1: otherwise
+ * Create a snapshot on the volume
*/
int
-ndmp_start_check_point(char *vol_name, char *jname)
+snapshot_create(char *volname, char *jname, boolean_t recursive,
+ boolean_t hold)
{
- int erc = 0;
- char vol[ZFS_MAXNAMELEN];
+ char snapname[ZFS_MAXNAMELEN];
+ int rv;
- if (vol_name == 0 ||
- get_zfsvolname(vol, sizeof (vol), vol_name) == -1)
- return (0);
+ if (!volname || !*volname)
+ return (-1);
- if (ndmp_add_chk_pnt_vol(vol) > 0) {
- /*
- * If there is an old checkpoint left from the previous
- * backup and the reference count of backup checkpoint of
- * the volume is 1 after increasing it, it shows that the
- * checkpoint on file system is a stale one and it must be
- * removed before using it.
- */
- if (ndmp_has_backup_chkpnt(vol, jname))
- (void) chkpnt_backup_successful(vol, jname, B_FALSE,
- NULL);
- if ((erc = chkpnt_backup_prepare(vol, jname, B_FALSE))
- < 0)
- (void) ndmp_remove_chk_pnt_vol(vol);
+ (void) snprintf(snapname, ZFS_MAXNAMELEN, "%s@%s", volname, jname);
+
+ (void) mutex_lock(&zlib_mtx);
+ if ((rv = zfs_snapshot(zlibh, snapname, recursive, NULL))
+ == -1) {
+ if (errno == EEXIST) {
+ (void) mutex_unlock(&zlib_mtx);
+ return (0);
+ }
+ NDMP_LOG(LOG_DEBUG,
+ "snapshot_create: %s failed (err=%d): %s",
+ snapname, errno, libzfs_error_description(zlibh));
+ (void) mutex_unlock(&zlib_mtx);
+ return (rv);
+ }
+ if (hold && snapshot_hold(volname, snapname, jname, recursive) != 0) {
+ NDMP_LOG(LOG_DEBUG,
+ "snapshot_create: %s hold failed (err=%d): %s",
+ snapname, errno, libzfs_error_description(zlibh));
+ (void) mutex_unlock(&zlib_mtx);
+ return (-1);
}
- return (erc);
+ (void) mutex_unlock(&zlib_mtx);
+ return (0);
}
/*
- * ndmp_release_check_point
- *
- * This function will parse the path, vol_name, to get the real volume name.
- * It will then check via ndmp_remove_chk_pnt_vol to see if removing a check
- * point for the volume is necessary. If it is, a checkpoint is removed.
- * This function should be called after NDMP backup is finished.
- *
- * Parameters:
- * vol_name (input) - name of the volume
- *
- * Returns:
- * 0: on success
- * -1: otherwise
+ * Remove and release the backup snapshot
*/
int
-ndmp_release_check_point(char *vol_name, char *jname)
+snapshot_destroy(char *volname, char *jname, boolean_t recursive,
+ boolean_t hold, int *zfs_err)
{
- int erc = 0;
- char vol[ZFS_MAXNAMELEN];
+ char snapname[ZFS_MAXNAMELEN];
+ zfs_handle_t *zhp;
+ zfs_type_t ztype;
+ int err;
- if (vol_name == 0 ||
- get_zfsvolname(vol, sizeof (vol), vol_name))
- return (0);
+ if (zfs_err)
+ *zfs_err = 0;
+
+ if (!volname || !*volname)
+ return (-1);
+
+ if (recursive) {
+ ztype = ZFS_TYPE_VOLUME | ZFS_TYPE_FILESYSTEM;
+ } else {
+ (void) snprintf(snapname, ZFS_MAXNAMELEN, "%s@%s", volname,
+ jname);
+ ztype = ZFS_TYPE_SNAPSHOT;
+ }
+
+ (void) mutex_lock(&zlib_mtx);
+ if (hold &&
+ snapshot_release(volname, snapname, jname, recursive) != 0) {
+ NDMP_LOG(LOG_DEBUG,
+ "snapshot_destroy: %s release failed (err=%d): %s",
+ snapname, errno, libzfs_error_description(zlibh));
+ (void) mutex_unlock(&zlib_mtx);
+ return (-1);
+ }
+
+ if ((zhp = zfs_open(zlibh, snapname, ztype)) == NULL) {
+ NDMP_LOG(LOG_DEBUG, "snapshot_destroy: open %s failed",
+ snapname);
+ (void) mutex_unlock(&zlib_mtx);
+ return (-1);
+ }
+
+ if (recursive) {
+ err = zfs_destroy_snaps(zhp, jname, B_TRUE);
+ } else {
+ err = zfs_destroy(zhp, B_TRUE);
+ }
+
+ if (err) {
+ NDMP_LOG(LOG_ERR, "%s (recursive destroy: %d): %d; %s; %s",
+ snapname,
+ recursive,
+ libzfs_errno(zlibh),
+ libzfs_error_action(zlibh),
+ libzfs_error_description(zlibh));
- if (ndmp_remove_chk_pnt_vol(vol) == 0)
- erc = chkpnt_backup_successful(vol, jname, B_FALSE, NULL);
+ if (zfs_err)
+ *zfs_err = err;
+ }
- return (erc);
+ zfs_close(zhp);
+ (void) mutex_unlock(&zlib_mtx);
+
+ return (0);
}
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar.c
index ac71943834..c9dcf33343 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar.c
@@ -1601,11 +1601,6 @@ check_backup_dir_validity(ndmpd_module_params_t *params, char *bkpath)
} else if (!S_ISDIR(st.st_mode)) {
MOD_LOG(params, "Error: %s is not a directory.\n", bkpath);
rv = NDMP_ILLEGAL_ARGS_ERR;
- } else if (ndmp_is_chkpnt_root(bkpath)) {
- /* It's a .chkpnt directory */
- MOD_LOG(params, "Error: %s is a checkpoint root directory.\n",
- bkpath);
- rv = NDMP_BAD_FILE_ERR;
} else if (fs_is_rdonly(bkpath) && !fs_is_chkpntvol(bkpath) &&
fs_is_chkpnt_enabled(bkpath)) {
MOD_LOG(params, "Error: %s is not a checkpointed path.\n",
@@ -1882,7 +1877,7 @@ ndmpd_tar_backup_starter(void *arg)
NLP_SET(nlp, NLPF_CHKPNTED_PATH);
else {
NLP_UNSET(nlp, NLPF_CHKPNTED_PATH);
- if (ndmp_start_check_point(nlp->nlp_backup_path,
+ if (ndmp_create_snapshot(nlp->nlp_backup_path,
nlp->nlp_jstat->js_job_name) < 0) {
MOD_LOG(mod_params,
"Error: creating checkpoint on %s\n",
@@ -1914,7 +1909,7 @@ ndmpd_tar_backup_starter(void *arg)
}
if (!NLP_ISCHKPNTED(nlp))
- (void) ndmp_release_check_point(nlp->nlp_backup_path,
+ (void) ndmp_remove_snapshot(nlp->nlp_backup_path,
nlp->nlp_jstat->js_job_name);
NDMP_LOG(LOG_DEBUG, "err %d, update %c",
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
index 19b3e0ef2d..92d2fcaf09 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
@@ -668,12 +668,6 @@ is_valid_backup_dir_v3(ndmpd_module_params_t *params, char *bkpath)
"\"%s\" is not a directory.\n", bkpath);
return (FALSE);
}
- if (ndmp_is_chkpnt_root(bkpath)) {
- /* it is the chkpnt root directory */
- MOD_LOGV3(params, NDMP_LOG_ERROR,
- "\"%s\" is a checkpoint root directory.\n", bkpath);
- return (FALSE);
- }
if (fs_is_rdonly(bkpath) && !fs_is_chkpntvol(bkpath) &&
fs_is_chkpnt_enabled(bkpath)) {
/* it is not a chkpnted path */
@@ -2312,7 +2306,7 @@ backup_reader_v3(backup_reader_arg_t *argp)
}
ft.ft_arg = &bp;
ft.ft_logfp = (ft_log_t)ndmp_log;
- ft.ft_flags = FST_VERBOSE; /* Solaris */
+ ft.ft_flags = FST_VERBOSE | FST_STOP_ONERR;
/* take into account the header written to the stream so far */
n = tlm_get_data_offset(lcmd);
@@ -2328,6 +2322,11 @@ backup_reader_v3(backup_reader_arg_t *argp)
n = tlm_get_data_offset(lcmd) - bpos;
nlp->nlp_session->
ns_data.dd_module.dm_stats.ms_bytes_processed += n;
+ } else {
+ MOD_LOGV3(nlp->nlp_params, NDMP_LOG_ERROR,
+ "Filesystem traverse error.\n");
+ ndmpd_data_error(nlp->nlp_session,
+ NDMP_DATA_HALT_INTERNAL_ERROR);
}
}
@@ -3755,7 +3754,7 @@ ndmpd_tar_backup_starter_v3(void *arg)
err = 0;
if (!NLP_ISCHKPNTED(nlp) &&
- ndmp_start_check_point(nlp->nlp_backup_path, jname) < 0) {
+ ndmp_create_snapshot(nlp->nlp_backup_path, jname) < 0) {
MOD_LOGV3(params, NDMP_LOG_ERROR,
"Creating checkpoint on \"%s\".\n",
nlp->nlp_backup_path);
@@ -3785,7 +3784,7 @@ ndmpd_tar_backup_starter_v3(void *arg)
}
if (!NLP_ISCHKPNTED(nlp))
- (void) ndmp_release_check_point(nlp->nlp_backup_path, jname);
+ (void) ndmp_remove_snapshot(nlp->nlp_backup_path, jname);
NDMP_LOG(LOG_DEBUG, "err %d, update %c",
err, NDMP_YORN(NLP_SHOULD_UPDATE(nlp)));
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
index 7f231ece16..68b50ae2fd 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
@@ -129,9 +129,6 @@ static void ndmpd_zfs_zerr_dma_log(ndmpd_zfs_args_t *);
static int ndmpd_zfs_backup(ndmpd_zfs_args_t *);
-#define snapshot_create chkpnt_backup_prepare
-#define snapshot_destroy chkpnt_backup_successful
-
/*
* Syntax for com.sun.ndmp:incr property value:
* #.#.n|u/$LEVEL.$DMP_NAME.$ZFS_MODE(/ ...)
@@ -1739,7 +1736,8 @@ ndmpd_zfs_snapshot_prepare(ndmpd_zfs_args_t *ndmpd_zfs_args)
recursive = B_TRUE;
(void) snapshot_destroy(ndmpd_zfs_args->nz_dataset,
- ndmpd_zfs_args->nz_snapname, recursive, &zfs_err);
+ ndmpd_zfs_args->nz_snapname, recursive, B_FALSE,
+ &zfs_err);
}
return (-1);
@@ -1847,7 +1845,7 @@ ndmpd_zfs_snapshot_create(ndmpd_zfs_args_t *ndmpd_zfs_args)
recursive = B_TRUE;
if (snapshot_create(ndmpd_zfs_args->nz_dataset,
- ndmpd_zfs_args->nz_snapname, recursive) != 0) {
+ ndmpd_zfs_args->nz_snapname, recursive, B_FALSE) != 0) {
NDMP_LOG(LOG_ERR, "could not create snapshot %s@%s",
ndmpd_zfs_args->nz_dataset, ndmpd_zfs_args->nz_snapname);
return (-1);
@@ -1886,7 +1884,7 @@ ndmpd_zfs_snapshot_unuse(ndmpd_zfs_args_t *ndmpd_zfs_args,
recursive = B_TRUE;
err = snapshot_destroy(ndmpd_zfs_args->nz_dataset,
- snapdata_p->nzs_snapname, recursive, &zfs_err);
+ snapdata_p->nzs_snapname, recursive, B_FALSE, &zfs_err);
if (err) {
NDMP_LOG(LOG_ERR, "snapshot_destroy: %s@%s;"
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_lib.c b/usr/src/cmd/ndmpd/tlm/tlm_lib.c
index 14801cb75e..ec9ee5f225 100644
--- a/usr/src/cmd/ndmpd/tlm/tlm_lib.c
+++ b/usr/src/cmd/ndmpd/tlm/tlm_lib.c
@@ -1170,111 +1170,6 @@ tlm_ioctl(int fd, int cmd, void *data)
*/
/*
- * Create a snapshot on the volume
- */
-int
-chkpnt_backup_prepare(char *volname, char *jname, boolean_t recursive)
-{
- char chk_name[PATH_MAX];
- char *p;
- int rv;
-
- if (!volname || !*volname)
- return (-1);
-
- /* Should also return -1 if checkpoint not enabled */
-
- /* Remove the leading slash */
- p = volname;
- while (*p == '/')
- p++;
-
- (void) snprintf(chk_name, PATH_MAX, "%s@%s", p, jname);
-
- (void) mutex_lock(&zlib_mtx);
- if ((rv = zfs_snapshot(zlibh, chk_name, recursive, NULL))
- == -1) {
- if (errno == EEXIST) {
- (void) mutex_unlock(&zlib_mtx);
- return (0);
- }
- NDMP_LOG(LOG_DEBUG,
- "chkpnt_backup_prepare: %s failed (err=%d): %s",
- chk_name, errno, libzfs_error_description(zlibh));
- (void) mutex_unlock(&zlib_mtx);
- return (rv);
- }
- (void) mutex_unlock(&zlib_mtx);
- return (0);
-}
-
-/*
- * Remove the 'backup' snapshot if backup was successful
- */
-int
-chkpnt_backup_successful(char *volname, char *jname, boolean_t recursive,
- int *zfs_err)
-{
- char chk_name[PATH_MAX];
- zfs_handle_t *zhp;
- zfs_type_t ztype;
- int err;
- char *p;
-
- if (zfs_err)
- *zfs_err = 0;
-
- if (!volname || !*volname)
- return (-1);
-
- /* Should also return -1 if checkpoint not enabled */
-
- /* Remove the leading slash */
- p = volname;
- while (*p == '/')
- p++;
-
- if (recursive) {
- ztype = ZFS_TYPE_VOLUME | ZFS_TYPE_FILESYSTEM;
- } else {
- (void) snprintf(chk_name, PATH_MAX, "%s@%s", p, jname);
- p = chk_name;
- ztype = ZFS_TYPE_SNAPSHOT;
- }
-
- (void) mutex_lock(&zlib_mtx);
- if ((zhp = zfs_open(zlibh, p, ztype)) == NULL) {
- NDMP_LOG(LOG_DEBUG, "chkpnt_backup_successful: open %s failed",
- p);
- (void) mutex_unlock(&zlib_mtx);
- return (-1);
- }
-
- if (recursive) {
- err = zfs_destroy_snaps(zhp, jname, B_TRUE);
- } else {
- err = zfs_destroy(zhp, B_TRUE);
- }
-
- if (err) {
- NDMP_LOG(LOG_ERR, "%s (recursive destroy: %d): %d; %s; %s",
- p,
- recursive,
- libzfs_errno(zlibh),
- libzfs_error_action(zlibh),
- libzfs_error_description(zlibh));
-
- if (zfs_err)
- *zfs_err = err;
- }
-
- zfs_close(zhp);
- (void) mutex_unlock(&zlib_mtx);
-
- return (0);
-}
-
-/*
* Get the snapshot creation time
*/
int
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_proto.h b/usr/src/cmd/ndmpd/tlm/tlm_proto.h
index 4551eb26be..f37f206e6e 100644
--- a/usr/src/cmd/ndmpd/tlm/tlm_proto.h
+++ b/usr/src/cmd/ndmpd/tlm/tlm_proto.h
@@ -1,6 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -106,8 +105,6 @@ extern int tlm_library_count(void);
extern boolean_t fs_is_rdonly(char *);
extern boolean_t fs_is_chkpntvol();
-extern int chkpnt_backup_successful();
-extern int chkpnt_backup_prepare();
extern int get_zfsvolname(char *, int, char *);
extern int chkpnt_creationtime_bypattern();