Skip to content

Commit

Permalink
OpenZFS 8940 - Sending an intra-pool resumable send stream may result…
Browse files Browse the repository at this point in the history
… in EXDEV

Because resuming from a token requires "guid" -> "snapshot" mapping
we have to walk the whole dataset hierarchy to find the right snapshot
to send; when both source and destination exists, for an incremental
resumable stream, libzfs gets confused and picks up the wrong snapshot
to send from: this results in attempting to send
   "destination@snap1 -> source@snap2"
instead of
   "source@snap1 -> source@snap2"
which fails with a "Invalid cross-device link" error (EXDEV).
Fix this by adjusting the logic behind dataset traversal in
zfs_iter_children() to pick the right snapshot to send from.
Additionally update dry-run 'zfs send -t' to print its output to
stderr: this is consistent with other dry-run commands.

Patch Notes:
Reconciled differences between OpenZFS and
aee1dd4.

Authored by: loli10K <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Brian Behlendorf <[email protected]>
Approved by: Hans Rosenfeld <[email protected]>
Ported-by: Giuseppe Di Natale <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/8940
OpenZFS-commit: openzfs/openzfs@9f7867c206
Closes #7171
  • Loading branch information
loli10K authored and behlendorf committed Feb 14, 2018
1 parent 9c5167d commit 4411de2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/libzfs/libzfs_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,

/*
* Iterate over all children, snapshots and filesystems
* Process snapshots before filesystems because they are nearer the input
* handle: this is extremely important when used with zfs_iter_f functions
* looking for data, following the logic that we would like to find it as soon
* and as close as possible.
*/
int
zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, void *data)
Expand Down

0 comments on commit 4411de2

Please sign in to comment.