Commit Graph

2048 Commits

Author SHA1 Message Date
Vladimir Serbinenko
66a03d4e4b Fix alignment of allocation in fuse_reply_create
When allocating as an array of char only alignment of 1 is guaranteed but
the structure needs an alignment of 8. Specify alignment explicitly
2024-11-21 21:42:18 +01:00
Joanne Koong
0e0f43b79b Reallocate fuse_session buffer transparently for extended max writes
A previous PR supported extended max writes (eg write requests larger than 1 MB)
by initializing the fuse session buffer size to use the max_pages_limit set in
/proc/sys/fs/fuse. However, this is a huge problem for machines where multiple
fuse servers may be running but only one server needs large writes. In this case,
a lot of memory will be wasted and will lead to OOM issues.

This PR does a reallocation of the session buffer transparently if the server set
 "se->conn.max_write" to a value larger than 1 MiB. This is only for buffers that
are "owned" by libfuse - if the server wishes to provide its own allocated buffer
for receiving/processing requests, then it should ensure that buffer is allocated
to the proper size from the start.

Local testing showed:
echo 65535 | sudo tee /proc/sys/fs/fuse/max_pages_limit
dd if=/dev/urandom of=hello_file bs=6M count=2

write requests:
write request size is 5242880
write request size is 1048576
write request size is 5242880
write request size is 1048576
2024-11-21 19:18:03 +01:00
dependabot[bot]
49f74c9b93 build(deps): bump github/codeql-action from 3.27.1 to 3.27.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.1 to 3.27.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4f3212b617...ea9e4e3799)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 23:39:10 +01:00
Joanne Koong
656868425d Use fuse_session_{receive/process}_buf() instead of _int version
No functional changes.
2024-11-18 15:51:22 +01:00
Bernd Schubert
e2eb1abb10 Add FUSE_CAP_NO_EXPORT and use it in passthrough_hp
This should stop some more xfstest test failures.
2024-11-13 16:43:59 +01:00
Bernd Schubert
15f5c81123 Add fuse_set_feature_flag() / fuse_unset_feature_flag
Simplify setting feature flags a bit by adding a helper
function.

Also move the check for valid flags into a funtion we can re-use
in a later patch.
2024-11-13 16:43:59 +01:00
dependabot[bot]
82cca94678 build(deps): bump github/codeql-action from 3.27.0 to 3.27.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](662472033e...4f3212b617)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-13 16:42:29 +01:00
Bernd Schubert
8a3746fe0e Correct arg documentation for FUSE_READLINK
It does not have an in-argument.
2024-10-30 17:58:09 +01:00
dependabot[bot]
e12c503ce6 build(deps): bump github/codeql-action from 3.26.13 to 3.27.0
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.13 to 3.27.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](f779452ac5...662472033e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-29 11:40:30 +01:00
dependabot[bot]
1062944102 build(deps): bump actions/checkout from 4.2.1 to 4.2.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](eef61447b9...11bd71901b)

---
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-10-29 10:36:04 +01:00
Bernd Schubert
3bf5ec7aff codeql workflow: Switch from pip to apt
On some runs:

Run pip install --break-system-packages -r requirements.txt
....
no such option: --break-system-packages
Error: Process completed with exit code 2.

On other runs it refuses to install and asks for that option
as it refuses to override system packages.

Also require ubuntu-latest only, as MacOS is not supported at all
by libfuse.
2024-10-20 14:20:55 +02:00
Bernd Schubert
617109955c Update libfuse-operations.txt for FUSE_SYMLINK 2024-10-20 14:20:55 +02:00
Bernd Schubert
88d2dbd0d2 Create codeql.yml 2024-10-14 21:17:51 +02:00
leipeng
fdafc1d1c6 fuse_buf_size fix for SIZE_MAX 2024-10-14 19:50:52 +02:00
Joanne Koong
535808c4d9 Add libfuse util strtol wrapper
Add a wrapper around strtol for more rigorous error checking
and convert uses of atoi and strtol to use this instead.
2024-10-11 13:15:38 +02:00
dependabot[bot]
55eb214db9 build(deps): bump actions/checkout from 4.2.0 to 4.2.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](d632683dd7...eef61447b9)

---
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-10-11 12:58:06 +02:00
Daniel Rosenberg
4007ad9a21 ignore mtab on android
Updating the mtab on Android fails due to differences in toybox's mount
command. Setting IGNORE_MTAB avoids that issue.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
2024-10-11 12:55:18 +02:00
dependabot[bot]
c37518ff0b build(deps): bump actions/checkout from 4.1.7 to 4.2.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](692973e3d9...d632683dd7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-04 00:05:01 +02:00
Bernd Schubert
2aeef499b8 fuse_lowlevel FUSE_INIT: Simplify the max_write/bufsize logic
max_write can be limited by se->op.init() and by the buffer size,
we use the minimum of these two.
Required se->bufsize is then set according to the determined
max_write. The current thread will have the old buffer size,
though, as it already had to the allocation to handle the
FUSE_INIT call (unless splice is used and ths variable
and related buffer is not used at all).

The given bufsize is just a hint for minimum size, allocation
could be actually larger (for example to get huge pages).
2024-09-28 16:24:22 +02:00
Bernd Schubert
ba7d362d14 fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustments
The further these lines are separated from each other the harder
it is to read the code.

There shouldn't be any code change behavior here.
2024-09-28 16:24:22 +02:00
Joanne Koong
9069ad9eb6 Change FUSE_MAX_MAX_PAGES to FUSE_DEFAULT_MAX_PAGES_LIMIT
A recent upstream patch [1] changed FUSE_MAX_MAX_PAGES to
FUSE_DEFAULT_MAX_PAGES_LIMIT.

Update libfuse to use FUSE_DEFAULT_MAX_PAGES_LIMIT as well
instead of FUSE_MAX_MAX_PAGES.

[1] https://lore.kernel.org/linux-fsdevel/20240923171311.1561917-1-joannelkoong@gmail.com/T/#t
2024-09-28 12:24:25 +02:00
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