Module Name: src
Committed By: snj
Date: Tue Nov 1 19:49:04 UTC 2016
Modified Files:
src/lib/libperfuse [netbsd-7]: fuse.h libperfuse.3 perfuse.c
perfuse_if.h
src/usr.sbin/perfused [netbsd-7]: msg.c perfused.8
Log Message:
Pull up following revision(s) (requested by manu in ticket #1266):
lib/libperfuse/fuse.h: revision 1.7
lib/libperfuse/libperfuse.3: revision 1.4, 1.5
lib/libperfuse/perfuse.c: revision 1.38-1.40
lib/libperfuse/perfuse_if.h: revision 1.21, 1.22
usr.sbin/perfused/msg.c: revision 1.23, 1.24
usr.sbin/perfused/perfused.8: revision 1.12
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.
--
make this compile again, and simplify.
--
Sort sections. new sentence, new line. Whitespace.
--
make the env stuff visible.
--
remove dup function
To generate a diff of this commit:
cvs rdiff -u -r1.5.18.1 -r1.5.18.2 src/lib/libperfuse/fuse.h
cvs rdiff -u -r1.3 -r1.3.22.1 src/lib/libperfuse/libperfuse.3
cvs rdiff -u -r1.31.10.5 -r1.31.10.6 src/lib/libperfuse/perfuse.c
cvs rdiff -u -r1.20 -r1.20.10.1 src/lib/libperfuse/perfuse_if.h
cvs rdiff -u -r1.21.10.1 -r1.21.10.2 src/usr.sbin/perfused/msg.c
cvs rdiff -u -r1.11 -r1.11.18.1 src/usr.sbin/perfused/perfused.8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libperfuse/fuse.h
diff -u src/lib/libperfuse/fuse.h:1.5.18.1 src/lib/libperfuse/fuse.h:1.5.18.2
--- src/lib/libperfuse/fuse.h:1.5.18.1 Wed Nov 5 18:11:30 2014
+++ src/lib/libperfuse/fuse.h Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.5.18.1 2014/11/05 18:11:30 snj Exp $ */
+/* $NetBSD: fuse.h,v 1.5.18.2 2016/11/01 19:49:04 snj Exp $ */
/*-
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -34,8 +34,8 @@
#define FUSE_UNKNOWN_FH (uint64_t)0
#ifndef FUSE_BUFSIZE
-#define FUSE_MIN_BUFSIZE 0x21000
-#define FUSE_PREF_BUFSIZE (sysconf(_SC_PAGESIZE) + 0x1000)
+#define FUSE_MIN_BUFSIZE ((size_t)0x21000)
+#define FUSE_PREF_BUFSIZE ((size_t)(sysconf(_SC_PAGESIZE) + 0x1000))
#define FUSE_BUFSIZE MAX(FUSE_PREF_BUFSIZE /* CONSTCOND */, FUSE_MIN_BUFSIZE)
#endif /* FUSE_BUFSIZE */
Index: src/lib/libperfuse/libperfuse.3
diff -u src/lib/libperfuse/libperfuse.3:1.3 src/lib/libperfuse/libperfuse.3:1.3.22.1
--- src/lib/libperfuse/libperfuse.3:1.3 Tue May 10 12:14:37 2011
+++ src/lib/libperfuse/libperfuse.3 Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: libperfuse.3,v 1.3 2011/05/10 12:14:37 njoly Exp $
+.\" $NetBSD: libperfuse.3,v 1.3.22.1 2016/11/01 19:49:04 snj Exp $
.\"
.\" Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
.\"
@@ -105,6 +105,22 @@ handles control to the regular
returns a file descriptor to the
.Pa /dev/fuse
socket on success, and causes exit on failure.
+.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 ERRORS
.\".Fn perfuse_mount
.\"will fail when one of the following occurs:
Index: src/lib/libperfuse/perfuse.c
diff -u src/lib/libperfuse/perfuse.c:1.31.10.5 src/lib/libperfuse/perfuse.c:1.31.10.6
--- src/lib/libperfuse/perfuse.c:1.31.10.5 Thu Aug 6 21:52:13 2015
+++ src/lib/libperfuse/perfuse.c Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse.c,v 1.31.10.5 2015/08/06 21:52:13 snj Exp $ */
+/* $NetBSD: perfuse.c,v 1.31.10.6 2016/11/01 19:49:04 snj Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -32,6 +32,7 @@
#include <string.h>
#include <errno.h>
#include <puffs.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/resource.h>
@@ -52,7 +53,6 @@ extern char **environ;
static struct perfuse_state *init_state(void);
static int get_fd(const char *);
-
static struct perfuse_state *
init_state(void)
{
@@ -146,6 +146,25 @@ get_fd(const char *data)
}
+uint32_t
+perfuse_bufvar_from_env(const char *name, uint32_t defval)
+{
+ char valstr[1024];
+ int e;
+ uint32_t retval;
+
+ if (getenv_r(name, valstr, sizeof(valstr)) == -1)
+ return defval;
+
+ retval = (uint32_t)strtoi(valstr, NULL, 0, 0, UINT32_MAX, &e);
+ if (!e)
+ return retval;
+
+ DWARNC(e, "conversion from `%s' to uint32_t failed, using %u",
+ valstr, defval);
+ return defval;
+}
+
int
perfuse_open(const char *path, int flags, mode_t mode)
{
@@ -180,10 +199,11 @@ perfuse_open(const char *path, int flags
}
/*
- * 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 = perfuse_bufvar_from_env("PERFUSE_BUFSIZE",
+ (uint32_t)(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 +231,11 @@ perfuse_open(const char *path, int flags
}
/*
- * 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 = perfuse_bufvar_from_env("PERFUSE_BUFSIZE",
+ (uint32_t)(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);
Index: src/lib/libperfuse/perfuse_if.h
diff -u src/lib/libperfuse/perfuse_if.h:1.20 src/lib/libperfuse/perfuse_if.h:1.20.10.1
--- src/lib/libperfuse/perfuse_if.h:1.20 Sat Jul 21 05:49:42 2012
+++ src/lib/libperfuse/perfuse_if.h Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse_if.h,v 1.20 2012/07/21 05:49:42 manu Exp $ */
+/* $NetBSD: perfuse_if.h,v 1.20.10.1 2016/11/01 19:49:04 snj Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -103,13 +103,20 @@ extern int perfuse_diagflags;
} while (0 /* CONSTCOND */)
#define DWARN(fmt, ...) do { \
- \
if (perfuse_diagflags & PDF_SYSLOG) \
syslog(LOG_WARNING, fmt ": %m", ## __VA_ARGS__); \
\
warn(fmt, ## __VA_ARGS__); \
} while (0 /* CONSTCOND */)
+#define DWARNC(e, fmt, ...) do { \
+ if (perfuse_diagflags & PDF_SYSLOG) { \
+ errno = e; \
+ syslog(LOG_WARNING, fmt ": %m", ## __VA_ARGS__); \
+ } \
+ warnc(e, fmt, ## __VA_ARGS__); \
+} while (0 /* CONSTCOND */)
+
/*
* frame handling callbacks
*/
@@ -212,5 +219,6 @@ int perfuse_mainloop(struct puffs_usermo
int perfuse_unmount(struct puffs_usermount *);
void perfuse_trace_dump(struct puffs_usermount *, FILE *);
void perfuse_fsreq(struct puffs_usermount *, perfuse_msg_t *);
+uint32_t perfuse_bufvar_from_env(const char *, uint32_t);
#endif /* _PERFUSE_IF_H */
Index: src/usr.sbin/perfused/msg.c
diff -u src/usr.sbin/perfused/msg.c:1.21.10.1 src/usr.sbin/perfused/msg.c:1.21.10.2
--- src/usr.sbin/perfused/msg.c:1.21.10.1 Sun Aug 24 08:42:06 2014
+++ src/usr.sbin/perfused/msg.c Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.c,v 1.21.10.1 2014/08/24 08:42:06 martin Exp $ */
+/* $NetBSD: msg.c,v 1.21.10.2 2016/11/01 19:49:04 snj Exp $ */
/*-
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -80,15 +80,13 @@ perfused_open_sock(void)
/*
* Set a buffer lentgh large enough so that a few FUSE packets
* will fit.
- * XXX We will have to find how many packets we need
*/
- opt = 4 * FUSE_BUFSIZE;
+ opt = perfuse_bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE);
if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) != 0)
- DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt);
+ DWARN("%s: setsockopt SO_SNDBUF = %d failed", __func__, opt);
- opt = 4 * FUSE_BUFSIZE;
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) != 0)
- DWARN("%s: setsockopt SO_RCVBUF to %d failed", __func__, opt);
+ DWARN("%s: setsockopt SO_RCVBUF = %d failed", __func__, opt);
/*
* Request peer credentials
Index: src/usr.sbin/perfused/perfused.8
diff -u src/usr.sbin/perfused/perfused.8:1.11 src/usr.sbin/perfused/perfused.8:1.11.18.1
--- src/usr.sbin/perfused/perfused.8:1.11 Sun Jan 29 11:32:23 2012
+++ src/usr.sbin/perfused/perfused.8 Tue Nov 1 19:49:04 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: perfused.8,v 1.11 2012/01/29 11:32:23 wiz Exp $
+.\" $NetBSD: perfused.8,v 1.11.18.1 2016/11/01 19:49:04 snj Exp $
.\"
.\" Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
.\"
@@ -118,6 +118,12 @@ is started from
Enable debug output only when receiving
.Li SIGINFO .
.El
+.Sh ENVIRONMENT
+See
+.Xr libperfuse 3
+for environment variables affecting
+.Nm
+behavior.
.Sh SIGNALS
.Bl -tag -width indent
.It Dv SIGINFO