diff options
| author | manu <manu@NetBSD.org> | 2016-10-18 15:06:17 +0000 |
|---|---|---|
| committer | manu <manu@NetBSD.org> | 2016-10-18 15:06:17 +0000 |
| commit | 920dced7880bb3b5c13f5d58e5df9019094b8a2b (patch) | |
| tree | c133768e6c915f36206be08a8d2f4fcd4a2f7099 /lib/libperfuse | |
| parent | 4d4e8c15e5537932bd538a92769b81a3ad99a1ef (diff) | |
Make FUSE socket buffer tunable
When dealing with high I/O throughput, we could run out of buffer
space if the filesystem was not consuming requests fast enough.
Here we slightly raise the buffer size, and we make it tunable
through the PERFUSE_BUFSIZE environment variable so that we can
cope with higher requirement later.
While there, document PERFUSE_OPTIONS environment variable.
Diffstat (limited to 'lib/libperfuse')
| -rw-r--r-- | lib/libperfuse/libperfuse.3 | 17 | ||||
| -rw-r--r-- | lib/libperfuse/perfuse.c | 40 |
2 files changed, 51 insertions, 6 deletions
diff --git a/lib/libperfuse/libperfuse.3 b/lib/libperfuse/libperfuse.3 index 4aab1b7c3b9..a18eb769a57 100644 --- a/lib/libperfuse/libperfuse.3 +++ b/lib/libperfuse/libperfuse.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: libperfuse.3,v 1.3 2011/05/10 12:14:37 njoly Exp $ +.\" $NetBSD: libperfuse.3,v 1.4 2016/10/18 15:06:17 manu Exp $ .\" .\" Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. .\" @@ -100,6 +100,21 @@ is different than .Fn perfuse_open handles control to the regular .Xr open 2 . +.Sh ENVIRONMENT +.Bl -tag -width Er +.It Ev PERFUSE_OPTIONS +Comma-separated values controlling the usage of some FUSE methods. Allowed +values are +.Li enable_access , +.Li disable_access , +.Li enable_creat , +.Li disable_creat . +.It Ev PERFUSE_BUFSIZE +Set the socket buffer sizes used for communication with the filesystem. +This should be raised as operation throughput requires it. Default is +.Li 2162688 +bytes, which is enough to queue 16 FUSE packets of maximum 132 kB length. +.El .Sh RETURN VALUES .Fn perfuse_mount returns a file descriptor to the diff --git a/lib/libperfuse/perfuse.c b/lib/libperfuse/perfuse.c index a48586f5a0c..611483407ed 100644 --- a/lib/libperfuse/perfuse.c +++ b/lib/libperfuse/perfuse.c @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.37 2015/06/19 17:33:20 christos Exp $ */ +/* $NetBSD: perfuse.c,v 1.38 2016/10/18 15:06:17 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -51,6 +51,7 @@ extern char **environ; static struct perfuse_state *init_state(void); static int get_fd(const char *); +static uint32_t bufvar_from_env(const char *, const uint32_t); static struct perfuse_state * @@ -146,6 +147,35 @@ get_fd(const char *data) } +static uint32_t +bufvar_from_env(name, defval) + const char *name; + const uint32_t defval; +{ + char valstr[1024]; + uint32_t retval = defval; + + if (getenv_r(name, valstr, sizeof(valstr)) != -1) { + long int val; + char *ep; + + errno = 0; + val = (int)strtol(valstr, &ep, 10); + if (*valstr == '\0' || *ep != '\0') + DWARNX("bad %s value \"%s\"", name, valstr); + else if (errno != 0) + DWARN("bad %s value \"%s\"", name, valstr); + else if (val <= 0L || + (unsigned long int)val > (unsigned long int)UINT32_MAX) + DWARNX("%s value %ld out of " + "uint32_t bounds", name, val); + else + retval = val; + } + + return retval; +} + int perfuse_open(const char *path, int flags, mode_t mode) { @@ -180,10 +210,10 @@ perfuse_open(const char *path, int flags, mode_t mode) } /* - * Set a buffer lentgh large enough so that any FUSE packet + * Set a buffer lentgh large enough so that enough FUSE packets * will fit. */ - opt = (uint32_t)FUSE_BUFSIZE; + opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE); optlen = sizeof(opt); if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) != 0) DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt); @@ -211,10 +241,10 @@ perfuse_open(const char *path, int flags, mode_t mode) } /* - * Set a buffer lentgh large enough so that any FUSE packet + * Set a buffer lentgh large enough so that enough FUSE packets * will fit. */ - opt = (uint32_t)(4 * FUSE_BUFSIZE); + opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE); optlen = sizeof(opt); if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) != 0) DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt); |
