From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 2 00:20:07 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B56F7106564A for ; Tue, 2 Oct 2012 00:20:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 9F1C88FC0C for ; Tue, 2 Oct 2012 00:20:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q920K7Kn056146 for ; Tue, 2 Oct 2012 00:20:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q920K7ah056139; Tue, 2 Oct 2012 00:20:07 GMT (envelope-from gnats) Date: Tue, 2 Oct 2012 00:20:07 GMT Message-Id: <201210020020.q920K7ah056139@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Steven Hartland" Cc: Subject: Re: bin/172259: ZFS fails to receive valid snapshots (patch included) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Steven Hartland List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2012 00:20:07 -0000 The following reply was made to PR bin/172259; it has been noted by GNATS. From: "Steven Hartland" To: Cc: Subject: Re: bin/172259: ZFS fails to receive valid snapshots (patch included) Date: Tue, 2 Oct 2012 01:12:23 +0100 This is a multi-part message in MIME format. ------=_NextPart_000_093F_01CDA03A.FA949040 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit Patch for this issue ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk. ------=_NextPart_000_093F_01CDA03A.FA949040 Content-Type: text/plain; format=flowed; name="zfs-recv-sortfix.txt"; reply-type=original Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zfs-recv-sortfix.txt" Fixes zfs receive errors caused by snapshot replication being processed = in a=0A= random order instead of creation order.=0A= =0A= Eliminates needless filesystem renames caused by removed parent snapshots=0A= which subsequently causes many more errors.=0A= --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c.orig2 = 2012-10-01 22:27:40.119762812 +0000=0A= +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c = 2012-10-01 23:20:02.440540612 +0000=0A= @@ -718,7 +718,7 @@=0A= sd->parent_fromsnap_guid =3D 0;=0A= VERIFY(0 =3D=3D nvlist_alloc(&sd->parent_snaps, NV_UNIQUE_NAME, 0));=0A= VERIFY(0 =3D=3D nvlist_alloc(&sd->snapprops, NV_UNIQUE_NAME, 0));=0A= - (void) zfs_iter_snapshots(zhp, send_iterate_snap, sd);=0A= + (void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd);=0A= VERIFY(0 =3D=3D nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps));=0A= VERIFY(0 =3D=3D nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops));=0A= nvlist_free(sd->parent_snaps);=0A= @@ -1859,11 +1859,12 @@=0A= recvflags_t *flags, nvlist_t *stream_nv, avl_tree_t *stream_avl,=0A= nvlist_t *renamed)=0A= {=0A= - nvlist_t *local_nv;=0A= + nvlist_t *local_nv, *deleted =3D NULL;=0A= avl_tree_t *local_avl;=0A= nvpair_t *fselem, *nextfselem;=0A= char *fromsnap;=0A= char newname[ZFS_MAXNAMELEN];=0A= + char guidname[32];=0A= int error;=0A= boolean_t needagain, progress, recursive;=0A= char *s1, *s2;=0A= @@ -1879,6 +1880,8 @@=0A= again:=0A= needagain =3D progress =3D B_FALSE;=0A= =0A= + VERIFY(0 =3D=3D nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0));=0A= +=0A= if ((error =3D gather_nvlist(hdl, tofs, fromsnap, NULL,=0A= recursive, &local_nv, &local_avl)) !=3D 0)=0A= return (error);=0A= @@ -1999,6 +2002,8 @@=0A= needagain =3D B_TRUE;=0A= else=0A= progress =3D B_TRUE;=0A= + sprintf(guidname, "%lu", thisguid);=0A= + nvlist_add_boolean(deleted, guidname);=0A= continue;=0A= }=0A= =0A= @@ -2054,6 +2059,8 @@=0A= needagain =3D B_TRUE;=0A= else=0A= progress =3D B_TRUE;=0A= + sprintf(guidname, "%lu", parent_fromsnap_guid);=0A= + nvlist_add_boolean(deleted, guidname);=0A= continue;=0A= }=0A= =0A= @@ -2076,6 +2083,23 @@=0A= s2 =3D strrchr(stream_fsname, '/');=0A= =0A= /*=0A= + * Check if we're going to rename based on parent guid change=0A= + * and the current parent guid was also deleted. If it was then=0A= + * rename will fail and is likely unneeded, so avoid this and=0A= + * force an early retry to determine the new parent_fromsnap_guid=0A= + */=0A= + if (stream_parent_fromsnap_guid !=3D 0 &&=0A= + parent_fromsnap_guid !=3D 0 &&=0A= + stream_parent_fromsnap_guid !=3D = parent_fromsnap_guid) {=0A= + sprintf(guidname, "%lu", parent_fromsnap_guid);=0A= + if (nvlist_exists(deleted, guidname)) {=0A= + progress =3D B_TRUE;=0A= + needagain =3D B_TRUE;=0A= + goto doagain;=0A= + }=0A= + }=0A= +=0A= + /*=0A= * Check for rename. If the exact receive path is specified, it=0A= * does not count as a rename, but we still need to check the=0A= * datasets beneath it.=0A= @@ -2129,8 +2153,10 @@=0A= }=0A= }=0A= =0A= +doagain:=0A= fsavl_destroy(local_avl);=0A= nvlist_free(local_nv);=0A= + nvlist_free(deleted);=0A= =0A= if (needagain && progress) {=0A= /* do another pass to fix up temporary names */=0A= ------=_NextPart_000_093F_01CDA03A.FA949040--