libzfs_core: lzc_send_wraper: maximise pipe buffer for existing pipes

This reduces scheduler overhead by letting the reader consume bigger
chunks (64k => 128k at full throttle)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13133
This commit is contained in:
наб 2022-02-21 19:51:48 +01:00 committed by Brian Behlendorf
parent 7eb179be18
commit a86e089415

View file

@ -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);