zrepl/zfs
Christian Schwarz 226962b4fb zfs: rewrite SendStream, fix bug in Close() on FreeBSD, add platformtests
This commit was motivated by https://github.com/zrepl/zrepl/issues/495
where, on FreeBSD with OpenZFS 2.0, a SendStream.Close() call might wait indefinitely for `zfs send` to exit.
The reason is that, due to the refactoring done for redacted send & recv
(30af21b025),
the `dump_bytes` function, which writes to the pipe, executes in a separate thread (synctask taskq) iff not `HAVE_LARGE_STACKS`.
The `zfs send` process/thread waits for that taskq thread using an uninterruptible primitive.
So when we SIGKILL `zfs send`, that signal doesn't reach the right thread to interrupt the pipe write.

Theoretically this affects both Linux and FreeBSD, but most Linux users `HAVE_LARGE_STACKS` and since https://github.com/penzfs/zfs/pull/12350/files OpenZFS on FreeBSD `HAVE_LARGE_STACKS` as well.
However, at least until FreeBSD 13.1, possibly for the entire 13 lifecycle, we're going to have to live with that oddity.

Measures taken in this commit:
- Report the behavior as an upstream bug https://github.com/openzfs/zfs/issues/12500
- Change SendStream code so that it closes zrepl's read-end of the pipe (see comment in code)
- Clean up and make explicit SendStream's state handling
- Write extensive platformtests for SendStream
    - They pass on my Linux install and on FreeBSD 12
    - FreeBSD 13 still needs testing.

fixes https://github.com/zrepl/zrepl/issues/495
2021-08-23 00:21:34 +02:00
..
property [#285] support setting zfs send / recv flags in the config (send: -wLcepbS, recv: -ox) 2021-02-20 17:20:45 +01:00
test_helpers Implement DatasetMapping + basic ZFS list functionality. 2017-04-26 17:39:16 +02:00
zfscmd zfs: rewrite SendStream, fix bug in Close() on FreeBSD, add platformtests 2021-08-23 00:21:34 +02:00
datasetpath_visitor_test.go [#342] endpoint: always create unencrypted placeholder filesystems 2020-07-26 20:32:35 +02:00
datasetpath_visitor.go [#342] endpoint: always create unencrypted placeholder filesystems 2020-07-26 20:32:35 +02:00
encryption.go [#285] support setting zfs send / recv flags in the config (send: -wLcepbS, recv: -ox) 2021-02-20 17:20:45 +01:00
holds.go endpoint: refactor, fix stale holds on initial replication failure, zfs-abstractions subcmd, more efficient ZFS queries 2020-04-18 12:26:03 +02:00
mapping.go endpoint: refactor, fix stale holds on initial replication failure, zfs-abstractions subcmd, more efficient ZFS queries 2020-04-18 12:26:03 +02:00
namecheck_test.go new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold 2020-02-14 22:00:13 +01:00
namecheck.go new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold 2020-02-14 22:00:13 +01:00
placeholder.go [#285] support setting zfs send / recv flags in the config (send: -wLcepbS, recv: -ox) 2021-02-20 17:20:45 +01:00
prometheus.go bring back prometheus metrics, with new metrics for replication state machine 2018-09-07 22:22:34 -07:00
propertysource_enumer.go zfs: PropertySource: set type to uint32 so that enumer-generated code is platform-independent 2021-03-14 22:32:45 +01:00
resume_token.go zfs: ResumeToken: parse embedok, largeblockok, savedok if available 2021-02-20 17:04:57 +01:00
versions_destroy_test.go zfs: use exec.CommandContext everywhere 2020-03-27 13:08:43 +01:00
versions_destroy.go [#307] add package trace, integrate it with logging, and adopt it throughout zrepl 2020-05-19 11:30:02 +02:00
versions.go [#285] support setting zfs send / recv flags in the config (send: -wLcepbS, recv: -ox) 2021-02-20 17:20:45 +01:00
zfs_debug.go run golangci-lint and apply suggested fixes 2019-03-27 13:12:26 +01:00
zfs_pipe_linux.go zfs: pipe size: default to value of /proc/sys/fs/pipe-max-siz 2021-03-25 22:24:50 +01:00
zfs_pipe.go zfs: pipe size: default to value of /proc/sys/fs/pipe-max-siz 2021-03-25 22:24:50 +01:00
zfs_test.go [#285] support setting zfs send / recv flags in the config (send: -wLcepbS, recv: -ox) 2021-02-20 17:20:45 +01:00
zfs.go zfs: rewrite SendStream, fix bug in Close() on FreeBSD, add platformtests 2021-08-23 00:21:34 +02:00