From 357fa8e0a74f6209cfdde1eeae047577d54e7f41 Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Sun, 2 Jun 2013 21:06:59 -0500 Subject: [PATCH] Add zvol link creating code to zfs_snapshot_nvl. The links are only 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. --- lib/libzfs/libzfs_dataset.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 01beca5aed0c..20d3b99d42d1 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -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);