Comments (4)
Having looked into this a bit more, the situation is this:
From the API, it may appear as if every fuse session (struct fuse_session
) is associated with a single fuse channel (struct fuse_chan
) that is created by fuse_mount()
and assigned to the session in fuse_session_add_chan()
. Therefore, one may wonder why there are two separate structs in the first place, and why the channel structure has a reference counter and mutex.
The answer is that when using the multi-threaded session loop with the clone_fd option enabled, there are actually multiple channel objects per session. The session only holds a reference to the first one, and the additional channel objects don't actually hold references to the session object -- but they still exist. The additional channels are created by duplicating the fd (in fuse_clone_chan()
, called by fuse_loop_start_thread
). When processing a request, fuse_session_process_buf()
records the active channel in the request object (struct fuse_req
) so that it can be retrieved by e.g. the fuse_reply_*
functions. Since the request object can potentially live longer than the worker thread that created it, we need to keep a reference count for the channel.
The reason for not having references to the session object from the extra channels is not clear, but with the current implementation this would not work because fuse_session_remove_chan
always attempts to remove the channel from the session.
from libfuse.
So in other words, although the implementation makes sense, it is rather confusing. I think it would be better to merge struct fuse_chan
into struct fuse_session
(because there is always exactly one channel object associated with one session object with pointers in both directions), and then use a reduced struct fuse_chan
only for the additional channels created by fuse_loop_mt (in particular, remove the session reference which is always null anyway).
This would also allow us to remove the fuse_session_add_chan
and fuse_session_remove_chan
functions which are rather pointless, since there is only ever one channel per session - so we may just as well create and destroy the channel together with the session.
from libfuse.
Another thought:
At the moment, the only channel that's accessible to the user application is the "master" channel that's stored in struct fuse_session
. The per-worker channels are stored in the worker array and the struct fuse_req
objects (so that they can be used by the fuse_reply_*
functions), but there is no public API for them. So even though libfuse currently has several API functions that take struct fuse_chan
parameters (notably all the fuse_lowlevel_notify_*
functions), all these parameters can be replaced by struct fuse_session
- because the channel that's embedded in there is the only one that the client application could pass anyway.
from libfuse.
This has been fixed in commit 5698ee0.
from libfuse.
Related Issues (20)
- How does libfuse ensure that fuse init will be processed first?
- commit c9905341ea34 ("Pass FUSE_PARALLEL_DIROPS to kernel (#861)") breaks backward comatibility HOT 5
- test/test_write_cache.c has test issues
- random failures of example/notify_inval_inode.c: HOT 1
- FUSE_CAP_HANDLE_KILLPRIV setting is missing when init HOT 10
- 3.16.2: test suite fails HOT 4
- Bind mounts of stale FUSE file systems remain despite auto_unmount HOT 8
- After PR 892 building libfuse fails with `error: unknown type name 'loff_t'; did you mean 'off_t'?` HOT 4
- example/poll.c triggers "Invalid read of size 4" HOT 3
- Where is the FUSE kernal model repository HOT 2
- Unimplemented link returns ENOSYS HOT 9
- test_release_unlink_race failed in mkstemp HOT 3
- signify: signature verification failed for 3.16.2 HOT 2
- [libFuse 3.16.2]Compilation failure on freeBSD HOT 3
- [FreeBSD] Compilation of libfuse fails on FreeBSD due to an unrecognized type/codes HOT 1
- severe file corruption when using libfuse3 with sshfs (probably not only with sshfs?) - possible fix HOT 12
- fuse_session_mount() is not thread-safe HOT 1
- FUSE_FILL_DIR_DEFAULTS undeclared HOT 1
- how to use libfuse??
- FreeBSD: with passthrough, getcwd returns "No such file or directory" within mount points HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libfuse.