Skip to content

Commit

Permalink
libzfs_core: lzc_send_wraper: maximise pipe buffer for existing pipes
Browse files Browse the repository at this point in the history
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 openzfs#13133
  • Loading branch information
nabijaczleweli authored and andrewc12 committed Aug 30, 2022
1 parent bd88f02 commit aecf6e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/libzfs_core/libzfs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down

0 comments on commit aecf6e8

Please sign in to comment.