libzfs: migrate single-use libzfs_set_pipe_max() to libzfs_core
Notably, this also means that the pipe is expanded before each dataset is received, so updates to /p/s/f/pipe-max-size are reflected for each new dataset Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rich Ercolani <rincebrain@gmail.com> Reviewed-by: Paul Dagnelie <pcd@delphix.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13133
This commit is contained in:
parent
08eb2309ce
commit
8a3d77358a
|
@ -41,7 +41,6 @@ if BUILD_LINUX
|
||||||
USER_C += \
|
USER_C += \
|
||||||
os/linux/libzfs_mount_os.c \
|
os/linux/libzfs_mount_os.c \
|
||||||
os/linux/libzfs_pool_os.c \
|
os/linux/libzfs_pool_os.c \
|
||||||
os/linux/libzfs_sendrecv_os.c \
|
|
||||||
os/linux/libzfs_util_os.c
|
os/linux/libzfs_util_os.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,6 @@ extern int libzfs_load_module(void);
|
||||||
extern int zpool_relabel_disk(libzfs_handle_t *hdl, const char *path,
|
extern int zpool_relabel_disk(libzfs_handle_t *hdl, const char *path,
|
||||||
const char *msg);
|
const char *msg);
|
||||||
extern int find_shares_object(differ_info_t *di);
|
extern int find_shares_object(differ_info_t *di);
|
||||||
extern void libzfs_set_pipe_max(int infd);
|
|
||||||
extern void zfs_commit_proto(const zfs_share_proto_t *);
|
extern void zfs_commit_proto(const zfs_share_proto_t *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -5243,13 +5243,6 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
|
||||||
return (-2);
|
return (-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* It is not uncommon for gigabytes to be processed in zfs receive.
|
|
||||||
* Speculatively increase the buffer size if supported by the platform.
|
|
||||||
*/
|
|
||||||
if (S_ISFIFO(sb.st_mode))
|
|
||||||
libzfs_set_pipe_max(infd);
|
|
||||||
|
|
||||||
if (props) {
|
if (props) {
|
||||||
err = nvlist_lookup_string(props, "origin", &originsnap);
|
err = nvlist_lookup_string(props, "origin", &originsnap);
|
||||||
if (err && err != ENOENT)
|
if (err && err != ENOENT)
|
||||||
|
|
|
@ -38,12 +38,6 @@
|
||||||
#define ZFS_KMOD "openzfs"
|
#define ZFS_KMOD "openzfs"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
libzfs_set_pipe_max(int infd)
|
|
||||||
{
|
|
||||||
/* FreeBSD automatically resizes */
|
|
||||||
(void) infd;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
execvPe(const char *name, const char *path, char * const *argv,
|
execvPe(const char *name, const char *path, char * const *argv,
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <libzfs.h>
|
|
||||||
|
|
||||||
#include "../../libzfs_impl.h"
|
|
||||||
|
|
||||||
#ifndef F_SETPIPE_SZ
|
|
||||||
#define F_SETPIPE_SZ (F_SETLEASE + 7)
|
|
||||||
#endif /* F_SETPIPE_SZ */
|
|
||||||
|
|
||||||
#ifndef F_GETPIPE_SZ
|
|
||||||
#define F_GETPIPE_SZ (F_GETLEASE + 7)
|
|
||||||
#endif /* F_GETPIPE_SZ */
|
|
||||||
|
|
||||||
void
|
|
||||||
libzfs_set_pipe_max(int infd)
|
|
||||||
{
|
|
||||||
FILE *procf = fopen("/proc/sys/fs/pipe-max-size", "re");
|
|
||||||
|
|
||||||
if (procf != NULL) {
|
|
||||||
unsigned long max_psize;
|
|
||||||
long cur_psize;
|
|
||||||
if (fscanf(procf, "%lu", &max_psize) > 0) {
|
|
||||||
cur_psize = fcntl(infd, F_GETPIPE_SZ);
|
|
||||||
if (cur_psize > 0 &&
|
|
||||||
max_psize > (unsigned long) cur_psize)
|
|
||||||
fcntl(infd, F_SETPIPE_SZ,
|
|
||||||
max_psize);
|
|
||||||
}
|
|
||||||
fclose(procf);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -586,6 +586,30 @@ lzc_get_holds(const char *snapname, nvlist_t **holdsp)
|
||||||
return (lzc_ioctl(ZFS_IOC_GET_HOLDS, snapname, NULL, holdsp));
|
return (lzc_ioctl(ZFS_IOC_GET_HOLDS, snapname, NULL, holdsp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
max_pipe_buffer(int infd)
|
||||||
|
{
|
||||||
|
#if __linux__
|
||||||
|
FILE *procf = fopen("/proc/sys/fs/pipe-max-size", "re");
|
||||||
|
|
||||||
|
if (procf != NULL) {
|
||||||
|
unsigned long max_psize;
|
||||||
|
long cur_psize;
|
||||||
|
if (fscanf(procf, "%lu", &max_psize) > 0) {
|
||||||
|
cur_psize = fcntl(infd, F_GETPIPE_SZ);
|
||||||
|
if (cur_psize > 0 &&
|
||||||
|
max_psize > (unsigned long) cur_psize)
|
||||||
|
fcntl(infd, F_SETPIPE_SZ,
|
||||||
|
max_psize);
|
||||||
|
}
|
||||||
|
fclose(procf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* FreeBSD automatically resizes */
|
||||||
|
(void) infd;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate a zfs send stream for the specified snapshot and write it to
|
* Generate a zfs send stream for the specified snapshot and write it to
|
||||||
* the specified file descriptor.
|
* the specified file descriptor.
|
||||||
|
@ -811,6 +835,16 @@ recv_impl(const char *snapname, nvlist_t *recvdprops, nvlist_t *localprops,
|
||||||
*slashp = '\0';
|
*slashp = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It is not uncommon for gigabytes to be processed by zfs receive.
|
||||||
|
* Speculatively increase the buffer size if supported by the platform.
|
||||||
|
*/
|
||||||
|
struct stat sb;
|
||||||
|
if (fstat(input_fd, &sb) == -1)
|
||||||
|
return (errno);
|
||||||
|
if (S_ISFIFO(sb.st_mode))
|
||||||
|
max_pipe_buffer(input_fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The begin_record is normally a non-byteswapped BEGIN record.
|
* The begin_record is normally a non-byteswapped BEGIN record.
|
||||||
* For resumable streams it may be set to any non-byteswapped
|
* For resumable streams it may be set to any non-byteswapped
|
||||||
|
|
Loading…
Reference in New Issue