Commit Graph

2027 Commits

Author SHA1 Message Date
Joanne Koong
78eeae60bb Initialize session buffer size to value set by sysctl
Currently in libfuse, the buffer size for a fuse session is
capped at 1 MiB on a 4k page system. A recent patch
upstream [1] was merged that allows the max number of pages
per fuse request to be dynamically configurable through the
/proc/sys interface (/proc/sys/fs/fuse/max_pages_limit).

This commit adds support for this on the libfuse side to set
the fuse session buffer to take into account the max pages
limit set in /proc/sys/fs/fuse/max_pages_limit. If this
sysctl does not exist (eg older kernels), it will default to
old behavior (using FUSE_MAX_MAX_PAGES (256) as the max pages
limit). This allows for things like bigger write buffers per
request.

[1] https://lore.kernel.org/linux-fsdevel/20240923171311.1561917-1-joannelkoong@gmail.com/T/#t
2024-09-28 12:24:25 +02:00
Bernd Schubert
d637fe6f3e ABI check: Use base commit / branch of a PR for ABI comparison
The base commit is needed for comparison when a PR has multiple
commits.
2024-09-25 12:51:25 +02:00
Bernd Schubert
1690d43f7f Libfuse check ABI differences with 'abidiff' 2024-09-24 20:21:16 +02:00
yangyun
e338c52363 add version check for the fuse_loop_cfg* operations
fuse_loop_cfg* operations are introduced in fuse version 312 and
can not be used in an early version.
Also fix some typo.
2024-09-23 18:13:41 +02:00
Bernd Schubert
00c0e9a45b passthrough_hp: Use fuse_loop_cfg_set_max_threads()
fuse_loop_cfg_set_idle_threads() was by accident and
setting it might cause a performance issue.
2024-09-19 16:59:13 +02:00
Bernd Schubert
3fe1b25d51 fusermount: Close file descriptors with close_range() if possible
close_range() is much more efficient.

Also remove the lower limit of 3 and set it to 0, as 0 to 1
might have been closed by the application and might be valid.
2024-09-16 13:59:27 +02:00
MJ Harvey
5f137f01c1 fusermount: close inherited fds
When using the auto_unmount option, the fusermount3
watchdog process retains any inherited file descriptors.
This PR ensures they are closed.

Reason is that FDs that are kept open for a long time might
cause issues for applications using libfuse, for example
if these expect a pipe close, but the pipe is kept open
through the inherited file descriptor.
See for example: https://github.com/cvmfs/cvmfs/issues/3645

Signed-off-by: MJ Harvey <mharvey@jumptrading.com>
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-09-16 13:59:27 +02:00
Bernd Schubert
97991a6569 example/passthrough_hp: Set keep_cache and noflush in sfs_create
These flags should be also set for O_CREAT
2024-09-13 19:10:44 +02:00
Bernd Schubert
c00c9fd831 example/passthrough_hp: No auto FOPEN_DIRECT_IO in passthrough mode
sfs_open and sfs_create set fi->direct_io (FOPEN_DIRECT_IO) when
O_DIRECT is given, in order to benefit from a shared inode lock
in kernel, i.e. to get parallel DIO writes. However, kernel side
disabled passthrough when FOPEN_DIRECT_IO is set. Reads/writes
had been totally failing in this case for O_DIRECT as
sfs_write_buf() and sfs_read() have a sanity check. That sanity
check could be modified, but for performance passthrough is
better than parallel DIO, hence, we only want automatic
FOPEN_DIRECT_IO for O_DIRECT when passthrough is not enabled.

Fixes: https://github.com/libfuse/libfuse/issues/1027

This also fixes automatically switching to FOPEN_DIRECT_IO
for O_DIRECT in sfs_create().
2024-09-13 19:10:44 +02:00
Bernd Schubert
0a76670183 getattr: Make use of FUSE_GETATTR_FH in lowlevel examples
High level examples were already using it, but not
lowlevel. Also update the documentation.
2024-09-12 18:21:25 +02:00
dependabot[bot]
373ddc7eae Bump codespell-project/actions-codespell from 2.0 to 2.1
Bumps [codespell-project/actions-codespell](https://github.com/codespell-project/actions-codespell) from 2.0 to 2.1.
- [Release notes](https://github.com/codespell-project/actions-codespell/releases)
- [Commits](94259cd8be...406322ec52)

---
updated-dependencies:
- dependency-name: codespell-project/actions-codespell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-05 23:15:27 +02:00
yangyun
d30247c36d remove unused headers in example/poll_client
fuse_config.h is used in libfuse internally. This may confuse developers
that fuse_config.h is used in the examples.
2024-08-26 18:01:33 +02:00
Norman Wilson
c9bf7d3e20 Rearrange util/fusermount.c umount_fuse_locked() so that
umount2 is called with privs dropped, not raised.  This
works around a clash with NFS permissions: if FUSE mounted
on NFS client directory with root_squash in effect, and
some directory in the path leading to the mount point denies
permissions to others, umount2 will fail because userid 0
cannot search it.  Since drop_privs merely sets the file-
system user- and group-ID without changing the CAP_SYS_ADMIN
capability needed to unmount a file system (which fusermount
has because it is set-user-ID root), umount2 works fine.
2024-08-21 23:58:25 +02:00
yangyun
0750b4a194 Fix FUSE_USE_VERSION in example/notify_store_retrieve.c
This is an addition to commit e75d2c54a3. This example sets
FUSE_USE_VERSION = 34 but uses fuse_loop_cfg_* APIs, which is
not allowed since these APIs are not introduced in version 34.
2024-08-19 13:53:11 +02:00
Joanne Koong
2251a69223 doc/libfuse-operations: Fix FUSE_STATX in_args[1] description 2024-08-07 10:12:12 +02:00
Bernd Schubert
beff8a8ebe Fix program-path in util/parse-backtrace and dump_stack function
The option to the path of the binary had been accidentally removed
in the scripts that can parse backtraces.
The dump_stack() function had left over debug messages.
2024-08-02 20:08:38 +02:00
Bernd Schubert
cb7c16acbf example/passthrough_hp: Remove unused includes
Fix some clang-tidy warnings.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-08-01 16:04:57 +02:00
Bernd Schubert
e75d2c54a3 Fix FUSE_USE_VERSION in example/
This is an addition to commit a8f1ae35af, which
introduced the 312 API, but didn't set the right
API version in all examples.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-08-01 16:04:57 +02:00
Bernd Schubert
a8a79341c0 synchronize fuse_kernel.h with linux-6.10
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-08-01 16:04:57 +02:00
Bernd Schubert
a83041fa1f example/passthrough_hp: Fix . and .. readdir lookup count
Commit 170edc6a8e added dot and dotdot (. and ..) to readdir
results, but introduced an issue when max number of entries
was reached - lookup count must not be decreased without
doing the lookup.
With ext4 as underlying file system readir seems to return . and ..
at random offsets and randomly failed xfstests for me.

This also fixes indentation, as passthrough_hp.cc does not follow
the linux indentation style (if we decide to fix this, it needs
to be done for the entire file).

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-07-30 10:53:16 +02:00
Bernd Schubert
fafe4069d0 Add a script to parse backtraces 2024-07-30 00:16:55 +02:00
Bernd Schubert
5cb5ac8d37 Add MS_NOSYMFOLLOW compat definition
After commit 54466d2c42 compilation was failing on my debian VM.
2024-07-29 22:22:44 +02:00
Tyler Hall
54466d2c42 Pass through nosymfollow mount option
This option is handled in VFS.

Added in Linux 5.10
dab741e0e02bd3c4f5e2e97be74b39df2523fc6e

Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
2024-07-29 10:59:22 +02:00
Nils
febea554d3 Gate #include <execinfo.h> behind #ifdef HAVE_BACKTRACE
execinfo.h is unnecessary if HAVE_BACKTRACE is not defined.
This increases portability for systems without execinfo.h
2024-07-29 08:55:44 +02:00
Joanne Koong
37bc4eb03c fuse_log: initialize sys_log_level variable to avoid compiler warning 2024-07-17 23:35:55 +02:00
Bernd Schubert
54b7d9a318 Add RAMFS to fusermount permitted mount targets
Addresses issue https://github.com/libfuse/libfuse/issues/982
2024-07-14 22:53:02 +02:00
Bernd Schubert
dae1184302 Add syslog and fatal signal handler feature
I see random ENOTCONN failures in xfstest generic/013 and generic/014
in my branch, but earliest on the 2nd run - takes ~12hours to get
the issue, but then there are no further information logged.
ENOTCONN points to a daemon crash - I need backtraces and a core dump.

This adds optional handling of fatal signals to print a core dump
and optional syslog logging with these new public functions:

fuse_set_fail_signal_handlers()
    In addition to the existing fuse_set_signal_handlers(). This is not
    enabled together with fuse_set_signal_handlers(), as it is change
    in behavior and file systems might already have their own fatal
    handlers.

fuse_log_enable_syslog
    Print logs to syslog instead of stderr

fuse_log_close_syslog
    Close syslog (for now just does closelog())

Code in fuse_signals.c is also updated, to be an array of signals,
and setting signal handlers is now down with a for-loop instead
of one hand coded set_one_signal_handler() per signal.
2024-07-14 14:28:44 +02:00
Bernd Schubert
67ce439e2d xfstests: Add '-odev' to passthrough mount options
generic/434 and generic/184 are testing device files and fail
because fuse sets 'nodev' by default.
2024-07-09 18:04:43 +02:00
Joanne Koong
170edc6a8e passthrough_hp: include . and .. in readdir
generic/401 fails currently because it checks that "." and ".." are
listed as directory entries.

Include "." and ".." as listed directory entries in passthrough_hp's
readdir implementation.

Signed-off by: Joanne Koong <joannelkoong@gmail.com>
2024-07-08 23:29:57 +02:00
desertwitch
366f6a6a9a example/notify_inval_entry.c: improve comment readability
Follow the same format as other arguments passed to example commands.
2024-07-08 09:53:08 +02:00
desertwitch
a36f16a3a4 example/notify_inval_entry.c: fix example command in comments
Notifications should be enabled here, but present command example would disable them.
2024-07-08 09:53:08 +02:00
Bernd Schubert
21b6ad2124 Add list of libfuse (kernel) operations
This is to document operations and to also list
their in/out arguments.
This list was auto generated and only partly verified,
use with care. Not all operations are supported by
libfuse yet.
2024-07-03 13:14:19 +02:00
Bernd Schubert
9581e214b8 Annotate ABI sensitivness for some data structures
These are not all ABI sensitive data structures yet.

Also some space vs tab indentation issues are corrected.
2024-07-03 13:10:46 +02:00
gandalfs_cat
54b8cd6757 high-level: add fmask and dmask options
dmask: umask applied to directories
fmask: umask applied to non-directories

to get "typical" permission bits for regular files (0644) and directories (0755), a single
umask option is not sufficient (or well, it isn't the way fuse implements it)

there is precident for separate umask and dmask options in other
filesystems (see for example fat: https://github.com/torvalds/linux/tree/master/fs/fat)

this addition should not affect backward-compatibility; the original
umask option retains the same meaning, but non-zero fmask or
dmask will override it.
2024-07-03 12:50:06 +02:00
Bernd Schubert
f88e08f34d Add nullptr check in fuse_session_mount
The pointer did not have any sanity check.

Addresses https://github.com/libfuse/libfuse/issues/979
2024-06-25 11:34:16 +02:00
CismonX
09e6583b54 Use off_t instead of loff_t
Since we're already enforcing 64-bit off_t, using loff_t
makes no difference.

Also loff_t is Linux-only, which breaks compatibility for *BSD.
2024-06-25 07:16:49 +02:00
CismonX
285465fbdb Fix wrong use of the EBADFD errno
should use EBADF instead
2024-06-25 07:16:49 +02:00
CismonX
0a62f5d761 Do not build the hello_ll_uds example for *BSD
since there's no splice(2) support
2024-06-25 07:16:49 +02:00
trapexit
e0dda7019d Update AUTHORS
Co-authored-by: Ashley Pittman <ashley@pittman.co.uk>
2024-06-22 14:14:53 +02:00
Antonio SJ Musumeci
2769a9edeb Update AUTHORS 2024-06-22 14:14:53 +02:00
dependabot[bot]
6b4b4dc859 Bump actions/checkout from 4.1.6 to 4.1.7
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](a5ac7e51b4...692973e3d9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-19 18:04:37 +02:00
Miklos Szeredi
29f621af8d libfuse: null-terminate buffer in fuse_req_getgroups()
After reading the file /proc/$PID/task/$PID/status the buffer wasn't
terminated with a null character.  This could theoretically lead to buffer
overrun by the subsequent strstr() call.

Since the contents of the proc file are guaranteed to contain the pattern
that strstr is looking for, this doesn't happen in normal situations.

Add null termination for robustness.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2024-06-13 16:39:54 +02:00
yangyun
8bd873cbcc fix useless fuse_init_intr_signal in high-level api
The code `fuse_init_intr_signal` in `_fuse_new_317` is useless
since commit 8ee553dac ("fuse_new(): don't accept options that
don't make sense for end-users") has remove the conf.intr option
for end-users. The conf.intr is always zero (i.e., disabled) here.

Move `fuse_init_intr_signal` after the user-defined `init()` function,
so that conf.intr and conf.intr_signal has been configured by the user.
2024-06-11 09:47:31 +02:00
Josef Bacik
c9204dbd0d libfuse: have passthrough_hp return an error with invalid mount options
generic/003 fails currently because if you specify -o relatime we will
fail to mount, but not return an error, so the test thinks that we
support relatime and then hilarity ensues.  Set ret so that if we get
any failures while trying to mount we will properly error out.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
2024-06-07 21:33:04 +02:00
Bernd Schubert
2105cd7724
xfstests: Add the possibility for extra daemon options (#964)
We need to test w/o page cache, w/o passthrough and other options.
I.e. we need to have the possibility to add these options via
local.config
2024-06-07 21:31:28 +02:00
Bernd Schubert
dd5349a2cf
Merge pull request #957 from bsbernd/fuse-req-atomic-ref-cnt
Atomic struct fuse_req::ref_cnt
2024-06-04 14:44:51 +02:00
Bernd Schubert
153d65ff6b Rename struct fuse_req::ctr to ::ref_cnt
ref_cnt should make the intention of this variable more clear.
2024-06-04 14:00:55 +02:00
Bernd Schubert
d44162534c Make struct fuse_req::ctr a C11 _Atomic
The variable is not modified exclusively with locks since commit
cef8c8b249 ("Add support for no_interrupt") anymore.
That commit is safe, but might be error prone to future updates.
Changing it to a C11 _Atomic should avoid issues.
2024-06-04 13:59:42 +02:00
yangyun50
cef8c8b249
Add support for no_interrupt (#956)
The function fuse_session_process_buf_int() would do much things
for FUSE_INTERRUPT requests, even there are no FUSE_INTERRUPT requests:

1. check every non-FUSE_INTERRUPT request and add these requests to the
linked list(se->list) under a big lock(se->lock).
2. the function fuse_free_req() frees every request and remove them from
the linked list(se->list) under a bing lock(se->lock).

These operations are not meaningful when there are no FUSE_INTERRUPT requests,
and have a great impact on the performance of fuse filesystem because the big
lock for each request.

In some cases, FUSE_INTERRUPT requests are infrequent, even none at all.
Besides, the user-defined filesystem may do nothing for FUSE_INTERRUPT requests.

And the kernel side has the option "no_interrupt" in struct fuse_conn. This kernel option
can be enabled by return ENOSYS in libfuse for the reply of FUSE_INTERRUPT request.
But I don't find the code to enable the "no_interrupt" kernel option in libfuse.

So add the no_interrupt support, and when this operaion is enabled:
1. remove the useless locking operaions and list operations.
2. return ENOSYS for the reply of FUSE_INTERRUPT request to inform the kernel to disable
FUSE_INTERRUPT request.
2024-06-04 13:50:48 +02:00
legezywzh
949944ff3b
Fix compatibility issue around fuse_custom_io->clone_fd (#953)
Fixes: 73cd124d04 ("Add clone_fd to custom IO (#927)")

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-06-01 23:18:35 +02:00