mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Illumos #3464
3464 zfs synctask code needs restructuring Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Approved by: Garrett D'Amore <garrett@damore.org> References: https://www.illumos.org/issues/3464 illumos/illumos-gate@3b2aab1880 Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1495
This commit is contained in:
committed by
Brian Behlendorf
parent
6f1ffb0665
commit
13fe019870
@@ -106,7 +106,7 @@ namespace_reload(libzfs_handle_t *hdl)
|
||||
nvlist_t *config;
|
||||
config_node_t *cn;
|
||||
nvpair_t *elem;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
void *cookie;
|
||||
|
||||
if (hdl->libzfs_ns_gen == 0) {
|
||||
@@ -261,7 +261,7 @@ zpool_get_features(zpool_handle_t *zhp)
|
||||
int
|
||||
zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error;
|
||||
nvlist_t *config;
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
+214
-142
@@ -313,7 +313,7 @@ get_recvd_props_ioctl(zfs_handle_t *zhp)
|
||||
{
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
nvlist_t *recvdprops;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int err;
|
||||
|
||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
|
||||
@@ -376,7 +376,7 @@ static int
|
||||
get_stats(zfs_handle_t *zhp)
|
||||
{
|
||||
int rc = 0;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
|
||||
return (-1);
|
||||
@@ -439,7 +439,7 @@ make_dataset_handle_common(zfs_handle_t *zhp, zfs_cmd_t *zc)
|
||||
zfs_handle_t *
|
||||
make_dataset_handle(libzfs_handle_t *hdl, const char *path)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
||||
|
||||
@@ -1427,7 +1427,7 @@ zfs_is_namespace_prop(zfs_prop_t prop)
|
||||
int
|
||||
zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int ret = -1;
|
||||
prop_changelist_t *cl = NULL;
|
||||
char errbuf[1024];
|
||||
@@ -1553,7 +1553,7 @@ error:
|
||||
int
|
||||
zfs_prop_inherit(zfs_handle_t *zhp, const char *propname, boolean_t received)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int ret;
|
||||
prop_changelist_t *cl;
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
@@ -1728,7 +1728,7 @@ static int
|
||||
get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||
char **source, uint64_t *val)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *zplprops = NULL;
|
||||
struct mnttab mnt;
|
||||
char *mntopt_on = NULL;
|
||||
@@ -2002,10 +2002,7 @@ get_clones_cb(zfs_handle_t *zhp, void *arg)
|
||||
NULL, NULL, 0, B_TRUE) != 0)
|
||||
goto out;
|
||||
if (strcmp(gca->buf, gca->origin) == 0) {
|
||||
if (nvlist_add_boolean(gca->value, zfs_get_name(zhp)) != 0) {
|
||||
zfs_close(zhp);
|
||||
return (no_memory(zhp->zfs_hdl));
|
||||
}
|
||||
fnvlist_add_boolean(gca->value, zfs_get_name(zhp));
|
||||
gca->numclones--;
|
||||
}
|
||||
|
||||
@@ -2580,7 +2577,7 @@ zfs_prop_get_userquota_common(zfs_handle_t *zhp, const char *propname,
|
||||
uint64_t *propvalue, zfs_userquota_prop_t *typep)
|
||||
{
|
||||
int err;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||
|
||||
@@ -2640,7 +2637,7 @@ zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
|
||||
uint64_t *propvalue)
|
||||
{
|
||||
int err;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
const char *snapname;
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||
@@ -2760,7 +2757,7 @@ static int
|
||||
check_parents(libzfs_handle_t *hdl, const char *path, uint64_t *zoned,
|
||||
boolean_t accept_ancestor, int *prefixlen)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char parent[ZFS_MAXNAMELEN];
|
||||
char *slash;
|
||||
zfs_handle_t *zhp;
|
||||
@@ -3120,7 +3117,7 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
|
||||
int
|
||||
zfs_destroy(zfs_handle_t *zhp, boolean_t defer)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||
|
||||
@@ -3200,46 +3197,50 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname, boolean_t defer)
|
||||
dgettext(TEXT_DOMAIN, "cannot destroy '%s@%s'"),
|
||||
zhp->zfs_name, snapname);
|
||||
} else {
|
||||
ret = zfs_destroy_snaps_nvl(zhp, dd.nvl, defer);
|
||||
ret = zfs_destroy_snaps_nvl(zhp->zfs_hdl, dd.nvl, defer);
|
||||
}
|
||||
nvlist_free(dd.nvl);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys all the snapshots named in the nvlist. They must be underneath
|
||||
* the zhp (either snapshots of it, or snapshots of its descendants).
|
||||
* Destroys all the snapshots named in the nvlist.
|
||||
*/
|
||||
int
|
||||
zfs_destroy_snaps_nvl(zfs_handle_t *zhp, nvlist_t *snaps, boolean_t defer)
|
||||
zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
|
||||
{
|
||||
int ret;
|
||||
nvlist_t *errlist;
|
||||
nvpair_t *pair;
|
||||
|
||||
ret = lzc_destroy_snaps(snaps, defer, &errlist);
|
||||
|
||||
if (ret != 0) {
|
||||
nvpair_t *pair;
|
||||
for (pair = nvlist_next_nvpair(errlist, NULL);
|
||||
pair != NULL; pair = nvlist_next_nvpair(errlist, pair)) {
|
||||
char errbuf[1024];
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot destroy snapshot %s"),
|
||||
nvpair_name(pair));
|
||||
if (ret == 0)
|
||||
return (0);
|
||||
|
||||
switch (fnvpair_value_int32(pair)) {
|
||||
case EEXIST:
|
||||
zfs_error_aux(zhp->zfs_hdl,
|
||||
dgettext(TEXT_DOMAIN,
|
||||
"snapshot is cloned"));
|
||||
ret = zfs_error(zhp->zfs_hdl, EZFS_EXISTS,
|
||||
errbuf);
|
||||
break;
|
||||
default:
|
||||
ret = zfs_standard_error(zhp->zfs_hdl, errno,
|
||||
errbuf);
|
||||
break;
|
||||
}
|
||||
if (nvlist_next_nvpair(errlist, NULL) == NULL) {
|
||||
char errbuf[1024];
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot destroy snapshots"));
|
||||
|
||||
ret = zfs_standard_error(hdl, ret, errbuf);
|
||||
}
|
||||
for (pair = nvlist_next_nvpair(errlist, NULL);
|
||||
pair != NULL; pair = nvlist_next_nvpair(errlist, pair)) {
|
||||
char errbuf[1024];
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot destroy snapshot %s"),
|
||||
nvpair_name(pair));
|
||||
|
||||
switch (fnvpair_value_int32(pair)) {
|
||||
case EEXIST:
|
||||
zfs_error_aux(hdl,
|
||||
dgettext(TEXT_DOMAIN, "snapshot is cloned"));
|
||||
ret = zfs_error(hdl, EZFS_EXISTS, errbuf);
|
||||
break;
|
||||
default:
|
||||
ret = zfs_standard_error(hdl, errno, errbuf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3388,7 +3389,7 @@ int
|
||||
zfs_promote(zfs_handle_t *zhp)
|
||||
{
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char parent[MAXPATHLEN];
|
||||
char *cp;
|
||||
int ret;
|
||||
@@ -3726,7 +3727,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
|
||||
{
|
||||
rollback_data_t cb = { 0 };
|
||||
int err;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
boolean_t restore_resv = 0;
|
||||
uint64_t old_volsize = 0, new_volsize;
|
||||
zfs_prop_t resv_prop = { 0 };
|
||||
@@ -3813,7 +3814,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
|
||||
boolean_t force_unmount)
|
||||
{
|
||||
int ret;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char *delim;
|
||||
prop_changelist_t *cl = NULL;
|
||||
zfs_handle_t *zhrp = NULL;
|
||||
@@ -4032,7 +4033,7 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset)
|
||||
static int
|
||||
zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char path[MAXPATHLEN];
|
||||
int error;
|
||||
|
||||
@@ -4096,7 +4097,7 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
|
||||
int
|
||||
zvol_remove_link(libzfs_handle_t *hdl, const char *dataset)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int timeout = 3000; /* in milliseconds */
|
||||
int error = 0;
|
||||
int i;
|
||||
@@ -4289,7 +4290,7 @@ static int
|
||||
zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
|
||||
zfs_smb_acl_op_t cmd, char *resource1, char *resource2)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *nvlist = NULL;
|
||||
int error;
|
||||
|
||||
@@ -4371,7 +4372,7 @@ int
|
||||
zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
|
||||
zfs_userspace_cb_t func, void *arg)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_useracct_t buf[100];
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
int ret;
|
||||
@@ -4408,37 +4409,83 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct holdarg {
|
||||
nvlist_t *nvl;
|
||||
const char *snapname;
|
||||
const char *tag;
|
||||
boolean_t recursive;
|
||||
};
|
||||
|
||||
static int
|
||||
zfs_hold_one(zfs_handle_t *zhp, void *arg)
|
||||
{
|
||||
struct holdarg *ha = arg;
|
||||
zfs_handle_t *szhp;
|
||||
char name[ZFS_MAXNAMELEN];
|
||||
int rv = 0;
|
||||
|
||||
(void) snprintf(name, sizeof (name),
|
||||
"%s@%s", zhp->zfs_name, ha->snapname);
|
||||
|
||||
szhp = make_dataset_handle(zhp->zfs_hdl, name);
|
||||
if (szhp) {
|
||||
fnvlist_add_string(ha->nvl, name, ha->tag);
|
||||
zfs_close(szhp);
|
||||
}
|
||||
|
||||
if (ha->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, zfs_hold_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
int
|
||||
zfs_hold(zfs_handle_t *zhp, const char *snapname, const char *tag,
|
||||
boolean_t recursive, boolean_t temphold, boolean_t enoent_ok,
|
||||
int cleanup_fd, uint64_t dsobj, uint64_t createtxg)
|
||||
boolean_t recursive, boolean_t enoent_ok, int cleanup_fd)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
int ret;
|
||||
struct holdarg ha;
|
||||
nvlist_t *errors;
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
char errbuf[1024];
|
||||
nvpair_t *elem;
|
||||
|
||||
ASSERT(!recursive || dsobj == 0);
|
||||
ha.nvl = fnvlist_alloc();
|
||||
ha.snapname = snapname;
|
||||
ha.tag = tag;
|
||||
ha.recursive = recursive;
|
||||
(void) zfs_hold_one(zfs_handle_dup(zhp), &ha);
|
||||
ret = lzc_hold(ha.nvl, cleanup_fd, &errors);
|
||||
fnvlist_free(ha.nvl);
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||
(void) strlcpy(zc.zc_value, snapname, sizeof (zc.zc_value));
|
||||
if (strlcpy(zc.zc_string, tag, sizeof (zc.zc_string))
|
||||
>= sizeof (zc.zc_string))
|
||||
return (zfs_error(hdl, EZFS_TAGTOOLONG, tag));
|
||||
zc.zc_cookie = recursive;
|
||||
zc.zc_temphold = temphold;
|
||||
zc.zc_cleanup_fd = cleanup_fd;
|
||||
zc.zc_sendobj = dsobj;
|
||||
zc.zc_createtxg = createtxg;
|
||||
if (ret == 0)
|
||||
return (0);
|
||||
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_HOLD, &zc) != 0) {
|
||||
char errbuf[ZFS_MAXNAMELEN+32];
|
||||
if (nvlist_next_nvpair(errors, NULL) == NULL) {
|
||||
/* no hold-specific errors */
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot hold"));
|
||||
switch (ret) {
|
||||
case ENOTSUP:
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"pool must be upgraded"));
|
||||
(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
|
||||
break;
|
||||
case EINVAL:
|
||||
(void) zfs_error(hdl, EZFS_BADTYPE, errbuf);
|
||||
break;
|
||||
default:
|
||||
(void) zfs_standard_error(hdl, ret, errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if it was recursive, the one that actually failed will be in
|
||||
* zc.zc_name.
|
||||
*/
|
||||
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
|
||||
"cannot hold '%s@%s'"), zc.zc_name, snapname);
|
||||
switch (errno) {
|
||||
for (elem = nvlist_next_nvpair(errors, NULL);
|
||||
elem != NULL;
|
||||
elem = nvlist_next_nvpair(errors, elem)) {
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN,
|
||||
"cannot hold snapshot '%s'"), nvpair_name(elem));
|
||||
switch (fnvpair_value_int32(elem)) {
|
||||
case E2BIG:
|
||||
/*
|
||||
* Temporary tags wind up having the ds object id
|
||||
@@ -4446,77 +4493,133 @@ zfs_hold(zfs_handle_t *zhp, const char *snapname, const char *tag,
|
||||
* above, it's still possible for the tag to wind
|
||||
* up being slightly too long.
|
||||
*/
|
||||
return (zfs_error(hdl, EZFS_TAGTOOLONG, errbuf));
|
||||
case ENOTSUP:
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"pool must be upgraded"));
|
||||
return (zfs_error(hdl, EZFS_BADVERSION, errbuf));
|
||||
(void) zfs_error(hdl, EZFS_TAGTOOLONG, errbuf);
|
||||
break;
|
||||
case EINVAL:
|
||||
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
|
||||
(void) zfs_error(hdl, EZFS_BADTYPE, errbuf);
|
||||
break;
|
||||
case EEXIST:
|
||||
return (zfs_error(hdl, EZFS_REFTAG_HOLD, errbuf));
|
||||
(void) zfs_error(hdl, EZFS_REFTAG_HOLD, errbuf);
|
||||
break;
|
||||
case ENOENT:
|
||||
if (enoent_ok)
|
||||
return (ENOENT);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return (zfs_standard_error_fmt(hdl, errno, errbuf));
|
||||
(void) zfs_standard_error(hdl,
|
||||
fnvpair_value_int32(elem), errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
fnvlist_free(errors);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
struct releasearg {
|
||||
nvlist_t *nvl;
|
||||
const char *snapname;
|
||||
const char *tag;
|
||||
boolean_t recursive;
|
||||
};
|
||||
|
||||
static int
|
||||
zfs_release_one(zfs_handle_t *zhp, void *arg)
|
||||
{
|
||||
struct holdarg *ha = arg;
|
||||
zfs_handle_t *szhp;
|
||||
char name[ZFS_MAXNAMELEN];
|
||||
int rv = 0;
|
||||
|
||||
(void) snprintf(name, sizeof (name),
|
||||
"%s@%s", zhp->zfs_name, ha->snapname);
|
||||
|
||||
szhp = make_dataset_handle(zhp->zfs_hdl, name);
|
||||
if (szhp) {
|
||||
nvlist_t *holds = fnvlist_alloc();
|
||||
fnvlist_add_boolean(holds, ha->tag);
|
||||
fnvlist_add_nvlist(ha->nvl, name, holds);
|
||||
zfs_close(szhp);
|
||||
}
|
||||
|
||||
if (ha->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, zfs_release_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
int
|
||||
zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag,
|
||||
boolean_t recursive)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
int ret;
|
||||
struct holdarg ha;
|
||||
nvlist_t *errors;
|
||||
nvpair_t *elem;
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||
(void) strlcpy(zc.zc_value, snapname, sizeof (zc.zc_value));
|
||||
if (strlcpy(zc.zc_string, tag, sizeof (zc.zc_string))
|
||||
>= sizeof (zc.zc_string))
|
||||
return (zfs_error(hdl, EZFS_TAGTOOLONG, tag));
|
||||
zc.zc_cookie = recursive;
|
||||
ha.nvl = fnvlist_alloc();
|
||||
ha.snapname = snapname;
|
||||
ha.tag = tag;
|
||||
ha.recursive = recursive;
|
||||
(void) zfs_release_one(zfs_handle_dup(zhp), &ha);
|
||||
ret = lzc_release(ha.nvl, &errors);
|
||||
fnvlist_free(ha.nvl);
|
||||
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_RELEASE, &zc) != 0) {
|
||||
char errbuf[ZFS_MAXNAMELEN+32];
|
||||
if (ret == 0)
|
||||
return (0);
|
||||
|
||||
if (nvlist_next_nvpair(errors, NULL) == NULL) {
|
||||
/* no hold-specific errors */
|
||||
char errbuf[1024];
|
||||
|
||||
/*
|
||||
* if it was recursive, the one that actually failed will be in
|
||||
* zc.zc_name.
|
||||
*/
|
||||
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
|
||||
"cannot release '%s' from '%s@%s'"), tag, zc.zc_name,
|
||||
snapname);
|
||||
"cannot release"));
|
||||
switch (errno) {
|
||||
case ESRCH:
|
||||
return (zfs_error(hdl, EZFS_REFTAG_RELE, errbuf));
|
||||
case ENOTSUP:
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"pool must be upgraded"));
|
||||
return (zfs_error(hdl, EZFS_BADVERSION, errbuf));
|
||||
case EINVAL:
|
||||
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
|
||||
(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
|
||||
break;
|
||||
default:
|
||||
return (zfs_standard_error_fmt(hdl, errno, errbuf));
|
||||
(void) zfs_standard_error_fmt(hdl, errno, errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
for (elem = nvlist_next_nvpair(errors, NULL);
|
||||
elem != NULL;
|
||||
elem = nvlist_next_nvpair(errors, elem)) {
|
||||
char errbuf[1024];
|
||||
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN,
|
||||
"cannot release hold from snapshot '%s'"),
|
||||
nvpair_name(elem));
|
||||
switch (fnvpair_value_int32(elem)) {
|
||||
case ESRCH:
|
||||
(void) zfs_error(hdl, EZFS_REFTAG_RELE, errbuf);
|
||||
break;
|
||||
case EINVAL:
|
||||
(void) zfs_error(hdl, EZFS_BADTYPE, errbuf);
|
||||
break;
|
||||
default:
|
||||
(void) zfs_standard_error_fmt(hdl,
|
||||
fnvpair_value_int32(elem), errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
fnvlist_free(errors);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
zfs_get_fsacl(zfs_handle_t *zhp, nvlist_t **nvl)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
int nvsz = 2048;
|
||||
void *nvbuf;
|
||||
int err = 0;
|
||||
char errbuf[ZFS_MAXNAMELEN+32];
|
||||
char errbuf[1024];
|
||||
|
||||
assert(zhp->zfs_type == ZFS_TYPE_VOLUME ||
|
||||
zhp->zfs_type == ZFS_TYPE_FILESYSTEM);
|
||||
@@ -4578,10 +4681,10 @@ out:
|
||||
int
|
||||
zfs_set_fsacl(zfs_handle_t *zhp, boolean_t un, nvlist_t *nvl)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
char *nvbuf;
|
||||
char errbuf[ZFS_MAXNAMELEN+32];
|
||||
char errbuf[1024];
|
||||
size_t nvsz;
|
||||
int err;
|
||||
|
||||
@@ -4632,38 +4735,18 @@ zfs_set_fsacl(zfs_handle_t *zhp, boolean_t un, nvlist_t *nvl)
|
||||
int
|
||||
zfs_get_holds(zfs_handle_t *zhp, nvlist_t **nvl)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
int nvsz = 2048;
|
||||
void *nvbuf;
|
||||
int err = 0;
|
||||
char errbuf[ZFS_MAXNAMELEN+32];
|
||||
int err;
|
||||
char errbuf[1024];
|
||||
|
||||
assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT);
|
||||
err = lzc_get_holds(zhp->zfs_name, nvl);
|
||||
|
||||
tryagain:
|
||||
if (err != 0) {
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
|
||||
nvbuf = malloc(nvsz);
|
||||
if (nvbuf == NULL) {
|
||||
err = (zfs_error(hdl, EZFS_NOMEM, strerror(errno)));
|
||||
goto out;
|
||||
}
|
||||
|
||||
zc.zc_nvlist_dst_size = nvsz;
|
||||
zc.zc_nvlist_dst = (uintptr_t)nvbuf;
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN);
|
||||
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_GET_HOLDS, &zc) != 0) {
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot get holds for '%s'"),
|
||||
zc.zc_name);
|
||||
switch (errno) {
|
||||
case ENOMEM:
|
||||
free(nvbuf);
|
||||
nvsz = zc.zc_nvlist_dst_size;
|
||||
goto tryagain;
|
||||
|
||||
zhp->zfs_name);
|
||||
switch (err) {
|
||||
case ENOTSUP:
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"pool must be upgraded"));
|
||||
@@ -4679,19 +4762,8 @@ tryagain:
|
||||
err = zfs_standard_error_fmt(hdl, errno, errbuf);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* success */
|
||||
int rc = nvlist_unpack(nvbuf, zc.zc_nvlist_dst_size, nvl, 0);
|
||||
if (rc) {
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot get holds for '%s'"),
|
||||
zc.zc_name);
|
||||
err = zfs_standard_error_fmt(hdl, rc, errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
free(nvbuf);
|
||||
out:
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ static int
|
||||
get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
|
||||
char *pn, int maxlen, zfs_stat_t *sb)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error;
|
||||
|
||||
(void) strlcpy(zc.zc_name, dsname, sizeof (zc.zc_name));
|
||||
@@ -379,7 +379,7 @@ describe_free(FILE *fp, differ_info_t *di, uint64_t object, char *namebuf,
|
||||
static int
|
||||
write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *lhdl = di->zhp->zfs_hdl;
|
||||
char fobjname[MAXPATHLEN];
|
||||
|
||||
@@ -507,7 +507,7 @@ static int
|
||||
make_temp_snapshot(differ_info_t *di)
|
||||
{
|
||||
libzfs_handle_t *hdl = di->zhp->zfs_hdl;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) snprintf(zc.zc_value, sizeof (zc.zc_value),
|
||||
ZDIFF_PREFIX, getpid());
|
||||
@@ -749,7 +749,7 @@ int
|
||||
zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap,
|
||||
const char *tosnap, int flags)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char errbuf[1024];
|
||||
differ_info_t di = { 0 };
|
||||
pthread_t tid;
|
||||
|
||||
@@ -361,7 +361,7 @@ libzfs_fru_devpath(libzfs_handle_t *hdl, const char *fru)
|
||||
int
|
||||
zpool_fru_set(zpool_handle_t *zhp, uint64_t vdev_guid, const char *fru)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) strncpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
(void) strncpy(zc.zc_value, fru, sizeof (zc.zc_value));
|
||||
|
||||
@@ -379,7 +379,7 @@ zfs_graph_add(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *source,
|
||||
static int
|
||||
iterate_children(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_vertex_t *zvp;
|
||||
|
||||
/*
|
||||
@@ -473,7 +473,7 @@ iterate_children(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset)
|
||||
static boolean_t
|
||||
external_dependents(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
/*
|
||||
* Check whether this dataset is a clone or has clones since
|
||||
|
||||
@@ -365,7 +365,7 @@ static nvlist_t *
|
||||
refresh_config(libzfs_handle_t *hdl, nvlist_t *config)
|
||||
{
|
||||
nvlist_t *nvl;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int err;
|
||||
|
||||
if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
|
||||
|
||||
@@ -103,7 +103,7 @@ top:
|
||||
int
|
||||
zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_handle_t *nzhp;
|
||||
int ret;
|
||||
|
||||
@@ -140,7 +140,7 @@ int
|
||||
zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
|
||||
void *data)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_handle_t *nzhp;
|
||||
int ret;
|
||||
|
||||
|
||||
+28
-28
@@ -64,7 +64,7 @@ typedef struct prop_flags {
|
||||
static int
|
||||
zpool_get_all_props(zpool_handle_t *zhp)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
@@ -692,7 +692,7 @@ error:
|
||||
int
|
||||
zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int ret = -1;
|
||||
char errbuf[1024];
|
||||
nvlist_t *nvl = NULL;
|
||||
@@ -1141,7 +1141,7 @@ int
|
||||
zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
|
||||
nvlist_t *props, nvlist_t *fsprops)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *zc_fsprops = NULL;
|
||||
nvlist_t *zc_props = NULL;
|
||||
char msg[1024];
|
||||
@@ -1275,7 +1275,7 @@ create_failed:
|
||||
int
|
||||
zpool_destroy(zpool_handle_t *zhp, const char *log_str)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_handle_t *zfp = NULL;
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
char msg[1024];
|
||||
@@ -1319,7 +1319,7 @@ zpool_destroy(zpool_handle_t *zhp, const char *log_str)
|
||||
int
|
||||
zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int ret;
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
char msg[1024];
|
||||
@@ -1446,7 +1446,7 @@ static int
|
||||
zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce,
|
||||
const char *log_str)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
|
||||
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
|
||||
@@ -1721,7 +1721,7 @@ int
|
||||
zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
|
||||
nvlist_t *props, int flags)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zpool_rewind_policy_t policy;
|
||||
nvlist_t *nv = NULL;
|
||||
nvlist_t *nvinfo = NULL;
|
||||
@@ -1913,7 +1913,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
|
||||
int
|
||||
zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
@@ -2389,7 +2389,7 @@ int
|
||||
zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
|
||||
vdev_state_t *newstate)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tgt;
|
||||
boolean_t avail_spare, l2cache, islog;
|
||||
@@ -2473,7 +2473,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
|
||||
int
|
||||
zpool_vdev_offline(zpool_handle_t *zhp, const char *path, boolean_t istmp)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tgt;
|
||||
boolean_t avail_spare, l2cache;
|
||||
@@ -2523,7 +2523,7 @@ zpool_vdev_offline(zpool_handle_t *zhp, const char *path, boolean_t istmp)
|
||||
int
|
||||
zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
@@ -2558,7 +2558,7 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
int
|
||||
zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
@@ -2612,7 +2612,7 @@ int
|
||||
zpool_vdev_attach(zpool_handle_t *zhp,
|
||||
const char *old_disk, const char *new_disk, nvlist_t *nvroot, int replacing)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
int ret;
|
||||
nvlist_t *tgt;
|
||||
@@ -2788,7 +2788,7 @@ zpool_vdev_attach(zpool_handle_t *zhp,
|
||||
int
|
||||
zpool_vdev_detach(zpool_handle_t *zhp, const char *path)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tgt;
|
||||
boolean_t avail_spare, l2cache;
|
||||
@@ -2886,7 +2886,7 @@ int
|
||||
zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
|
||||
nvlist_t *props, splitflags_t flags)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tree, *config, **child, **newchild, *newconfig = NULL;
|
||||
nvlist_t **varray = NULL, *zc_props = NULL;
|
||||
@@ -3097,7 +3097,7 @@ out:
|
||||
int
|
||||
zpool_vdev_remove(zpool_handle_t *zhp, const char *path)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tgt;
|
||||
boolean_t avail_spare, l2cache, islog;
|
||||
@@ -3142,7 +3142,7 @@ zpool_vdev_remove(zpool_handle_t *zhp, const char *path)
|
||||
int
|
||||
zpool_clear(zpool_handle_t *zhp, const char *path, nvlist_t *rewindnvl)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
nvlist_t *tgt;
|
||||
zpool_rewind_policy_t policy;
|
||||
@@ -3218,7 +3218,7 @@ zpool_clear(zpool_handle_t *zhp, const char *path, nvlist_t *rewindnvl)
|
||||
int
|
||||
zpool_vdev_clear(zpool_handle_t *zhp, uint64_t guid)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
@@ -3244,7 +3244,7 @@ zpool_reguid(zpool_handle_t *zhp)
|
||||
{
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) snprintf(msg, sizeof (msg),
|
||||
dgettext(TEXT_DOMAIN, "cannot reguid '%s'"), zhp->zpool_name);
|
||||
@@ -3262,7 +3262,7 @@ zpool_reguid(zpool_handle_t *zhp)
|
||||
int
|
||||
zpool_reopen(zpool_handle_t *zhp)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
@@ -3342,7 +3342,7 @@ path_to_devid(const char *path)
|
||||
static void
|
||||
set_path(zpool_handle_t *zhp, nvlist_t *nv, const char *path)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) strncpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
(void) strncpy(zc.zc_value, path, sizeof (zc.zc_value));
|
||||
@@ -3517,7 +3517,7 @@ zbookmark_compare(const void *a, const void *b)
|
||||
int
|
||||
zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
uint64_t count;
|
||||
zbookmark_t *zb = NULL;
|
||||
int i;
|
||||
@@ -3613,7 +3613,7 @@ nomem:
|
||||
int
|
||||
zpool_upgrade(zpool_handle_t *zhp, uint64_t new_version)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
(void) strcpy(zc.zc_name, zhp->zpool_name);
|
||||
@@ -3641,7 +3641,7 @@ zfs_save_arguments(int argc, char **argv, char *string, int len)
|
||||
int
|
||||
zpool_log_history(libzfs_handle_t *hdl, const char *message)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *args;
|
||||
int err;
|
||||
|
||||
@@ -3667,7 +3667,7 @@ zpool_log_history(libzfs_handle_t *hdl, const char *message)
|
||||
static int
|
||||
get_history(zpool_handle_t *zhp, char *buf, uint64_t *off, uint64_t *len)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
@@ -3804,7 +3804,7 @@ int
|
||||
zpool_events_next(libzfs_handle_t *hdl, nvlist_t **nvp,
|
||||
int *dropped, int block, int cleanup_fd)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error = 0;
|
||||
|
||||
*nvp = NULL;
|
||||
@@ -3863,7 +3863,7 @@ out:
|
||||
int
|
||||
zpool_events_clear(libzfs_handle_t *hdl, int *count)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
|
||||
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
|
||||
@@ -3882,7 +3882,7 @@ void
|
||||
zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
|
||||
char *pathname, size_t len)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
boolean_t mounted = B_FALSE;
|
||||
char *mntpnt = NULL;
|
||||
char dsname[MAXNAMELEN];
|
||||
|
||||
@@ -812,7 +812,7 @@ static int
|
||||
estimate_ioctl(zfs_handle_t *zhp, uint64_t fromsnap_obj,
|
||||
boolean_t fromorigin, uint64_t *sizep)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
|
||||
assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT);
|
||||
@@ -876,7 +876,7 @@ static int
|
||||
dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
|
||||
boolean_t fromorigin, int outfd, nvlist_t *debugnv)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
nvlist_t *thisdbg;
|
||||
|
||||
@@ -978,9 +978,7 @@ hold_for_send(zfs_handle_t *zhp, send_dump_data_t *sdd)
|
||||
*/
|
||||
if (pzhp) {
|
||||
error = zfs_hold(pzhp, thissnap, sdd->holdtag,
|
||||
B_FALSE, B_TRUE, B_TRUE, sdd->cleanup_fd,
|
||||
zfs_prop_get_int(zhp, ZFS_PROP_OBJSETID),
|
||||
zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG));
|
||||
B_FALSE, B_TRUE, sdd->cleanup_fd);
|
||||
zfs_close(pzhp);
|
||||
}
|
||||
|
||||
@@ -992,7 +990,7 @@ send_progress_thread(void *arg)
|
||||
{
|
||||
progress_arg_t *pa = arg;
|
||||
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_handle_t *zhp = pa->pa_zhp;
|
||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||
unsigned long long bytes;
|
||||
@@ -1195,7 +1193,7 @@ dump_filesystem(zfs_handle_t *zhp, void *arg)
|
||||
int rv = 0;
|
||||
send_dump_data_t *sdd = arg;
|
||||
boolean_t missingfrom = B_FALSE;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s",
|
||||
zhp->zfs_name, sdd->tosnap);
|
||||
@@ -1683,7 +1681,7 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname,
|
||||
int baselen, char *newname, recvflags_t *flags)
|
||||
{
|
||||
static int seq;
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int err;
|
||||
prop_changelist_t *clp;
|
||||
zfs_handle_t *zhp;
|
||||
@@ -1719,12 +1717,11 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname,
|
||||
err = ENOENT;
|
||||
}
|
||||
|
||||
if (err != 0 && strncmp(name+baselen, "recv-", 5) != 0) {
|
||||
if (err != 0 && strncmp(name + baselen, "recv-", 5) != 0) {
|
||||
seq++;
|
||||
|
||||
(void) strncpy(newname, name, baselen);
|
||||
(void) snprintf(newname+baselen, ZFS_MAXNAMELEN-baselen,
|
||||
"recv-%ld-%u", (long) getpid(), seq);
|
||||
(void) snprintf(newname, ZFS_MAXNAMELEN, "%.*srecv-%u-%u",
|
||||
baselen, name, getpid(), seq);
|
||||
(void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value));
|
||||
|
||||
if (flags->verbose) {
|
||||
@@ -1756,7 +1753,7 @@ static int
|
||||
recv_destroy(libzfs_handle_t *hdl, const char *name, int baselen,
|
||||
char *newname, recvflags_t *flags)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int err = 0;
|
||||
prop_changelist_t *clp;
|
||||
zfs_handle_t *zhp;
|
||||
@@ -2015,7 +2012,7 @@ again:
|
||||
stream_originguid, originguid)) {
|
||||
case 1: {
|
||||
/* promote it! */
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *origin_nvfs;
|
||||
char *origin_fsname;
|
||||
|
||||
@@ -2087,7 +2084,7 @@ again:
|
||||
if (0 == nvlist_lookup_nvlist(stream_nvfs, "snapprops",
|
||||
&props) && 0 == nvlist_lookup_nvlist(props,
|
||||
stream_snapname, &props)) {
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
zc.zc_cookie = B_TRUE; /* received */
|
||||
(void) snprintf(zc.zc_name, sizeof (zc.zc_name),
|
||||
@@ -2518,7 +2515,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
|
||||
uint64_t *action_handlep)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
time_t begin_time;
|
||||
int ioctl_err, ioctl_errno, err;
|
||||
char *cp;
|
||||
@@ -2649,7 +2646,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
/*
|
||||
* Determine name of destination snapshot, store in zc_value.
|
||||
*/
|
||||
(void) strcpy(zc.zc_top_ds, tosnap);
|
||||
(void) strcpy(zc.zc_value, tosnap);
|
||||
(void) strlcat(zc.zc_value, chopprefix, sizeof (zc.zc_value));
|
||||
free(cp);
|
||||
@@ -2892,7 +2888,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
zcmd_free_nvlists(&zc);
|
||||
|
||||
if (err == 0 && snapprops_nvlist) {
|
||||
zfs_cmd_t zc2 = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc2 = {"\0"};
|
||||
|
||||
(void) strcpy(zc2.zc_name, zc.zc_value);
|
||||
zc2.zc_cookie = B_TRUE; /* received */
|
||||
|
||||
@@ -118,7 +118,7 @@ static int
|
||||
lzc_ioctl(zfs_ioc_t ioc, const char *name,
|
||||
nvlist_t *source, nvlist_t **resultp)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error = 0;
|
||||
char *packed;
|
||||
size_t size;
|
||||
@@ -132,6 +132,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
|
||||
zc.zc_nvlist_src_size = size;
|
||||
|
||||
if (resultp != NULL) {
|
||||
*resultp = NULL;
|
||||
zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
|
||||
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
|
||||
malloc(zc.zc_nvlist_dst_size);
|
||||
@@ -159,8 +160,6 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
|
||||
if (zc.zc_nvlist_dst_filled) {
|
||||
*resultp = fnvlist_unpack((void *)(uintptr_t)zc.zc_nvlist_dst,
|
||||
zc.zc_nvlist_dst_size);
|
||||
} else if (resultp != NULL) {
|
||||
*resultp = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -209,7 +208,7 @@ lzc_clone(const char *fsname, const char *origin,
|
||||
* The value will be the (int32) error code.
|
||||
*
|
||||
* The return value will be 0 if all snapshots were created, otherwise it will
|
||||
* be the errno of a (undetermined) snapshot that failed.
|
||||
* be the errno of a (unspecified) snapshot that failed.
|
||||
*/
|
||||
int
|
||||
lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist)
|
||||
@@ -258,7 +257,7 @@ lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist)
|
||||
* The return value will be 0 if all snapshots were destroyed (or marked for
|
||||
* later destruction if 'defer' is set) or didn't exist to begin with.
|
||||
*
|
||||
* Otherwise the return value will be the errno of a (undetermined) snapshot
|
||||
* Otherwise the return value will be the errno of a (unspecified) snapshot
|
||||
* that failed, no snapshots will be destroyed, and the errlist will have an
|
||||
* entry for each snapshot that failed. The value in the errlist will be
|
||||
* the (int32) error code.
|
||||
@@ -326,12 +325,107 @@ lzc_exists(const char *dataset)
|
||||
* The objset_stats ioctl is still legacy, so we need to construct our
|
||||
* own zfs_cmd_t rather than using zfsc_ioctl().
|
||||
*/
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
|
||||
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
|
||||
return (ioctl(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create "user holds" on snapshots. If there is a hold on a snapshot,
|
||||
* the snapshot can not be destroyed. (However, it can be marked for deletion
|
||||
* by lzc_destroy_snaps(defer=B_TRUE).)
|
||||
*
|
||||
* The keys in the nvlist are snapshot names.
|
||||
* The snapshots must all be in the same pool.
|
||||
* The value is the name of the hold (string type).
|
||||
*
|
||||
* If cleanup_fd is not -1, it must be the result of open("/dev/zfs", O_EXCL).
|
||||
* In this case, when the cleanup_fd is closed (including on process
|
||||
* termination), the holds will be released. If the system is shut down
|
||||
* uncleanly, the holds will be released when the pool is next opened
|
||||
* or imported.
|
||||
*
|
||||
* The return value will be 0 if all holds were created. Otherwise the return
|
||||
* value will be the errno of a (unspecified) hold that failed, no holds will
|
||||
* be created, and the errlist will have an entry for each hold that
|
||||
* failed (name = snapshot). The value in the errlist will be the error
|
||||
* code (int32).
|
||||
*/
|
||||
int
|
||||
lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist)
|
||||
{
|
||||
char pool[MAXNAMELEN];
|
||||
nvlist_t *args;
|
||||
nvpair_t *elem;
|
||||
int error;
|
||||
|
||||
/* determine the pool name */
|
||||
elem = nvlist_next_nvpair(holds, NULL);
|
||||
if (elem == NULL)
|
||||
return (0);
|
||||
(void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
|
||||
pool[strcspn(pool, "/@")] = '\0';
|
||||
|
||||
args = fnvlist_alloc();
|
||||
fnvlist_add_nvlist(args, "holds", holds);
|
||||
if (cleanup_fd != -1)
|
||||
fnvlist_add_int32(args, "cleanup_fd", cleanup_fd);
|
||||
|
||||
error = lzc_ioctl(ZFS_IOC_HOLD, pool, args, errlist);
|
||||
nvlist_free(args);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release "user holds" on snapshots. If the snapshot has been marked for
|
||||
* deferred destroy (by lzc_destroy_snaps(defer=B_TRUE)), it does not have
|
||||
* any clones, and all the user holds are removed, then the snapshot will be
|
||||
* destroyed.
|
||||
*
|
||||
* The keys in the nvlist are snapshot names.
|
||||
* The snapshots must all be in the same pool.
|
||||
* The value is a nvlist whose keys are the holds to remove.
|
||||
*
|
||||
* The return value will be 0 if all holds were removed.
|
||||
* Otherwise the return value will be the errno of a (unspecified) release
|
||||
* that failed, no holds will be released, and the errlist will have an
|
||||
* entry for each snapshot that has failed releases (name = snapshot).
|
||||
* The value in the errlist will be the error code (int32) of a failed release.
|
||||
*/
|
||||
int
|
||||
lzc_release(nvlist_t *holds, nvlist_t **errlist)
|
||||
{
|
||||
char pool[MAXNAMELEN];
|
||||
nvpair_t *elem;
|
||||
|
||||
/* determine the pool name */
|
||||
elem = nvlist_next_nvpair(holds, NULL);
|
||||
if (elem == NULL)
|
||||
return (0);
|
||||
(void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
|
||||
pool[strcspn(pool, "/@")] = '\0';
|
||||
|
||||
return (lzc_ioctl(ZFS_IOC_RELEASE, pool, holds, errlist));
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve list of user holds on the specified snapshot.
|
||||
*
|
||||
* On success, *holdsp will be set to a nvlist which the caller must free.
|
||||
* The keys are the names of the holds, and the value is the creation time
|
||||
* of the hold (uint64) in seconds since the epoch.
|
||||
*/
|
||||
int
|
||||
lzc_get_holds(const char *snapname, nvlist_t **holdsp)
|
||||
{
|
||||
int error;
|
||||
nvlist_t *innvl = fnvlist_alloc();
|
||||
error = lzc_ioctl(ZFS_IOC_GET_HOLDS, snapname, innvl, holdsp);
|
||||
fnvlist_free(innvl);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* If fromsnap is NULL, a full (non-incremental) stream will be sent.
|
||||
*/
|
||||
@@ -411,7 +505,7 @@ lzc_receive(const char *snapname, nvlist_t *props, const char *origin,
|
||||
* The receive ioctl is still legacy, so we need to construct our own
|
||||
* zfs_cmd_t rather than using zfsc_ioctl().
|
||||
*/
|
||||
zfs_cmd_t zc = {"\0", 0, 0, 0, 0, 0, 0, 0, "\0", "\0", "\0"};
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char *atp;
|
||||
char *packed = NULL;
|
||||
size_t size;
|
||||
|
||||
@@ -45,6 +45,8 @@ libzpool_la_SOURCES = \
|
||||
$(top_srcdir)/module/zfs/dsl_prop.c \
|
||||
$(top_srcdir)/module/zfs/dsl_scan.c \
|
||||
$(top_srcdir)/module/zfs/dsl_synctask.c \
|
||||
$(top_srcdir)/module/zfs/dsl_destroy.c \
|
||||
$(top_srcdir)/module/zfs/dsl_userhold.c \
|
||||
$(top_srcdir)/module/zfs/fm.c \
|
||||
$(top_srcdir)/module/zfs/gzip.c \
|
||||
$(top_srcdir)/module/zfs/lzjb.c \
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/processor.h>
|
||||
#include <sys/zfs_context.h>
|
||||
#include <sys/rrwlock.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/systeminfo.h>
|
||||
@@ -1042,6 +1043,8 @@ umem_out_of_memory(void)
|
||||
void
|
||||
kernel_init(int mode)
|
||||
{
|
||||
extern uint_t rrw_tsd_key;
|
||||
|
||||
umem_nofail_callback(umem_out_of_memory);
|
||||
|
||||
physmem = sysconf(_SC_PHYS_PAGES);
|
||||
@@ -1059,6 +1062,8 @@ kernel_init(int mode)
|
||||
system_taskq_init();
|
||||
|
||||
spa_init(mode);
|
||||
|
||||
tsd_create(&rrw_tsd_key, rrw_tsd_destroy);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user