Commit Graph

1997 Commits

Author SHA1 Message Date
Yaroslav Halchenko
0f8cb28883
Fix typos and configure spellcheck for PRs 2023-03-29 19:47:13 +01:00
Matthias Goergens
ed9be12837 Fix meson deprecation warning
When running `meson ..` I get:

```
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
```

So let's fix this in the docs.
2023-03-29 09:17:05 +01:00
Matthias Goergens
f2144c6c3a Fix use-after-free warning
When building, I get the following warning:

```bash
$ ninja
[18/71] Compiling C object lib/libfuse3.so.3.14.1.p/modules_iconv.c.o
../lib/modules/iconv.c: In function ‘iconv_convpath’:
../lib/modules/iconv.c:85:38: warning: pointer ‘newpath’ may be used after ‘realloc’ [-Wuse-after-free]
   85 |                         p = tmp + (p - newpath);
      |                                   ~~~^~~~~~~~~~
../lib/modules/iconv.c:80:31: note: call to ‘realloc’ here
   80 |                         tmp = realloc(newpath, newpathlen + 1);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[71/71] Linking target example/passthrough_hp
```

It's a false positive,  I thinks.  But it's also easy to silence this
warning with a small refactor.
2023-03-28 21:32:00 +01:00
Matthias Goergens
1703ccb31c Review feedback: rename and comments 2023-03-28 21:31:18 +01:00
Matthias Goergens
055478f11d Fix auto_unmount to work without allow_other
In
77d662459a/util/fusermount.c (L1219)
`open` is executed as root which does not have access to the mount
point if `allow_other` was not used and the real user id is not 0. Since
`allow_other` usually cannot be specified by unprivileged users,
`auto_unmount` has no effect for unprivileged users.

In this commit, we work around this limitation:

We first try to open the mountpoint as root, and if we get `EACCES`, we
retry as the user who started fusermount, and see if we get `ENOTCONN`.

In my testing, I found that `setfsuid` and `setfsgid` don't work to get
around the lack of `allow_other`.  (Sorry, I don't know enough about the
Linux kernel to tell whether that's significant.)  As a workaround, I
decided to use `setresuid` and `setresgid` in a forked child process,
and communicate via its exit status.

Please give feedback on correctness, style and suggest tests.

Fixes https://github.com/libfuse/libfuse/issues/586
2023-03-28 21:31:18 +01:00
Nikolaus Rath
b509964f7c Update script to drop references to Travis CI. 2023-03-26 11:49:40 +01:00
Nikolaus Rath
d8d1f84200 Released 3.14.1 2023-03-26 11:44:40 +01:00
Nikolaus Rath
024eccbfa5 Revert "upgrade of fuse_kernel.h based on Miklos expire_only kernel patch https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/commit/?h=for-next&id=53e949edb7692dce02220eba926c9d75ecbb47f7"
This reverts commit 7f430a39db because it
breaks setxattr().

Fixes: #730
2023-03-26 11:35:22 +01:00
Bernd Schubert
81ad52c7db Add more time mount options to fusermount / fix lazytime
Previous patch had forgotten fusermount. And also had "lazyatime"
instead of "lazytime".
2023-03-20 09:00:14 +00:00
Bernd Schubert
1e66c92153 Add more time mount options
These are especially needed for xfstests, but also
useful in general.
2023-03-19 15:13:57 +00:00
Heiko Becker
b45d66cafb Respect includedir when installing libfuse_config.h 2023-03-12 18:58:59 +00:00
Sarath Lakshman
ab5ca07af0 Fix max_threads command line parameter propagation
The fuse_main_real() method doesn't apply the max_threads parameter
parsed through the commandline arguments. This commit fixes the wiring
of max_threads argument.
2023-03-11 17:06:21 +00:00
Dharmendra singh
a5eb7f2a01 Enable parallel direct writes on the same file.
Right now fuse kernel serializes direct writes on the
same file. This serialization is good for such FUSE
implementations which rely on the inode lock to
avoid any data inconsistency issues but it hurts badly
such FUSE implementations which have their own mechanism
of dealing with cache/data integrity and can handle
parallel direct writes on the same file.

This patch allows parallel direct writes on the same file to be
enabled with the help of a flag FOPEN_PARALLEL_DIRECT_WRITES.
FUSE implementations which want to use this feature can
set this flag during fuse init. Default behaviour remains
same i.e no parallel direct writes on the same file.

Corresponding fuse kernel patch(Merged).
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.2&id=153524053bbb0d27bb2e0be36d1b46862e9ce74c
2023-03-03 12:41:49 +00:00
Nikolaus Rath
4f8aae77e6 Update description of keep_cache. 2023-03-01 09:46:10 +00:00
Nikolaus Rath
17e8b3e273 Migrate from Travis to Github actions
With current Ubuntu, Valgrind apparently does not like clang debug info, so do not run
valgrind with clang-compiled binaries.
2023-02-20 20:28:12 +00:00
Bernd Schubert
2da03e3898 Avoid max-idle threads warning
If a program with API before 312 did not set
max_idle_threads the new default from
fuse_parse_cmdline_312() is applied, which sets
UINT_MAX (-1).

Later in compat fuse_session_loop_mt_32 the old
config v1 struct is converted and that conversion
prints a warning if the default unset value was used.

This could have also happened to programs using the current
API, which just apply values struct fuse_cmdline_opts,
without checking if the defaults are set.
2023-02-20 10:14:17 +00:00
Pierre Labastie
df2cde25a6 Change define for C++ too
Commit d7560cc has split defines into private and public, and passed -DHAVE_LIBFUSE-PRIVATE_CONFIG_H to all C programs. But the arguments of C++ programs have not been changed. This leads to a test failure as reported in issue #734. Pass -DHAVE_LIBFUSE-PRIVATE_CONFIG_H to C++ programs too.

Fixes: #734
2023-02-20 10:13:32 +00:00
Bernd Schubert
91e6e3c863 Add a github actions file
converted from travis with _sligh_ editing by
https://akx.github.io/travis-to-github-actions/
2023-02-20 10:08:25 +00:00
Nikolaus Rath
3f65bb699c Released 3.14.0 2023-02-17 09:31:14 +00:00
Xiubo Li
418b7efca9 fuse_lowlevel.h: add more setattr flags
Such as for the xfstest-dev's generic/684 test case it will clear
suid and sgid if the fallocate request is commited by an unprivileged
user.

The kernel fuse passed the ATTR_KILL_SUID/ATTR_KILL_SGID flags to
userspace but it will be dropped.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
2023-02-09 10:22:15 +00:00
Bernd Schubert
d7560cc991 Split config.h into private and public config
This addresses https://github.com/libfuse/libfuse/issues/729

commit db35a37def introduced a public
config.h (rename to fuse_config.h to avoid conflicts) that
was installed with the package and included by libfuse users
through fuse_common.h. Probablem is that this file does not have
unique defines so that they are unique to libfuse - on including
the file conflicts with libfuse users came up.

In principle all defines could be prefixed, but then most of them
are internal for libfuse compilation only. So this splits out
publically required defines to a new file 'libfuse_config.h'
and changes back to include of "fuse_config.h" only when
HAVE_LIBFUSE_PRIVATE_CONFIG_H is defined.

This also renames HAVE_LIBC_VERSIONED_SYMBOLS to
LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS, as it actually
better explains for libfuse users what that variable
is for.
2023-02-09 10:21:29 +00:00
Nikolaus Rath
becc030e94 Released 3.13.1 2023-02-03 10:05:30 +00:00
Bernd Schubert
db35a37def Install a the configure_file (config.h) and use in headers
This addresses: https://github.com/libfuse/libfuse/issues/724

HAVE_LIBC_VERSIONED_SYMBOLS configures the library if to use
versioned symbols and is set at meson configuration time.
External filesystems (the main target, actually)
include fuse headers and the preprocessor
then acts on HAVE_LIBC_VERSIONED_SYMBOLS. Problem was now that
'config.h' was not distributed with libfuse and so
HAVE_LIBC_VERSIONED_SYMBOLS was never defined with external
tools and the preprocessor did the wrong decision.

This commit also increases the the minimal meson version,
as this depends on meson feature only available in 0.50

<quote 'meson' >
WARNING: Project specifies a minimum meson_
version '>= 0.42' but uses features which were added
 in newer versions:
 * 0.50.0: {'install arg in configure_file'}
</quote>

Additionally the config file has been renamed to "fuse_config.h"
to avoid clashes - 'config.h' is not very specific.
2023-01-28 09:35:34 +00:00
Bernd Schubert
e42b972271 Update travis to ubuntu jammy (22.04)
A newer ubuntu version is required to get a more recent meson
(at least 0.50 now)
2023-01-28 09:35:34 +00:00
psykose
19d95c0e70 use off_t over __off64_t
when -D_FILE_OFFSET_BITS=64 is defined, the off_t type is 64 bits wide
already. the fuse_common.h header already checks for this, and errors
when it is not, so be consistent with all the other uses of off_t.

some libcs like musl do not have a 32-bit off_t type, and don't define
__off64_t.
2023-01-15 10:09:10 +00:00
Nikolaus Rath
9acd183460 Released 3.13.0 2023-01-13 10:33:35 +00:00
Bernd Schubert
c67b9219cf passthrough_hp: Avoid a bit code dup in readdir
Just a slight code simplification.
2023-01-13 10:21:42 +00:00
Bernd Schubert
856c683c36 passthrough_hp: Add options for clone_fd, max_threads, daemonize
This is useful for benchmarking.

Note: This changes behavior - passthrough_hp runs in background by default
      now.
2023-01-13 10:21:42 +00:00
Goswin von Brederlow
aad5c3a44d
Fix loading of FUSE modules
dlsym returns the address of the module factory symbol, not the actual function (#722)
pointer. Change the type of `factory` to `fuse_module_factory_t*` to reflect
this and then dereference it when registering the module.

This is a followup to d92bf83, which introduced a NULL pointer dereference
when dlsym returns NULL, and 8ec7fd9, which reverted it back to not
dereferencing the symbol at all.

Fixes: #721

Co-authored-by: Goswin von Brederlow <brederlo@q-leap.de>
2023-01-13 09:36:52 +00:00
Tofik Sonono
50c74e6459
Support application-defined I/O functions for FUSE fd
The io for FUSE requests and responses can now be further customized by allowing to write custom functions for reading/writing the responses. This includes overriding the splice io.

The reason for this addition is that having a custom file descriptor is not sufficient to allow custom io. Different types of file descriptor require different mechanisms of io interaction. For example, some file descriptor communication has boundaries (SOCK_DGRAM, EOF, etc...), while other types of fd:s might be unbounded (SOCK_STREAMS, ...). For unbounded communication, you have to read the header of the FUSE request first, and then read the remaining packet data. Furthermore, the one read call does not necessarily return all the data expected, requiring further
calls in a loop.
2023-01-10 10:04:35 +00:00
HereThereBeDragons
c0a344e379 Test for fuse_lowlevel_notify_expire_entry.
This test is too simple to check for all functionalities of notify_expire as it always successfully passes when libfuse supports the function (even if kernel does not support it -  it just takes it as notify_inval)
2023-01-06 18:35:52 +00:00
HereThereBeDragons
91083df90e adding comments and capability discovery, enum for flags moved to top of file 2023-01-06 18:35:52 +00:00
HereThereBeDragons
7f430a39db upgrade of fuse_kernel.h based on Miklos expire_only kernel patch https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/commit/?h=for-next&id=53e949edb7692dce02220eba926c9d75ecbb47f7 2023-01-06 18:35:52 +00:00
HereThereBeDragons
8fd95ab0a6 Initial patch provided by Miklos Szeredi <mszeredi@redhat.com> 2023-01-06 18:35:52 +00:00
Bernd Schubert
d372d3f80b Fixes when HAVE_LIBC_VERSIONED_SYMBOLS is not defined
fuse_loop_mt and fuse_new had not been defined when
HAVE_LIBC_VERSIONED_SYMBOLS had not been set and additionally,
fuse_new_31 was missing in the version script and was therefore
an unusable symbol.

This also adds a test for unset HAVE_LIBC_VERSIONED_SYMBOLS.
2023-01-04 15:27:21 +00:00
Bernd Schubert
3736e0c85f convert __APPLE__ and __ULIBC__ to HAVE_LIBC_VERSIONED_SYMBOLS
In fact only gnu-libc fully supports symbol versioning, so it is
better to have a generic macro for it. This also allows to manually
disable symbol version and allows to run tests with that
configuration on gnu-libc. That testing will still not catch compat
issues, but least ensures the code can compile.

Testing for __APPLE__ and __ULIBC__ is now done by meson. More of such
checks can be added by people using other libcs.
2023-01-04 15:27:21 +00:00
Bernd Schubert
f212ec0870 Fix ublic/apple build for the fuse_parse_cmdline ABI symbol
For __APPLE__ and __ULIBC__, which are assumed to not support
versioned symbols, helper.c has a compat ABI symbol for
fuse_parse_cmdline(). However that ABI symbol was conflicting
with the API macro (which redirects to the right API function
for recompilations against current libfuse).
Additionally the parameter 'opts' had a typo and was called
'out_opts'.
2023-01-04 15:27:21 +00:00
Kyle Lippincott
33736958b6 Remove partial locking of paths when using high-level API
As described in https://github.com/libfuse/libfuse/issues/695 and below, partial
locking of paths can cause a deadlock. Partial locking was added to prevent
starvation, but it's unclear what specific cases of starvation were of concern.
As far as I was able to determine, since we support reader locks that give
priority to writers (to prevent starvation), this means that to starve the queue
element, we'd need a constant stream of queued requests that lock the path for
write. Write locks are used when the element is being (potentially) removed, so
this stream of requests that starve the `rename` or `lock` operations seems
unlikely.

### Summarizing issue #695

The high-level API handles locking of the node structures it maintains to
prevent concurrent requests from deleting nodes that are in use by other
requests. This means that requests that might remove these structs (`rmdir`,
`rename`, `unlink`, `link`) need to acquire an (internally managed - not
pthread) exclusive lock before doing so. In the case where the lock is already
held (for read or for write), the operation is placed onto a queue of waiters.
On every unlock, the queue is reinspected for any element that might now be able
to make progress.

Since `rename` and `link` involve two paths, when added to the queue, a single
queue entry requires that we lock two different paths. There was, prior to this
change, support for partially locking the first queue element if it had two
paths to lock. This partial locking can cause a deadlock:

- set up a situation where the first element in the queue is partially locked
  (such as by holding a reader lock on one of the paths being renamed, but not
  the other). For example: `/rmthis/foo/foo.txt` [not-yet-locked] and
  `/rmthis/bar/bar.txt` [locked]
- add an `rmdir` for an ancestor directory of the not-yet-locked path to the
  queue. In this example: `/rmthis`

After getting into this situation, we have the following `treelock` values:

- `/rmthis`: 1 current reader (due to the locked `/rmthis/bar/bar.txt`), one
  waiting writer (`rmdir`): no new readers will acquire a read lock here.
- `/rmthis/bar`: 1 reader (the locked `/rmthis/bar/bar.txt`)
- `/rmthis/bar/bar.txt`: 1 writer (the locked `/rmthis/bar/bar.txt`)

This is deadlocked, because the partial lock will never be able to be completely
locked, as doing so would require adding a reader lock on `/rmthis`, and that
will be rejected due to write lock requests having priority -- until the writer
succeeds in locking it, no new readers can be added. However, the writer (the
`rmdir`) will never be able to acquire its write lock, as the reader lock will
never be dropped -- there's no support for downgrading a partially locked
element to be unlocked, the only state change that's allowed involves it
becoming completely locked.
2023-01-04 09:41:56 +00:00
Kyle Lippincott
30d423ee74 Move try_get_path2 earlier in the file 2023-01-04 09:41:56 +00:00
Nikolaus Rath
06be4565bf Revert "libfuse custom communication interface"
This reverts commit 7776639533.
2023-01-02 11:09:07 +00:00
Ciaran
40b0cf9029 update mount.c, in order to pass through -n.
autofs uses automount, which calls fuse, during an sshfs call. fuse complains about -n being an unknown option (ref. https://github.com/libfuse/libfuse/issues/715) 
this one line edit provides the command to be accepted, and pass through, allowing autofs-automount to operate on the mount, even though it is already in the mtab, given the nature of autofs/automount.
2023-01-02 10:53:24 +00:00
Zhansong Gao
5aaec929a4 Make it work even if max_idle_threads is set to 0
It may happen that none of the worker threads are running
if max_idle_threads is set to 0 although few people will do this.
Adding a limit of keeping at least one worker thread will make
our code more rigorous.

Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
2022-12-01 09:20:54 +00:00
y
7776639533 libfuse custom communication interface
libfuse can now be used without having a mount interface.
2022-11-15 11:25:49 +00:00
Bernd Schubert
b1290d4c09 Fix the fuse_parse_cmdline@FUSE_3.0 ABI compat symbol
There was a simple typo and sym1 didn't match the function name
with the older __asm__(".symver " sym1 "," sym2) way to define
ABI compatibility. 
Witht the newer "__attribute__ ((symver (sym2)))" sym1 is not used
at all and in manual testing the issue didn't come up therefore.
2022-09-11 19:29:33 +01:00
Nikolaus Rath
0c3fbe2ce2 Released 3.12.0 2022-09-08 11:02:45 +01:00
Fina Wilke
059045807d Add option to specify init script location
Also allows to disable the installation if desired
2022-09-08 10:50:53 +01:00
Frank Dinoff
9e1601add4 Use destroy_req instead of free to destroy fuse_req
If we get the interrupt before the fuse op, the fuse_req is deleted without
decrementing the refcount on the cloned file descriptor. This leads to a
leak of the cloned /dev/fuse file descriptor.
2022-09-08 10:49:37 +01:00
Bernd Schubert
8de32bc3c5 Add summary of changes regarding 'max_threads' to ChangeLog.rst
Update the change log file with the summary of API changes related
to the 'max_threads' changes.
2022-09-04 13:07:15 +01:00
Bernd Schubert
d823cab63a fuse_session_loop_mt: Accept a NULL config - use defaults
If an application does not want to bother with the session
and wants to keep defaults, it can now just pass a NULL
as config parameter.
2022-09-04 13:07:15 +01:00
Bernd Schubert
af5710e7a3 fuse-loop/fuse_do_work: Avoid lots of thread creations/destructions
On benchmarking metadata operations with a single threaded bonnie++
and "max_idle_threads" limited to 1, 'top' was showing suspicious
160% cpu usage.
Profiling the system with flame graphs showed that an astonishing
amount of CPU time was spent in thread creation and destruction.

After verifying the code it turned out that fuse_do_work() was
creating a new thread every time all existing idle threads
were already busy. And then just a few lines later after processing
the current request it noticed that it had created too many threads
and destructed the current thread. I.e. there was a thread
creation/destruction ping-pong.

Code is changed to only create new threads if the max number of
threads is not reached.

Furthermore, thread destruction is disabled, as creation/destruction
is expensive in general.

With this change cpu usage of passthrough_hp went from ~160% to
~80% (with different values of max_idle_threads). And bonnie
values got approximately faster by 90%. This is a with single
threaded bonnie++
bonnie++ -x 4 -q -s0  -d <path> -n 30:1:1:10 -r 0

Without this patch, using the default max_idle_threads=10 and just
a single bonnie++ the thread creation/destruction code path is not
triggered.  Just one libfuse and one application thread is just
a corner case - the requirement for the issue was just
n-application-threads >= max_idle_threads.


Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04 13:07:15 +01:00