-
Notifications
You must be signed in to change notification settings - Fork 241
Description
Problem Summary
The Linux kernel is deprecating the fscache-based on-demand read feature in EROFS. This feature is marked as deprecated since Linux 6.12 and is scheduled for removal after fanotify pre-content hooks land in the kernel.
Currently, Nydus uses fscache (CONFIG_EROFS_FS_ONDEMAND) to handle on-demand loading of container image data. This requires:
- Kernel fscache subsystem (
CONFIG_FSCACHE) - Cachefiles driver (
CONFIG_CACHEFILES_ONDEMAND) - Special device interface (
/dev/cachefiles)
As the kernel moves away from this approach in favor of fanotify-based pre-content hooks, Nydus must migrate to remain compatible with future Linux versions.
Why This Matters
-
Deprecation Timeline:
- Linux 6.12 (October 2024):
CONFIG_EROFS_FS_ONDEMANDmarked deprecated - Current status: Still functional up to Linux 6.18
- Future removal: Scheduled after fanotify pre-content hooks merge
- Linux 6.12 (October 2024):
-
Kernel References:
- Deprecation commit:
0d442ce0b302 - erofs: mark experimental fscache backend deprecated - Removal branch: https://kernel.googlesource.com/pub/scm/linux/kernel/git/xiang/linux/+/refs/heads/erofs/remove_fscache
- Deprecation commit:
Current State
Nydus currently implements on-demand read via fscache in:
service/src/fs_cache.rs- FsCacheHandlerstorage/src/cache/fscache/mod.rs- FsCacheMgr- Requires kernel config:
CONFIG_FSCACHE,CONFIG_CACHEFILES,CONFIG_CACHEFILES_ONDEMAND,CONFIG_EROFS_FS_ONDEMAND
What Needs to Happen
Nydus needs to implement fanotify pre-content hook support as an alternative or replacement to the fscache backend, allowing it to:
- Work with future Linux kernels after fscache on demand is removed
- Reduce kernel dependency footprint (fanotify is lighter weight)
- Support both old (fscache) and new (fanotify) systems during transition period
Related Issues
- [Bug] FSCache on demand loading not working #1769 - FSCache on demand loading not working
Resources
- Kernel deprecation: [Bug] FSCache on demand loading not working #1769 (comment)
- EROFS removal branch: https://kernel.googlesource.com/pub/scm/linux/kernel/git/xiang/linux/+/refs/heads/erofs/remove_fscache
Proposed Improvement
Implement a new fanotify-based cache backend driver alongside the existing fscache driver:
-
Create
service/src/fs_fanotify.rs- New FanotifyHandler that:- Listens for fanotify permission events (FAN_PRE_ACCESS, FAN_OPEN_PERM, FAN_ACCESS_PERM)
- Fetches chunks from backend when needed
- Writes data to file via pwrite() to populate page cache
- Responds with FAN_ALLOW to unblock access
-
Update
service/src/fs_service.rs- Route cache backend based on config:cache_type = "fscache"→ FsCacheHandler (existing)cache_type = "fanotify"→ FanotifyHandler (new)
-
Configuration - Simplify kernel requirements:
- Remove:
CONFIG_FSCACHE,CONFIG_CACHEFILES,CONFIG_CACHEFILES_ONDEMAND,CONFIG_EROFS_FS_ONDEMAND - Keep:
CONFIG_EROFS_FS,CONFIG_FANOTIFY
- Remove:
This allows Nydus to support both backends during the transition, with fanotify as the new standard for future Linux versions.
Additional Context
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!