Skip to content

Commit

Permalink
zfs send -p send properties only for snapshots that are actually sent
Browse files Browse the repository at this point in the history
... as opposed to sending properties of all snapshots of the relevant
filesystem.  The previous behavior results in properties being set on
all snapshots on the receiving side, which is quite slow.
More details are here:
  http://thread.gmane.org/gmane.comp.file-systems.openzfs.devel/346

Behavior of zfs send -R is not changed.
  • Loading branch information
avg-I authored and ryao committed Jun 27, 2014
1 parent 4398c54 commit 5e2746a
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ typedef struct send_data {
const char *fromsnap;
const char *tosnap;
boolean_t recursive;
boolean_t seenfrom;
boolean_t seento;

/*
* The header nvlist is of the following format:
Expand Down Expand Up @@ -595,20 +597,39 @@ send_iterate_snap(zfs_handle_t *zhp, void *arg)
uint64_t guid = zhp->zfs_dmustats.dds_guid;
char *snapname;
nvlist_t *nv;
boolean_t isfromsnap, istosnap;

snapname = strrchr(zhp->zfs_name, '@')+1;
isfromsnap = (sd->fromsnap != NULL &&
strcmp(sd->fromsnap, snapname) == 0);
istosnap = (sd->tosnap != NULL && (strcmp(sd->tosnap, snapname) == 0));

VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid));
/*
* NB: if there is no fromsnap here (it's a newly created fs in
* an incremental replication), we will substitute the tosnap.
*/
if ((sd->fromsnap && strcmp(snapname, sd->fromsnap) == 0) ||
(sd->parent_fromsnap_guid == 0 && sd->tosnap &&
strcmp(snapname, sd->tosnap) == 0)) {
if (isfromsnap || (sd->parent_fromsnap_guid == 0 && istosnap)) {
sd->parent_fromsnap_guid = guid;
}

if (!sd->recursive) {
if (!sd->seenfrom && isfromsnap) {
sd->seenfrom = B_TRUE;
zfs_close(zhp);
return (0);
}

if (sd->seento || !sd->seenfrom) {
zfs_close(zhp);
return (0);
}

if (istosnap)
sd->seento = B_TRUE;
}

VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid));

VERIFY(0 == nvlist_alloc(&nv, NV_UNIQUE_NAME, 0));
send_iterate_prop(zhp, nv);
VERIFY(0 == nvlist_add_nvlist(sd->snapprops, snapname, nv));
Expand Down

0 comments on commit 5e2746a

Please sign in to comment.