From owner-svn-src-all@FreeBSD.ORG Thu Apr 25 00:17:32 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CE76579C; Thu, 25 Apr 2013 00:17:32 +0000 (UTC) (envelope-from smh@freebsd.org) Received: from smtp1.multiplay.co.uk (smtp1.multiplay.co.uk [85.236.96.35]) by mx1.freebsd.org (Postfix) with ESMTP id 678611584; Thu, 25 Apr 2013 00:17:32 +0000 (UTC) Received: by smtp1.multiplay.co.uk (Postfix, from userid 65534) id 431EA20E7088A; Thu, 25 Apr 2013 00:17:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.multiplay.co.uk X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=8.0 tests=AWL,BAYES_00,DOS_OE_TO_MX, FSL_HELO_NON_FQDN_1,HELO_NO_DOMAIN,RDNS_DYNAMIC,STOX_REPLY_TYPE autolearn=no version=3.3.1 Received: from r2d2 (46-65-172-4.zone16.bethere.co.uk [46.65.172.4]) by smtp1.multiplay.co.uk (Postfix) with ESMTP id 984D320E70885; Thu, 25 Apr 2013 00:17:23 +0000 (UTC) Message-ID: From: "Steven Hartland" To: "Martin Matuska" , , , References: <201304110749.r3B7nGxR071588@svn.freebsd.org> Subject: Re: svn commit: r249357 - head/cddl/contrib/opensolaris/lib/libzfs/common Date: Thu, 25 Apr 2013 01:17:53 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Apr 2013 00:17:32 -0000 I believe this needs a little tweak so you don't get issues with zfs send which makes use of holds to ensure snapshots being sent don't get deleted while processing. In essence it should honor the enoent_ok flag and not report such an error to stdout. @@ -4207,6 +4238,9 @@ if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) { fnvlist_free(ha.nvl); ret = ENOENT; + if (enoent_ok) + return (ret); + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot hold snapshot '%s@%s'"), zhp->zfs_name, snapname); ----- Original Message ----- From: "Martin Matuska" To: ; ; Sent: Thursday, April 11, 2013 8:49 AM Subject: svn commit: r249357 - head/cddl/contrib/opensolaris/lib/libzfs/common > Author: mm > Date: Thu Apr 11 07:49:16 2013 > New Revision: 249357 > URL: http://svnweb.freebsd.org/changeset/base/249357 > > Log: > Fix libzfs to report error instead of returning zero if trying to hold or > release a non-existing snapshot of a existing dataset. In recursive case > error is reported if no snapshots with the requested name have been found. > > Problem and proposed solution reported to illumos: > 3699 zfs hold or release of a non-existent snapshot does not output error > > MFC after: 8 days > > Modified: > head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c > > Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c > ============================================================================== > --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Thu Apr 11 07:40:30 2013 (r249356) > +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Thu Apr 11 07:49:16 2013 (r249357) > @@ -4203,6 +4203,17 @@ zfs_hold(zfs_handle_t *zhp, const char * > ha.tag = tag; > ha.recursive = recursive; > (void) zfs_hold_one(zfs_handle_dup(zhp), &ha); > + > + if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) { > + fnvlist_free(ha.nvl); > + ret = ENOENT; > + (void) snprintf(errbuf, sizeof (errbuf), > + dgettext(TEXT_DOMAIN, "cannot hold snapshot '%s@%s'"), > + zhp->zfs_name, snapname); > + (void) zfs_standard_error(hdl, ret, errbuf); > + return (ret); > + } > + > ret = lzc_hold(ha.nvl, cleanup_fd, &errors); > fnvlist_free(ha.nvl); > > @@ -4304,12 +4315,25 @@ zfs_release(zfs_handle_t *zhp, const cha > nvlist_t *errors; > nvpair_t *elem; > libzfs_handle_t *hdl = zhp->zfs_hdl; > + char errbuf[1024]; > > ha.nvl = fnvlist_alloc(); > ha.snapname = snapname; > ha.tag = tag; > ha.recursive = recursive; > (void) zfs_release_one(zfs_handle_dup(zhp), &ha); > + > + if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) { > + fnvlist_free(ha.nvl); > + ret = ENOENT; > + (void) snprintf(errbuf, sizeof (errbuf), > + dgettext(TEXT_DOMAIN, > + "cannot release hold from snapshot '%s@%s'"), > + zhp->zfs_name, snapname); > + (void) zfs_standard_error(hdl, ret, errbuf); > + return (ret); > + } > + > ret = lzc_release(ha.nvl, &errors); > fnvlist_free(ha.nvl); > > @@ -4318,8 +4342,6 @@ zfs_release(zfs_handle_t *zhp, const cha > > if (nvlist_next_nvpair(errors, NULL) == NULL) { > /* no hold-specific errors */ > - char errbuf[1024]; > - > (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, > "cannot release")); > switch (errno) { > @@ -4336,8 +4358,6 @@ zfs_release(zfs_handle_t *zhp, const cha > 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'"), >