aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/pyzfs
diff options
context:
space:
mode:
authorPaul Dagnelie <[email protected]>2020-03-17 10:30:33 -0700
committerGitHub <[email protected]>2020-03-17 10:30:33 -0700
commit7145123b0ae4d625a419ee357a0df9467b1e8311 (patch)
treed09d3799ab5b2326200f95a32c78b7c8cbfb7625 /contrib/pyzfs
parent5b3b79559c3206ea5916cbdab72b88344aa6e9a2 (diff)
Separate warning for incomplete and corrupt streams
This change adds a separate return code to zfs_ioc_recv that is used for incomplete streams, in addition to the existing return code for streams that contain corruption. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #10122
Diffstat (limited to 'contrib/pyzfs')
-rw-r--r--contrib/pyzfs/libzfs_core/_constants.py1
-rw-r--r--contrib/pyzfs/libzfs_core/_error_translation.py2
-rw-r--r--contrib/pyzfs/libzfs_core/exceptions.py8
-rw-r--r--contrib/pyzfs/libzfs_core/test/test_libzfs_core.py4
4 files changed, 12 insertions, 3 deletions
diff --git a/contrib/pyzfs/libzfs_core/_constants.py b/contrib/pyzfs/libzfs_core/_constants.py
index e1364aa33..5c285164b 100644
--- a/contrib/pyzfs/libzfs_core/_constants.py
+++ b/contrib/pyzfs/libzfs_core/_constants.py
@@ -94,6 +94,7 @@ zfs_errno = enum_with_offset(1024, [
'ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE',
'ZFS_ERR_EXPORT_IN_PROGRESS',
'ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR',
+ 'ZFS_ERR_STREAM_TRUNCATED',
],
{}
)
diff --git a/contrib/pyzfs/libzfs_core/_error_translation.py b/contrib/pyzfs/libzfs_core/_error_translation.py
index 7881715c9..5a063c714 100644
--- a/contrib/pyzfs/libzfs_core/_error_translation.py
+++ b/contrib/pyzfs/libzfs_core/_error_translation.py
@@ -469,6 +469,8 @@ def lzc_receive_translate_errors(
raise lzc_exc.BadStream()
if ret == ZFS_ERR_WRONG_PARENT:
raise lzc_exc.WrongParent(_fs_name(snapname))
+ if ret == zfs_errno.ZFS_ERR_STREAM_TRUNCATED:
+ raise lzc_exc.StreamTruncated()
raise lzc_exc.StreamIOError(ret)
diff --git a/contrib/pyzfs/libzfs_core/exceptions.py b/contrib/pyzfs/libzfs_core/exceptions.py
index 9eeab1d7c..6c571b7e2 100644
--- a/contrib/pyzfs/libzfs_core/exceptions.py
+++ b/contrib/pyzfs/libzfs_core/exceptions.py
@@ -29,7 +29,8 @@ from ._constants import (
ZFS_ERR_NO_CHECKPOINT,
ZFS_ERR_DEVRM_IN_PROGRESS,
ZFS_ERR_VDEV_TOO_BIG,
- ZFS_ERR_WRONG_PARENT
+ ZFS_ERR_WRONG_PARENT,
+ zfs_errno
)
@@ -351,6 +352,11 @@ class StreamFeatureIncompatible(ZFSError):
message = "Incompatible embedded feature with encrypted receive"
+class StreamTruncated(ZFSError):
+ errno = zfs_errno.ZFS_ERR_STREAM_TRUNCATED
+ message = "incomplete stream"
+
+
class ReceivePropertyFailure(MultipleOperationsFailure):
message = "Receiving of properties failed for one or more reasons"
diff --git a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
index f47583b83..a841f96af 100644
--- a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
+++ b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
@@ -2714,7 +2714,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(src, None, stream.fileno())
stream.seek(0)
stream.truncate(1024 * 3)
- with self.assertRaises(lzc_exc.BadStream):
+ with self.assertRaises(lzc_exc.StreamTruncated):
lzc.lzc_receive_resumable(dst, stream.fileno())
# Resume token code from zfs_send_resume_token_to_nvlist()
# XXX: if used more than twice move this code into an external func
@@ -2771,7 +2771,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap2, snap1, stream.fileno())
stream.seek(0)
stream.truncate(1024 * 3)
- with self.assertRaises(lzc_exc.BadStream):
+ with self.assertRaises(lzc_exc.StreamTruncated):
lzc.lzc_receive_resumable(dst2, stream.fileno())
# Resume token code from zfs_send_resume_token_to_nvlist()
# format: <version>-<cksum>-<packed-size>-<compressed-payload>