libzfs_core: block delivery of SIGUSR1 in send_worker thread - #19098
Merged
behlendorf merged 1 commit intoSep 14, 2026
Merged
Conversation
herrhotzenplotz
force-pushed
the
nsonack/send-progress-bug
branch
2 times, most recently
from
September 11, 2026 09:30
21a4fb2 to
f096b92
Compare
behlendorf
reviewed
Sep 11, 2026
behlendorf
left a comment
Contributor
There was a problem hiding this comment.
I agree limiting the fix to send_worker() is the way to go. That fix itself looks good, just one comment on the error handling. Thanks for running this down!
herrhotzenplotz
force-pushed
the
nsonack/send-progress-bug
branch
from
September 14, 2026 05:45
f096b92 to
ae86284
Compare
This fixes a Linux-specific bug. 3a909fe (libzfs, libzfs_core: send: always write to pipe, 2022-02-21) introduced a subtle bug where zfs send -RPv would not print status information periodically anymore when the stdout is redirected to something that isn't a pipe (e.g. >/dev/null). This is because the send_worker thread introduced by this commit is created with an unmodified signal mask from libzfs. When zfs_send_space is called it creates this thread. When we request verbose status information another thread is created which, in theory, should periodically receive a SIGUSR1 via a POSIX timer. The main thread blocks USR1 delivery *after* the creation of the progress thread, leaving the send_worker thread's signal mask unmodified. The delivery of SIGUSR1 is now random and for at least Debian Trixie with kernel 6.12.107+deb13-amd64 this causes the send_worker to be favoured. Interestingly, when stracing the zfs send, sometimes delivery flaps over to the correct thread. Without tracing this doesn't happen and the output remains silent instead. Fix this by blocking delivery of SIGUSR1 in the send_worker thread. We don't need to take care of SIGINFO since this thread is only created on Linux and SIGINFO is a BSD-specific signal. Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de>
herrhotzenplotz
force-pushed
the
nsonack/send-progress-bug
branch
from
September 14, 2026 05:48
ae86284 to
f7d8edb
Compare
behlendorf
approved these changes
Sep 14, 2026
lundman
pushed a commit
to openzfsonwindows/openzfs
that referenced
this pull request
Sep 27, 2026
This fixes a Linux-specific bug. 3a909fe (libzfs, libzfs_core: send: always write to pipe, 2022-02-21) introduced a subtle bug where zfs send -RPv would not print status information periodically anymore when the stdout is redirected to something that isn't a pipe (e.g. >/dev/null). This is because the send_worker thread introduced by this commit is created with an unmodified signal mask from libzfs. When zfs_send_space is called it creates this thread. When we request verbose status information another thread is created which, in theory, should periodically receive a SIGUSR1 via a POSIX timer. The main thread blocks USR1 delivery *after* the creation of the progress thread, leaving the send_worker thread's signal mask unmodified. The delivery of SIGUSR1 is now random and for at least Debian Trixie with kernel 6.12.107+deb13-amd64 this causes the send_worker to be favoured. Interestingly, when stracing the zfs send, sometimes delivery flaps over to the correct thread. Without tracing this doesn't happen and the output remains silent instead. Fix this by blocking delivery of SIGUSR1 in the send_worker thread. We don't need to take care of SIGINFO since this thread is only created on Linux and SIGINFO is a BSD-specific signal. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de> Closes openzfs#19098
4 of 14 tasks
behlendorf
pushed a commit
that referenced
this pull request
Sep 28, 2026
This fixes a Linux-specific bug. 3a909fe (libzfs, libzfs_core: send: always write to pipe, 2022-02-21) introduced a subtle bug where zfs send -RPv would not print status information periodically anymore when the stdout is redirected to something that isn't a pipe (e.g. >/dev/null). This is because the send_worker thread introduced by this commit is created with an unmodified signal mask from libzfs. When zfs_send_space is called it creates this thread. When we request verbose status information another thread is created which, in theory, should periodically receive a SIGUSR1 via a POSIX timer. The main thread blocks USR1 delivery *after* the creation of the progress thread, leaving the send_worker thread's signal mask unmodified. The delivery of SIGUSR1 is now random and for at least Debian Trixie with kernel 6.12.107+deb13-amd64 this causes the send_worker to be favoured. Interestingly, when stracing the zfs send, sometimes delivery flaps over to the correct thread. Without tracing this doesn't happen and the output remains silent instead. Fix this by blocking delivery of SIGUSR1 in the send_worker thread. We don't need to take care of SIGINFO since this thread is only created on Linux and SIGINFO is a BSD-specific signal. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de> Closes #19098
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
zfs send -RPv <snapshot-here>does not periodically print progress information on Linux when stdout is not a pipe.Description
A detailed explanation can be found in the commit message.
The fix is simple: block delivery of SIGUSR1 to the
send_workerquirk thread.I am not sure about the error case when pthread_sigmask returns an error. I suppose that could be improved.
An alternative would be to go through each place in libzfs and libzfs_core and check where threads are created, modify the signal masks to block delivery of USR1 and selectively unblock them in the progress threads again.
Really, that solution is "more correct" but it seems error-prone.
How Has This Been Tested?
I've verified that this change fixes the bug on Debian Trixie w/ kernel
6.12.107+deb13-amd64.I have not tested this on FreeBSD and/or Illumos since the code path I have changed is only enabled on Linux.
I have test-compiled on FreeBSD.
Types of Changes
Checklist
Signed-off-by.