From a86e089415679cf1b98eb424a159bb36aa2c19e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 21 Feb 2022 19:51:48 +0100 Subject: [PATCH] libzfs_core: lzc_send_wraper: maximise pipe buffer for existing pipes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This reduces scheduler overhead by letting the reader consume bigger chunks (64k => 128k at full throttle) Reviewed-by: Brian Behlendorf Reviewed-by: Paul Dagnelie Reviewed-by: Rich Ercolani Signed-off-by: Ahelenia Ziemiańska Closes #13133 --- lib/libzfs_core/libzfs_core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libzfs_core/libzfs_core.c b/lib/libzfs_core/libzfs_core.c index f3e505265d73..0d74aa2133f4 100644 --- a/lib/libzfs_core/libzfs_core.c +++ b/lib/libzfs_core/libzfs_core.c @@ -652,8 +652,9 @@ send_worker(void *arg) * Returns the error from func(), if nonzero, * otherwise the error from the thread. * - * No-op if orig_fd is -1, already a pipe, and on not-Linux; - * as such, it is safe to wrap/call wrapped functions in a wrapped context. + * No-op if orig_fd is -1, already a pipe (but the buffer size is bumped), + * and on not-Linux; as such, it is safe to wrap/call wrapped functions + * in a wrapped context. */ int lzc_send_wrapper(int (*func)(int, void *), int orig_fd, void *data) @@ -662,8 +663,11 @@ lzc_send_wrapper(int (*func)(int, void *), int orig_fd, void *data) struct stat sb; if (orig_fd != -1 && fstat(orig_fd, &sb) == -1) return (errno); - if (orig_fd == -1 || S_ISFIFO(sb.st_mode)) + if (orig_fd == -1 || S_ISFIFO(sb.st_mode)) { + if (orig_fd != -1) + (void) max_pipe_buffer(orig_fd); return (func(orig_fd, data)); + } if ((fcntl(orig_fd, F_GETFL) & O_ACCMODE) == O_RDONLY) return (errno = EBADF); -- 2.41.0