本文将mark下FUSE Passthrough的相关notes。

Overview

FUSE (Filesystem in Userspace) passthrough is a feature designed to improve the performance of FUSE filesystems for I/O operations. Typically, FUSE operations involve communication between the kernel and a userspace FUSE daemon, which can incur overhead. Passthrough allows certain operations on a FUSE file to bypass the userspace daemon and be executed directly by the kernel on an underlying “backing file”.

What

FUSE Passthrough 是一种为 FUSE 文件系统加速数据 I/O 的机制。

普通 FUSE 中,即使 daemon 最终只是读写本地的另一个文件,每次 read()write() 都需要在内核和用户态 daemon 之间往返:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
应用程序

│ read/write



Linux VFS / FUSE 内核模块

│ /dev/fuse 请求



FUSE daemon(用户态)

│ pread/pwrite



底层文件系统中的真实文件

开启 FUSE Passthrough 后,daemon 可以在打开文件时告诉内核:

这个 FUSE 文件对应底层的哪个 backing file。后续数据读写可以直接访问它,不必再把每个请求发给我。

于是路径变成:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
                 OPEN / CREATE

应用程序 ─────► FUSE 内核模块 ─────► FUSE daemon



│ 返回 backing_id



底层 backing file

READ / WRITE / MMAP

应用程序 ─────► FUSE 内核模块 ─────► backing file ─────► 底层文件系统

不再经过用户态 daemon

可以把它概括为:

文件系统控制面仍在用户态 daemon,文件数据面可以下沉到内核。

总结

FUSE Passthrough 的核心不是绕过整个 FUSE 文件系统,而是:

1
2
3
4
5
6
7
8
路径、打开、权限、映射和元数据

仍由 FUSE daemon 控制


read / write / splice / mmap

内核直接访问 backing file

它保留了 FUSE 灵活的用户态控制能力,同时避开了高频数据 I/O 的用户态往返开销。

个人总结: 思想类似于vhost


参考资料:

  1. AOSP: FUSE passthrough
  2. https://docs.kernel.org/: FUSE Passthrough
  3. FUSE passthrough for file io