zfsonlinux/debian/patches/0013-Add-workaround-for-broken-Linux-pipes.patch
Thomas Lamprecht dca6abbf07 backport pipe-resize and xattr fix
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-07 13:19:51 +01:00

69 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Rich Ercolani <214141+rincebrain@users.noreply.github.com>
Date: Mon, 9 May 2022 19:33:55 -0400
Subject: [PATCH] Add workaround for broken Linux pipes
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 <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13309
(cherry picked from commit e84a2ed7a8b9e6458c25c6e93a93601eaf4128eb)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
lib/libzfs/os/linux/libzfs_sendrecv_os.c | 16 ++++++++++++++++
man/man8/zfs.8 | 8 ++++++++
2 files changed, 24 insertions(+)
diff --git a/lib/libzfs/os/linux/libzfs_sendrecv_os.c b/lib/libzfs/os/linux/libzfs_sendrecv_os.c
index ac7ab95a3..8fc02fff2 100644
--- a/lib/libzfs/os/linux/libzfs_sendrecv_os.c
+++ b/lib/libzfs/os/linux/libzfs_sendrecv_os.c
@@ -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) {
diff --git a/man/man8/zfs.8 b/man/man8/zfs.8
index fca1ba00d..a5c944169 100644
--- a/man/man8/zfs.8
+++ b/man/man8/zfs.8
@@ -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 .