dsl_userhold.c revision c1379625401dfbe1c39b79136dd384a571d47fde
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/
#include <sys/zfs_context.h>
#include <sys/dsl_userhold.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_destroy.h>
#include <sys/dsl_synctask.h>
#include <sys/zfs_onexit.h>
#include <sys/dsl_pool.h>
#include <sys/zfs_ioctl.h>
typedef struct dsl_dataset_user_hold_arg {
/*
* If you add new checks here, you may need to add additional checks to the
* "temporary" case in snapshot_check() in dmu_objset.c.
*/
int
{
int error = 0;
/* Tempholds have a more restricted length */
/* tags must be unique (if ds already exists) */
if (error == 0)
error = 0;
}
return (error);
}
static int
{
if (!dmu_tx_is_syncing(tx))
return (0);
int error = 0;
/* must be a snapshot */
if (error == 0)
if (error == 0)
if (error == 0) {
}
if (error == 0) {
} else {
/*
* We register ENOENT errors so they can be correctly
* reported if needed, such as when all holds fail.
*/
return (error);
}
}
return (0);
}
static void
{
/*
* This is the first user hold for this dataset. Create
* the userrefs zap object.
*/
} else {
}
ds->ds_userrefs++;
if (minor != 0) {
char name[MAXNAMELEN];
tags = fnvlist_alloc();
} else {
}
}
"tag=%s temp=%d refs=%llu",
}
typedef struct zfs_hold_cleanup_arg {
char zhca_spaname[MAXNAMELEN];
static void
{
int error;
if (error != 0) {
zfs_dbgmsg("couldn't release holds on pool=%s "
"because pool is no longer loaded",
ca->zhca_spaname);
return;
}
zfs_dbgmsg("couldn't release holds on pool=%s "
"because pool is no longer loaded (guid doesn't match)",
ca->zhca_spaname);
return;
}
}
static void
{
return;
}
sizeof (ca->zhca_spaname));
}
void
{
if (minor != 0)
tmpholds = fnvlist_alloc();
else
}
static void
{
if (dduha->dduha_minor != 0)
tmpholds = fnvlist_alloc();
else
}
}
/*
* The full semantics of this function are described in the comment above
* lzc_hold().
*
* To summarize:
* holds is nvl of snapname -> holdname
* errlist will be filled in with snapname -> error
*
* The snaphosts must all be in the same pool.
*
* Holds for snapshots that don't exist will be skipped.
*
* If none of the snapshots for requested holds exist then ENOENT will be
* returned.
*
* If cleanup_minor is not 0, the holds will be temporary, which will be cleaned
* up when the process exits.
*
* On success all the holds, for snapshots that existed, will be created and 0
* will be returned.
*
* On failure no holds will be created, the errlist will be filled in,
* and an errno will returned.
*
* In all cases the errlist will contain entries for holds where the snapshot
* didn't exist.
*/
int
{
int ret;
return (0);
return (ret);
}
dsl_dataset_t **dsp);
typedef struct dsl_dataset_user_release_arg {
/* Place a dataset hold on the snapshot identified by passed dsobj string */
static int
dsl_dataset_t **dsp)
{
}
static int
{
int numholds;
if (!dsl_dataset_is_snapshot(ds))
if (nvlist_empty(holds))
return (0);
numholds = 0;
holds_found = fnvlist_alloc();
int error;
if (zapobj != 0)
else
/*
* Non-existent holds are put on the errlist, but don't
* cause an overall failure.
*/
ENOENT);
}
continue;
}
if (error != 0) {
return (error);
}
numholds++;
}
if (DS_IS_DEFER_DESTROY(ds) &&
/* we need to destroy the snapshot as well */
if (dsl_dataset_long_held(ds)) {
}
}
if (numholds != 0) {
}
return (0);
}
static int
{
dsl_pool_t *dp;
if (!dmu_tx_is_syncing(tx))
return (0);
int error;
if (error != 0)
else
if (error == 0) {
}
if (error != 0) {
}
/*
* Non-existent snapshots are put on the errlist,
* but don't cause an overall failure.
*/
return (error);
}
}
return (0);
}
static void
{
int error;
/* Remove temporary hold if one exists. */
ds->ds_userrefs--;
}
}
static void
{
pair)) {
}
}
}
/*
* The full semantics of this function are described in the comment above
* lzc_release().
*
* To summarize:
* Releases holds specified in the nvl holds.
*
* holds is nvl of snapname -> { holdname, ... }
* errlist will be filled in with snapname -> error
*
* If tmpdp is not NULL the names for holds should be the dsobj's of snapshots,
* otherwise they should be the names of shapshots.
*
* As a release may cause snapshots to be destroyed this trys to ensure they
* aren't mounted.
*
* The release of non-existent holds are skipped.
*
* At least one hold must have been released for the this function to succeed
* and return 0.
*/
static int
{
char *pool;
int error;
return (0);
/*
* The release may cause snapshots to be destroyed; make sure they
* are not mounted.
*/
/* Temporary holds are specified by dsobj string. */
#ifdef _KERNEL
if (error == 0) {
char name[MAXNAMELEN];
(void) zfs_unmount_snap(name);
} else {
}
}
#endif
} else {
/* Non-temporary holds are specified by name. */
#ifdef _KERNEL
}
#endif
}
return (error);
}
/*
* holds is nvl of snapname -> { holdname, ... }
* errlist will be filled in with snapname -> error
*/
int
{
}
/*
* holds is nvl of snapdsobj -> { holdname, ... }
*/
void
{
}
int
{
dsl_pool_t *dp;
int err;
if (err != 0)
return (err);
if (err != 0) {
return (err);
}
zap_cursor_advance(&zc)) {
}
}
return (0);
}