ndmpd_chkpnt.c revision 3b2aab18808792cbd248a12f1edf139b89833c13
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
* BSD 3 Clause License
*
* Copyright (c) 2007, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* - Neither the name of The Storage Networking Industry Association (SNIA)
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include "ndmpd.h"
#include <libzfs.h>
typedef struct snap_param {
char *snp_name;
} snap_param_t;
static int cleanup_fd = -1;
/*
* ndmp_has_backup
*
* Call backup function which looks for backup snapshot.
* This is a callback function used with zfs_iter_snapshots.
*
* Parameters:
* zhp (input) - ZFS handle pointer
* data (output) - 0 - no backup snapshot
* 1 - has backup snapshot
*
* Returns:
* 0: on success
* -1: otherwise
*/
static int
{
const char *name;
return (-1);
}
return (0);
}
/*
* ndmp_has_backup_snapshot
*
* Returns TRUE if the volume has an active backup snapshot, otherwise,
* returns FALSE.
*
* Parameters:
* volname (input) - name of the volume
*
* Returns:
* 0: on success
* -1: otherwise
*/
static int
{
char chname[ZFS_MAXNAMELEN];
(void) mutex_lock(&zlib_mtx);
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
(void) mutex_unlock(&zlib_mtx);
}
/*
* ndmp_create_snapshot
*
* 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:
* 0: on success
* -1: otherwise
*/
int
{
char vol[ZFS_MAXNAMELEN];
if (vol_name == 0 ||
return (0);
/*
* If there is an old snapshot left from the previous
* backup it could be stale one and it must be
* removed before using it.
*/
}
/*
* ndmp_remove_snapshot
*
* 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:
* 0: on success
* -1: otherwise
*/
int
{
char vol[ZFS_MAXNAMELEN];
if (vol_name == 0 ||
return (0);
}
/*
* Put a hold on snapshot
*/
int
{
char *p;
return (-1);
}
return (-1);
}
return (-1);
}
return (0);
}
int
{
char *p;
int rv = 0;
return (-1);
}
rv = -1;
}
if (cleanup_fd != -1) {
(void) close(cleanup_fd);
cleanup_fd = -1;
}
return (rv);
}
/*
* Create a snapshot on the volume
*/
int
{
char snapname[ZFS_MAXNAMELEN];
int rv;
return (-1);
(void) mutex_lock(&zlib_mtx);
== -1) {
(void) mutex_unlock(&zlib_mtx);
return (0);
}
"snapshot_create: %s failed (err=%d): %s",
(void) mutex_unlock(&zlib_mtx);
return (rv);
}
"snapshot_create: %s hold failed (err=%d): %s",
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
(void) mutex_unlock(&zlib_mtx);
return (0);
}
/*
* Remove and release the backup snapshot
*/
int
{
char snapname[ZFS_MAXNAMELEN];
char *namep;
int err;
if (zfs_err)
*zfs_err = 0;
return (-1);
if (recursive) {
} else {
jname);
}
(void) mutex_lock(&zlib_mtx);
if (hold &&
"snapshot_destroy: %s release failed (err=%d): %s",
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
namep);
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
if (recursive) {
} else {
}
if (err) {
if (zfs_err)
}
(void) mutex_unlock(&zlib_mtx);
return (0);
}