Commit Graph

460 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Nikolaus Rath
06be4565bf Revert "libfuse custom communication interface"
This reverts commit 7776639533.
2023-01-02 11:09:07 +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
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
Bernd Schubert
30a126c5f9 API update for fuse_loop_config additions
struct fuse_loop_config was passed as a plain struct, without any
version identifer. This had two implications

1) Any addition of new parameters required a FUSE_SYMVER for
fuse_session_loop_mt() and fuse_loop_mt() as otherwise a read
beyond end-of previous struct size might have happened.

2) Filesystems also might have been recompiled and the developer
might not have noticed the struct extensions and unexpected for
the developer (or people recomliling the code) uninitialized
parameters would have been passed.


Code is updated to have struct fuse_loop_config as an opaque/private
data type for file systems that want version 312
(FUSE_MAKE_VERSION(3, 12)). The deprecated fuse_loop_config_v1
is visible, but should not be used outside of internal
conversion functions

File systems that want version >= 32 < 312 get the previous
struct (through ifdefs) and the #define of fuse_loop_mt
and fuse_session_loop_mt ensures that these recompiled file
systems call into the previous API, which then converts
the struct. This is similar to existing compiled applications
when just libfuse updated, but binaries it is solved with
the FUSE_SYMVER ABI compact declarations.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04 13:07:15 +01:00
Nikolaus Rath
a56147d3cb Released 3.11.0 2022-05-02 10:11:41 +01:00
André Schröder
96ad05c8e1 patch: document ignored fill parameter of readdir 2022-04-20 11:15:08 +01:00
Bernd Schubert
7e5278c03d Add missing kernel flags up to 1ULL << 33
Just a further sync with the in-kernel flags.
2022-04-17 13:45:38 +01:00
Dharmendra Singh
4df08719f3 Modify structures in libfuse to handle flags beyond 32 bits.
In fuse kernel, 'commit 53db28933e95 ("fuse: extend init flags")'
made the changes to handle flags going beyond 32 bits but i think
changes were not done in libfuse to handle the same.

This patch prepares the ground in libfuse for incoming FUSE kernel
patches (Atomic open + lookup) where flags went beyond 32 bits.
It makes struct same as in fuse kernel resulting in name change of
few fields.
2022-04-08 15:34:32 +01:00
Amir Goldstein
dad15aee26 Add no_rofd_flush mount option
To disable flush for read-only fd.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2022-01-03 14:55:34 +02:00
Amir Goldstein
1b498ac9b3 Add support for FOPEN_NOFLUSH flag
Allow requesting from kernel to avoid flush on close at file open
time.  If kernel does not support FOPEN_NOFLUSH flag, the request
will be ignored.

For passthrough_hp example, request to avoid flush on close when
writeback cache is disabled and file is opened O_RDONLY.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2022-01-03 14:55:34 +02:00
Maximilian Heinzler
48ae2e72b3
Document possible NULL paths when directories are removed (#633)
When directories with open handles are removed, the releasedir and
fsyncdir operations might be called with a NULL path. That is because
there is no hiding behavior like for regular files and the nodes get
removed immediately.
2021-12-12 16:28:57 +00:00
Junichi Uekawa
0b6d97cf59
Define FUSE_USE_VERSION in Doxygen. (#608)
We currently do not pass anything in PREDEFINED and that means
FUSE_USE_VERSION is undefined.

Add that definition so that Doxygen built-in C pre-processor can use
FUSE_USE_VERSION value to find the correct comment to parse.
2021-05-19 09:32:14 +01:00
Junichi Uekawa
8c4d315108
Fix doxygen warnings. (#600)
Some parameters were undocumented, and @file does not mean to expand current file name.
2021-05-07 10:43:30 +01:00
Manuel Jacob
d85d26b88c
Add missing exceptions to fuse_reply_err() documentation. (#597)
Co-authored-by: Manuel Jacob <test>
2021-04-23 08:31:37 +01:00
Tobias Nießen
f4eaff6af0
Fix typo in fuse_lowlevel.h (#593) 2021-03-30 13:37:30 +01:00
Andrew Gaul
da474fe7d7
Fix typos (#592) 2021-03-25 08:40:27 +00:00
Feverfew
770bccfcf2
Fix typo (#578) 2021-01-10 11:50:28 +00:00
Nikolaus Rath
0105e061b9 Released 3.10.0 2020-10-09 10:47:25 +01:00
ferivoz
f54eb86e9a
Fix typo "retuned" -> "returned" (#553) 2020-10-03 13:14:00 +01:00
Etienne Dublé
ba3b225a12
Allow caching symlinks in kernel page cache. (#551)
This commit defines a new capability called `FUSE_CAP_CACHE_SYMLINKS`.
It is off by default but you can now enable it by setting this flag in
in the `want` field of the `fuse_conn_info` structure.

When enabled, the kernel will save symlinks in its page cache,
by making use of the feature introduced in kernel 4.20:
5571f1e654
2020-09-20 19:08:15 +01:00
asafkahlon
7b3e389915
Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532)
On uclibc and MacOS we don't use versioned symbols. Hence,
there's no definition for fuse_session_loop_mt on those cases
and the linker won't be able to resolve calls to fuse_session_loop_mt()

Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
2020-08-09 12:37:26 +01:00
Junichi Uekawa
e8a9e84672
Doc fixes (#537)
* Add fallocate to list of operations that may omit path.

* earlier versions is 10+ years old.

Document is not obvious how old it is. Add it.

* Update manpage link
2020-08-09 12:35:28 +01:00
Florian Weimer
a7ba1d42d0
Update comment for the copy_file_range operation (#497)
copy_file_range was first implemented with copy-based emulation in
glibc 2.27, but the emulation was subsequently removed again because
correct emulation depends on why the application attempted to make a
copy.  Therefore, file systems cannot rely on low-level userspace
performing emulation.
2020-01-31 13:38:41 -05:00
zsugabubus
38c9cb4378 Remove trailing comma in enums (#494)
They are illegal in C89/90.
2020-01-27 16:13:11 +00:00
Changli Gao
7b993f7450 Style: Fix an indention in comments (#480) 2019-12-31 10:01:26 +00:00
Nikolaus Rath
2cfce39909 Bump FUSE_MINOR_VERSION
This was forgotten over several releases.
2019-12-31 09:59:43 +00:00
Bill Zissimopoulos
abdd45f83c Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)
Define FUSE_USE_VERSION < 35 to get old ioctl prototype
with int commands; define FUSE_USE_VERSION >= 35 to get
new ioctl prototype with unsigned int commands.

Fixes #463.
2019-12-31 09:58:57 +00:00
Albert Chen
ada08d50a6 Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474) 2019-11-27 09:36:30 +00:00
Yuri Per
d735af94fa Implement lseek operation (#457) 2019-11-03 09:44:31 +00:00
Stefan Hajnoczi
d368dad2c8 log: move fuse_log() to the public header file
Applications may wish to call fuse_log() for unified logging.  This way
they don't need to define their own wrappers to invoke the log message
handler function installed by fuse_set_log_func().

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-10 14:25:15 +01:00
Stefan Hajnoczi
317181e8ea Introduce callback for logging
Introduce an API for custom log handler functions.  This allows libfuse
applications to send messages to syslog(3) or other logging systems.
See include/fuse_log.h for details.

Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...).  Most
messages are error messages with FUSE_LOG_ERR log level.  There are also
some debug messages which now use the FUSE_LOG_DEBUG log level.

Note that lib/mount_util.c is used by both libfuse and fusermount3.
Since fusermount3 does not link against libfuse, we cannot call
fuse_log() from lib/mount_util.c.  This file will continue to use
fprintf(stderr, ...) until someone figures out how to split it up.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-04 15:59:18 +01:00
Nikolaus Rath
ab26ad4dfa Shorten comment. 2019-08-23 20:58:54 +01:00
Nikolaus Rath
3c31bead28 Improve description of READDIRPLUS_AUTO. 2019-08-23 20:58:23 +01:00
AsumFace
1d8e8ca94a Clarify bitfield padding issue (#445)
* Clarify bitfield padding issue

* Add a more elaborate note to fuse_file_info
2019-08-23 20:58:06 +01:00
Kirill Smelkov
249942f641 Sync fuse_kernel.h with Linux 5.2 (#433) 2019-07-09 13:54:09 -07:00