Project

General

Profile

Bug #4919

zfs send returns "unknown" error if from snap does not exist

Added by Jan Kryl over 5 years ago. Updated over 5 years ago.

Status:
In Progress
Priority:
Low
Assignee:
Category:
lib - userland libraries
Start date:
2014-06-10
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:

Description

zfs send returns EZFS_UNKNOWN error when trying to send incremental stream and "from" snapshot does not exist. libzfs prints warning message to stderr:

WARNING: could not send sourcePool/fs0@snap2:
incremental source (sourcePool/fs0@base-does-not-exists) does not exist

However that is not helpful for analyzing the error in programs.

Steps to Reproduce: Try to send incremental stream with "from" snapshot which doesn't exist.

Expected Results: Instead of unknown error it should return ENOENT (as in case when "to" snapshot does not exist.

History

#1

Updated by Jan Kryl over 5 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 90
#2

Updated by Jan Kryl over 5 years ago

  • % Done changed from 90 to 0
  • Tags deleted (needs-triage)

I had relatively simple fix, which fails to work with replication streams (it works but in certain situation the error messages are confusing):

@@ -1610,9 +1612,9 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
                }

                /* Ensure no snaps found is treated as an error. */
-               if (!sdd.seento) {
+               if (!sdd.seento || !sdd.seenfrom) {
                        err = ENOENT;
-                       goto err_out;
+                       goto stderr_out;
                }

                /* Skip the second run if dryrun was requested. */
@@ -1637,8 +1639,8 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
        nvlist_free(fss);

        /* Ensure no snaps found is treated as an error. */
-       if (err == 0 && !sdd.seento)
-               err = ENOENT;
+       if (err == 0 && (!sdd.seento || !sdd.seenfrom))
+               zfs_standard_error(zhp->zfs_hdl, ENOENT, errbuf);

        if (tid != 0) {
                if (err != 0)

It seems to me that this is not fixable without redesigning the way how error reporting in libzfs is done and since programatical interface to zfs is libzfs_core, it's better to use libzfs_core if proper error reporting is needed.

Also available in: Atom PDF