zrepl/zfs/zfscmd
Christian Schwarz a8e92971d0 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-09-19 20:11:31 +02:00
..
zfscmd-logging-scraper [#307] add package trace, integrate it with logging, and adopt it throughout zrepl 2020-05-19 11:30:02 +02:00
zfscmd_context.go [#307] add package trace, integrate it with logging, and adopt it throughout zrepl 2020-05-19 11:30:02 +02:00
zfscmd_logging.go zfscmd: fix crash in zfscmd_prometheus.go due to incorrectly extracted ProcessState 2020-04-21 14:10:25 +02:00
zfscmd_platform_test.bash zfs: introduce pkg zfs/zfscmd for command logging, status, prometheus metrics 2020-04-05 20:47:25 +02:00
zfscmd_platform_test.go [#307] add package trace, integrate it with logging, and adopt it throughout zrepl 2020-05-19 11:30:02 +02:00
zfscmd_prometheus.go zfscmd: fix crash in zfscmd_prometheus.go due to incorrectly extracted ProcessState 2020-04-21 14:10:25 +02:00
zfscmd_report.go zfscmd: fix crash in zfscmd_prometheus.go due to incorrectly extracted ProcessState 2020-04-21 14:10:25 +02:00
zfscmd.go zfs: rewrite SendStream, fix bug in Close() on FreeBSD, add platformtests 2021-09-19 20:11:31 +02:00