This document discusses FUSE (Filesystem in Userspace) and its implementation in the Gluster filesystem. It provides an overview of the FUSE protocol, including the message structure used between the kernel and userspace FUSE servers. It also describes the different parts of the Gluster codebase that relate to FUSE and discusses some of the tradeoffs of using the libfuse library versus implementing FUSE functionality from scratch.
2. Scope
various parts of fuse code in the glusterfs source
tree
the story FUSE version macros tell
the tale of FUSE and fuse (historical context,
terminology)
to libfuse or not to libfuse?
FUSE proto breakdown
mount and INIT
3. fuse code in the gluster tree
> git ls-files '*fuse*.[ch]' | grep -v ^tests/ |
sed 's@/[^/]*$@/@' | uniq | cat -n
1 contrib/fuse-include/
2 contrib/fuse-lib/
3 contrib/fuse-util/
4 contrib/macfuse/
5 xlators/mount/fuse/src/
6. fuse history
kernel: micro (GNU Hurd) vs monolithic
userspace filesystesms: "tarfs", "sshfs"; NFS, Arla,
9P
Linux: AFVS, lufis, shfs
fuse: project of Miklós Szeredi; got merged in
2005 to 2.6.14 (gmailfs, sshfs)
first non-Linux port: fuse4bsd, GSoC 2005, Csaba
Henk
NetBSD: puffs/refuse; Mac: OSXFUSE / FUSE for
macOS / macFUSE, 2011-
7. fuse and FUSE
fuse: project / code
FUSE: protocol
FUSE follows a client-server architecture
kernel: client
userspace: server
libfuse: de facto reference server lib
however, a server lib is more like a framework
(think of Apache, Nginx)
Go, Rust...
glusterfs is also a framework
8. What have the Romans
libfuse ever done for us?
we do use:
mounting
we do roll our own:
uniform API over versions and platforms
we make up our own minds about it:
threading / synchronization / fuse dev I/O
although automatic thread scaling would
be nice to have
...
9. we don't need:
support for all FUSE features
command-line driven configuration
we need to roll our own:
support for FUSE features
10. fuse code in the gluster tree,
continued
> git ls-files '*fuse*.[ch]' | grep -v ^tests/ |
sed 's@/[^/]*$@/@' | uniq | (i=1; while read d; do
echo "# $i. $d"; git ls-files "$d/*.[ch]" | cat -n
i=$(($i+1))
done)
# 1. contrib/fuse-include/
1 contrib/fuse-include/fuse-misc.h
2 contrib/fuse-include/fuse-mount.h
3 contrib/fuse-include/fuse_kernel.h
4 contrib/fuse-include/fuse_kernel_macfuse.h
5 contrib/fuse-include/mount_util.h
...
15. FUSE
client (kernel) sends FUSE request
server (userspace) replies with FUSE response
message structure: header + body
exceptions:
FORGET does not get a response
reverse notifications (invalidations): server's
requests
17. mount and INIT
mount(2): VFS general and instance specific
options
INIT: version handshake + option negotiation
mount options are per-mount, INIT options are
per-fs
18. initialization sequence:
open /dev/fuse
mount with -ofd=...
kernel sends INIT
userspace replies INIT
mount returns
concerns:
unprivileged mounting
security frameworks' (eg. SELinux) probing