Skip to content

fuse: improve crash recovery for backing files

Chunsheng Luo linux-fsdevel lkml 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 0 repliesNew
  2. v22 patches 8 repliesSuperseded
  3. v1 RFC2 patches 10 repliesSuperseded

Changes in v3 from the cover letter

===============
Based on Amir Goldstein's review feedback, this v3 series updates:

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2fuse: add ioctl to cleanup all backing filesfs/fuse/backing.c fs/fuse/dev.c fs/fuse/fuse_i.h +2 more+94 -150 replies
2/2fuse: Relax backing file validation to compare backing inodesfs/fuse/iomode.c+1 -10 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAmir Goldstein
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] fuse: improve crash recovery for backing files

Hello maintainers and community,

This v3 series addresses crash recovery issues for FUSE daemons with passthrough support, following up on the previous RFC discussion [1].

Problem Summary
===============
To simplify FUSE daemon crash recovery and reduce performance overhead, passthrough backing_id information is not persisted. However, this design choice introduces two issues when the daemon restarts:

1. Non-persistent backing_ids prevent proper resource cleanup during daemon restart, potentially causing resource leaks.

2. New backing_ids allocated for the same backing file trigger -EBUSY errors due to strict pointer validation in fuse_inode_uncached_io_start(), even though the backing inodes are identical.

Changes from v2
===============
Based on Amir Goldstein's review feedback, this v3 series updates:

Patch 1/2: "fuse: add ioctl to cleanup all backing files"
- Changed backing_files_map to RCU-protected pointer for safe concurrent access, using rcu_replace_pointer() instead of swap().
- Added synchronize_rcu() to prevent use-after-free with in-flight lookups.
- Made fuse_backing_files_init() return int to handle allocation failures.

Patch 2/2: "fuse: Relax backing file validation to compare backing inodes"
- No changes from v2.

Changes from RFC v1 [2]
=======================
v2 series implemented:
- Replaced magic -1 value with dedicated FUSE_DEV_IOC_BACKING_CLOSE_ALL ioctl for comprehensive cleanup during daemon restart.
- Dropped FOPEN_PASSTHROUGH_INODE_CACHE flag approach.
- Modified fuse_inode_uncached_io_start() to compare backing inodes instead of fuse_backing pointers, allowing safe reuse of identical backing files after recovery.

Testing
=======
The patches have been tested with FUSE daemon crash and recovery scenarios on kernel 6.19.0-rc4, successfully resolving the -EIO errors and backing file resource leaks.

This approach maintains the simplicity of non-persistent backing_ids while ensuring proper recovery semantics and thread safety.

Thank you for your review and guidance.

[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
[2] https://lore.kernel.org/linux-fsdevel/[email protected]/T/#t

Chunsheng Luo (2):
fuse: add ioctl to cleanup all backing files
fuse: Relax backing file validation to compare backing inodes

 fs/fuse/backing.c         | 76 +++++++++++++++++++++++++++++++++++----
 fs/fuse/dev.c             | 16 +++++++++
 fs/fuse/fuse_i.h          |  5 +--
 fs/fuse/inode.c           | 11 +++---
 fs/fuse/iomode.c          |  2 +-
 include/uapi/linux/fuse.h |  1 +
 6 files changed, 95 insertions(+), 16 deletions(-)
Signature · 1 line
2.41.0