bin/172259: ZFS fails to receive valid snapshots (patch
included)
Steven Hartland
killing at multiplay.co.uk
Tue Oct 2 00:20:07 UTC 2012
The following reply was made to PR bin/172259; it has been noted by GNATS.
From: "Steven Hartland" <killing at multiplay.co.uk>
To: <bug-followup at freebsd.org>
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 at 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--
More information about the freebsd-bugs
mailing list