diff options
author | Matthias Goergens <matthias.goergens@gmail.com> | 2024-03-05 15:10:21 +0100 |
---|---|---|
committer | Bernd Schubert <bschubert@ddn.com> | 2024-03-07 11:56:04 +0100 |
commit | bb9cecbf67341e03e53dd36b8f69520f3a26f834 (patch) | |
tree | cd9ed27fad20dfcdcbce5aa864dd5b846f23476b /util | |
parent | 9e35addc358375c9228fcc2d5df780e9f4fef164 (diff) | |
download | libfuse-bb9cecbf67341e03e53dd36b8f69520f3a26f834.tar.gz |
Use posix_spawn instead of fork+exec
Client code might allocate a lot of memory before starting the mount.
Fork is slow for processes that are using a lot of memory. But
posix_spawn fixes that.
Another issue with fork is if the process is also doing RDMA - this
might lead to data corruption, as least if memory used for RDMA
is not marked with MADV_DONTFORK. At least with linux kernels
before 5.12.
Also see https://blog.nelhage.com/post/a-cursed-bug/ for more details
Change by Bernd:
This also prepares the new fusermount option "--comm-fd", but keeps
the previous way to pass the parameter as env variable. In a future
release (exact data to be determined) we are going to remove usage
of the env variable and will switch to the new parameter.
Diffstat (limited to 'util')
-rw-r--r-- | util/fusermount.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index 06f5f56..5716c76 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -1454,7 +1454,7 @@ int main(int argc, char *argv[]) static int unmount = 0; static int lazy = 0; static int quiet = 0; - char *commfd; + char *commfd = NULL; int cfd; const char *opts = ""; const char *type = NULL; @@ -1462,14 +1462,15 @@ int main(int argc, char *argv[]) static const struct option long_opts[] = { {"unmount", no_argument, NULL, 'u'}, - // Note: auto-unmount deliberately does not have a short version. - // It's meant for internal use by mount.c's setup_auto_unmount. - {"auto-unmount", no_argument, NULL, 'U'}, {"lazy", no_argument, NULL, 'z'}, {"quiet", no_argument, NULL, 'q'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, {"options", required_argument, NULL, 'o'}, + // Note: auto-unmount and comm-fd don't have short versions. + // They'ne meant for internal use by mount.c + {"auto-unmount", no_argument, NULL, 'U'}, + {"comm-fd", required_argument, NULL, 'c'}, {0, 0, 0, 0}}; progname = strdup(argc > 0 ? argv[0] : "fusermount"); @@ -1501,6 +1502,9 @@ int main(int argc, char *argv[]) auto_unmount = 1; setup_auto_unmount_only = 1; break; + case 'c': + commfd = optarg; + break; case 'z': lazy = 1; break; @@ -1547,7 +1551,8 @@ int main(int argc, char *argv[]) if (!setup_auto_unmount_only && unmount) goto do_unmount; - commfd = getenv(FUSE_COMMFD_ENV); + if(commfd == NULL) + commfd = getenv(FUSE_COMMFD_ENV); if (commfd == NULL) { fprintf(stderr, "%s: old style mounting not supported\n", progname); |