Closed FUSE sessions stay pinned by open files, exhausting the 8 session slots

未关闭
#520 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
43/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c

调研方向

Start with session refcounting and cleanup in src/syscall/fuse.c, then follow the /dev/fuse open path at src/syscall/fs.c:887 and inspect fuse_proc_open. Reproduce by repeating the issue’s mount, open-file, and daemon-close steps until the ninth open fails. Done means dead sessions no longer block new opens and the guest receives an appropriate errno; the issue lists several possible approaches without choosing one.

由索引模型根据 Issue 内容生成。

描述

A session's refcount in src/syscall/fuse.c is held by the /dev/fuse fd, by each live mount, and by each open FUSE file fd. When the daemon closes /dev/fuse, fuse_fd_cleanup marks the session dead and tombstones its mounts. The slot is freed only when the last file fd on it closes.

With FUSE_MAX_SESSIONS at 8, a daemon that restarts while consumers keep old files open runs out of slots.

Reproduction (one guest process, daemon on a thread):

  1. Open /dev/fuse, mount it, open a file under the mount and keep it open.
  2. Close /dev/fuse to simulate the daemon exiting.
  3. Repeat.
Round Result
1-8 succeed
9 open("/dev/fuse") fails
after closing the 8 held files open("/dev/fuse") succeeds again

In the 9th round the guest sees EPERM, not the EMFILE that fuse_proc_open sets. src/syscall/fs.c:887 returns fuse_proc_open(linux_flags) directly, so its -1 reaches the guest as -EPERM. pipe() and fd_alloc failures inside fuse_proc_open are mapped the same way.

Linux has no fixed cap here. fuse_dev_open (fs/fuse/dev.c) only allocates a struct fuse_dev. The connection is created at mount time and released with the superblock (fuse_kill_sb_anon → fuse_mount_destroy → fuse_conn_put), so a dead connection still referenced by open files does not block a new daemon.

Possible directions:

  • Map the fuse_proc_open failure through linux_errno(), and pick an errno that does not claim the fd table is full.
  • Do not count a dead session (daemon_dead) against FUSE_MAX_SESSIONS. For example, keep its remaining state in a smaller structure for the open files, and free the 158 KiB slot.
  • Or allocate sessions on demand, which the fixed-table issue also suggests.

主要语言
C
星标
287
派生
33
平均合并
2 天 17 小时
30 天内合并 PR
18

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。