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 #13309
  • Loading branch information
rincebrain authored May 9, 2022
1 parent a18d13c commit a30927f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/libzfs_core/libzfs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,19 @@ max_pipe_buffer(int infd)
}

unsigned int cur = fcntl(infd, F_GETPIPE_SZ);
/*
* 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 (cur);
if (cur < max && fcntl(infd, F_SETPIPE_SZ, max) != -1)
cur = max;
return (cur);
Expand Down
8 changes: 8 additions & 0 deletions man/man8/zfs.8
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,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 a30927f

Please sign in to comment.