Skip to content

Commit

Permalink
Add workaround for broken Linux pipes
Browse files Browse the repository at this point in the history
Linux has an unresolved hang if you resize a pipe with bytes
in it.

Since there's no obvious way to detect this happening, added a
workaround to disable resizing the pipe buffer if you set an
environment variable.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Rich Ercolani <[email protected]>
Closes openzfs#13309
  • Loading branch information
rincebrain committed Jan 3, 2023
1 parent f28c730 commit da42e0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/libzfs/os/linux/libzfs_sendrecv_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@
void
libzfs_set_pipe_max(int infd)
{
#if __linux__
/*
* Sadly, Linux has an unfixed deadlock if you do SETPIPE_SZ on a pipe
* with data in it.
* cf. #13232, https://bugzilla.kernel.org/show_bug.cgi?id=212295
*
* And since the problem is in waking up the writer, there's nothing
* we can do about it from here.
*
* So if people want to, they can set this, but they
* may regret it...
*/
if (getenv("ZFS_SET_PIPE_MAX") == NULL)
return;
#endif

FILE *procf = fopen("/proc/sys/fs/pipe-max-size", "re");

if (procf != NULL) {
Expand Down
8 changes: 8 additions & 0 deletions man/man8/zfs.8
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,14 @@ to use
to mount ZFS datasets.
This option is provided for backwards compatibility with older ZFS versions.
.El
.Bl -tag -width "ZFS_SET_PIPE_MAX"
.It Sy ZFS_SET_PIPE_MAX
Tells
.Nm zfs
to set the maximum pipe size for sends/recieves.
Disabled by default on Linux
due to an unfixed deadlock in Linux's pipe size handling code.
.El
.
.Sh INTERFACE STABILITY
.Sy Committed .
Expand Down

0 comments on commit da42e0c

Please sign in to comment.