Skip to content

Commit

Permalink
Add zvol link creating code to zfs_snapshot_nvl. The links are only
Browse files Browse the repository at this point in the history
created upon successful completion of an atomic group-snapshot operation.

I still have to do something to get the "Volume successfully snapshotted,
but device links were not created" message back.
  • Loading branch information
dweeezil committed Jun 3, 2013
1 parent 6ed1435 commit 357fa8e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,31 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
(void) zfs_standard_error(hdl, ret, errbuf);
}
}
} else {
zfs_handle_t *zhp;
int linktries = 0, linkok = 0, linkfail = 0;
nvpair_t *snap;

for (snap = nvlist_next_nvpair(snaps, NULL); snap != NULL;
snap = nvlist_next_nvpair(snaps, snap)) {
char *cp, *snapname;

snapname = nvpair_name(snap);
cp = strchr(snapname, '@');
*cp = '\0';

if ((zhp = zfs_open(hdl, snapname, ZFS_TYPE_FILESYSTEM |
ZFS_TYPE_VOLUME)) != NULL) {
if (zhp->zfs_type == ZFS_TYPE_VOLUME) {
++linktries;
*cp = '@';
if (zvol_create_link(zhp->zfs_hdl, nvpair_name(snap)))
++linkfail;
else
++linkok;
}
}
}
}

nvlist_free(props);
Expand Down

0 comments on commit 357fa8e

Please sign in to comment.