From 4411de2116bbe46633746a163c54445db9e786d4 Mon Sep 17 00:00:00 2001 From: loli10K Date: Sun, 31 Dec 2017 00:25:56 +0100 Subject: [PATCH] OpenZFS 8940 - Sending an intra-pool resumable send stream may result 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 aee1dd4d983c64db3c3155290d48f05243e85709. Authored by: loli10K Reviewed by: Paul Dagnelie Reviewed by: Matthew Ahrens Reviewed by: Brian Behlendorf Approved by: Hans Rosenfeld Ported-by: Giuseppe Di Natale OpenZFS-issue: https://www.illumos.org/issues/8940 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/9f7867c206 Closes #7171 --- lib/libzfs/libzfs_iter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libzfs/libzfs_iter.c b/lib/libzfs/libzfs_iter.c index 75267d053..6f9b3f465 100644 --- a/lib/libzfs/libzfs_iter.c +++ b/lib/libzfs/libzfs_iter.c @@ -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) -- 2.40.0