famfs: port into fuse
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
v10 cover famfs: port into fuse
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses to FUSE_IS_VIRTIO_DAX() macro, in case something bad is passed in as fuse_inode (thanks Jonathan's AI)
Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP - Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV - Retrieves the details of a particular daxdev that was
referenced by an fmap
Famfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs: GET_FMAP and GET_DAXDEV.
Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a GET_FMAP message and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.
- After each GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with a GET_DAXDEV message and response.
- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the fs_dax_get() call (modeled after how fs-dax handles this with pmem devices). Famfs provides holder_operations to devdax, providing a notification path in the event of memory errors or forced reconfiguration.
- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires CAP_SYS_RAWIO).
- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse fs_type - but I'm not sure that's ultimately optimal (thoughts?)
Changes v8 -> v9
- Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the new CONFIG_DEV_DAX_FSDEV (from drivers/dax/Kconfig) rather than just CONFIG_DEV_DAX and CONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAX depends on those...)
Changes v7 -> v8
- Moved to inline __free declaration in fuse_get_fmap() and famfs_fuse_meta_alloc(), famfs_teardown()
- Adopted FIELD_PREP() macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers to include/uapi/linux/magic.h. That can be done later if appropriate
Changes v6 -> v7
- Fixed a regression in famfs_interleave_fileofs_to_daxofs() that was reported by Intel's kernel test robot
- Added a check in __fsdev_dax_direct_access() for negative return from pgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in __famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks in famfs_fuse_meta_alloc() and famfs_interleave_fileofs_to_daxofs() as interleaved chunks must be PTE or PMD aligned
- Simplified famfs_file_init_dax() a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issues
Changes v4 -> v5 -> v6
- None. Re-sending due to technical difficulties
Changes v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed the fs/fuse/Kconfig patch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.
Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces the dev_dax_iomap modifications to bus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev uses MEMORY_DEVICE_FS_DAX type and leaves folios at order-0 (no vmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed via fsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporary WARN_ON_ONCE workaround in fs/dax.c has been removed.
- Dax: Added dax_set_ops() so fsdev can set dax_operations at bind time (and clear them on unbind), since the dax_device is created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return -EBUSY if a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon has CAP_SYS_RAWIO because they expose raw memory devices.
- Fuse: Added DAX address_space_operations with noop_dirty_folio since famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.
Changes v1 [8] -> v2:
- The GET_FMAP message/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload to GET_FMAP variable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak of fc->shadow in patch 11 (thanks Joanne)
- Dropped many pr_debug and pr_notice calls
References
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)
John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb the GET_FMAP message/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse: GET_DAXDEV message and daxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Add holder_operations for dax notify_failure()
famfs_fuse: Add DAX address_space_operations with noop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentation
Documentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.h
base-commit: 2ae624d5a555d47a735fb3f4d850402859a4db77
Signature · 1 line
2.53.0
PATCH v10 1/10 famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
From: John Groves <[email protected]>
Virtio_fs now needs to determine if an inode is DAX && not famfs. This relaces the FUSE_IS_DAX() macro with FUSE_IS_VIRTIO_DAX(), in preparation for famfs in later commits. The dummy fuse_file_famfs() macro will be replaced with a working function.
--- fs/fuse/dir.c | 2 +- fs/fuse/file.c | 13 ++++++++----- fs/fuse/fuse_i.h | 9 ++++++++- fs/fuse/inode.c | 4 ++-- fs/fuse/iomode.c | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-)
fs/fuse/dir.c +1 -1
@@ -2161,7 +2161,7 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, is_truncate = true; } -if (FUSE_IS_DAX (inode) && is_truncate) { +if (FUSE_IS_VIRTIO_DAX (fi) && is_truncate) {filemap_invalidate_lock (mapping); fault_blocked = true; err =fuse_dax_break_layouts (inode,0 ,-1 );
fs/fuse/file.c +8 -5
@@ -252,7 +252,7 @@ static int fuse_open(struct inode *inode, struct file *file)int err;bool is_truncate = (file->f_flags &O_TRUNC ) && fc->atomic_o_trunc;bool is_wb_truncate = is_truncate && fc->writeback_cache; -bool dax_truncate = is_truncate &&FUSE_IS_DAX (inode); +bool dax_truncate = is_truncate &&FUSE_IS_VIRTIO_DAX (fi);if (fuse_is_bad (inode))return -EIO ;
@@ -1812,11 +1812,12 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to)struct file *file = iocb->ki_filp;struct fuse_file *ff = file->private_data;struct inode *inode =file_inode (file); +struct fuse_inode *fi =get_fuse_inode (inode);if (fuse_is_bad (inode))return -EIO ; -if (FUSE_IS_DAX (inode)) +if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_read_iter (iocb, to);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */
@@ -1833,11 +1834,12 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)struct file *file = iocb->ki_filp;struct fuse_file *ff = file->private_data;struct inode *inode =file_inode (file); +struct fuse_inode *fi =get_fuse_inode (inode);if (fuse_is_bad (inode))return -EIO ; -if (FUSE_IS_DAX (inode)) +if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_write_iter (iocb, from);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */
@@ -2370,10 +2372,11 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)struct fuse_file *ff = file->private_data;struct fuse_conn *fc = ff->fm->fc;struct inode *inode =file_inode (file); +struct fuse_inode *fi =get_fuse_inode (inode);int rc;/* DAX mmap is superior to direct_io mmap */ -if (FUSE_IS_DAX (inode)) +if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_mmap (file, vma);/*
@@ -2934,7 +2937,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, .mode = mode };int err; -bool block_faults =FUSE_IS_DAX (inode) && +bool block_faults =FUSE_IS_VIRTIO_DAX (fi) && (!(mode &FALLOC_FL_KEEP_SIZE ) || (mode & (FALLOC_FL_PUNCH_HOLE |FALLOC_FL_ZERO_RANGE )));
fs/fuse/fuse_i.h +8 -1
@@ -1508,7 +1508,14 @@ void fuse_free_conn(struct fuse_conn *fc);/* dax.c */ -#define FUSE_IS_DAX (inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode)) +static inline bool fuse_file_famfs (struct fuse_inode *fuse_inode)/* Will be superseded */ +{ + (void )fuse_inode; +return false; +} +#define FUSE_IS_VIRTIO_DAX (fuse_inode) (IS_ENABLED(CONFIG_FUSE_DAX) \ + && IS_DAX(&(fuse_inode)->inode) \ + && !fuse_file_famfs(fuse_inode))ssize_t fuse_dax_read_iter (struct kiocb *iocb,struct iov_iter *to);ssize_t fuse_dax_write_iter (struct kiocb *iocb,struct iov_iter *from);
fs/fuse/inode.c +2 -2
@@ -162,7 +162,7 @@ static void fuse_evict_inode(struct inode *inode)/* Will write inode on close/munmap and in all other dirtiers */ WARN_ON (inode_state_read_once (inode) &I_DIRTY_INODE ); -if (FUSE_IS_DAX (inode)) +if (FUSE_IS_VIRTIO_DAX (fi))dax_break_layout_final (inode);truncate_inode_pages_final (&inode->i_data);
@@ -170,7 +170,7 @@ static void fuse_evict_inode(struct inode *inode)if (inode->i_sb->s_flags &SB_ACTIVE ) {struct fuse_conn *fc =get_fuse_conn (inode); -if (FUSE_IS_DAX (inode)) +if (FUSE_IS_VIRTIO_DAX (fi))fuse_dax_inode_cleanup (inode);if (fi->nlookup) { fuse_queue_forget(fc, fi->forget, fi->nodeid,
fs/fuse/iomode.c +1 -1
@@ -203,7 +203,7 @@ int fuse_file_io_open(struct file *file, struct inode *inode)* io modes are not relevant with DAX and with server that does not * implement open. */ -if (FUSE_IS_DAX (inode) || !ff->args) +if (FUSE_IS_VIRTIO_DAX (fi) || !ff->args)return 0 ;/*
Signature · 1 line
2.53.0
PATCH v10 2/10 famfs_fuse: Basic fuse kernel ABI enablement for famfs
In reply to John GrovesFrom: John Groves <[email protected]>
This patch starts the kernel ABI enablement of famfs in fuse.
- Kconfig: Add FUSE_FAMFS_DAX config parameter, to control compilation of famfs within fuse.
- FUSE_DAX_FMAP flag in INIT request/reply
- fuse_conn->famfs_iomap (enable famfs-mapped files) to denote a famfs-enabled connection
--- fs/fuse/Kconfig | 13 +++++++++++++ fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 6 ++++++ include/uapi/linux/fuse.h | 5 +++++ 4 files changed, 27 insertions(+)
fs/fuse/Kconfig +13 -0
@@ -76,3 +76,16 @@ config FUSE_IO_URING If you want to allow fuse server/client communication through io-uring, answer Y + +config FUSE_FAMFS_DAX + bool "FUSE support for fs-dax filesystems backed by devdax" + depends on FUSE_FS + depends on DEV_DAX_FSDEV + default FUSE_FS + help + This enables the fabric-attached memory file system (famfs), + which enables formatting devdax memory as a file system. Famfs + is primarily intended for scale-out shared access to + disaggregated memory. + + To enable famfs or other fuse/fs-dax file systems, answer Y
fs/fuse/fuse_i.h +3 -0
@@ -921,6 +921,9 @@ struct fuse_conn {/* Is synchronous FUSE_INIT allowed? */ unsigned int sync_init:1; +/* dev_dax_iomap support for famfs */ + unsigned int famfs_iomap:1; +/* Use io_uring for communication */ unsigned int io_uring;
fs/fuse/inode.c +6 -0
@@ -1456,6 +1456,10 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,if (flags &FUSE_REQUEST_TIMEOUT ) timeout = arg->request_timeout; + +if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX ) && + flags &FUSE_DAX_FMAP ) + fc->famfs_iomap =1 ; }else { ra_pages = fc->max_read /PAGE_SIZE ; fc->no_lock =1 ;
@@ -1517,6 +1521,8 @@ static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm) flags |=FUSE_SUBMOUNTS ;if (IS_ENABLED (CONFIG_FUSE_PASSTHROUGH )) flags |=FUSE_PASSTHROUGH ; +if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX )) + flags |=FUSE_DAX_FMAP ;/* * This is just an information flag for fuse server. No need to check
include/uapi/linux/fuse.h +5 -0
@@ -240,6 +240,9 @@* - add FUSE_COPY_FILE_RANGE_64 * - add struct fuse_copy_file_range_out * - add FUSE_NOTIFY_PRUNE +* +* 7.46 +* - Add FUSE_DAX_FMAP capability - ability to handle in-kernel fsdax maps */ #ifndef _LINUX_FUSE_H
@@ -448,6 +451,7 @@ struct fuse_file_lock {* FUSE_OVER_IO_URING: Indicate that client supports io-uring * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests. * init_out.request_timeout contains the timeout (in secs) +* FUSE_DAX_FMAP: kernel supports dev_dax_iomap (aka famfs) fmaps */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -495,6 +499,7 @@ struct fuse_file_lock {#define FUSE_ALLOW_IDMAP (1ULL << 40)#define FUSE_OVER_IO_URING (1ULL << 41)#define FUSE_REQUEST_TIMEOUT (1ULL << 42) +#define FUSE_DAX_FMAP (1ULL << 43)/** * CUSE INIT request/reply flags
Signature · 1 line
2.53.0
PATCH v10 3/10 famfs_fuse: Plumb the GET_FMAP message/response
In reply to John GrovesFrom: John Groves <[email protected]>
Upon completion of an OPEN, if we're in famfs-mode we do a GET_FMAP to retrieve and cache up the file-to-dax map in the kernel. If this succeeds, read/write/mmap are resolved direct-to-dax with no upcalls.
--- MAINTAINERS | 8 +++++ fs/fuse/Makefile | 1 + fs/fuse/famfs.c | 73 +++++++++++++++++++++++++++++++++++++++ fs/fuse/file.c | 14 +++++++- fs/fuse/fuse_i.h | 70 ++++++++++++++++++++++++++++++++++--- fs/fuse/inode.c | 8 ++++- fs/fuse/iomode.c | 2 +- include/uapi/linux/fuse.h | 7 ++++ 8 files changed, 175 insertions(+), 8 deletions(-) create mode 100644 fs/fuse/famfs.c
MAINTAINERS +8 -0
@@ -10523,6 +10523,14 @@ F: fs/fuse/ F: include/uapi/linux/fuse.h F: tools/testing/selftests/filesystems/fuse/ +FUSE [FAMFS Fabric-Attached Memory File System] +M: John Groves <[email protected]> +M: John Groves <[email protected]> +L: [email protected] +L: [email protected] +S: Supported +F: fs/fuse/famfs.c + FUTEX SUBSYSTEM M: Thomas Gleixner <[email protected]> M: Ingo Molnar <[email protected]>
fs/fuse/Makefile +1 -0
@@ -17,5 +17,6 @@ fuse-$(CONFIG_FUSE_DAX) += dax.o fuse-$(CONFIG_FUSE_PASSTHROUGH) += passthrough.o backing.o fuse-$(CONFIG_SYSCTL) += sysctl.o fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o +fuse-$(CONFIG_FUSE_FAMFS_DAX) += famfs.o virtiofs-y := virtio_fs.o
fs/fuse/famfs.c new file +73 -0
73 lines not on this page · raw message
fs/fuse/file.c +13 -1
@@ -277,6 +277,16 @@ static int fuse_open(struct inode *inode, struct file *file) err =fuse_do_open (fm,get_node_id (inode), file, false);if (!err) { ff = file->private_data; + +if ((fm->fc->famfs_iomap) && (S_ISREG (inode->i_mode))) { +/* Get the famfs fmap - failure is fatal */ + err =fuse_get_fmap (fm, inode); +if (err) { +fuse_sync_release (fi, ff, file->f_flags); + goto out_nowrite; + } + } + err =fuse_finish_open (inode, file);if (err)fuse_sync_release (fi, ff, file->f_flags);
@@ -284,12 +294,14 @@ static int fuse_open(struct inode *inode, struct file *file)fuse_truncate_update_attr (inode, file); } +out_nowrite:if (is_wb_truncate || dax_truncate)fuse_release_nowrite (inode);if (!err) {if (is_truncate)truncate_pagecache (inode,0 ); -else if (!(ff->open_flags &FOPEN_KEEP_CACHE )) +else if (!(ff->open_flags &FOPEN_KEEP_CACHE ) && + !fuse_file_famfs (fi))invalidate_inode_pages2 (inode->i_mapping); }if (dax_truncate)
fs/fuse/fuse_i.h +65 -5
86 lines not on this page · raw message
fs/fuse/inode.c +7 -1
@@ -120,6 +120,9 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)if (IS_ENABLED (CONFIG_FUSE_PASSTHROUGH ))fuse_inode_backing_set (fi,NULL ); +if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX )) +famfs_meta_set (fi,NULL ); +return &fi->inode; out_free_forget:
@@ -141,6 +144,9 @@ static void fuse_free_inode(struct inode *inode)if (IS_ENABLED (CONFIG_FUSE_PASSTHROUGH ))fuse_backing_put (fuse_inode_backing (fi)); +if (S_ISREG (inode->i_mode) &&fuse_file_famfs (fi)) +famfs_meta_free (fi); +kmem_cache_free (fuse_inode_cachep, fi); }
@@ -162,7 +168,7 @@ static void fuse_evict_inode(struct inode *inode)/* Will write inode on close/munmap and in all other dirtiers */ WARN_ON (inode_state_read_once (inode) &I_DIRTY_INODE ); -if (FUSE_IS_VIRTIO_DAX (fi)) +if (FUSE_IS_VIRTIO_DAX (fi) ||fuse_file_famfs (fi))dax_break_layout_final (inode);truncate_inode_pages_final (&inode->i_data);
fs/fuse/iomode.c +1 -1
@@ -203,7 +203,7 @@ int fuse_file_io_open(struct file *file, struct inode *inode)* io modes are not relevant with DAX and with server that does not * implement open. */ -if (FUSE_IS_VIRTIO_DAX (fi) || !ff->args) +if (FUSE_IS_VIRTIO_DAX (fi) ||fuse_file_famfs (fi) || !ff->args)return 0 ;/*
include/uapi/linux/fuse.h +7 -0
@@ -669,6 +669,9 @@ enum fuse_opcode {FUSE_STATX =52 ,FUSE_COPY_FILE_RANGE_64 =53 , +/* Famfs / devdax opcodes */ +FUSE_GET_FMAP =54 , +/* CUSE specific operations */ CUSE_INIT = 4096,
@@ -1313,4 +1316,8 @@ struct fuse_uring_cmd_req { uint8_t padding[6]; }; +/* Famfs fmap message components */ + +#define FAMFS_FMAP_MAX 32768/* Largest supported fmap message */ +#endif /* _LINUX_FUSE_H */
Signature · 1 line
2.53.0
PATCH v10 4/10 famfs_fuse: Create files with famfs fmaps
In reply to John GrovesFrom: John Groves <[email protected]>
On completion of GET_FMAP message/response, setup the full famfs metadata such that it's possible to handle read/write/mmap directly to dax. Note that the devdax_iomap plumbing is not in yet...
* Add famfs_kfmap.h: in-memory structures for resolving famfs file maps (fmaps) to dax.
* famfs.c: allocate, initialize and free fmaps
* inode.c: only allow famfs mode if the fuse server has CAP_SYS_RAWIO
* Update MAINTAINERS for the new file.
--- MAINTAINERS | 1 + fs/fuse/famfs.c | 339 +++++++++++++++++++++++++++++++++++++- fs/fuse/famfs_kfmap.h | 67 ++++++++ fs/fuse/fuse_i.h | 8 +- fs/fuse/inode.c | 20 ++- include/uapi/linux/fuse.h | 56 +++++++ 6 files changed, 481 insertions(+), 10 deletions(-) create mode 100644 fs/fuse/famfs_kfmap.h
MAINTAINERS +1 -0
@@ -10530,6 +10530,7 @@ L: [email protected] L: [email protected] S: Supported F: fs/fuse/famfs.c +F: fs/fuse/famfs_kfmap.h FUTEX SUBSYSTEM M: Thomas Gleixner <[email protected]>
fs/fuse/famfs.c +333 -6
353 lines not on this page · raw message
fs/fuse/famfs_kfmap.h new file +67 -0
67 lines not on this page · raw message
fs/fuse/fuse_i.h +7 -1
@@ -1642,6 +1642,9 @@ extern void fuse_sysctl_unregister(void);/* famfs.c */ #if IS_ENABLED (CONFIG_FUSE_FAMFS_DAX ) +int famfs_file_init_dax (struct fuse_mount *fm, +struct inode *inode,void *fmap_buf, +size_t fmap_size);void __famfs_meta_free (void *map);/* Set fi->famfs_meta = NULL regardless of prior value */
@@ -1659,7 +1662,10 @@ static inline struct fuse_backing *famfs_meta_set(struct fuse_inode *fi,static inline void famfs_meta_free (struct fuse_inode *fi) { -famfs_meta_set (fi,NULL ); +if (fi->famfs_meta !=NULL ) { +__famfs_meta_free (fi->famfs_meta); +famfs_meta_set (fi,NULL ); + } }static inline int fuse_file_famfs (struct fuse_inode *fi)
fs/fuse/inode.c +17 -3
@@ -10,6 +10,7 @@#include "fuse_dev_i.h" #include "dev_uring_i.h" +#include <linux/bitfield.h> #include <linux/dax.h> #include <linux/pagemap.h> #include <linux/slab.h>
@@ -1464,8 +1465,21 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, timeout = arg->request_timeout;if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX ) && - flags &FUSE_DAX_FMAP ) - fc->famfs_iomap =1 ; + flags &FUSE_DAX_FMAP ) { +/* famfs_iomap is only allowed if the fuse +* server has CAP_SYS_RAWIO. This was checked +* in fuse_send_init, and FUSE_DAX_IOMAP was +* set in in_flags if so. Only allow enablement +* if we find it there. This function is +* normally not running in fuse server context, +* so we can't do the capability check here... +*/ +u64 in_flags =FIELD_PREP (GENMASK_ULL (63 ,32 ), ia->in.flags2) + | ia->in.flags; + +if (in_flags &FUSE_DAX_FMAP ) + fc->famfs_iomap =1 ; + } }else { ra_pages = fc->max_read /PAGE_SIZE ; fc->no_lock =1 ;
@@ -1527,7 +1541,7 @@ static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm) flags |=FUSE_SUBMOUNTS ;if (IS_ENABLED (CONFIG_FUSE_PASSTHROUGH )) flags |=FUSE_PASSTHROUGH ; -if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX )) +if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX ) &&capable (CAP_SYS_RAWIO )) flags |=FUSE_DAX_FMAP ;/*
include/uapi/linux/fuse.h +56 -0
68 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v10 5/10 famfs_fuse: GET_DAXDEV message and daxdev_table
In reply to John GrovesFrom: John Groves <[email protected]>
- The new GET_DAXDEV message/response is added
- The famfs.c:famfs_teardown() function is added as a primary teardown function for famfs.
- The command it triggered by the update_daxdev_table() call, if there are any daxdevs in the subject fmap that are not represented in the daxdev_table yet.
- fs/namei.c: export may_open_dev()
--- fs/fuse/famfs.c | 227 +++++++++++++++++++++++++++++++++++++- fs/fuse/famfs_kfmap.h | 26 +++++ fs/fuse/fuse_i.h | 19 ++++ fs/fuse/inode.c | 7 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 20 ++++ 6 files changed, 298 insertions(+), 2 deletions(-)
fs/fuse/famfs.c +226 -1
@@ -21,6 +21,228 @@#include "famfs_kfmap.h" #include "fuse_i.h" +/* +* famfs_teardown() +* +* Deallocate famfs metadata for a fuse_conn +*/ +void +famfs_teardown (struct fuse_conn *fc) +{ + struct famfs_dax_devlist *devlist __free(kfree) = fc->dax_devlist; +int i; + + fc->dax_devlist =NULL ; + +if (!devlist) +return ; + +if (!devlist->devlist) +return ; + +/* Close & release all the daxdevs in our table */ +for (i =0 ; i < devlist->nslots; i++) { +struct famfs_daxdev *dd = &devlist->devlist[i]; + +if (!dd->valid) +continue ; + +/* Release reference from dax_dev_get() */ +if (dd->devp) +put_dax (dd->devp); + +kfree (dd->name); + } +kfree (devlist->devlist); +} + +static int +famfs_verify_daxdev (const char *pathname,dev_t *devno) +{ +struct inode *inode; +struct path path; +int err; + +if (!pathname || !*pathname) +return -EINVAL ; + + err =kern_path (pathname,LOOKUP_FOLLOW , &path); +if (err) +return err; + + inode =d_backing_inode (path.dentry); +if (!S_ISCHR (inode->i_mode)) { + err = -EINVAL ; + goto out_path_put; + } + +if (!may_open_dev (&path)) {/* had to export this */ + err = -EACCES ; + goto out_path_put; + } + + *devno = inode->i_rdev; + +out_path_put: +path_put (&path); +return err; +} + +/** +* famfs_fuse_get_daxdev() - Retrieve info for a DAX device from fuse server +* +* Send a GET_DAXDEV message to the fuse server to retrieve info on a +* dax device. +* +* @fm: fuse_mount +* @index: the index of the dax device; daxdevs are referred to by index +* in fmaps, and the server resolves the index to a particular daxdev +* +* Returns: 0=success +* -errno=failure +*/ +static int +famfs_fuse_get_daxdev (struct fuse_mount *fm,const u64 index) +{ +struct fuse_daxdev_out daxdev_out = {0 }; +struct fuse_conn *fc = fm->fc; +struct famfs_daxdev *daxdev; +int rc; + +FUSE_ARGS (args); + +/* Store the daxdev in our table */ +if (index >= fc->dax_devlist->nslots) { +pr_err ("%s: index(%lld) > nslots(%d)\n" , + __func__, index, fc->dax_devlist->nslots); +return -EINVAL ; + } + + args.opcode =FUSE_GET_DAXDEV ; + args.nodeid = index; + + args.in_numargs =0 ; + + args.out_numargs =1 ; + args.out_args[0 ].size =sizeof (daxdev_out); + args.out_args[0 ].value = &daxdev_out; + +/* Send GET_DAXDEV command */ + rc =fuse_simple_request (fm, &args); +if (rc) { +pr_err ("%s: rc=%d from fuse_simple_request()\n" , + __func__, rc); +/* Error will be that the payload is smaller than FMAP_BUFSIZE, +* which is the max we can handle. Empty payload handled below. +*/ +return rc; + } + + scoped_guard(rwsem_write, &fc->famfs_devlist_sem) { + daxdev = &fc->dax_devlist->devlist[index]; + +/* Abort if daxdev is now valid (races are possible here) */ +if (daxdev->valid) { +pr_debug ("%s: daxdev already known\n" , __func__); +return 0 ; + } + +/* Verify dev is valid and can be opened and gets the devno */ + rc =famfs_verify_daxdev (daxdev_out.name, &daxdev->devno); +if (rc) { +pr_err ("%s: rc=%d from famfs_verify_daxdev()\n" , + __func__, rc); +return rc; + } + + daxdev->name =kstrdup (daxdev_out.name,GFP_KERNEL ); +if (!daxdev->name) +return -ENOMEM ; + +/* This will fail if it's not a dax device */ + daxdev->devp =dax_dev_get (daxdev->devno); +if (!daxdev->devp) { +pr_warn ("%s: device %s not found or not dax\n" , + __func__, daxdev_out.name); +kfree (daxdev->name); + daxdev->name =NULL ; +return -ENODEV ; + } + +wmb ();/* All other fields must be visible before valid */ + daxdev->valid =1 ; + } + +return 0 ; +} + +/** +* famfs_update_daxdev_table() - Update the daxdev table +* @fm: fuse_mount +* @meta: famfs_file_meta, in-memory format, built from a GET_FMAP response +* +* This function is called for each new file fmap, to verify whether all +* referenced daxdevs are already known (i.e. in the table). Any daxdev +* indices referenced in @meta but not in the table will be retrieved via +* famfs_fuse_get_daxdev() and added to the table +* +* Return: 0=success +* -errno=failure +*/ +static int +famfs_update_daxdev_table ( +struct fuse_mount *fm, +const struct famfs_file_meta *meta) +{ +struct famfs_dax_devlist *local_devlist; +struct fuse_conn *fc = fm->fc; +int indices_to_fetch[MAX_DAXDEVS ]; +int n_to_fetch =0 ; +int err; + +/* First time through we will need to allocate the dax_devlist */ +if (!fc->dax_devlist) { + local_devlist =kcalloc (1 ,sizeof (*fc->dax_devlist),GFP_KERNEL ); +if (!local_devlist) +return -ENOMEM ; + + local_devlist->nslots =MAX_DAXDEVS ; + + local_devlist->devlist =kcalloc (MAX_DAXDEVS , +sizeof (struct famfs_daxdev ), +GFP_KERNEL ); +if (!local_devlist->devlist) { +kfree (local_devlist); +return -ENOMEM ; + } + +/* We don't need famfs_devlist_sem here because we use cmpxchg */ +if (cmpxchg (&fc->dax_devlist,NULL , local_devlist) !=NULL ) { +kfree (local_devlist->devlist); +kfree (local_devlist);/* another thread beat us to it */ + } + } + +/* Collect indices that need fetching while holding read lock */ + scoped_guard(rwsem_read, &fc->famfs_devlist_sem) { +unsigned long i; + +for_each_set_bit (i, (unsigned long *)&meta->dev_bitmap,MAX_DAXDEVS ) { +if (!(fc->dax_devlist->devlist[i].valid)) + indices_to_fetch[n_to_fetch++] = i; + } + } + +/* Fetch needed daxdevs outside the read lock */ +for (int j =0 ; j < n_to_fetch; j++) { + err =famfs_fuse_get_daxdev (fm, indices_to_fetch[j]); +if (err) +pr_err ("%s: failed to get daxdev=%d\n" , + __func__, indices_to_fetch[j]); + } + +return 0 ; +}/***************************************************************************/
@@ -184,7 +406,7 @@ famfs_fuse_meta_alloc(/* ie_in = one interleaved extent in fmap_buf */ ie_in = fmap_buf + next_offset; -/* Move past one interleaved extent header in fmap_buf */ +/* Move past 1 interleaved extent header in fmap_buf */ next_offset +=sizeof (*ie_in);if (next_offset > fmap_buf_size) { pr_err("%s:%d: fmap_buf underflow offset/size %ld/%ld\n",
@@ -329,6 +551,9 @@ famfs_file_init_dax(if (rc) goto errout; +/* Make sure this fmap doesn't reference any unknown daxdevs */ +famfs_update_daxdev_table (fm, meta); +/* Publish the famfs metadata on fi->famfs_meta */ inode_lock (inode);
fs/fuse/famfs_kfmap.h +26 -0
@@ -64,4 +64,30 @@ struct famfs_file_meta { }; }; +/* +* famfs_daxdev - tracking struct for a daxdev within a famfs file system +* +* This is the in-memory daxdev metadata that is populated by parsing +* the responses to GET_FMAP messages +*/ +struct famfs_daxdev { +/* Include dev uuid? */ +bool valid; +bool error; +dev_t devno; +struct dax_device *devp; +char *name; +}; + +#define MAX_DAXDEVS 24 + +/* +* famfs_dax_devlist - list of famfs_daxdev's +*/ +struct famfs_dax_devlist { +int nslots; +int ndevs; +struct famfs_daxdev *devlist; +}; +#endif /* FAMFS_KFMAP_H */
fs/fuse/fuse_i.h +19 -0
@@ -1006,6 +1006,11 @@ struct fuse_conn {/* Request timeout (in jiffies). 0 = no timeout */ unsigned int req_timeout; } timeout; + +#if IS_ENABLED (CONFIG_FUSE_FAMFS_DAX ) +struct rw_semaphore famfs_devlist_sem; +struct famfs_dax_devlist *dax_devlist; +#endif };/*
@@ -1647,6 +1652,8 @@ int famfs_file_init_dax(struct fuse_mount *fm, size_t fmap_size);void __famfs_meta_free (void *map); +void famfs_teardown (struct fuse_conn *fc); +/* Set fi->famfs_meta = NULL regardless of prior value */ static inline void famfs_meta_init (struct fuse_inode *fi) {
@@ -1668,6 +1675,11 @@ static inline void famfs_meta_free(struct fuse_inode *fi) } } +static inline void famfs_init_devlist_sem (struct fuse_conn *fc) +{ +init_rwsem (&fc->famfs_devlist_sem); +} +static inline int fuse_file_famfs (struct fuse_inode *fi) {return (READ_ONCE (fi->famfs_meta) !=NULL );
@@ -1677,6 +1689,9 @@ int fuse_get_fmap(struct fuse_mount *fm, struct inode *inode);#else /* !CONFIG_FUSE_FAMFS_DAX */ +static inline void famfs_teardown (struct fuse_conn *fc) +{ +}static inline struct fuse_backing *famfs_meta_set (struct fuse_inode *fi,void *meta) {
@@ -1687,6 +1702,10 @@ static inline void famfs_meta_free(struct fuse_inode *fi) { } +static inline void famfs_init_devlist_sem (struct fuse_conn *fc) +{ +} +static inline int fuse_file_famfs (struct fuse_inode *fi) {return 0 ;
fs/fuse/inode.c +6 -1
@@ -1048,6 +1048,9 @@ void fuse_conn_put(struct fuse_conn *fc)WARN_ON (atomic_read (&bucket->count) !=1 );kfree (bucket); } +if (IS_ENABLED (CONFIG_FUSE_FAMFS_DAX )) +famfs_teardown (fc); +if (IS_ENABLED (CONFIG_FUSE_PASSTHROUGH ))fuse_backing_files_free (fc);call_rcu (&fc->rcu, delayed_release);
@@ -1477,8 +1480,10 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,u64 in_flags =FIELD_PREP (GENMASK_ULL (63 ,32 ), ia->in.flags2) | ia->in.flags; -if (in_flags &FUSE_DAX_FMAP ) +if (in_flags &FUSE_DAX_FMAP ) { +famfs_init_devlist_sem (fc); fc->famfs_iomap =1 ; + } } }else { ra_pages = fc->max_read /PAGE_SIZE ;
fs/namei.c +1 -0
@@ -4212,6 +4212,7 @@ bool may_open_dev(const struct path *path)return !(path->mnt->mnt_flags &MNT_NODEV ) && !(path->mnt->mnt_sb->s_iflags &SB_I_NODEV ); } +EXPORT_SYMBOL (may_open_dev);static int may_open (struct mnt_idmap *idmap,const struct path *path,int acc_mode,int flag)
include/uapi/linux/fuse.h +20 -0
@@ -247,6 +247,9 @@* - struct fuse_famfs_simple_ext * - struct fuse_famfs_iext * - struct fuse_famfs_fmap_header +* - Add the following structs for the GET_DAXDEV message and reply +* - struct fuse_get_daxdev_in +* - struct fuse_get_daxdev_out * - Add the following enumerated types * - enum fuse_famfs_file_type * - enum famfs_ext_type
@@ -678,6 +681,7 @@ enum fuse_opcode {/* Famfs / devdax opcodes */ FUSE_GET_FMAP =54 , +FUSE_GET_DAXDEV =55 ,/* CUSE specific operations */ CUSE_INIT = 4096,
@@ -1369,6 +1373,22 @@ struct fuse_famfs_fmap_header {uint64_t reserved1; }; +struct fuse_get_daxdev_in { +uint32_t daxdev_num; +}; + +#define DAXDEV_NAME_MAX 256 + +/* fuse_daxdev_out has enough space for a uuid if we need it */ +struct fuse_daxdev_out { +uint16_t index; +uint16_t reserved; +uint32_t reserved2; +uint64_t reserved3; +uint64_t reserved4; +char name[DAXDEV_NAME_MAX ]; +}; +static inline int32_t fmap_msg_min_size (void ) {/* Smallest fmap message is a header plus one simple extent */
Signature · 1 line
2.53.0
PATCH v10 6/10 famfs_fuse: Plumb dax iomap and fuse read/write/mmap
In reply to John GrovesFrom: John Groves <[email protected]>
This commit fills in read/write/mmap handling for famfs files. The dev_dax_iomap interface is used - just like xfs in fs-dax mode.
- Read/write are handled by famfs_fuse_[read|write]_iter() via dax_iomap_rw() to fsdev_dax.
- Mmap is handled by famfs_fuse_mmap()
- Faults are handled by famfs_filemap_fault(), using dax_iomap_fault() to fsdev_dax.
- File offset to dax offset resolution is handled via famfs_fuse_iomap_begin(), which uses famfs "fmaps" to resolve the the requested (file, offset) to an offset on a dax device (by way of famfs_fileofs_to_daxofs() and famfs_interleave_fileofs_to_daxofs())
--- fs/fuse/famfs.c | 448 +++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/file.c | 18 +- fs/fuse/fuse_i.h | 19 ++ 3 files changed, 483 insertions(+), 2 deletions(-)
fs/fuse/famfs.c +448 -0
@@ -576,6 +576,454 @@ famfs_file_init_dax(return rc; } +/********************************************************************* +* iomap_operations +* +* This stuff uses the iomap (dax-related) helpers to resolve file offsets to +* offsets within a dax device. +*/ + +static int famfs_file_bad (struct inode *inode); + +static int +famfs_interleave_fileofs_to_daxofs (struct inode *inode,struct iomap *iomap, +loff_t file_offset,off_t len,unsigned int flags) +{ +struct fuse_inode *fi =get_fuse_inode (inode); +struct famfs_file_meta *meta = fi->famfs_meta; +struct fuse_conn *fc =get_fuse_conn (inode); +loff_t local_offset = file_offset; + +/* This function is only for extent_type INTERLEAVED_EXTENT */ +if (meta->fm_extent_type !=INTERLEAVED_EXTENT ) { +pr_err ("%s: bad extent type\n" , __func__); + goto err_out; + } + +if (famfs_file_bad (inode)) + goto err_out; + + iomap->offset = file_offset; + +for (int i =0 ; i < meta->fm_niext; i++) { +struct famfs_meta_interleaved_ext *fei = &meta->ie[i]; +u64 chunk_size = fei->fie_chunk_size; +u64 nstrips = fei->fie_nstrips; +u64 ext_size =min (fei->fie_nbytes, meta->file_size); + +if (!IS_ALIGNED (chunk_size,PMD_SIZE )) { +pr_err ("%s: chunk_size %lld not PMD-aligned\n" , + __func__, meta->ie[i].fie_chunk_size); +return -EINVAL ; + } +if (ext_size ==0 ) { +pr_err ("%s: ext_size=%lld file_size=%ld\n" , + __func__, fei->fie_nbytes, meta->file_size); + goto err_out; + } + +/* Is the data is in this striped extent? */ +if (local_offset < ext_size) { +u64 chunk_num = local_offset / chunk_size; +u64 chunk_offset = local_offset % chunk_size; +u64 chunk_remainder = chunk_size - chunk_offset; +u64 stripe_num = chunk_num / nstrips; +u64 strip_num = chunk_num % nstrips; +u64 strip_offset = chunk_offset + (stripe_num * chunk_size); +u64 strip_dax_ofs = fei->ie_strips[strip_num].ext_offset; +u64 strip_devidx = fei->ie_strips[strip_num].dev_index; + +if (strip_devidx >= fc->dax_devlist->nslots) { +pr_err ("%s: strip_devidx %llu >= nslots %d\n" , + __func__, strip_devidx, + fc->dax_devlist->nslots); + goto err_out; + } + +if (!fc->dax_devlist->devlist[strip_devidx].valid) { +pr_err ("%s: daxdev=%lld invalid\n" , __func__, + strip_devidx); + goto err_out; + } + + iomap->addr = strip_dax_ofs + strip_offset; + iomap->offset = file_offset; + iomap->length =min_t (loff_t, len, chunk_remainder); + + iomap->dax_dev = fc->dax_devlist->devlist[strip_devidx].devp; + + iomap->type =IOMAP_MAPPED ; + iomap->flags = flags; + +return 0 ; + } + local_offset -= ext_size;/* offset is beyond this striped extent */ + } + + err_out: +pr_err ("%s: err_out\n" , __func__); + +/* We fell out the end of the extent list. +* Set iomap to zero length in this case, and return 0 +* This just means that the r/w is past EOF +*/ + iomap->addr =0 ;/* there is no valid dax device offset */ + iomap->offset = file_offset;/* file offset */ + iomap->length =0 ;/* this had better result in no access to dax mem */ + iomap->dax_dev =NULL ; + iomap->type =IOMAP_MAPPED ; + iomap->flags = flags; + +return -EIO ; +} + +/** +* famfs_fileofs_to_daxofs() - Resolve (file, offset, len) to (daxdev, offset, len) +* +* This function is called by famfs_fuse_iomap_begin() to resolve an offset in a +* file to an offset in a dax device. This is upcalled from dax from calls to +* both * dax_iomap_fault() and dax_iomap_rw(). Dax finishes the job resolving +* a fault to a specific physical page (the fault case) or doing a memcpy +* variant (the rw case) +* +* Pages can be PTE (4k), PMD (2MiB) or (theoretically) PuD (1GiB) +* (these sizes are for X86; may vary on other cpu architectures +* +* @inode: The file where the fault occurred +* @iomap: To be filled in to indicate where to find the right memory, +* relative to a dax device. +* @file_offset: Within the file where the fault occurred (will be page boundary) +* @len: The length of the faulted mapping (will be a page multiple) +* (will be trimmed in *iomap if it's disjoint in the extent list) +* @flags: flags passed to famfs_fuse_iomap_begin(), and sent back via +* struct iomap +* +* Return values: 0. (info is returned in a modified @iomap struct) +*/ +static int +famfs_fileofs_to_daxofs (struct inode *inode,struct iomap *iomap, +loff_t file_offset,off_t len,unsigned int flags) +{ +struct fuse_inode *fi =get_fuse_inode (inode); +struct famfs_file_meta *meta = fi->famfs_meta; +struct fuse_conn *fc =get_fuse_conn (inode); +loff_t local_offset = file_offset; + +if (!fc->dax_devlist) { +pr_err ("%s: null dax_devlist\n" , __func__); + goto err_out; + } + +if (famfs_file_bad (inode)) + goto err_out; + +if (meta->fm_extent_type ==INTERLEAVED_EXTENT ) +return famfs_interleave_fileofs_to_daxofs (inode, iomap, + file_offset, + len, flags); + + iomap->offset = file_offset; + +for (int i =0 ; i < meta->fm_nextents; i++) { +/* TODO: check devindex too */ +loff_t dax_ext_offset = meta->se[i].ext_offset; +loff_t dax_ext_len = meta->se[i].ext_len; +u64 daxdev_idx = meta->se[i].dev_index; + + +/* TODO: test that superblock and log offsets only happen +* with superblock and log files. Requires instrumentaiton +* from user space... +*/ + +/* local_offset is the offset minus the size of extents skipped +* so far; If local_offset < dax_ext_len, the data of interest +* starts in this extent +*/ +if (local_offset < dax_ext_len) { +loff_t ext_len_remainder = dax_ext_len - local_offset; +struct famfs_daxdev *dd; + +if (daxdev_idx >= fc->dax_devlist->nslots) { +pr_err ("%s: daxdev_idx %llu >= nslots %d\n" , + __func__, daxdev_idx, + fc->dax_devlist->nslots); + goto err_out; + } + + dd = &fc->dax_devlist->devlist[daxdev_idx]; + +if (!dd->valid || dd->error) { +pr_err ("%s: daxdev=%lld %s\n" , __func__, + daxdev_idx, + dd->valid ?"error" :"invalid" ); + goto err_out; + } + +/* +* OK, we found the file metadata extent where this +* data begins +* @local_offset - The offset within the current +* extent +* @ext_len_remainder - Remaining length of ext after +* skipping local_offset +* Outputs: +* iomap->addr: the offset within the dax device where +* the data starts +* iomap->offset: the file offset +* iomap->length: the valid length resolved here +*/ + iomap->addr = dax_ext_offset + local_offset; + iomap->offset = file_offset; + iomap->length =min_t (loff_t, len, ext_len_remainder); + + iomap->dax_dev = fc->dax_devlist->devlist[daxdev_idx].devp; + + iomap->type =IOMAP_MAPPED ; + iomap->flags = flags; +return 0 ; + } + local_offset -= dax_ext_len;/* Get ready for the next extent */ + } + + err_out: +pr_err ("%s: err_out\n" , __func__); + +/* We fell out the end of the extent list. +* Set iomap to zero length in this case, and return 0 +* This just means that the r/w is past EOF +*/ + iomap->addr =0 ;/* there is no valid dax device offset */ + iomap->offset = file_offset;/* file offset */ + iomap->length =0 ;/* this had better result in no access to dax mem */ + iomap->dax_dev =NULL ; + iomap->type =IOMAP_MAPPED ; + iomap->flags = flags; + +return -EIO ; +} + +/** +* famfs_fuse_iomap_begin() - Handler for iomap_begin upcall from dax +* +* This function is pretty simple because files are +* * never partially allocated +* * never have holes (never sparse) +* * never "allocate on write" +* +* @inode: inode for the file being accessed +* @offset: offset within the file +* @length: Length being accessed at offset +* @flags: flags to be retured via struct iomap +* @iomap: iomap struct to be filled in, resolving (offset, length) to +* (daxdev, offset, len) +* @srcmap: source mapping if it is a COW operation (which it is not here) +*/ +static int +famfs_fuse_iomap_begin (struct inode *inode,loff_t offset,loff_t length, +unsigned int flags,struct iomap *iomap,struct iomap *srcmap) +{ +struct fuse_inode *fi =get_fuse_inode (inode); +struct famfs_file_meta *meta = fi->famfs_meta; +size_t size; + + size =i_size_read (inode); + +WARN_ON (size != meta->file_size); + +return famfs_fileofs_to_daxofs (inode, iomap, offset, length, flags); +} + +/* Note: We never need a special set of write_iomap_ops because famfs never +* performs allocation on write. +*/ +const struct iomap_ops famfs_iomap_ops = { + .iomap_begin = famfs_fuse_iomap_begin, +}; + +/********************************************************************* +* vm_operations +*/ +static vm_fault_t +__famfs_fuse_filemap_fault (struct vm_fault *vmf,unsigned int pe_size, +bool write_fault) +{ +struct inode *inode =file_inode (vmf->vma->vm_file); +vm_fault_t ret; +unsigned long pfn; + +if (!IS_DAX (file_inode (vmf->vma->vm_file))) { +pr_err ("%s: file not marked IS_DAX!!\n" , __func__); +return VM_FAULT_SIGBUS ; + } + +if (write_fault) { +sb_start_pagefault (inode->i_sb); +file_update_time (vmf->vma->vm_file); + } + + ret =dax_iomap_fault (vmf, pe_size, &pfn,NULL , &famfs_iomap_ops); +if (ret &VM_FAULT_NEEDDSYNC ) + ret =dax_finish_sync_fault (vmf, pe_size, pfn); + +if (write_fault) +sb_end_pagefault (inode->i_sb); + +return ret; +} + +static inline bool +famfs_is_write_fault (struct vm_fault *vmf) +{ +return (vmf->flags &FAULT_FLAG_WRITE ) && + (vmf->vma->vm_flags &VM_SHARED ); +} + +static vm_fault_t +famfs_filemap_fault (struct vm_fault *vmf) +{ +return __famfs_fuse_filemap_fault (vmf,0 ,famfs_is_write_fault (vmf)); +} + +static vm_fault_t +famfs_filemap_huge_fault (struct vm_fault *vmf,unsigned int pe_size) +{ +return __famfs_fuse_filemap_fault (vmf, pe_size, +famfs_is_write_fault (vmf)); +} + +static vm_fault_t +famfs_filemap_mkwrite (struct vm_fault *vmf) +{ +return __famfs_fuse_filemap_fault (vmf,0 , true); +} + +const struct vm_operations_struct famfs_file_vm_ops = { + .fault = famfs_filemap_fault, + .huge_fault = famfs_filemap_huge_fault, + .map_pages = filemap_map_pages, + .page_mkwrite = famfs_filemap_mkwrite, + .pfn_mkwrite = famfs_filemap_mkwrite, +}; + +/********************************************************************* +* file_operations +*/ + +/** +* famfs_file_bad() - Check for files that aren't in a valid state +* +* @inode: inode +* +* Returns: 0=success +* -errno=failure +*/ +static int +famfs_file_bad (struct inode *inode) +{ +struct fuse_inode *fi =get_fuse_inode (inode); +struct famfs_file_meta *meta = fi->famfs_meta; +size_t i_size =i_size_read (inode); + +if (!meta) { +pr_err ("%s: un-initialized famfs file\n" , __func__); +return -EIO ; + } +if (meta->error) { +pr_debug ("%s: previously detected metadata errors\n" , __func__); +return -EIO ; + } +if (i_size != meta->file_size) { +pr_warn ("%s: i_size overwritten from %ld to %ld\n" , + __func__, meta->file_size, i_size); + meta->error = true; +return -ENXIO ; + } +if (!IS_DAX (inode)) { +pr_debug ("%s: inode %llx IS_DAX is false\n" , + __func__, (u64 )inode); +return -ENXIO ; + } +return 0 ; +} + +static ssize_t +famfs_fuse_rw_prep (struct kiocb *iocb,struct iov_iter *ubuf) +{ +struct inode *inode = iocb->ki_filp->f_mapping->host; +size_t i_size =i_size_read (inode); +size_t count =iov_iter_count (ubuf); +size_t max_count; +ssize_t rc; + + rc =famfs_file_bad (inode); +if (rc) +return (ssize_t )rc; + +/* Avoid unsigned underflow if position is past EOF */ +if (iocb->ki_pos >= i_size) + max_count =0 ; +else + max_count = i_size - iocb->ki_pos; + +if (count > max_count) +iov_iter_truncate (ubuf, max_count); + +if (!iov_iter_count (ubuf)) +return 0 ; + +return rc; +} + +ssize_t +famfs_fuse_read_iter (struct kiocb *iocb,struct iov_iter *to) +{ +ssize_t rc; + + rc =famfs_fuse_rw_prep (iocb, to); +if (rc) +return rc; + +if (!iov_iter_count (to)) +return 0 ; + + rc =dax_iomap_rw (iocb, to, &famfs_iomap_ops); + +file_accessed (iocb->ki_filp); +return rc; +} + +ssize_t +famfs_fuse_write_iter (struct kiocb *iocb,struct iov_iter *from) +{ +ssize_t rc; + + rc =famfs_fuse_rw_prep (iocb, from); +if (rc) +return rc; + +if (!iov_iter_count (from)) +return 0 ; + +return dax_iomap_rw (iocb, from, &famfs_iomap_ops); +} + +int +famfs_fuse_mmap (struct file *file,struct vm_area_struct *vma) +{ +struct inode *inode =file_inode (file); +ssize_t rc; + + rc =famfs_file_bad (inode); +if (rc) +return rc; + +file_accessed (file); + vma->vm_ops = &famfs_file_vm_ops; +vm_flags_set (vma,VM_HUGEPAGE ); +return 0 ; +} +#define FMAP_BUFSIZE PAGE_SIZEint fuse_get_fmap (struct fuse_mount *fm,struct inode *inode)
fs/fuse/file.c +16 -2
@@ -1831,6 +1831,8 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to)if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_read_iter (iocb, to); +if (fuse_file_famfs (fi)) +return famfs_fuse_read_iter (iocb, to);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags &FOPEN_DIRECT_IO )
@@ -1853,6 +1855,8 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_write_iter (iocb, from); +if (fuse_file_famfs (fi)) +return famfs_fuse_write_iter (iocb, from);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags &FOPEN_DIRECT_IO )
@@ -1868,9 +1872,13 @@ static ssize_t fuse_splice_read(struct file *in, loff_t *ppos, unsigned int flags) {struct fuse_file *ff = in->private_data; +struct inode *inode =file_inode (in); +struct fuse_inode *fi =get_fuse_inode (inode);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ -if (fuse_file_passthrough (ff) && !(ff->open_flags &FOPEN_DIRECT_IO )) +if (fuse_file_famfs (fi)) +return -EIO ;/* famfs does not use the page cache... */ +else if (fuse_file_passthrough (ff) && !(ff->open_flags &FOPEN_DIRECT_IO ))return fuse_passthrough_splice_read (in, ppos, pipe, len, flags);else return filemap_splice_read (in, ppos, pipe, len, flags);
@@ -1880,9 +1888,13 @@ static ssize_t fuse_splice_write(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags) { struct fuse_file *ff = out->private_data; +struct inode *inode =file_inode (out); +struct fuse_inode *fi =get_fuse_inode (inode);/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ -if (fuse_file_passthrough (ff) && !(ff->open_flags &FOPEN_DIRECT_IO )) +if (fuse_file_famfs (fi)) +return -EIO ;/* famfs does not use the page cache... */ +else if (fuse_file_passthrough (ff) && !(ff->open_flags &FOPEN_DIRECT_IO ))return fuse_passthrough_splice_write (pipe, out, ppos, len, flags);else return iter_file_splice_write (pipe, out, ppos, len, flags);
@@ -2390,6 +2402,8 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)/* DAX mmap is superior to direct_io mmap */ if (FUSE_IS_VIRTIO_DAX (fi))return fuse_dax_mmap (file, vma); +if (fuse_file_famfs (fi)) +return famfs_fuse_mmap (file, vma);/* * If inode is in passthrough io mode, because it has some file open
fs/fuse/fuse_i.h +19 -0
@@ -1650,6 +1650,9 @@ extern void fuse_sysctl_unregister(void);int famfs_file_init_dax (struct fuse_mount *fm,struct inode *inode,void *fmap_buf,size_t fmap_size); +ssize_t famfs_fuse_write_iter (struct kiocb *iocb,struct iov_iter *from); +ssize_t famfs_fuse_read_iter (struct kiocb *iocb,struct iov_iter *to); +int famfs_fuse_mmap (struct file *file,struct vm_area_struct *vma);void __famfs_meta_free (void *map);void famfs_teardown (struct fuse_conn *fc);
@@ -1692,6 +1695,22 @@ int fuse_get_fmap(struct fuse_mount *fm, struct inode *inode);static inline void famfs_teardown (struct fuse_conn *fc) { } +static inline ssize_t famfs_fuse_write_iter (struct kiocb *iocb, +struct iov_iter *to) +{ +return -ENODEV ; +} +static inline ssize_t famfs_fuse_read_iter (struct kiocb *iocb, +struct iov_iter *to) +{ +return -ENODEV ; +} +static inline int famfs_fuse_mmap (struct file *file, +struct vm_area_struct *vma) +{ +return -ENODEV ; +} +static inline struct fuse_backing *famfs_meta_set (struct fuse_inode *fi,void *meta) {
Signature · 1 line
2.53.0
PATCH v10 7/10 famfs_fuse: Add holder_operations for dax notify_failure()
In reply to John GrovesFrom: John Groves <[email protected]>
Memory errors are at least somewhat more likely on disaggregated memory than on-board memory. This commit registers to be notified by fsdev_dax in the event that a memory failure is detected.
When a file access resolves to a daxdev with memory errors, it will fail with an appropriate error.
If a daxdev failed fs_dax_get(), we set dd->dax_err. If a daxdev called our notify_failure(), set dd->error. When any of the above happens, set (file)->error and stop allowing access.
In general, the recovery from memory errors is to unmount the file system and re-initialize the memory, but there may be usable degraded modes of operation - particularly in the future when famfs supports file systems backed by more than one daxdev. In those cases, accessing data that is on a working daxdev can still work.
For now, return errors for any file that has encountered a memory or dax error.
--- fs/fuse/famfs.c | 110 +++++++++++++++++++++++++++++++++++++++--- fs/fuse/famfs_kfmap.h | 3 +- 2 files changed, 105 insertions(+), 8 deletions(-)
fs/fuse/famfs.c +103 -7
@@ -21,6 +21,26 @@#include "famfs_kfmap.h" #include "fuse_i.h" +static void famfs_set_daxdev_err ( +struct fuse_conn *fc,struct dax_device *dax_devp); + +static int +famfs_dax_notify_failure (struct dax_device *dax_devp,u64 offset, +u64 len,int mf_flags) +{ +struct fuse_conn *fc =dax_holder (dax_devp); + +famfs_set_daxdev_err (fc, dax_devp); + +return 0 ; +} + +static const struct dax_holder_operations famfs_fuse_dax_holder_ops = { + .notify_failure = famfs_dax_notify_failure, +}; + +/*****************************************************************************/ +/* * famfs_teardown() *
@@ -47,9 +67,12 @@ famfs_teardown(struct fuse_conn *fc)if (!dd->valid)continue ; -/* Release reference from dax_dev_get() */ -if (dd->devp) +/* Only call fs_put_dax if fs_dax_get succeeded */ +if (dd->devp) { +if (!dd->dax_err) +fs_put_dax (dd->devp, fc);put_dax (dd->devp); + }kfree (dd->name); }
@@ -169,6 +192,17 @@ famfs_fuse_get_daxdev(struct fuse_mount *fm, const u64 index)return -ENODEV ; } + rc =fs_dax_get (daxdev->devp, fc, &famfs_fuse_dax_holder_ops); +if (rc) { +/* Mark as valid with dax_err to prevent retry loop. +* famfs_dax_err() will return -EIO on access attempts. +* Teardown handles this case: skips fs_put_dax, calls put_dax. +*/ + daxdev->dax_err =1 ; +pr_err ("%s: fs_dax_get(%lld) failed\n" , + __func__, (u64 )daxdev->devno); + } +wmb ();/* All other fields must be visible before valid */ daxdev->valid =1 ; }
@@ -244,6 +278,36 @@ famfs_update_daxdev_table(return 0 ; } +static void +famfs_set_daxdev_err ( +struct fuse_conn *fc, +struct dax_device *dax_devp) +{ +int i; + +/* Gotta search the list by dax_devp; +* read lock because we're not adding or removing daxdev entries +*/ + scoped_guard(rwsem_write, &fc->famfs_devlist_sem) { +for (i =0 ; i < fc->dax_devlist->nslots; i++) { +if (fc->dax_devlist->devlist[i].valid) { +struct famfs_daxdev *dd; + + dd = &fc->dax_devlist->devlist[i]; +if (dd->devp != dax_devp) +continue ; + + dd->error = true; + +pr_err ("%s: memory error on daxdev %s (%d)\n" , + __func__, dd->name, i); +return ; + } + } + } +pr_err ("%s: memory err on unrecognized daxdev\n" , __func__); +} +/***************************************************************************/ void __famfs_meta_free (void *famfs_meta)
@@ -585,6 +649,26 @@ famfs_file_init_dax(static int famfs_file_bad (struct inode *inode); +static int famfs_dax_err (struct famfs_daxdev *dd) +{ +if (!dd->valid) { +pr_err ("%s: daxdev=%s invalid\n" , + __func__, dd->name); +return -EIO ; + } +if (dd->dax_err) { +pr_err ("%s: daxdev=%s dax_err\n" , + __func__, dd->name); +return -EIO ; + } +if (dd->error) { +pr_err ("%s: daxdev=%s memory error\n" , + __func__, dd->name); +return -EHWPOISON ; + } +return 0 ; +} +static int famfs_interleave_fileofs_to_daxofs (struct inode *inode,struct iomap *iomap,loff_t file_offset,off_t len,unsigned int flags)
@@ -624,6 +708,7 @@ famfs_interleave_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap,/* Is the data is in this striped extent? */ if (local_offset < ext_size) { +struct famfs_daxdev *dd;u64 chunk_num = local_offset / chunk_size;u64 chunk_offset = local_offset % chunk_size;u64 chunk_remainder = chunk_size - chunk_offset;
@@ -632,6 +717,7 @@ famfs_interleave_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap,u64 strip_offset = chunk_offset + (stripe_num * chunk_size);u64 strip_dax_ofs = fei->ie_strips[strip_num].ext_offset;u64 strip_devidx = fei->ie_strips[strip_num].dev_index; +int rc;if (strip_devidx >= fc->dax_devlist->nslots) { pr_err("%s: strip_devidx %llu >= nslots %d\n",
@@ -646,6 +732,15 @@ famfs_interleave_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap, goto err_out; } + dd = &fc->dax_devlist->devlist[strip_devidx]; + + rc =famfs_dax_err (dd); +if (rc) { +/* Shut down access to this file */ + meta->error = true; +return rc; + } + iomap->addr = strip_dax_ofs + strip_offset; iomap->offset = file_offset; iomap->length =min_t (loff_t, len, chunk_remainder);
@@ -743,6 +838,7 @@ famfs_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap,if (local_offset < dax_ext_len) {loff_t ext_len_remainder = dax_ext_len - local_offset;struct famfs_daxdev *dd; +int rc;if (daxdev_idx >= fc->dax_devlist->nslots) { pr_err("%s: daxdev_idx %llu >= nslots %d\n",
@@ -753,11 +849,11 @@ famfs_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap, dd = &fc->dax_devlist->devlist[daxdev_idx]; -if (!dd->valid || dd->error) { -pr_err ("%s: daxdev=%lld %s\n" , __func__, - daxdev_idx, - dd->valid ?"error" :"invalid" ); - goto err_out; + rc =famfs_dax_err (dd); +if (rc) { +/* Shut down access to this file */ + meta->error = true; +return rc; }/*
fs/fuse/famfs_kfmap.h +2 -1
@@ -73,7 +73,8 @@ struct famfs_file_meta {struct famfs_daxdev {/* Include dev uuid? */ bool valid; -bool error; +bool error;/* Dax has reported a memory error (probably poison) */ +bool dax_err;/* fs_dax_get() failed */ dev_t devno;struct dax_device *devp;char *name;
Signature · 1 line
2.53.0
PATCH v10 8/10 famfs_fuse: Add DAX address_space_operations with noop_dirty_folio
In reply to John GrovesFrom: John Groves <[email protected]>
Famfs is memory-backed; there is no place to write back to, and no reason to mark pages dirty at all.
--- fs/fuse/famfs.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/fuse/famfs.c +11 -0
@@ -14,6 +14,7 @@#include <linux/mm.h> #include <linux/dax.h> #include <linux/iomap.h> +#include <linux/pagemap.h> #include <linux/path.h> #include <linux/namei.h> #include <linux/string.h>
@@ -39,6 +40,15 @@ static const struct dax_holder_operations famfs_fuse_dax_holder_ops = { .notify_failure = famfs_dax_notify_failure, }; +/* +* DAX address_space_operations for famfs. +* famfs doesn't need dirty tracking - writes go directly to +* memory with no writeback required. +*/ +static const struct address_space_operations famfs_dax_aops = { + .dirty_folio = noop_dirty_folio, +}; +/*****************************************************************************/ /*
@@ -624,6 +634,7 @@ famfs_file_init_dax(if (famfs_meta_set (fi, meta) ==NULL ) {i_size_write (inode, meta->file_size); inode->i_flags |=S_DAX ; + inode->i_data.a_ops = &famfs_dax_aops; }else {pr_debug ("%s: file already had metadata\n" , __func__);__famfs_meta_free (meta);
Signature · 1 line
2.53.0
PATCH v10 9/10 famfs_fuse: Add famfs fmap metadata documentation
In reply to John GrovesFrom: John Groves <[email protected]>
This describes the fmap metadata - both simple and interleaved
--- fs/fuse/famfs_kfmap.h | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
fs/fuse/famfs_kfmap.h +73 -0
@@ -7,6 +7,79 @@#ifndef FAMFS_KFMAP_H #define FAMFS_KFMAP_H +/* KABI version 43 (aka v2) fmap structures +* +* The location of the memory backing for a famfs file is described by +* the response to the GET_FMAP fuse message (defined in +* include/uapi/linux/fuse.h +* +* There are currently two extent formats: Simple and Interleaved. +* +* Simple extents are just (devindex, offset, length) tuples, where devindex +* references a devdax device that must be retrievable via the GET_DAXDEV +* message/response. +* +* The extent list size must be >= file_size. +* +* Interleaved extents merit some additional explanation. Interleaved +* extents stripe data across a collection of strips. Each strip is a +* contiguous allocation from a single devdax device - and is described by +* a simple_extent structure. +* +* Interleaved_extent example: +* ie_nstrips = 4 +* ie_chunk_size = 2MiB +* ie_nbytes = 24MiB +* +* ┌────────────┐────────────┐────────────┐────────────┐ +* │Chunk = 0 │Chunk = 1 │Chunk = 2 │Chunk = 3 │ +* │Strip = 0 │Strip = 1 │Strip = 2 │Strip = 3 │ +* │Stripe = 0 │Stripe = 0 │Stripe = 0 │Stripe = 0 │ +* │ │ │ │ │ +* └────────────┘────────────┘────────────┘────────────┘ +* │Chunk = 4 │Chunk = 5 │Chunk = 6 │Chunk = 7 │ +* │Strip = 0 │Strip = 1 │Strip = 2 │Strip = 3 │ +* │Stripe = 1 │Stripe = 1 │Stripe = 1 │Stripe = 1 │ +* │ │ │ │ │ +* └────────────┘────────────┘────────────┘────────────┘ +* │Chunk = 8 │Chunk = 9 │Chunk = 10 │Chunk = 11 │ +* │Strip = 0 │Strip = 1 │Strip = 2 │Strip = 3 │ +* │Stripe = 2 │Stripe = 2 │Stripe = 2 │Stripe = 2 │ +* │ │ │ │ │ +* └────────────┘────────────┘────────────┘────────────┘ +* +* * Data is laid out across chunks in chunk # order +* * Columns are strips +* * Strips are contiguous devdax extents, normally each coming from a +* different memory device +* * Rows are stripes +* * The number of chunks is (int)((file_size + chunk_size - 1) / chunk_size) +* (and obviously the last chunk could be partial) +* * The stripe_size = (nstrips * chunk_size) +* * chunk_num(offset) = offset / chunk_size //integer division +* * strip_num(offset) = chunk_num(offset) % nchunks +* * stripe_num(offset) = offset / stripe_size //integer division +* * ...You get the idea - see the code for more details... +* +* Some concrete examples from the layout above: +* * Offset 0 in the file is offset 0 in chunk 0, which is offset 0 in +* strip 0 +* * Offset 4MiB in the file is offset 0 in chunk 2, which is offset 0 in +* strip 2 +* * Offset 15MiB in the file is offset 1MiB in chunk 7, which is offset +* 3MiB in strip 3 +* +* Notes about this metadata format: +* +* * For various reasons, chunk_size must be a multiple of the applicable +* PAGE_SIZE +* * Since chunk_size and nstrips are constant within an interleaved_extent, +* resolving a file offset to a strip offset within a single +* interleaved_ext is order 1. +* * If nstrips==1, a list of interleaved_ext structures degenerates to a +* regular extent list (albeit with some wasted struct space). +*/ +/* * The structures below are the in-memory metadata format for famfs files. * Metadata retrieved via the GET_FMAP response is converted to this format
Signature · 1 line
2.53.0
PATCH v10 10/10 famfs_fuse: Add documentation
In reply to John GrovesFrom: John Groves <[email protected]>
Add Documentation/filesystems/famfs.rst and update MAINTAINERS
--- Documentation/filesystems/famfs.rst | 142 ++++++++++++++++++++++++++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 1 + 3 files changed, 144 insertions(+) create mode 100644 Documentation/filesystems/famfs.rst
Documentation/filesystems/famfs.rst new file +142 -0
@@ -0,0 +1,142 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _famfs_index: + +================================================================== +famfs: The fabric-attached memory file system +================================================================== + +- Copyright (C) 2024-2026 Micron Technology, Inc. + +Introduction +============ +Compute Express Link (CXL) provides a mechanism for disaggregated or +fabric-attached memory (FAM). This creates opportunities for data sharing; +clustered apps that would otherwise have to shard or replicate data can +share one copy in disaggregated memory. + +Famfs, which is not CXL-specific in any way, provides a mechanism for +multiple hosts to concurrently access data in shared memory, by giving it +a file system interface. With famfs, any app that understands files can +access data sets in shared memory. Although famfs supports read and write, +the real point is to support mmap, which provides direct (dax) access to +the memory - either writable or read-only. + +Shared memory can pose complex coherency and synchronization issues, but +there are also simple cases. Two simple and eminently useful patterns that +occur frequently in data analytics and AI are: + +* Serial Sharing - Only one host or process at a time has access to a file +* Read-only Sharing - Multiple hosts or processes share read-only access + to a file + +The famfs fuse file system is part of the famfs framework; user space +components [1] handle metadata allocation and distribution, and provide a +low-level fuse server to expose files that map directly to [presumably +shared] memory. + +The famfs framework manages coherency of its own metadata and structures, +but does not attempt to manage coherency for applications. + +Famfs also provides data isolation between files. That is, even though +the host has access to an entire memory "device" (as a devdax device), apps +cannot write to memory for which the file is read-only, and mapping one +file provides isolation from the memory of all other files. This is pretty +basic, but some experimental shared memory usage patterns provide no such +isolation. + +Principles of Operation +======================= + +Famfs is a file system with one or more devdax devices as a first-class +backing device(s). Metadata maintenance and query operations happen +entirely in user space. + +The famfs low-level fuse server daemon provides file maps (fmaps) and +devdax device info to the fuse/famfs kernel component so that +read/write/mapping faults can be handled without up-calls for all active +files. + +The famfs user space is responsible for maintaining and distributing +consistent metadata. This is currently handled via an append-only +metadata log within the memory, but this is orthogonal to the fuse/famfs +kernel code. + +Once instantiated, "the same file" on each host points to the same shared +memory, but in-memory metadata (inodes, etc.) is ephemeral on each host +that has a famfs instance mounted. Use cases are free to allow or not +allow mutations to data on a file-by-file basis. + +When an app accesses a data object in a famfs file, there is no page cache +involvement. The CPU cache is loaded directly from the shared memory. In +some use cases, this is an enormous reduction in read amplification +compared to loading an entire page into the page cache. + + +Famfs is Not a Conventional File System +--------------------------------------- + +Famfs files can be accessed by conventional means, but there are +limitations. The kernel component of fuse/famfs is not involved in the +allocation of backing memory for files at all; the famfs user space +creates files and responds as a low-level fuse server with fmaps and +devdax device info upon request. + +Famfs differs in some important ways from conventional file systems: + +* Files must be pre-allocated by the famfs framework; allocation is never + performed on (or after) write. +* Any operation that changes a file's size is considered to put the file + in an invalid state, disabling access to the data. It may be possible to + revisit this in the future. (Typically the famfs user space can restore + files to a valid state by replaying the famfs metadata log.) + +Famfs exists to apply the existing file system abstractions to shared +memory so applications and workflows can more easily adapt to an +environment with disaggregated shared memory. + +Memory Error Handling +===================== + +Possible memory errors include timeouts, poison, and unexpected +reconfiguration of an underlying dax device. In all of these cases, famfs +receives a call from the devdax layer via its iomap_ops->notify_failure() +function. If any memory errors have been detected, access to the affected +daxdev is disabled to avoid further errors or corruption. + +In all known cases, famfs can be unmounted cleanly. In most cases errors +can be cleared by re-initializing the memory - at which point a new famfs +file system can be created. + +Key Requirements +================ + +The primary requirements for famfs are: + +1. Must support a file system abstraction backed by sharable devdax memory +2. Files must efficiently handle VMA faults +3. Must support metadata distribution in a sharable way +4. Must handle clients with a stale copy of metadata + +The famfs kernel component takes care of 1-2 above by caching each file's +mapping metadata in the kernel. + +Requirements 3 and 4 are handled by the user space components, and are +largely orthogonal to the functionality of the famfs kernel module. + +Requirements 3 and 4 cannot be met by conventional fs-dax file systems +(e.g. xfs) because they use write-back metadata; it is not valid to mount +such a file system on two hosts from the same in-memory image. + + +Famfs Usage +=========== + +Famfs usage is documented at [1]. + + +References +========== + +- [1] Famfs user space repository and documentation + https://github.com/cxl-micron-reskit/famfs
Documentation/filesystems/index.rst +1 -0
@@ -89,6 +89,7 @@ Documentation for filesystem implementations. ext3 ext4/index f2fs + famfs gfs2/index hfs hfsplus
MAINTAINERS +1 -0
@@ -10529,6 +10529,7 @@ M: John Groves <[email protected]> L: [email protected] L: [email protected] S: Supported +F: Documentation/filesystems/famfs.rst F: fs/fuse/famfs.c F: fs/fuse/famfs_kfmap.h
Signature · 1 line
2.53.0
Quoted 214 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses toFUSE_IS_VIRTIO_DAX()macro, in case something bad is passed in asfuse_inode(thanks Jonathan's AI)Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP- Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV- Retrieves the details of a particular daxdev that was
referenced by an fmapFamfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs:
GET_FMAPandGET_DAXDEV.Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a
GET_FMAPmessage and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.- After each
GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with aGET_DAXDEVmessage and response.- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the
fs_dax_get()call (modeled after how fs-dax handles this with pmem devices). Famfs providesholder_operationsto devdax, providing a notification path in the event of memory errors or forced reconfiguration.- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires
CAP_SYS_RAWIO).- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse
fs_type- but I'm not sure that's ultimately optimal (thoughts?)Changes v8 -> v9
-Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the newCONFIG_DEV_DAX_FSDEV(fromdrivers/dax/Kconfig) rather than justCONFIG_DEV_DAXandCONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAXdepends on those...)Changes v7 -> v8
- Moved to inline__freedeclaration infuse_get_fmap()andfamfs_fuse_meta_alloc(),famfs_teardown()
- AdoptedFIELD_PREP()macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers toinclude/uapi/linux/magic.h. That can be done later if appropriateChanges v6 -> v7
- Fixed a regression infamfs_interleave_fileofs_to_daxofs()that was reported by Intel's kernel test robot
- Added a check in__fsdev_dax_direct_access()for negative return frompgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in__famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks infamfs_fuse_meta_alloc()andfamfs_interleave_fileofs_to_daxofs()as interleaved chunks must be PTE or PMD aligned
- Simplifiedfamfs_file_init_dax()a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issuesChanges v4 -> v5 -> v6
- None. Re-sending due to technical difficultiesChanges v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed thefs/fuse/Kconfigpatch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces thedev_dax_iomapmodifications tobus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev usesMEMORY_DEVICE_FS_DAXtype and leaves folios at order-0 (novmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed viafsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporaryWARN_ON_ONCEworkaround infs/dax.chas been removed.
- Dax: Addeddax_set_ops()so fsdev can setdax_operationsat bind time (and clear them on unbind), since thedax_deviceis created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return-EBUSYif a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon hasCAP_SYS_RAWIObecause they expose raw memory devices.
- Fuse: Added DAXaddress_space_operationswithnoop_dirty_foliosince famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.Changes v1 [8] -> v2:
- The
GET_FMAPmessage/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload toGET_FMAPvariable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak offc->shadowin patch 11 (thanks Joanne)
- Dropped manypr_debugandpr_noticecallsReferences
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.h
Quoted 5 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77Signature · 1 line
2.53.0
Miklos,
I would appreciate a read on what you're thinking WRT merging famfs. The dax patches are ready; this series should be applied on top of Ira's for-7.1/dax-famfs branch, which is at [1].
I saw that you had the famfs series in your for-next branch briefly a couple of weeks ago, but it didn't build because it depends on the dax series. It will build and run cleanly if you put it on Ira's branch above.
Famfs has been in use for a long time, though availability of sharable cxl memory is still limited; that is changing with early availability (now) of sharable JBOMs up to 100TB.
The presence of famfs won't affect anybody who doesn't use it though...
What are your thoughts?
Thanks,
John
[1] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
Quoted 215 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses toFUSE_IS_VIRTIO_DAX()macro, in case something bad is passed in asfuse_inode(thanks Jonathan's AI)Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP- Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV- Retrieves the details of a particular daxdev that was
referenced by an fmapFamfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs:
GET_FMAPandGET_DAXDEV.Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a
GET_FMAPmessage and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.- After each
GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with aGET_DAXDEVmessage and response.- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the
fs_dax_get()call (modeled after how fs-dax handles this with pmem devices). Famfs providesholder_operationsto devdax, providing a notification path in the event of memory errors or forced reconfiguration.- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires
CAP_SYS_RAWIO).- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse
fs_type- but I'm not sure that's ultimately optimal (thoughts?)Changes v8 -> v9
-Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the newCONFIG_DEV_DAX_FSDEV(fromdrivers/dax/Kconfig) rather than justCONFIG_DEV_DAXandCONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAXdepends on those...)Changes v7 -> v8
- Moved to inline__freedeclaration infuse_get_fmap()andfamfs_fuse_meta_alloc(),famfs_teardown()
- AdoptedFIELD_PREP()macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers toinclude/uapi/linux/magic.h. That can be done later if appropriateChanges v6 -> v7
- Fixed a regression infamfs_interleave_fileofs_to_daxofs()that was reported by Intel's kernel test robot
- Added a check in__fsdev_dax_direct_access()for negative return frompgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in__famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks infamfs_fuse_meta_alloc()andfamfs_interleave_fileofs_to_daxofs()as interleaved chunks must be PTE or PMD aligned
- Simplifiedfamfs_file_init_dax()a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issuesChanges v4 -> v5 -> v6
- None. Re-sending due to technical difficultiesChanges v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed thefs/fuse/Kconfigpatch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces thedev_dax_iomapmodifications tobus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev usesMEMORY_DEVICE_FS_DAXtype and leaves folios at order-0 (novmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed viafsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporaryWARN_ON_ONCEworkaround infs/dax.chas been removed.
- Dax: Addeddax_set_ops()so fsdev can setdax_operationsat bind time (and clear them on unbind), since thedax_deviceis created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return-EBUSYif a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon hasCAP_SYS_RAWIObecause they expose raw memory devices.
- Fuse: Added DAXaddress_space_operationswithnoop_dirty_foliosince famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.Changes v1 [8] -> v2:
- The
GET_FMAPmessage/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload toGET_FMAPvariable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak offc->shadowin patch 11 (thanks Joanne)
- Dropped manypr_debugandpr_noticecallsReferences
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.h
Quoted 4 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77--
2.53.0
Hi John,
I’m curious to hear your thoughts on whether you think it makes sense for the famfs-specific logic in this series to be moved to a bpf program that goes through a generic fuse iomap dax layer.
Based on [1], this gives feature-parity with the famfs logic in this series. In my opinion, having famfs go through a generic fuse iomap dax layer makes the fuse kernel code more extensible for future servers that will also want to use dax iomap, and keeps the fuse code cleaner by not having famfs-specific logic hardcoded in and having to introduce new fuse uapis for something famfs-specific. In my understanding of it, fuse is meant to be generic and it feels like adding server-specific logic goes against that design philosophy and sets a precedent for other servers wanting similar special-casing in the future. I'd like to explore whether the bpf and generic fuse iomap dax layer approach can preserve that philosophy while still giving famfs the flexibility it needs.
I think moving the famfs logic to bpf benefits famfs as well:
- Instead of needing to issue a FUSE_GET_FMAP request after a file is opened, the server can directly populate the metadata map from userspace with the mapping info when it processes the FUSE_OPEN request, which gets rid of the roundtrip cost
- The server can dynamically update the metadata / bpf maps during runtime from userspace if any mapping info needs to change
- Future code changes / updates for famfs are all server-side and can be deployed immediately instead of needing to go through the upstream kernel mailing list process
- Famfs updates / new releases can ship independently of kernel releases
I'd appreciate the chance to discuss tradeoffs or if you'd rather discuss this at the fuse BoF at lsf, that sounds great too.
Thanks,
Joanne
Quoted 1 line
Quoted 252 lines · Joanne Koong
Quoted 215 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses toFUSE_IS_VIRTIO_DAX()macro, in case something bad is passed in asfuse_inode(thanks Jonathan's AI)Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP- Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV- Retrieves the details of a particular daxdev that was
referenced by an fmapFamfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs:
GET_FMAPandGET_DAXDEV.Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a
GET_FMAPmessage and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.- After each
GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with aGET_DAXDEVmessage and response.- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the
fs_dax_get()call (modeled after how fs-dax handles this with pmem devices). Famfs providesholder_operationsto devdax, providing a notification path in the event of memory errors or forced reconfiguration.- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires
CAP_SYS_RAWIO).- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse
fs_type- but I'm not sure that's ultimately optimal (thoughts?)Changes v8 -> v9
-Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the newCONFIG_DEV_DAX_FSDEV(fromdrivers/dax/Kconfig) rather than justCONFIG_DEV_DAXandCONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAXdepends on those...)Changes v7 -> v8
- Moved to inline__freedeclaration infuse_get_fmap()andfamfs_fuse_meta_alloc(),famfs_teardown()
- AdoptedFIELD_PREP()macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers toinclude/uapi/linux/magic.h. That can be done later if appropriateChanges v6 -> v7
- Fixed a regression infamfs_interleave_fileofs_to_daxofs()that was reported by Intel's kernel test robot
- Added a check in__fsdev_dax_direct_access()for negative return frompgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in__famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks infamfs_fuse_meta_alloc()andfamfs_interleave_fileofs_to_daxofs()as interleaved chunks must be PTE or PMD aligned
- Simplifiedfamfs_file_init_dax()a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issuesChanges v4 -> v5 -> v6
- None. Re-sending due to technical difficultiesChanges v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed thefs/fuse/Kconfigpatch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces thedev_dax_iomapmodifications tobus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev usesMEMORY_DEVICE_FS_DAXtype and leaves folios at order-0 (novmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed viafsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporaryWARN_ON_ONCEworkaround infs/dax.chas been removed.
- Dax: Addeddax_set_ops()so fsdev can setdax_operationsat bind time (and clear them on unbind), since thedax_deviceis created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return-EBUSYif a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon hasCAP_SYS_RAWIObecause they expose raw memory devices.
- Fuse: Added DAXaddress_space_operationswithnoop_dirty_foliosince famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.Changes v1 [8] -> v2:
- The
GET_FMAPmessage/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload toGET_FMAPvariable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak offc->shadowin patch 11 (thanks Joanne)
- Dropped manypr_debugandpr_noticecallsReferences
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.hQuoted 4 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77--
2.53.0Hi John,
I’m curious to hear your thoughts on whether you think it makes sense for the famfs-specific logic in this series to be moved to a bpf program that goes through a generic fuse iomap dax layer.
Based on [1], this gives feature-parity with the famfs logic in this series. In my opinion, having famfs go through a generic fuse iomap dax layer makes the fuse kernel code more extensible for future servers that will also want to use dax iomap, and keeps the fuse code cleaner by not having famfs-specific logic hardcoded in and having to introduce new fuse uapis for something famfs-specific. In my understanding of it, fuse is meant to be generic and it feels like adding server-specific logic goes against that design philosophy and sets a precedent for other servers wanting similar special-casing in the future. I'd like to explore whether the bpf and generic fuse iomap dax layer approach can preserve that philosophy while still giving famfs the flexibility it needs.
I think moving the famfs logic to bpf benefits famfs as well:
- Instead of needing to issue aFUSE_GET_FMAPrequest after a file is opened, the server can directly populate the metadata map from userspace with the mapping info when it processes theFUSE_OPENrequest, which gets rid of the roundtrip cost
- The server can dynamically update the metadata / bpf maps during runtime from userspace if any mapping info needs to change
- Future code changes / updates for famfs are all server-side and can be deployed immediately instead of needing to go through the upstream kernel mailing list process
- Famfs updates / new releases can ship independently of kernel releases
Quoted 6 lines
I'd appreciate the chance to discuss tradeoffs or if you'd rather discuss this at the fuse BoF at lsf, that sounds great too.
Thanks,
Joanne
Hi Joanne,
I'm definitely up for discussing it, and talking before LSFMM would be good because then I'd have some time to think about before we discuss at LSFMM.
I have not had a chance to really study this, in part since I've never even written a "hello world" BPF program.
I'll ping off-list about times to talk.
However...
I would object vehemently to this sort of re-write prior to going upstream, as would users and vendors who need famfs now that the memory products it enables have started to ship.
This work started over 3 years ago, initial patches over 2 years ago, community decision that it should go into fuse 2 years ago, first fuse patches a year ago.
This implementation is pretty much exactly in line with expectation-setting starting two years ago. Famfs is a complicated orchestration between dax, fuse, ndctl (for daxctl), libfuse and the extensive famfs user space. Famfs has a fairly small kernel footprint, but its user space is much larger. This could set it back a year if we re-write now.
Two things are true at once: I think this is a serious idea worth considering, and I think it's too late to make this sort of change before going upstream. Products need this enablement, and quite a long process has run in order to make it available in a timely fashion (which means soon now). I hope we can avoid making the perfect the enemy of the good.
I believe the risk of merging famfs soon is quite low, because famfs will not affect anybody who doesn't use it. I hope we can run this discussion and analysis in parallel with merging the current implementation of famfs soon.
Thank you,
John
Quoted 293 lines · John Groves
Quoted 252 lines · Joanne Koong
Quoted 215 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses toFUSE_IS_VIRTIO_DAX()macro, in case something bad is passed in asfuse_inode(thanks Jonathan's AI)Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP- Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV- Retrieves the details of a particular daxdev that was
referenced by an fmapFamfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs:
GET_FMAPandGET_DAXDEV.Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a
GET_FMAPmessage and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.- After each
GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with aGET_DAXDEVmessage and response.- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the
fs_dax_get()call (modeled after how fs-dax handles this with pmem devices). Famfs providesholder_operationsto devdax, providing a notification path in the event of memory errors or forced reconfiguration.- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires
CAP_SYS_RAWIO).- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse
fs_type- but I'm not sure that's ultimately optimal (thoughts?)Changes v8 -> v9
-Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the newCONFIG_DEV_DAX_FSDEV(fromdrivers/dax/Kconfig) rather than justCONFIG_DEV_DAXandCONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAXdepends on those...)Changes v7 -> v8
- Moved to inline__freedeclaration infuse_get_fmap()andfamfs_fuse_meta_alloc(),famfs_teardown()
- AdoptedFIELD_PREP()macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers toinclude/uapi/linux/magic.h. That can be done later if appropriateChanges v6 -> v7
- Fixed a regression infamfs_interleave_fileofs_to_daxofs()that was reported by Intel's kernel test robot
- Added a check in__fsdev_dax_direct_access()for negative return frompgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in__famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks infamfs_fuse_meta_alloc()andfamfs_interleave_fileofs_to_daxofs()as interleaved chunks must be PTE or PMD aligned
- Simplifiedfamfs_file_init_dax()a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issuesChanges v4 -> v5 -> v6
- None. Re-sending due to technical difficultiesChanges v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed thefs/fuse/Kconfigpatch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces thedev_dax_iomapmodifications tobus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev usesMEMORY_DEVICE_FS_DAXtype and leaves folios at order-0 (novmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed viafsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporaryWARN_ON_ONCEworkaround infs/dax.chas been removed.
- Dax: Addeddax_set_ops()so fsdev can setdax_operationsat bind time (and clear them on unbind), since thedax_deviceis created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return-EBUSYif a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon hasCAP_SYS_RAWIObecause they expose raw memory devices.
- Fuse: Added DAXaddress_space_operationswithnoop_dirty_foliosince famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.Changes v1 [8] -> v2:
- The
GET_FMAPmessage/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload toGET_FMAPvariable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak offc->shadowin patch 11 (thanks Joanne)
- Dropped manypr_debugandpr_noticecallsReferences
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.hQuoted 4 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77--
2.53.0Hi John,
I’m curious to hear your thoughts on whether you think it makes sense for the famfs-specific logic in this series to be moved to a bpf program that goes through a generic fuse iomap dax layer.
Based on [1], this gives feature-parity with the famfs logic in this series. In my opinion, having famfs go through a generic fuse iomap dax layer makes the fuse kernel code more extensible for future servers that will also want to use dax iomap, and keeps the fuse code cleaner by not having famfs-specific logic hardcoded in and having to introduce new fuse uapis for something famfs-specific. In my understanding of it, fuse is meant to be generic and it feels like adding server-specific logic goes against that design philosophy and sets a precedent for other servers wanting similar special-casing in the future. I'd like to explore whether the bpf and generic fuse iomap dax layer approach can preserve that philosophy while still giving famfs the flexibility it needs.
I think moving the famfs logic to bpf benefits famfs as well:
- Instead of needing to issue aFUSE_GET_FMAPrequest after a file is opened, the server can directly populate the metadata map from userspace with the mapping info when it processes theFUSE_OPENrequest, which gets rid of the roundtrip cost
- The server can dynamically update the metadata / bpf maps during runtime from userspace if any mapping info needs to change
- Future code changes / updates for famfs are all server-side and can be deployed immediately instead of needing to go through the upstream kernel mailing list process
- Famfs updates / new releases can ship independently of kernel releasesQuoted 6 lines
I'd appreciate the chance to discuss tradeoffs or if you'd rather discuss this at the fuse BoF at lsf, that sounds great too.
Thanks,
JoanneHi Joanne,
I'm definitely up for discussing it, and talking before LSFMM would be good because then I'd have some time to think about before we discuss at LSFMM.
I have not had a chance to really study this, in part since I've never even written a "hello world" BPF program.
I'll ping off-list about times to talk.
However...
I would object vehemently to this sort of re-write prior to going upstream, as would users and vendors who need famfs now that the memory products it enables have started to ship.
This work started over 3 years ago, initial patches over 2 years ago, community decision that it should go into fuse 2 years ago, first fuse patches a year ago.
This implementation is pretty much exactly in line with expectation-setting starting two years ago. Famfs is a complicated orchestration between dax, fuse, ndctl (for daxctl), libfuse and the extensive famfs user space. Famfs has a fairly small kernel footprint, but its user space is much larger. This could set it back a year if we re-write now.
Two things are true at once: I think this is a serious idea worth considering, and I think it's too late to make this sort of change before going upstream. Products need this enablement, and quite a long process has run in order to make it available in a timely fashion (which means soon now). I hope we can avoid making the perfect the enemy of the good.
Quoted 3 lines
I believe the risk of merging famfs soon is quite low, because famfs will not affect anybody who doesn't use it. I hope we can run this discussion and analysis in parallel with merging the current implementation of famfs soon.
Hi John,
one question, assuming most of these things can be done with eBPF, would you convert to eBPF after the merge?
(I also need to find the time to review at least all of your libfuse changes, I feel guilty that still haven't done it.).
Thanks,
Bernd
Quoted 301 lines · Bernd Schubert
Quoted 293 lines · John Groves
Quoted 252 lines · Joanne Koong
Quoted 215 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Changes v9 -> v10
- Rebased to Ira's for-7.1/dax-famfs branch [0], which contains the required dax patches
- Add parentheses toFUSE_IS_VIRTIO_DAX()macro, in case something bad is passed in asfuse_inode(thanks Jonathan's AI)Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
Fuse Overview:
Famfs started as a standalone file system, but this series is intended to permanently supersede that implementation. At a high level, famfs adds two new fuse server messages:
GET_FMAP- Retrieves a famfs fmap (the file-to-dax map for a famfs
file)GET_DAXDEV- Retrieves the details of a particular daxdev that was
referenced by an fmapFamfs Overview
Famfs exposes shared memory as a file system. Famfs consumes shared memory from dax devices, and provides memory-mappable files that map directly to the memory - no page cache involvement. Famfs differs from conventional file systems in fs-dax mode, in that it handles in-memory metadata in a sharable way (which begins with never caching dirty shared metadata).
Famfs started as a standalone file system [2,3], but the consensus at LSFMM was that it should be ported into fuse [4,5].
The key performance requirement is that famfs must resolve mapping faults without upcalls. This is achieved by fully caching the file-to-devdax metadata for all active files. This is done via two fuse client/server message/response pairs:
GET_FMAPandGET_DAXDEV.Famfs remains the first fs-dax file system that is backed by devdax rather than pmem in fs-dax mode (hence the need for the new dax mode).
Notes
- When a file is opened in a famfs mount, the OPEN is followed by a
GET_FMAPmessage and response. The "fmap" is the full file-to-dax mapping, allowing the fuse/famfs kernel code to handle read/write/fault without any upcalls.- After each
GET_FMAP, the fmap is checked for extents that reference previously-unknown daxdevs. Each such occurrence is handled with aGET_DAXDEVmessage and response.- Daxdevs are stored in a table (which might become an xarray at some point). When entries are added to the table, we acquire exclusive access to the daxdev via the
fs_dax_get()call (modeled after how fs-dax handles this with pmem devices). Famfs providesholder_operationsto devdax, providing a notification path in the event of memory errors or forced reconfiguration.- If devdax notifies famfs of memory errors on a dax device, famfs currently blocks all subsequent accesses to data on that device. The recovery is to re-initialize the memory and file system. Famfs is memory, not storage...
- Because famfs uses backing (devdax) devices, only privileged mounts are supported (i.e. the fuse server requires
CAP_SYS_RAWIO).- The famfs kernel code never accesses the memory directly - it only facilitates read, write and mmap on behalf of user processes, using fmap metadata provided by its privileged fuse server. As such, the RAS of the shared memory affects applications, but not the kernel.
- Famfs has backing device(s), but they are devdax (char) rather than block. Right now there is no way to tell the vfs layer that famfs has a char backing device (unless we say it's block, but it's not). Currently we use the standard anonymous fuse
fs_type- but I'm not sure that's ultimately optimal (thoughts?)Changes v8 -> v9
-Kconfig: fs/fuse/Kconfig:CONFIG_FUSE_FAMFS_DAX now depends on the newCONFIG_DEV_DAX_FSDEV(fromdrivers/dax/Kconfig) rather than justCONFIG_DEV_DAXandCONFIG_FS_DAX. (CONFIG_FUSE_FAMFS_DAXdepends on those...)Changes v7 -> v8
- Moved to inline__freedeclaration infuse_get_fmap()andfamfs_fuse_meta_alloc(),famfs_teardown()
- AdoptedFIELD_PREP()macro rather than manual bitfield manipulation
- Minor doc edits
- I dropped adding magic numbers toinclude/uapi/linux/magic.h. That can be done later if appropriateChanges v6 -> v7
- Fixed a regression infamfs_interleave_fileofs_to_daxofs()that was reported by Intel's kernel test robot
- Added a check in__fsdev_dax_direct_access()for negative return frompgoff_to_phys(), which would indicate an out-of-range offset
- Fixed a bug in__famfs_meta_free(), where not all interleaved extents were freed
- Added chunksize alignment checks infamfs_fuse_meta_alloc()andfamfs_interleave_fileofs_to_daxofs()as interleaved chunks must be PTE or PMD aligned
- Simplifiedfamfs_file_init_dax()a bit
- Re-ran CM's kernel code review prompts on the entire series and fixed several minor issuesChanges v4 -> v5 -> v6
- None. Re-sending due to technical difficultiesChanges v3 [9] -> v4
- The patch "dax: prevent driver unbind while filesystem holds device" has been dropped. Dan Williams indicated that the favored behavior is for a file system to stop working if an underlying driver is unbound, rather than preventing the unbind.
- The patch "famfs_fuse: Famfs mount opt: -o shadow=<shadowpath>" has been dropped. Found a way for the famfs user space to do without the -o opt (via getxattr).
- Squashed thefs/fuse/Kconfigpatch into the first subsequent patch that needed the change
("famfs_fuse: Basic fuse kernel ABI enablement for famfs")
- Many review comments addressed.
- Addressed minor kerneldoc infractions reported by test robot.Changes v2 [7] -> v3
- Dax: Completely new fsdev driver (drivers/dax/fsdev.c) replaces thedev_dax_iomapmodifications tobus.c/device.c. Devdax devices can now be switched among 'devdax', 'famfs' and 'system-ram' modes via daxctl or sysfs.
- Dax: fsdev usesMEMORY_DEVICE_FS_DAXtype and leaves folios at order-0 (novmemmap_shift), allowing fs-dax to manage folio lifecycles dynamically like pmem does.
- Dax: The "poisoned page" problem is properly fixed viafsdev_clear_folio_state(), which clears stale mapping/compound state when fsdev binds. The temporaryWARN_ON_ONCEworkaround infs/dax.chas been removed.
- Dax: Addeddax_set_ops()so fsdev can setdax_operationsat bind time (and clear them on unbind), since thedax_deviceis created before we know which driver will bind.
- Dax: Added custom bind/unbind sysfs handlers; unbind return-EBUSYif a filesystem holds the device, preventing unbind while famfs is mounted.
- Fuse: Famfs mounts now require that the fuse server/daemon hasCAP_SYS_RAWIObecause they expose raw memory devices.
- Fuse: Added DAXaddress_space_operationswithnoop_dirty_foliosince famfs is memory-backed with no writeback required.
- Rebased to latest kernels, fully compatible with Alistair Popple et. al's recent dax refactoring.
- Ran this series through Chris Mason's code review AI prompts to check for issues - several subtle problems found and fixed.
- Dropped RFC status - this version is intended to be mergeable.Changes v1 [8] -> v2:
- The
GET_FMAPmessage/response has been moved from LOOKUP to OPEN, as was the pretty much unanimous consensus.
- Made the response payload toGET_FMAPvariable sized (patch 12)
- Dodgy kerneldoc comments cleaned up or removed.
- Fixed memory leak offc->shadowin patch 11 (thanks Joanne)
- Dropped manypr_debugandpr_noticecallsReferences
[0] - https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/
[1] - https://famfs.org (famfs user space)
[2] - https://lore.kernel.org/linux-cxl/[email protected]/
[3] - https://lore.kernel.org/linux-cxl/[email protected]/
[4] - https://lwn.net/Articles/983105/ (lsfmm 2024)
[5] - https://lwn.net/Articles/1020170/ (lsfmm 2025)
[6] - https://lore.kernel.org/linux-cxl/cover.8068ad144a7eea4a813670301f4d2a86a8e68ec4.1740713401.git-series.apopple@nvidia.com/
[7] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v2)
[8] - https://lore.kernel.org/linux-fsdevel/[email protected]/ (famfs fuse v1)
[9] - https://lore.kernel.org/linux-fsdevel/[email protected]/T/#mb2c868801be16eca82dab239a1d201628534aea7 (famfs fuse v3)John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.hQuoted 4 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77--
2.53.0Hi John,
I’m curious to hear your thoughts on whether you think it makes sense for the famfs-specific logic in this series to be moved to a bpf program that goes through a generic fuse iomap dax layer.
Based on [1], this gives feature-parity with the famfs logic in this series. In my opinion, having famfs go through a generic fuse iomap dax layer makes the fuse kernel code more extensible for future servers that will also want to use dax iomap, and keeps the fuse code cleaner by not having famfs-specific logic hardcoded in and having to introduce new fuse uapis for something famfs-specific. In my understanding of it, fuse is meant to be generic and it feels like adding server-specific logic goes against that design philosophy and sets a precedent for other servers wanting similar special-casing in the future. I'd like to explore whether the bpf and generic fuse iomap dax layer approach can preserve that philosophy while still giving famfs the flexibility it needs.
I think moving the famfs logic to bpf benefits famfs as well:
- Instead of needing to issue aFUSE_GET_FMAPrequest after a file is opened, the server can directly populate the metadata map from userspace with the mapping info when it processes theFUSE_OPENrequest, which gets rid of the roundtrip cost
- The server can dynamically update the metadata / bpf maps during runtime from userspace if any mapping info needs to change
- Future code changes / updates for famfs are all server-side and can be deployed immediately instead of needing to go through the upstream kernel mailing list process
- Famfs updates / new releases can ship independently of kernel releasesQuoted 6 lines
I'd appreciate the chance to discuss tradeoffs or if you'd rather discuss this at the fuse BoF at lsf, that sounds great too.
Thanks,
JoanneHi Joanne,
I'm definitely up for discussing it, and talking before LSFMM would be good because then I'd have some time to think about before we discuss at LSFMM.
I have not had a chance to really study this, in part since I've never even written a "hello world" BPF program.
I'll ping off-list about times to talk.
However...
I would object vehemently to this sort of re-write prior to going upstream, as would users and vendors who need famfs now that the memory products it enables have started to ship.
This work started over 3 years ago, initial patches over 2 years ago, community decision that it should go into fuse 2 years ago, first fuse patches a year ago.
This implementation is pretty much exactly in line with expectation-setting starting two years ago. Famfs is a complicated orchestration between dax, fuse, ndctl (for daxctl), libfuse and the extensive famfs user space. Famfs has a fairly small kernel footprint, but its user space is much larger. This could set it back a year if we re-write now.
Two things are true at once: I think this is a serious idea worth considering, and I think it's too late to make this sort of change before going upstream. Products need this enablement, and quite a long process has run in order to make it available in a timely fashion (which means soon now). I hope we can avoid making the perfect the enemy of the good.
Quoted 3 lines
I believe the risk of merging famfs soon is quite low, because famfs will not affect anybody who doesn't use it. I hope we can run this discussion and analysis in parallel with merging the current implementation of famfs soon.
Quoted 4 lines
Hi John,
one question, assuming most of these things can be done with eBPF, would you convert to eBPF after the merge?
Hi Bernd,
Stipulating that I've never even written 'hello world' with BPF, if it's a nicer solution with no downsides we would migrate there. I don't know enough yet to put a time frame on it, but I'll certainly understand more by LSFMM. Will you be there?
I'm hoping for a call with Joanne and Darrick in the next few days to get better educated on it.
Quoted 7 lines
(I also need to find the time to review at least all of your libfuse changes, I feel guilty that still haven't done it.).
Thanks,
Bernd
The libfuse changes are pretty small now. Two new messages - GET_FMAP and GET_DAXDEV - plus a few more bits and bobs. If a future BPF migration took place, there is a chance that those message numbers could be retired and reused in the future.
Watch this space...
Thanks,
John
Quoted 116 lines · John Groves
Quoted 114 lines · Bernd Schubert
Quoted 111 lines · John Groves
Quoted 82 lines · Joanne Koong
Quoted 45 lines · John Groves
From: John Groves <[email protected]>
NOTE: this series depends on the famfs dax series in Ira's for-7.1/dax-famfs branch [0]
Description:
This patch series introduces famfs into the fuse file system framework. Famfs depends on the bundled dax patch set.
The famfs user space code can be found at [1].
John Groves (10):
famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/
famfs_fuse: Basic fuse kernel ABI enablement for famfs
famfs_fuse: Plumb theGET_FMAPmessage/response
famfs_fuse: Create files with famfs fmaps
famfs_fuse:GET_DAXDEVmessage anddaxdev_table
famfs_fuse: Plumb dax iomap and fuse read/write/mmap
famfs_fuse: Addholder_operationsfor daxnotify_failure()
famfs_fuse: Add DAXaddress_space_operationswithnoop_dirty_folio
famfs_fuse: Add famfs fmap metadata documentation
famfs_fuse: Add documentationDocumentation/filesystems/famfs.rst | 142 ++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 10 + fs/fuse/Kconfig | 13 + fs/fuse/Makefile | 1 + fs/fuse/dir.c | 2 +- fs/fuse/famfs.c | 1180 +++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 167 ++++ fs/fuse/file.c | 45 +- fs/fuse/fuse_i.h | 116 ++- fs/fuse/inode.c | 35 +- fs/fuse/iomode.c | 2 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 88 ++ 14 files changed, 1790 insertions(+), 13 deletions(-) create mode 100644 Documentation/filesystems/famfs.rst create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.hQuoted 4 lines
base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77--
2.53.0Hi John,
I’m curious to hear your thoughts on whether you think it makes sense for the famfs-specific logic in this series to be moved to a bpf program that goes through a generic fuse iomap dax layer.
Based on [1], this gives feature-parity with the famfs logic in this series. In my opinion, having famfs go through a generic fuse iomap dax layer makes the fuse kernel code more extensible for future servers that will also want to use dax iomap, and keeps the fuse code cleaner by not having famfs-specific logic hardcoded in and having to introduce new fuse uapis for something famfs-specific. In my understanding of it, fuse is meant to be generic and it feels like adding server-specific logic goes against that design philosophy and sets a precedent for other servers wanting similar special-casing in the future. I'd like to explore whether the bpf and generic fuse iomap dax layer approach can preserve that philosophy while still giving famfs the flexibility it needs.
I think moving the famfs logic to bpf benefits famfs as well:
- Instead of needing to issue aFUSE_GET_FMAPrequest after a file is opened, the server can directly populate the metadata map from userspace with the mapping info when it processes theFUSE_OPENrequest, which gets rid of the roundtrip cost
- The server can dynamically update the metadata / bpf maps during runtime from userspace if any mapping info needs to change
- Future code changes / updates for famfs are all server-side and can be deployed immediately instead of needing to go through the upstream kernel mailing list process
- Famfs updates / new releases can ship independently of kernel releasesQuoted 6 lines
I'd appreciate the chance to discuss tradeoffs or if you'd rather discuss this at the fuse BoF at lsf, that sounds great too.
Thanks,
JoanneHi Joanne,
I'm definitely up for discussing it, and talking before LSFMM would be good because then I'd have some time to think about before we discuss at LSFMM.
I have not had a chance to really study this, in part since I've never even written a "hello world" BPF program.
I'll ping off-list about times to talk.
However...
I would object vehemently to this sort of re-write prior to going upstream, as would users and vendors who need famfs now that the memory products it enables have started to ship.
This work started over 3 years ago, initial patches over 2 years ago, community decision that it should go into fuse 2 years ago, first fuse patches a year ago.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This implementation is pretty much exactly in line with expectation-setting starting two years ago. Famfs is a complicated orchestration between dax, fuse, ndctl (for daxctl), libfuse and the extensive famfs user space. Famfs has a fairly small kernel footprint, but its user space is much larger. This could set it back a year if we re-write now.
Hi John,
Thanks for your email. I totally understand where you're coming from - having already spent a year reworking your initial patches to go through fuse, the last thing needed is another change. Bernd brought up the question of whether after merging this series in, it could then be converted to bpf. If this is an option on the table, I'd say we should just merge your series now and do any conversions later, but I don't think this is possible. As I understand it, the policy is that all kernel releases must be backwards-compatible, which means once this series lands, the famfs code will live within fuse permanently.
I definitely do not want to see famfs set back by yet another year. With the bpf approach, I don't think it requires another rewrite. I'm not sure if you had the chance to look at my email from February [1], but it contains the prototype code for the generic fuse iomap dax layer with your famfs logic in this series moved to bpf. I think it's pretty technically straightforward as it uses the famfs code logic you've already written in this series and just moves it to bpf.
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
Thanks,
Joanne
Quoted 45 lines
Quoted 12 lines
Quoted 10 lines
Two things are true at once: I think this is a serious idea worth considering, and I think it's too late to make this sort of change before going upstream. Products need this enablement, and quite a long process has run in order to make it available in a timely fashion (which means soon now). I hope we can avoid making the perfect the enemy of the good.
I believe the risk of merging famfs soon is quite low, because famfs will not affect anybody who doesn't use it. I hope we can run this discussion and analysis in parallel with merging the current implementation of famfs soon.
Quoted 4 lines
Hi John,
one question, assuming most of these things can be done with eBPF, would you convert to eBPF after the merge?
Hi Bernd,
Stipulating that I've never even written 'hello world' with BPF, if it's a nicer solution with no downsides we would migrate there. I don't know enough yet to put a time frame on it, but I'll certainly understand more by LSFMM. Will you be there?
I'm hoping for a call with Joanne and Darrick in the next few days to get better educated on it.
Quoted 7 lines
(I also need to find the time to review at least all of your libfuse changes, I feel guilty that still haven't done it.).
Thanks,
BerndThe libfuse changes are pretty small now. Two new messages -
GET_FMAPandGET_DAXDEV- plus a few more bits and bobs. If a future BPF migration took place, there is a chance that those message numbers could be retired and reused in the future.Watch this space...
Thanks,
John
Miklos Szeredi
maintainerQuoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
However with the bpf approach this would be gone, which is great.
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
Thanks,
Miklos
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 7 lines
However with the bpf approach this would be gone, which is great.
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
Thanks,
Miklos
Thanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
What are the risks of converting to BPF?
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
- Those of us who are involved don't fully understand either the security or performance implications of this. It
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Please reconsider Miklos. To use an American football metaphor, this moves the goal posts by a mile, and that's not reasonable!!!
Thanks,
John
Miklos Szeredi
maintainerQuoted 1 line · John Groves
My short response: Noooooooooo!!!!!!
:) Seems like this is a highly emotional topic... I suggest that we go ahead with bpf experiments, then discuss results and path forward at LSM.
Thanks,
Miklos
Quoted 10 lines · Miklos Szeredi
Quoted 1 line · John Groves
My short response: Noooooooooo!!!!!!
:) Seems like this is a highly emotional topic... I suggest that we go ahead with bpf experiments, then discuss results and path forward at LSM.
Thanks,
Miklos
I think we need to try to emergency-add a session at LSFMM on this, with fs/mm/bpf people. Any ideas on how to do this?
John
Quoted 8 lines · John Groves
Quoted 7 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
Quoted 5 lines
Quoted 5 lines
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all. You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
Quoted 5 lines
What are the risks of converting to BPF?
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
Quoted 2 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
Quoted 6 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted x86_64 math code.
(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
Quoted 2 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
--D
Quoted 10 lines · Darrick J. Wong
Quoted 8 lines · John Groves
Quoted 7 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all.
Yes but the mapping interface should be *generic*, not one that is so specifically tailored to one server. fuse will have to support this forever.
Quoted 87 lines
You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 7 lines
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
I don't think the problem is the command field. As I understand it, if this lands and is converted over later, none of the famfs code in this series can be removed from fuse. If fuse has native non-bpf support for famfs, then it will always need to have that. That's the part that worries me.
Quoted 2 lines
Quoted 2 lines
What are the risks of converting to BPF?
I think maybe there is a misinterpretation of what the alternative approach entails. From my point of view, the alternative approach is not that different from what is already in this series. The only piece of the famfs logic that would need to use bpf is the logic for finding/computing the extent mappings (which is the famfs-specific logic that would not be applicable to any other server). That famfs bpf code is minimal and already written [1], as it is just the logic that is in patch 6 [2] in this series copied over. No other part of famfs touches bpf. The rest is renaming the functions in fs/fuse/famfs.c to generic fuse_iomap_dax_XXX names (the logic is the same logic in this series, eg invoking the lower-level calls to dax_iomap_rw/fault/etc) and moving the daxdev setup/initialization to connection initialization time where the server passes that daxdev setup info/configs upfront. I don't think this would delay things by several merge windows, as the code is already mostly written. If it would be helpful, I can clean up what's in the prototype and send that out.
I think the part that is not clear yet and needs to be verified is whether this approach runs into any technical limitations on famfs's production workloads. For example, does the overhead of using bpf maps lead to a noticeable performance drop on real workloads? In the future, will there be too many extent mappings on high-scale systems to make this feasible? etc. If there are technical reasons why the famfs logic has to be in fuse, then imo we should figure that out and ideally that's the discussion we should be having. I am not a cxl expert so perhaps there is something missing in the approach that makes it not sufficient on production systems. If we don't end up going with the alternative approach, I still think this series should try to make the famfs uapi additions to fuse as generic as possible since that will be irreversible.
If we expedited the alternative approach in terms of reviewing and merging, would that suffice? Is the main pushback the timing of it, eg that it would take too long to get reviewed, merged, and shipped?
Quoted 7 lines
Quoted 4 lines
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
It doesn't avoid the expansion of the UABI but it makes the UABI generic (eg plenty of future servers can/will use the generic iomap layer).
Quoted 7 lines
Quoted 3 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
bpf is used elsewhere in the kernel (eg networking, scheduling). If it is the case that it is unsafe (which maybe it is, I don't know), then wouldn't those other areas have the same issues?
Quoted 16 lines
Quoted 7 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 6 lines
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
I think what fuse4fs needs for bpf is significantly more complicated and intensive than what famfs needs. For famfs, the extent mapping logic is straightforward computation.
Quoted 7 lines
Quoted 3 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
I recognize this is an unfair situation John as you've already spent years working on this and did what the community asked with rewriting it. What I'm hoping to convey is that the approach where the extent computing/finding logic gets moved to bpf is not radically different from the famfs logic already in this patchset. In my view, moving this logic to bpf is more advantageous for both fuse *and* famfs (decoupling famfs releases from kernel releases) - it would be great to consider this on technical merits if expediting the timeline of the alternative approach would suffice.
Thanks,
Joanne
[1] https://github.com/joannekoong/libfuse/blob/444fa27fa9fd2118a0dc332933197faf9bbf25aa/example/famfs.bpf.c
[2] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/
Quoted 2 lines
--D
Quoted 15 lines · Joanne Koong
Quoted 14 lines · Darrick J. Wong
Quoted 12 lines · John Groves
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all.
Yes but the mapping interface should be *generic*, not one that is so specifically tailored to one server. fuse will have to support this forever.
<nod> On second thought, there's a way to read Miklos' sentence that I hadn't thought of before:
"However, with the [fuse-iomap] bpf approach, this [famfs specific mapping interface] would be gone, which is great."
vs. the way I had thought:
"However, with the bpf approach, this [famfs specific mapping interface] would be gone [in favor of filling out a struct iomap directly], which is great."
So maybe Miklos actually /has/ at least read all the way through the February posting, though I have no data to make such a conclusion. :/
Quoted 104 lines
Quoted 87 lines
You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 7 lines
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
I don't think the problem is the command field. As I understand it, if this lands and is converted over later, none of the famfs code in this series can be removed from fuse. If fuse has native non-bpf support for famfs, then it will always need to have that. That's the part that worries me.
Quoted 2 lines
Quoted 2 lines
What are the risks of converting to BPF?
Quoted 7 lines
I think maybe there is a misinterpretation of what the alternative approach entails. From my point of view, the alternative approach is not that different from what is already in this series. The only piece of the famfs logic that would need to use bpf is the logic for finding/computing the extent mappings (which is the famfs-specific logic that would not be applicable to any other server). That famfs bpf code is minimal and already written [1], as it is just the logic
Remember where struct fuse_iomap_io came from -- the fuse-iomap patchset. It would be rather odd to start accepting fuse_iomap_io objects from a user's bpf program without examining the rest of the fuse iomap stuff.
Quoted 10 lines
that is in patch 6 [2] in this series copied over. No other part of famfs touches bpf. The rest is renaming the functions in
fs/fuse/famfs.cto genericfuse_iomap_dax_XXXnames (the logic is the same logic in this series, eg invoking the lower-level calls to dax_iomap_rw/fault/etc) and moving the daxdev setup/initialization to connection initialization time where the server passes that daxdev setup info/configs upfront. I don't think this would delay things by several merge windows, as the code is already mostly written. If it would be helpful, I can clean up what's in the prototype and send that out.
I agree that you and I and John could probably get the code and review part wrapped up in perhaps two merge windows -- one for fuse-iomap, and the second for famfs. The userspace parts of both are more or less done, which would minimize the amount of rework when we get to the libfuse part.
(Let's be honest, with LSFMM happening during the week between -rc2 and -rc3 and everyone's travel thereto, that's going to blow a big hole in the 7.2 schedule)
The question is, would Miklos acquiesce to merging a large ball of code that the three of us have been collaborating on? Even if he wasn't deeply involved in that collaboration?
Quoted 4 lines
I think the part that is not clear yet and needs to be verified is whether this approach runs into any technical limitations on famfs's production workloads. For example, does the overhead of using bpf maps lead to a noticeable performance drop on real workloads? In the
I see a custom hashtable map implementation in kernel/bpf/hashtab.c, and no particular evidence that it can rehash itself to cut down on bucket list chasing. That's too bad, because rhashtable rehashing is generally effective at keeping the xfs icache pointer chasing down.
If we have a per-inode famfs_file_meta object, I wonder if we could just attach it to the fuse_inode as a void *private pointer? That wouldn't be any worse than current famfs.
Quoted 2 lines
future, will there be too many extent mappings on high-scale systems to make this feasible? etc. If there are technical reasons why the
I've asked that question (are we going to have millions of mappings?) before. From what John has told me and what I've seen with cxl and pmem devices before that, the memory manager is heavily incentivized to give out large static(ish) allocations to constrain the metadata overhead, enable the use of PMD/PGD TLB entries, and minimize pointer chasing through mapping structures.
The only reason we let that happen in the disk filesystems is that the IO service times are so high nobody cares about L3 misses.
Quoted 7 lines
famfs logic has to be in fuse, then imo we should figure that out and ideally that's the discussion we should be having. I am not a cxl expert so perhaps there is something missing in the approach that makes it not sufficient on production systems. If we don't end up going with the alternative approach, I still think this series should try to make the famfs uapi additions to fuse as generic as possible since that will be irreversible.
<nod>
Quoted 3 lines
If we expedited the alternative approach in terms of reviewing and merging, would that suffice? Is the main pushback the timing of it, eg that it would take too long to get reviewed, merged, and shipped?
I think John's been pretty clear that he doesn't want to drag this out even a day longer. Given current trends this month, I might run out of time soon too.
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
It doesn't avoid the expansion of the UABI but it makes the UABI generic (eg plenty of future servers can/will use the generic iomap layer).
(Oh good, nobody's talking about going the evil route and just fill out struct iomap directly!)
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
bpf is used elsewhere in the kernel (eg networking, scheduling). If it is the case that it is unsafe (which maybe it is, I don't know), then wouldn't those other areas have the same issues?
Well ok, here we go -- I don't think there's any serious technical problems with BPF. The ability to read (and in some cases write) to kernel memory looks like it's flexible enough to do the classification and data collection stuff that most current bpf users want to do.
The issues I was alluding to are BPF being used as a means to get around slow/unresponsive maintainers; and the kernel community's collective refusal to explore any other path to building new user APIs besides designing everything generically perfectly up front in the kernel UABI along with all the stress that involves.
Once upon a time I tried to push on these UAPI stressfulness issues and Linus told me I had a loose grip on reality. He's probably right.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Quoted 6 lines
Quoted 2 lines
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
I think what fuse4fs needs for bpf is significantly more complicated and intensive than what famfs needs. For famfs, the extent mapping logic is straightforward computation.
Agreed. For fuse4fs I'm content to let it manage the iomap cache.
Quoted 26 lines
Quoted 6 lines
Quoted 2 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
I recognize this is an unfair situation John as you've already spent years working on this and did what the community asked with rewriting it. What I'm hoping to convey is that the approach where the extent computing/finding logic gets moved to bpf is not radically different from the famfs logic already in this patchset. In my view, moving this logic to bpf is more advantageous for both fuse *and* famfs (decoupling famfs releases from kernel releases) - it would be great to consider this on technical merits if expediting the timeline of the alternative approach would suffice.
Thanks,
Joanne[1] https://github.com/joannekoong/libfuse/blob/444fa27fa9fd2118a0dc332933197faf9bbf25aa/example/famfs.bpf.c
[2] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/Quoted 2 lines
--D
Quoted 15 lines · Joanne Koong
Quoted 14 lines · Darrick J. Wong
Quoted 12 lines · John Groves
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all.
Yes but the mapping interface should be *generic*, not one that is so specifically tailored to one server. fuse will have to support this forever.
Mapping interfaces being generic is a nice idea, but I'm no sure it's realistic in a generalized sense. But other mitigating comments below.
Quoted 93 lines
Quoted 93 lines
You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Quoted 8 lines
Quoted 2 lines
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
I don't think the problem is the command field. As I understand it, if this lands and is converted over later, none of the famfs code in this series can be removed from fuse. If fuse has native non-bpf support for famfs, then it will always need to have that. That's the part that worries me.
I believe this basic premise is completely wrong. Here is why:
There is a FUSE_DAX_FMAP capability that the kernel may advertise or not at init time; this capability "is" the famfs GET_FMAP AND GET_DAXDEV commands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise the FUSE_DAX_FMAP capability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.
Simple, really. Can't re-use the message opcodes, but as Darrick pointed out those are not a scarce resource.
Quoted 45 lines
Quoted 3 lines
Quoted 3 lines
What are the risks of converting to BPF?
I think maybe there is a misinterpretation of what the alternative approach entails. From my point of view, the alternative approach is not that different from what is already in this series. The only piece of the famfs logic that would need to use bpf is the logic for finding/computing the extent mappings (which is the famfs-specific logic that would not be applicable to any other server). That famfs bpf code is minimal and already written [1], as it is just the logic that is in patch 6 [2] in this series copied over. No other part of famfs touches bpf. The rest is renaming the functions in
fs/fuse/famfs.cto genericfuse_iomap_dax_XXXnames (the logic is the same logic in this series, eg invoking the lower-level calls to dax_iomap_rw/fault/etc) and moving the daxdev setup/initialization to connection initialization time where the server passes that daxdev setup info/configs upfront. I don't think this would delay things by several merge windows, as the code is already mostly written. If it would be helpful, I can clean up what's in the prototype and send that out.I think the part that is not clear yet and needs to be verified is whether this approach runs into any technical limitations on famfs's production workloads. For example, does the overhead of using bpf maps lead to a noticeable performance drop on real workloads? In the future, will there be too many extent mappings on high-scale systems to make this feasible? etc. If there are technical reasons why the famfs logic has to be in fuse, then imo we should figure that out and ideally that's the discussion we should be having. I am not a cxl expert so perhaps there is something missing in the approach that makes it not sufficient on production systems. If we don't end up going with the alternative approach, I still think this series should try to make the famfs uapi additions to fuse as generic as possible since that will be irreversible.
If we expedited the alternative approach in terms of reviewing and merging, would that suffice? Is the main pushback the timing of it, eg that it would take too long to get reviewed, merged, and shipped?
Quoted 5 lines
Quoted 4 lines
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
Quoted 6 lines
Quoted 2 lines
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
It doesn't avoid the expansion of the UABI but it makes the UABI generic (eg plenty of future servers can/will use the generic iomap layer).
Um, advertised capabilities allow contraction of the UABI-handling code with only some small cruft. Code that is only reachable in the presence of dead capability can totally be removed.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Quoted 7 lines
Quoted 3 lines
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
bpf is used elsewhere in the kernel (eg networking, scheduling). If it is the case that it is unsafe (which maybe it is, I don't know), then wouldn't those other areas have the same issues?
See my long comment to Darrick's prior email.
I suspect that this would be the only place BPF has been tried for a vma fault handler. That is a special, performance critical path - especially for famfs. In discussion with the right people we can probably reason through whether this is a non-starter or not.
Quoted 46 lines
Quoted 17 lines
Quoted 8 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 6 lines
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
I think what fuse4fs needs for bpf is significantly more complicated and intensive than what famfs needs. For famfs, the extent mapping logic is straightforward computation.
Quoted 7 lines
Quoted 3 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
I recognize this is an unfair situation John as you've already spent years working on this and did what the community asked with rewriting it. What I'm hoping to convey is that the approach where the extent computing/finding logic gets moved to bpf is not radically different from the famfs logic already in this patchset. In my view, moving this logic to bpf is more advantageous for both fuse *and* famfs (decoupling famfs releases from kernel releases) - it would be great to consider this on technical merits if expediting the timeline of the alternative approach would suffice.
Quoted 8 lines
Thanks,
Joanne[1] https://github.com/joannekoong/libfuse/blob/444fa27fa9fd2118a0dc332933197faf9bbf25aa/example/famfs.bpf.c
[2] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/Quoted 2 lines
--D
Regards,
John
Quoted 130 lines · John Groves
Quoted 15 lines · Joanne Koong
Quoted 14 lines · Darrick J. Wong
Quoted 12 lines · John Groves
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all.
Yes but the mapping interface should be *generic*, not one that is so specifically tailored to one server. fuse will have to support this forever.
Mapping interfaces being generic is a nice idea, but I'm no sure it's realistic in a generalized sense. But other mitigating comments below.
Quoted 93 lines
Quoted 93 lines
You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Quoted 8 lines
Quoted 2 lines
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
I don't think the problem is the command field. As I understand it, if this lands and is converted over later, none of the famfs code in this series can be removed from fuse. If fuse has native non-bpf support for famfs, then it will always need to have that. That's the part that worries me.
Quoted 8 lines
I believe this basic premise is completely wrong. Here is why:
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
John, with what you have in this series, is there any way we can make it generalizable so it can be used by any dax-based server? Would you be open to that?
My main gripe is with the layout encoding for FUSE_GET_FMAP and how it bakes in famfs-specific layout concepts (simple vs interleaved extents, file type, strip definitions, etc) into the uapi and forces the kernel to interpret/process this super-specific encoding in a hardcoded way. Is it not possible to just move this all to the server side? Could the famfs server just preprocess the mappings and take care of the simple vs interleaved extents stuff and do all the logic that's in [1] in userspace and simply just give the kernel a list of generic extent mapping information? The kernel could then just cache this generic mapping per inode and do the lookup on fault with no famfs-specific logic needed in the kernel. Or is there a reason the famfs processing logic needs to happen in the kernel? That's the part I'm unclear about.
I think this is pretty much what Darrick is doing in his iomap patchset [2] except in his case, the mappings are fetched lazily on access, whereas I guess for your case that would be too slow so it needs to be prepopulated at open time. imo that seems fine since prepopulating mappings would be a useful feature in general. So could we rename FUSE_GET_FMAP to something like FUSE_IOMAP_GETMAP and have it just return super generic mapping info? Darrick already adds a "struct fuse_iomap_io" [3] to the uapi, could we just use that and add a uint32_t dev_id; to that?
Looking more at Darrick's patchset, his caching [4] uses the b+ tree and is more performant but imo also more complex, but I don't think that would be necessary for this series. imo we could just use a basic interval tree for now for famfs's needs and optimize / converge it later.
As well, are you open to renaming the FUSE_DAX_FMAP capability and FUSE_FAMFS_DAX config to a generic FUSE_IOMAP_DAX naming scheme instead?
Additionally, it would be really nice to replace FUSE_GET_DAXDEV and add the daxdev config stuff to the generic FUSE_IOMAP_CONFIG Darrick has for iomap [5], but this one might be more contentious in getting the config uapi solidified. I think in general though for famfs, it makes more sense for all the dax devices to be set up upfront all at once at connection init time instead of discovered lazily on every file open, which as I understand it, would make things less complex server side for famfs too, so even if this doesn't go through FUSE_IOMAP_CONFIG, maybe it makes sense to have this be on init where the server sends all the daxdev device information all at once? That seems less confusing (and better performance-wise) of a flow than having it be lazily discovered on open, though if I'm misunderstanding something here please let me know.
I'm not sure how Miklos feels about this, but I think this would get rid of all the famfs-specific logic in fuse and would be adding infrastrucutre that other dax-backed servers in the future would use. On my end, this eases my concerns and would be just as good as what the bpf approach is trying to accomplish.
There's some ties between your and Darrick's work as you guys are both using iomap, and maybe/hopefully this aligns with Darrick's thoughts combining the two, but in my opinion (and maybe Darrick disagrees with this), to get famfs out the door, we wouldn't need all the code in Darrick's patchset to land before famfs. In my view, we would only need to borrow/steal the 'struct fuse_iomap_io' definition in uapi and hopefully converge on a FUSE_IOMAP_CONFIG uapi format, for famfs to land, if you agree this direction makes sense. I think we just need to get the uapi stuff figured out and everything else could be optimized in the future post-merge. Darrick, do you agree with this assessment?
John, is this a middle ground you think is reasonable? I know this whole thing has kind of been a mess with the moving goalposts - if the above would work for famfs but you're slammed with other work and don't have the bandwidth to make these changes, I'm happy to help out with the restructuring if that would be useful.
Quoted 73 lines
Simple, really. Can't re-use the message opcodes, but as Darrick pointed out those are not a scarce resource.
Quoted 45 lines
Quoted 3 lines
Quoted 3 lines
What are the risks of converting to BPF?
I think maybe there is a misinterpretation of what the alternative approach entails. From my point of view, the alternative approach is not that different from what is already in this series. The only piece of the famfs logic that would need to use bpf is the logic for finding/computing the extent mappings (which is the famfs-specific logic that would not be applicable to any other server). That famfs bpf code is minimal and already written [1], as it is just the logic that is in patch 6 [2] in this series copied over. No other part of famfs touches bpf. The rest is renaming the functions in
fs/fuse/famfs.cto genericfuse_iomap_dax_XXXnames (the logic is the same logic in this series, eg invoking the lower-level calls to dax_iomap_rw/fault/etc) and moving the daxdev setup/initialization to connection initialization time where the server passes that daxdev setup info/configs upfront. I don't think this would delay things by several merge windows, as the code is already mostly written. If it would be helpful, I can clean up what's in the prototype and send that out.I think the part that is not clear yet and needs to be verified is whether this approach runs into any technical limitations on famfs's production workloads. For example, does the overhead of using bpf maps lead to a noticeable performance drop on real workloads? In the future, will there be too many extent mappings on high-scale systems to make this feasible? etc. If there are technical reasons why the famfs logic has to be in fuse, then imo we should figure that out and ideally that's the discussion we should be having. I am not a cxl expert so perhaps there is something missing in the approach that makes it not sufficient on production systems. If we don't end up going with the alternative approach, I still think this series should try to make the famfs uapi additions to fuse as generic as possible since that will be irreversible.
If we expedited the alternative approach in terms of reviewing and merging, would that suffice? Is the main pushback the timing of it, eg that it would take too long to get reviewed, merged, and shipped?
Quoted 5 lines
Quoted 4 lines
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
Quoted 6 lines
Quoted 2 lines
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
It doesn't avoid the expansion of the UABI but it makes the UABI generic (eg plenty of future servers can/will use the generic iomap layer).
Um, advertised capabilities allow contraction of the UABI-handling code with only some small cruft. Code that is only reachable in the presence of dead capability can totally be removed.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Quoted 7 lines
Quoted 3 lines
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
bpf is used elsewhere in the kernel (eg networking, scheduling). If it is the case that it is unsafe (which maybe it is, I don't know), then wouldn't those other areas have the same issues?
Quoted 6 lines
See my long comment to Darrick's prior email.
I suspect that this would be the only place BPF has been tried for a vma fault handler. That is a special, performance critical path - especially for famfs. In discussion with the right people we can probably reason through whether this is a non-starter or not.
Yes, I think the bpf overhead is the main uncertainty about whether this suffices or not for famfs. I understand (from the all caps in your previous messages :)) that performance is critical. The bpf overhead could indeed be too much for the special famfs performance critical path. I'll try to get some time next week to benchmark this.
Thanks,
Joanne
[1] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/
[2] https://lore.kernel.org/linux-fsdevel/177188733084.3935219.10400570136529869673.stgit@frogsfrogsfrogs/T/#t
[3] https://lore.kernel.org/linux-fsdevel/176169810371.1424854.3010195280915622081.stgit@frogsfrogsfrogs/
[4] https://lore.kernel.org/linux-fsdevel/177188735954.3937557.841478048197856035.stgit@frogsfrogsfrogs/
[5] https://lore.kernel.org/linux-fsdevel/176169813786.1427432.414564085463311156.stgit@frogsfrogsfrogs/
Quoted 59 lines
Quoted 47 lines
Quoted 18 lines
Quoted 9 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 6 lines
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
I think what fuse4fs needs for bpf is significantly more complicated and intensive than what famfs needs. For famfs, the extent mapping logic is straightforward computation.
Quoted 7 lines
Quoted 3 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
I recognize this is an unfair situation John as you've already spent years working on this and did what the community asked with rewriting it. What I'm hoping to convey is that the approach where the extent computing/finding logic gets moved to bpf is not radically different from the famfs logic already in this patchset. In my view, moving this logic to bpf is more advantageous for both fuse *and* famfs (decoupling famfs releases from kernel releases) - it would be great to consider this on technical merits if expediting the timeline of the alternative approach would suffice.
Quoted 8 lines
Thanks,
Joanne[1] https://github.com/joannekoong/libfuse/blob/444fa27fa9fd2118a0dc332933197faf9bbf25aa/example/famfs.bpf.c
[2] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/Quoted 2 lines
--D
Regards,
John
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.
Quoted 5 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
FUSE_DAX_FMAP is already conditional on CONFIG_FUSE_DAX, the kernel is not required to continue advertising FUSE_DAX_FMAP in perpetuity.
Setting CONFIG_FUSE_DAX=n does not mean userland "is broken", this would only be the case if FUSE_DAX_FMAP was advertised but not actually supported.
If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing CONFIG_FUSE_DAX to always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax).
While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
---
I think the focus here needs to be on whether this interface ACTUALLY needs to be more generic - and whether that is actually FEASIBLE.
It's not like this is a new problem - and there are real design reasons why John chose this route.
The additional overhead is not trivial for FAMFS - FAMFS is not doing i/o. He already has data showing fuse caused a performance hit due to overhead on open - his concern of overhead on fault being catastrophic is grounded in data.
For others it's an age old problem of self-describing protocols (parsing vs giant inflexible binary blobs, pick your poison). It's extremely unlikely we will find a one-size-fits-all solution that doesn't eventually run right back into this same problem.
I worry that this discussion is going to turn towards implementing a solution grounded in parsing arbitrary formats and how to store them, and that is completely detached from why FAMFS went this route in the first place.
I question whether the actual issue here lies in the interface APPEARING more general purpose than it actually is - and therefore inviting attempts to over-genericize it.
Is there a world here where this is solved by a name change and a capability bit? I think so.
~Gregory
Dan Williams
maintainerQuoted 28 lines · Gregory Price
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.Quoted 5 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
FUSE_DAX_FMAPis already conditional onCONFIG_FUSE_DAX, the kernel is not required to continue advertisingFUSE_DAX_FMAPin perpetuity.Setting
CONFIG_FUSE_DAX=ndoes not mean userland "is broken", this would only be the case ifFUSE_DAX_FMAPwas advertised but not actually supported.If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing
CONFIG_FUSE_DAXto always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax).
Quoted 6 lines
While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
Right, if the protocol on day one is "user space must ask which method is available", then userspace can not be surprised when one option disappears. So to give time for the bpf approach to mature the kernel can do something like "famfs and bpf mapping support are available". In some future kernel the famfs native option disappears after a deprecation period.
When folks ask 10 years from now why this ever supported optionality the explanation is "oh because famfs enjoyed first mover advantage to prove out fs semantics layered on dax devices", or "turns out there are some cases where bpf is not fast enough but it still stops the proliferation of more in kernel mapping implementations".
Something like FUSE_DAX_FMAP is always available but the backend to that is optionally native vs bpf. ...or some other arrangement to make it clear that native might be gone someday.
Quoted 13 lines · Dan Williams
Quoted 10 lines · Gregory Price
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
So don't break fuse servers. If you wanted to (say) get rid of GET_FMAP in favor of IOMAP_BEGIN, you could alter libfuse to translate a fuse server's ->get_fmap implementation into the equivalent ->iomap_begin, and eventually the kernel can stop making GET_FMAP calls to userspace.
The trouble here is that I've also seen half a dozen projects vendoring libfuse so that's a nightmare that will have to be dealt with. But maybe that doesn't even matter, because...
Quoted 6 lines
Quoted 6 lines
FUSE_DAX_FMAPis already conditional onCONFIG_FUSE_DAX, the kernel is not required to continue advertisingFUSE_DAX_FMAPin perpetuity.Setting
CONFIG_FUSE_DAX=ndoes not mean userland "is broken", this would only be the case ifFUSE_DAX_FMAPwas advertised but not actually supported.
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of GET_FMAP at this time...
Quoted 4 lines
Quoted 4 lines
If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing
CONFIG_FUSE_DAXto always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax).
...however the strongest case (IMO) would be if (having merged famfs) we then merge fuse-iomap after famfs. Then we extend the existing fuse-iomap-bpf prototype to allow per-mount and per-inode iomap bpf ops. That enables us to analyze thoroughly the performance characteristics of:
a) Using GET_FMAP as-is
b) Uploading raw iomaps (HA)
c) Uploading a single bpf program to make iomaps, exchanging fmap-style mapping data into a bpf map, and having the single bpf program walk through the map
d) Uploading a custom bpf program per famfs file to make iomaps. No bpfmap required, but the setup and compilation are now much more complex
Then we'll finally know which approach is the best, having broken the Gordian Knot of how to merge famfs and fuse-iomap.
If we decide that (c) or (d) are actually better, then guess what? To get any of the iomap functionality, you have to set an inode flag, and that (FUSE_CAP_FAMFS && FUSE_CAP_IOMAP && FUSE_ATTR_IOMAP) is the signal for "don't call GET_FMAP". FUSE_CAP_FAMFS && (!FUSE_CAP_IOMAP || !FUSE_ATTR_IOMAP) means "call GET_FMAP".
Yes, we burn a couple of fuse command values to find out, but that's all.
(TBH I still dislike GET_DAXDEV, that really should just be another application of backing files, and the backing file id gets passed to GET_FMAP.)
What do you all think of doing that?
Quoted 14 lines
Quoted 6 lines
While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
Right, if the protocol on day one is "user space must ask which method is available", then userspace can not be surprised when one option disappears. So to give time for the bpf approach to mature the kernel can do something like "famfs and bpf mapping support are available". In some future kernel the famfs native option disappears after a deprecation period.
Quoted 5 lines
When folks ask 10 years from now why this ever supported optionality the explanation is "oh because famfs enjoyed first mover advantage to prove out fs semantics layered on dax devices", or "turns out there are some cases where bpf is not fast enough but it still stops the proliferation of more in kernel mapping implementations".
Yes. We're not *capable* of determining the best mechanism unless we can start shipping these things to users to get their feedback. Only then can we iterate and make real improvements.
Quoted 3 lines
Something like
FUSE_DAX_FMAPis always available but the backend to that is optionally native vs bpf. ...or some other arrangement to make it clear that native might be gone someday.
--D
Quoted 20 lines · Darrick J. Wong
Quoted 13 lines · Dan Williams
Quoted 10 lines · Gregory Price
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
Quoted 5 lines
So don't break fuse servers. If you wanted to (say) get rid of
GET_FMAPin favor ofIOMAP_BEGIN, you could alter libfuse to translate a fuse server's ->get_fmap implementation into the equivalent ->iomap_begin, and eventually the kernel can stop makingGET_FMAPcalls to userspace.
I don't think it's this simple. We can't assume libfuse is the only way servers talk to the kernel. Some servers use the /dev/fuse interface directly. And, as I understand it, this would still break users who are on older versions of libfuse if they upgrade to a newer kernel.
My reason for pushing back isn't because I don't want this to work; I just want to make sure that if we're going to rely on this as a safety hatch, then we can actually do it.
Going back to what Dan said about using the capability bits for deprecation, "In some future kernel the famfs native option disappears after a deprecation period" - what does the deprecation period/process look like? Do you have to wait a certain amount of time before it can be fully removed or is it pretty immediate?
Quoted 12 lines
The trouble here is that I've also seen half a dozen projects vendoring libfuse so that's a nightmare that will have to be dealt with. But maybe that doesn't even matter, because...
Quoted 6 lines
Quoted 6 lines
FUSE_DAX_FMAPis already conditional onCONFIG_FUSE_DAX, the kernel is not required to continue advertisingFUSE_DAX_FMAPin perpetuity.Setting
CONFIG_FUSE_DAX=ndoes not mean userland "is broken", this would only be the case ifFUSE_DAX_FMAPwas advertised but not actually supported.
Quoted 6 lines
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of
GET_FMAPat this time...
So could we make the interleaving part generic then? Striped / interleaved layouts are used elsewhere (eg RAID-0, md-stripe, etc.) - could we add a generic interleave descriptor to the uapi and use that for what famfs needs?
Quoted 31 lines
Quoted 5 lines
Quoted 5 lines
If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing
CONFIG_FUSE_DAXto always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax)....however the strongest case (IMO) would be if (having merged famfs) we then merge fuse-iomap after famfs. Then we extend the existing fuse-iomap-bpf prototype to allow per-mount and per-inode iomap bpf ops. That enables us to analyze thoroughly the performance characteristics of:
a) Using
GET_FMAPas-isb) Uploading raw iomaps (HA)
c) Uploading a single bpf program to make iomaps, exchanging fmap-style mapping data into a bpf map, and having the single bpf program walk through the map
d) Uploading a custom bpf program per famfs file to make iomaps. No bpfmap required, but the setup and compilation are now much more complex
Then we'll finally know which approach is the best, having broken the Gordian Knot of how to merge famfs and fuse-iomap.
If we decide that (c) or (d) are actually better, then guess what? To get any of the iomap functionality, you have to set an inode flag, and that (
FUSE_CAP_FAMFS&&FUSE_CAP_IOMAP&&FUSE_ATTR_IOMAP) is the signal for "don't callGET_FMAP".FUSE_CAP_FAMFS&& (!FUSE_CAP_IOMAP || !FUSE_ATTR_IOMAP) means "callGET_FMAP".
Quoted 7 lines
Yes, we burn a couple of fuse command values to find out, but that's all.
(TBH I still dislike
GET_DAXDEV, that really should just be another application of backing files, and the backing file id gets passed toGET_FMAP.)What do you all think of doing that?
To be completely honest, this is orthogonal to what I was hoping we could discuss on this thread. My main concern is the GET_FMAP part. Can we make it more generic to other interleaved/striped layouts?
Thanks,
Joanne
Quoted 30 lines
Quoted 15 lines
Quoted 7 lines
While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
Right, if the protocol on day one is "user space must ask which method is available", then userspace can not be surprised when one option disappears. So to give time for the bpf approach to mature the kernel can do something like "famfs and bpf mapping support are available". In some future kernel the famfs native option disappears after a deprecation period.
Quoted 5 lines
When folks ask 10 years from now why this ever supported optionality the explanation is "oh because famfs enjoyed first mover advantage to prove out fs semantics layered on dax devices", or "turns out there are some cases where bpf is not fast enough but it still stops the proliferation of more in kernel mapping implementations".
Yes. We're not *capable* of determining the best mechanism unless we can start shipping these things to users to get their feedback. Only then can we iterate and make real improvements.
Quoted 3 lines
Something like
FUSE_DAX_FMAPis always available but the backend to that is optionally native vs bpf. ...or some other arrangement to make it clear that native might be gone someday.--D
Quoted 37 lines · Joanne Koong
Quoted 20 lines · Darrick J. Wong
Quoted 13 lines · Dan Williams
Quoted 10 lines · Gregory Price
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
Quoted 5 lines
So don't break fuse servers. If you wanted to (say) get rid of
GET_FMAPin favor ofIOMAP_BEGIN, you could alter libfuse to translate a fuse server's ->get_fmap implementation into the equivalent ->iomap_begin, and eventually the kernel can stop makingGET_FMAPcalls to userspace.I don't think it's this simple. We can't assume libfuse is the only way servers talk to the kernel. Some servers use the
/dev/fuseinterface directly. And, as I understand it, this would still break users who are on older versions of libfuse if they upgrade to a newer kernel.My reason for pushing back isn't because I don't want this to work; I just want to make sure that if we're going to rely on this as a safety hatch, then we can actually do it.
Quoted 5 lines
Going back to what Dan said about using the capability bits for deprecation, "In some future kernel the famfs native option disappears after a deprecation period" - what does the deprecation period/process look like? Do you have to wait a certain amount of time before it can be fully removed or is it pretty immediate?
That depends on how much gluecode you can stand up to redirect older programs.
Quoted 18 lines
Quoted 11 lines
The trouble here is that I've also seen half a dozen projects vendoring libfuse so that's a nightmare that will have to be dealt with. But maybe that doesn't even matter, because...
Quoted 6 lines
Quoted 6 lines
FUSE_DAX_FMAPis already conditional onCONFIG_FUSE_DAX, the kernel is not required to continue advertisingFUSE_DAX_FMAPin perpetuity.Setting
CONFIG_FUSE_DAX=ndoes not mean userland "is broken", this would only be the case ifFUSE_DAX_FMAPwas advertised but not actually supported.Quoted 6 lines
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of
GET_FMAPat this time...
Quoted 4 lines
So could we make the interleaving part generic then? Striped / interleaved layouts are used elsewhere (eg RAID-0, md-stripe, etc.) - could we add a generic interleave descriptor to the uapi and use that for what famfs needs?
I doubt it. md-raid presents a unified LBA address space, which means that the filesystem doesn't have to know anything about whatever translations might happen underneath it. Even memory controllers quietly take care of striping across DIMMs and whatnot.
Most filesystems that implement striping themselves don't restrict themselves to monotonically increasing LBA ranges rotored across each device like md-raid0 does.
But for whatever reason, pmem/dax don't have remapping layers like md/dm so filesystems have to do that on their own if the hardware doesn't do it for them.
Quoted 36 lines
Quoted 36 lines
Quoted 4 lines
Quoted 4 lines
If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing
CONFIG_FUSE_DAXto always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax)....however the strongest case (IMO) would be if (having merged famfs) we then merge fuse-iomap after famfs. Then we extend the existing fuse-iomap-bpf prototype to allow per-mount and per-inode iomap bpf ops. That enables us to analyze thoroughly the performance characteristics of:
a) Using
GET_FMAPas-isb) Uploading raw iomaps (HA)
c) Uploading a single bpf program to make iomaps, exchanging fmap-style mapping data into a bpf map, and having the single bpf program walk through the map
d) Uploading a custom bpf program per famfs file to make iomaps. No bpfmap required, but the setup and compilation are now much more complex
Then we'll finally know which approach is the best, having broken the Gordian Knot of how to merge famfs and fuse-iomap.
If we decide that (c) or (d) are actually better, then guess what? To get any of the iomap functionality, you have to set an inode flag, and that (
FUSE_CAP_FAMFS&&FUSE_CAP_IOMAP&&FUSE_ATTR_IOMAP) is the signal for "don't callGET_FMAP".FUSE_CAP_FAMFS&& (!FUSE_CAP_IOMAP || !FUSE_ATTR_IOMAP) means "callGET_FMAP".Yes, we burn a couple of fuse command values to find out, but that's all.
(TBH I still dislike
GET_DAXDEV, that really should just be another application of backing files, and the backing file id gets passed toGET_FMAP.)
Quoted 5 lines
Quoted 1 line
What do you all think of doing that?
To be completely honest, this is orthogonal to what I was hoping we could discuss on this thread. My main concern is the
GET_FMAPpart. Can we make it more generic to other interleaved/striped layouts?
"Generic"... do we even /have/ a second user? I don't feel like we do.
--D
Quoted 34 lines
Thanks,
JoanneQuoted 30 lines
Quoted 15 lines
Quoted 7 lines
While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
Right, if the protocol on day one is "user space must ask which method is available", then userspace can not be surprised when one option disappears. So to give time for the bpf approach to mature the kernel can do something like "famfs and bpf mapping support are available". In some future kernel the famfs native option disappears after a deprecation period.
Quoted 5 lines
When folks ask 10 years from now why this ever supported optionality the explanation is "oh because famfs enjoyed first mover advantage to prove out fs semantics layered on dax devices", or "turns out there are some cases where bpf is not fast enough but it still stops the proliferation of more in kernel mapping implementations".
Yes. We're not *capable* of determining the best mechanism unless we can start shipping these things to users to get their feedback. Only then can we iterate and make real improvements.
Quoted 3 lines
Something like
FUSE_DAX_FMAPis always available but the backend to that is optionally native vs bpf. ...or some other arrangement to make it clear that native might be gone someday.--D
Quoted 7 lines · Darrick J. Wong
Quoted 7 lines
Quoted 6 lines
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of
GET_FMAPat this time...
Quoted 8 lines
Quoted 4 lines
So could we make the interleaving part generic then? Striped / interleaved layouts are used elsewhere (eg RAID-0, md-stripe, etc.) - could we add a generic interleave descriptor to the uapi and use that for what famfs needs?
I doubt it. md-raid presents a unified LBA address space, which means that the filesystem doesn't have to know anything about whatever translations might happen underneath it.
Unless that translation happens in the file system. It does for btrfs right now, and it does for pNFS blocklayout. The former is using iomap for direct I/O (and has old code and vague plans for using it for buffered I/O maybe eventually), the latter does not currently but would benefit a lot, although wiring it through the NFS code will be painful.
Quoted 3 lines
Most filesystems that implement striping themselves don't restrict themselves to monotonically increasing LBA ranges rotored across each device like md-raid0 does.
Mappings can be more flexible, but they usually would not in a single iomap iteration.
Quoted 3 lines
But for whatever reason, pmem/dax don't have remapping layers like md/dm so filesystems have to do that on their own if the hardware doesn't do it for them.
DM actually supports DAX. I don't think that's a very good way as it adds a lot of overhead for little gain for striping.
Quoted 17 lines · Christoph Hellwig
Quoted 7 lines · Darrick J. Wong
Quoted 7 lines
Quoted 6 lines
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of
GET_FMAPat this time...Quoted 8 lines
Quoted 4 lines
So could we make the interleaving part generic then? Striped / interleaved layouts are used elsewhere (eg RAID-0, md-stripe, etc.) - could we add a generic interleave descriptor to the uapi and use that for what famfs needs?
I doubt it. md-raid presents a unified LBA address space, which means that the filesystem doesn't have to know anything about whatever translations might happen underneath it.
Quoted 5 lines
Unless that translation happens in the file system. It does for btrfs right now, and it does for pNFS blocklayout. The former is using iomap for direct I/O (and has old code and vague plans for using it for buffered I/O maybe eventually), the latter does not currently but would benefit a lot, although wiring it through the NFS code will be painful.
Not to mention a huge layering violation unless you're doing xraid. ;)
That said, the fuse-iomap patches have been waiting for a review since October, and I'd really prefer to get the base enablement of iomap merged before we start asking about things that existing fuse servers and iomap client filesystems don't do, like in-filesystem raid.
Quoted 7 lines
Quoted 3 lines
Most filesystems that implement striping themselves don't restrict themselves to monotonically increasing LBA ranges rotored across each device like md-raid0 does.
Mappings can be more flexible, but they usually would not in a single iomap iteration.
Quoted 6 lines
Quoted 3 lines
But for whatever reason, pmem/dax don't have remapping layers like md/dm so filesystems have to do that on their own if the hardware doesn't do it for them.
DM actually supports DAX. I don't think that's a very good way as it adds a lot of overhead for little gain for striping.
Aha, it has long been my suspicion that looping through mapping layers is a real performance pit for memory-based file stores. Thanks for saying that explicitly.
--D
Quoted 6 lines · Darrick J. Wong
...the memory interleaving is a rather interesting quality of famfs. There's no good way to express a formulaic meta-mapping in traditional iomap parlance, and famfs needs that to interleave across memory controllers/dimm boxen/whatever. Throwing individual iomaps at the kernel is a very inefficient way to do that. So I don't think there's a good reason to get rid of
GET_FMAPat this time...
Why no? We can triviall make an iomap point to multiple backing devices and throw in a stride/offset. That would make btrfs striping (and non-degraded parity RAID reads) a lot more efficient.
Quoted 4 lines
...however the strongest case (IMO) would be if (having merged famfs) we then merge fuse-iomap after famfs. Then we extend the existing fuse-iomap-bpf prototype to allow per-mount and per-inode iomap bpf ops. That enables us to analyze thoroughly the performance characteristics of:
Don't go there. I think that you two are comining up with two interfaces for roughly the same thing is a pretty clear indicator that this needs to be fully hashed out as a single interface first, and any kind of preliminary merging is just going to create problems.
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
...however the strongest case (IMO) would be if (having merged famfs) we then merge fuse-iomap after famfs. Then we extend the existing fuse-iomap-bpf prototype to allow per-mount and per-inode iomap bpf ops. That enables us to analyze thoroughly the performance characteristics of:
Quoted 5 lines
Don't go there. I think that you two are comining up with two interfaces for roughly the same thing is a pretty clear indicator that this needs to be fully hashed out as a single interface first, and any kind of preliminary merging is just going to create problems.
We're not sure how deep this rathole goes, and John's work has been in the rathole for a few years now. Hence the desire to hedge.
But it's obvious no decisions will be made before LSFMM - so we can take a breath and chew on it. Maybe we'll get there in person.
~Gregory
Quoted 53 lines · Gregory Price
Quoted 9 lines · Joanne Koong
Quoted 7 lines · John Groves
There is a
FUSE_DAX_FMAPcapability that the kernel may advertise or not at init time; this capability "is" the famfsGET_FMAPANDGET_DAXDEVcommands. In the future, if we find a way to use BPF (or some other mechanism) to avoid needing those fuse messages, the kernel could be updated to NEVER advertise theFUSE_DAX_FMAPcapability. All of the famfs-specific code could be taken out of kernels that never advertise that capability.Quoted 5 lines
I’m not sure the capability bit can be used like that (though I am hoping it can!). As I understand it, once the kernel advertises a capability, it must continue supporting it in future kernels else userspace programs that rely on it will break.
FUSE_DAX_FMAPis already conditional onCONFIG_FUSE_DAX, the kernel is not required to continue advertisingFUSE_DAX_FMAPin perpetuity.Setting
CONFIG_FUSE_DAX=ndoes not mean userland "is broken", this would only be the case ifFUSE_DAX_FMAPwas advertised but not actually supported.If DAX were removed from the kernel (unlikely, but stick with me) this would be equivalent to permanently changing
CONFIG_FUSE_DAXto always off, and there would be no squabbles over whether that particular change broke userland (there would be much strife over removing dax).While not a deprecation method, this is what capability bits are designed for. Same as cpuid capability bits - just because the bit is there doesn't mean a processor is required to support it in perpetuity.
They're only required to support it if the bit is turned on.
---
I think the focus here needs to be on whether this interface ACTUALLY needs to be more generic - and whether that is actually FEASIBLE.
It's not like this is a new problem - and there are real design reasons why John chose this route.
The additional overhead is not trivial for FAMFS - FAMFS is not doing i/o. He already has data showing fuse caused a performance hit due to overhead on open - his concern of overhead on fault being catastrophic is grounded in data.
For others it's an age old problem of self-describing protocols (parsing vs giant inflexible binary blobs, pick your poison). It's extremely unlikely we will find a one-size-fits-all solution that doesn't eventually run right back into this same problem.
Quoted 8 lines
I worry that this discussion is going to turn towards implementing a solution grounded in parsing arbitrary formats and how to store them, and that is completely detached from why FAMFS went this route in the first place.
I question whether the actual issue here lies in the interface APPEARING more general purpose than it actually is - and therefore inviting attempts to over-genericize it.
Would you mind clarifying this part? Are you saying that the interface and logic is *already* generic and usable for other dax-backed servers, just that everything is *named* famfs but it's not really famfs specific? That's what I was trying to figure out - looking at the uapi, it seems pretty generic with defining bytes, strips, chunk size, etc which all seem like general concepts but the naming of it is so implementation-specific, eg
enum fuse_famfs_file_type {
FUSE_FAMFS_FILE_REG,
FUSE_FAMFS_FILE_SUPERBLOCK,
FUSE_FAMFS_FILE_LOG,
};
enum famfs_ext_type {
FUSE_FAMFS_EXT_SIMPLE = 0,
FUSE_FAMFS_EXT_INTERLEAVE = 1,
};
struct fuse_famfs_simple_ext {
uint32_t se_devindex;
uint32_t reserved;
uint64_t se_offset;
uint64_t se_len;
};struct fuse_famfs_iext { /* Interleaved extent */
uint32_t ie_nstrips;
uint32_t ie_chunk_size;
uint64_t ie_nbytes; /* Total bytes for this interleaved_ext;
* sum of strips may be more
*/
uint64_t reserved;
};struct fuse_famfs_fmap_header {
uint8_t file_type; /* enum famfs_file_type */
uint8_t reserved;
uint16_t fmap_version;
uint32_t ext_type; /* enum famfs_log_ext_type */
uint32_t nextents;
uint32_t reserved0;
uint64_t file_size;
uint64_t reserved1;
};which made me think this is only famfs-specific. Are all of these reusable / generally applicable structs? And just to double-check, the computation logic in patch 6 [1] would be generic to other dax-backed servers as well or is that part famfs-specific?
Thanks,
Joanne
Quoted 5 lines
Is there a world here where this is solved by a name change and a capability bit? I think so.
~Gregory
Quoted 7 lines · Joanne Koong
Quoted 6 lines · Gregory Price
I worry that this discussion is going to turn towards implementing a solution grounded in parsing arbitrary formats and how to store them, and that is completely detached from why FAMFS went this route in the first place.
Quoted 8 lines
Quoted 3 lines
I question whether the actual issue here lies in the interface APPEARING more general purpose than it actually is - and therefore inviting attempts to over-genericize it.
Would you mind clarifying this part? Are you saying that the interface and logic is *already* generic and usable for other dax-backed servers, just that everything is *named* famfs but it's not really famfs specific?
Yes.
If you just find/replace "famfs" with "dax_iomap", the structures here don't really seem all *that* crazy specific - they're just optimized for memory speeds instead of I/O.
There is a circular nature to this - FAMFS figured it out first, in what we think is a reasonably generic way, but we can't know for sure.
John, Dan, and Darrick have all proposed reasonable ways to hedge against the obvious fact the interface will not be perfect - which incorporates your BPF proposal along with a reasonably straight forward deprecation path that's not always possible in other arenas.
All that while solving a real (and novel) problem.
That's actually pretty damn cool.
I would urge you to consider these proposals earnestly.
~Gregory
Amir Goldstein
maintainerQuoted 32 lines · Gregory Price
Quoted 7 lines · Joanne Koong
Quoted 6 lines · Gregory Price
I worry that this discussion is going to turn towards implementing a solution grounded in parsing arbitrary formats and how to store them, and that is completely detached from why FAMFS went this route in the first place.
Quoted 8 lines
Quoted 3 lines
I question whether the actual issue here lies in the interface APPEARING more general purpose than it actually is - and therefore inviting attempts to over-genericize it.
Would you mind clarifying this part? Are you saying that the interface and logic is *already* generic and usable for other dax-backed servers, just that everything is *named* famfs but it's not really famfs specific?
Yes.
If you just find/replace "famfs" with "
dax_iomap", the structures here don't really seem all *that* crazy specific - they're just optimized for memory speeds instead of I/O.There is a circular nature to this - FAMFS figured it out first, in what we think is a reasonably generic way, but we can't know for sure.
John, Dan, and Darrick have all proposed reasonable ways to hedge against the obvious fact the interface will not be perfect - which incorporates your BPF proposal along with a reasonably straight forward deprecation path that's not always possible in other arenas.
Quoted 6 lines
All that while solving a real (and novel) problem.
That's actually pretty damn cool.
I would urge you to consider these proposals earnestly.
Apart from your suggestion to replace s/famfs/dax_iomap/ the fact that this logic sits in fs/fuse/famfs.c (or fuse/dax_iomap.c) is the other big architecture issue.
If this logic was to be placed in fs/iomap/ as Christoph suggested, I think the rest of the UAPI issues could be sorted out.
In any case, considering the sheer amount of discussion on this thread I have scheduled a cross-track FS+MM+IO for Famfs and DAX iomap.
I wasn't going to include Storage people at first, but since Christoph mentioned that stride/offset iomap could be useful for block iomap, I included them as well.
Thanks,
Amir.
Quoted 2 lines · Amir Goldstein
If this logic was to be placed in
fs/iomap/as Christoph suggested, I think the rest of the UAPI issues could be sorted out.
For that you don't need it in iomap, it could stay in fuse an be a generic striping API. Although IMHO doing it in iomap would be a lot cleaner and more efficient as well.
Quoted 6 lines
In any case, considering the sheer amount of discussion on this thread I have scheduled a cross-track FS+MM+IO for Famfs and DAX iomap.
I wasn't going to include Storage people at first, but since Christoph mentioned that stride/offset iomap could be useful for block iomap, I included them as well.
There is no overlap with storage. Any use of this would have to be file system level striping, not stackable block driver level striping. And keeping the rooms smaller is a win on it's own - anyone interested can join anyway.
Amir Goldstein
maintainerQuoted 12 lines · Christoph Hellwig
Quoted 2 lines · Amir Goldstein
If this logic was to be placed in
fs/iomap/as Christoph suggested, I think the rest of the UAPI issues could be sorted out.For that you don't need it in iomap, it could stay in fuse an be a generic striping API. Although IMHO doing it in iomap would be a lot cleaner and more efficient as well.
Quoted 3 lines
In any case, considering the sheer amount of discussion on this thread I have scheduled a cross-track FS+MM+IO for Famfs and DAX iomap.
Quoted 9 lines
Quoted 3 lines
I wasn't going to include Storage people at first, but since Christoph mentioned that stride/offset iomap could be useful for block iomap, I included them as well.
There is no overlap with storage. Any use of this would have to be file system level striping, not stackable block driver level striping. And keeping the rooms smaller is a win on it's own - anyone interested can join anyway.
OK. Changed to FS+MM.
Thanks,
Amir.
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
...
Quoted 4 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
This seems a bit more than moving a goalpost.
We're now gating working software, for real working hardware, on a novel, unproven BPF ops structure that controls page table mappings on page table faults which would be used by exactly 1 user : FAMFS.
And that singular user is harmed because it turns an O(1) offset calculation into a pointer chase - on the hottest path (every fault).
John is right to push back here.
---
That said - I'm looking at fs/fuse/famfs.c and I'm asking myself what in here is actually famfs-specific. If you just s/FAMFS/DAX/g - the file just reads like a simple DAX-iomap backend with optional striping.
Would it be reasonable to refactor the dax layer (and users) to create an ops structure that becomes the basis for the BPF solution?
We don't even know what the whole BPF scope is, and it seems wholly unfair to John's and his users to make that solely their problem (for negative value!).
~Gregory
Quoted 13 lines · Gregory Price
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
...
Quoted 4 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
Quoted 5 lines
This seems a bit more than moving a goalpost.
We're now gating working software, for real working hardware, on a novel, unproven BPF ops structure that controls page table mappings on page table faults which would be used by exactly 1 user : FAMFS.
Are MM people on board with even letting BPF do that? Honest question, if someone has a pointer to how that should work, that would be appreciated.
Signature · 3 lines
Cheers, David
Quoted 14 lines · David Hildenbrand (Arm)
Quoted 13 lines · Gregory Price
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
...
Quoted 4 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
Quoted 9 lines
Quoted 5 lines
This seems a bit more than moving a goalpost.
We're now gating working software, for real working hardware, on a novel, unproven BPF ops structure that controls page table mappings on page table faults which would be used by exactly 1 user : FAMFS.
Are MM people on board with even letting BPF do that? Honest question, if someone has a pointer to how that should work, that would be appreciated.
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
~Gregory
Miklos Szeredi
maintainerQuoted 3 lines · Gregory Price
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
I'm wondering which part of this triggers the big (!).
BPF program being run in the fault path?
Or that the return value from the BPF function is used as iomap?
Or something else?
Thanks,
Miklos
Quoted 6 lines · Miklos Szeredi
Quoted 3 lines · Gregory Price
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
Quoted 7 lines
I'm wondering which part of this triggers the big (!).
BPF program being run in the fault path?
Or that the return value from the BPF function is used as iomap?
Or something else?
If a BPF program controls what memory address a fault now allows access to, who validates that this is a memory address within the purview of the BPF program, and not, say, the address of the kernel page tables?
(I have done no looking to determine if this is already considered)
Quoted 13 lines · Matthew Wilcox
Quoted 12 lines · Miklos Szeredi
Quoted 3 lines · Gregory Price
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
I'm wondering which part of this triggers the big (!).
BPF program being run in the fault path?
Or that the return value from the BPF function is used as iomap?
Quoted 7 lines
Quoted 1 line
Or something else?
If a BPF program controls what memory address a fault now allows access to, who validates that this is a memory address within the purview of the BPF program, and not, say, the address of the kernel page tables?
(I have done no looking to determine if this is already considered)
We're not using bpf to implement ->filemap_fault directly. fuse would implement that as a call to dax_iomap_fault, iomap would then call fuse's ->iomap_begin, and that's where the bpf program would take over. The mapping provided would return a (struct dax_device, u64 addr, u64 length), and (presumably) the dax device access function would rangecheck that.
Unless someone foolishly puts kernel page tables on the dax device...
--D
Quoted 13 lines · Matthew Wilcox
Quoted 12 lines · Miklos Szeredi
Quoted 3 lines · Gregory Price
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
I'm wondering which part of this triggers the big (!).
BPF program being run in the fault path?
Or that the return value from the BPF function is used as iomap?
Quoted 7 lines
Quoted 1 line
Or something else?
If a BPF program controls what memory address a fault now allows access to, who validates that this is a memory address within the purview of the BPF program, and not, say, the address of the kernel page tables?
(I have done no looking to determine if this is already considered)
From an initial look at the existing bpf ops structures, I do not see any other struct with a similar (obvious) pattern - so it's not clear to me such a concern has been exposed elsewhere or directly addressed.
There is a verifier step for the BPF program that in theory would validate the range matches the DAX ranges, but i think that only validates the types are right and only on load - I think the BPF program itself would be the address validater, which is a strong no.
BPF folks please correct me if i'm off base here.
My initial take is that it's a real concern a "bug" in a BPF program could let userland map arbitrary memory into userland page tables, and such an extension would not be a quick fix to the FAMFS problem.
~Gregory
Quoted 32 lines · Gregory Price
Quoted 13 lines · Matthew Wilcox
Quoted 12 lines · Miklos Szeredi
Quoted 3 lines · Gregory Price
This was my first reaction when I realized the BPF program would be controlling iomap return value in the fault path. Big ol' (!) popped up over my head.
I'm wondering which part of this triggers the big (!).
BPF program being run in the fault path?
Or that the return value from the BPF function is used as iomap?
Quoted 7 lines
Quoted 1 line
Or something else?
If a BPF program controls what memory address a fault now allows access to, who validates that this is a memory address within the purview of the BPF program, and not, say, the address of the kernel page tables?
(I have done no looking to determine if this is already considered)
From an initial look at the existing bpf ops structures, I do not see any other struct with a similar (obvious) pattern - so it's not clear to me such a concern has been exposed elsewhere or directly addressed.
There is a verifier step for the BPF program that in theory would validate the range matches the DAX ranges, but i think that only validates the types are right and only on load - I think the BPF program itself would be the address validater, which is a strong no.
Quoted 5 lines
BPF folks please correct me if i'm off base here.
My initial take is that it's a real concern a "bug" in a BPF program could let userland map arbitrary memory into userland page tables, and such an extension would not be a quick fix to the FAMFS problem.
If you're concerned about arbitrary addresses in the bpf path, you should be equally concerned about the FUSE_GET_FMAP path that's in this series, because they're functionally identical. The kernel trusts userspace-provided addresses in both cases. If that's acceptable for this series then it's acceptable for bpf too. You can't reject bpf on security grounds without also rejecting the current approach.
Please take a look at the famfs bpf program [1] and compare that to the logic in patch 6 in this series [2]. In both cases, iomap->addr gets set to the address that was earlier specified by the userspace famfs server. In the non-bpf path, the userspace server passes this address through a FUSE_GET_FMAP request. In the bpf path, the userspace server passes this address by updating the bpf hashmap from userspace. There is no functional difference. Also btw, this is one of the cases that I was referring to about the bpf path being more helpful - in the bpf path, we avoid having to add a FUSE_FMAP opcode to fuse (which will be used by no other server) and famfs gets to skip 2 extra context-switches that the FUSE_FMAP path otherwise entails.
As I understand it, famfs is gated behind CAP_SYS_RAWIO, which is a highly privileged capability. To use iomap bpf, this would also require similar high privileges.
Thanks,
Joanne
[1] https://github.com/joannekoong/libfuse/blob/444fa27fa9fd2118a0dc332933197faf9bbf25aa/example/famfs.bpf.c
[2] https://lore.kernel.org/linux-fsdevel/0100019d43e79794-0eadcf5e-b659-43f7-8fdc-dec9f4ccce14-000000@email.amazonses.com/
Quoted 2 lines
~Gregory
Quoted 6 lines · Joanne Koong
Quoted 4 lines · Gregory Price
My initial take is that it's a real concern a "bug" in a BPF program could let userland map arbitrary memory into userland page tables, and such an extension would not be a quick fix to the FAMFS problem.
Quoted 7 lines
If you're concerned about arbitrary addresses in the bpf path, you should be equally concerned about the
FUSE_GET_FMAPpath that's in this series, because they're functionally identical. The kernel trusts userspace-provided addresses in both cases. If that's acceptable for this series then it's acceptable for bpf too. You can't reject bpf on security grounds without also rejecting the current approach.
To be clear, i'm not rejecting it. I'm saying (!) that's something that needs a careful look.
It's a novel interaction and a new ops structure. I don't think it's in any way unfair to point out there will (and should) be questions outside the scope of FAMFS.
Quoted 12 lines
Please take a look at the famfs bpf program [1] and compare that to the logic in patch 6 in this series [2]. In both cases,
iomap->addrgets set to the address that was earlier specified by the userspace famfs server. In the non-bpf path, the userspace server passes this address through aFUSE_GET_FMAPrequest. In the bpf path, the userspace server passes this address by updating the bpf hashmap from userspace. There is no functional difference. Also btw, this is one of the cases that I was referring to about the bpf path being more helpful - in the bpf path, we avoid having to add aFUSE_FMAPopcode to fuse (which will be used by no other server) and famfs gets to skip 2 extra context-switches that theFUSE_FMAPpath otherwise entails.
The question isn't about the functional differences between the FAMFS static code or a BPF blob doing the same thing - the question is what the new ops structure introduces for the general case that wasn't there before.
We have to reason about the BPF extension separately from the context of FAMFS - as it's a general interface now (forever :P).
~Gregory
Quoted 14 lines · David Hildenbrand (Arm)
Quoted 13 lines · Gregory Price
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
...
Quoted 4 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
Quoted 8 lines
Quoted 5 lines
This seems a bit more than moving a goalpost.
We're now gating working software, for real working hardware, on a novel, unproven BPF ops structure that controls page table mappings on page table faults which would be used by exactly 1 user : FAMFS.
Are MM people on board with even letting BPF do that? Honest question, if someone has a pointer to how that should work, that would be appreciated.
David, that question is pivotal!! How can we get at least a preliminary answer sooner rather than later? If the answer is "Hell No", a lot of this thread (but not all) becomes moot.
Prior to today this entire discussion has happened in the absence, to my knowledge, of anybody actually hooking famfs for BPF-based fault handling. But today Gregory has shared some code with me that does that. However, the code doesn't build for me so I guess I'll have to debug that as soon as I can.
Gregory's code, in the current form, still uses two new fuse messages, GET_FMAP and GET_DAXDEV, but it makes the fmap message format opaque by removing fmap format structs from the uapi. It also uses two BPF programs. One BPF program parses and validates the GET_FMAP payload for every file, and hangs it from a 'void *' in each fuse_inode (just like the current famfs code). The other BPF program is called during vma faults and reads the fuse_inode->'void *' in order to handle faults the same way famfs-fuse does today, but via BPF instead.
As with all vma "providers", famfs services zillions of faults. But famfs faults never involve blocking or retrieving from storage, so we don't have that to amortize a less efficient fault handling code path over. As I've said many times, we're enabling memory and it must run at "memory speeds". Gregory's code includes a BPF invocation to resolve each vma fault, but does avoid the BPF hashmap lookup that would be required with a generalized implementation of Joanne's ideas.
The first question (very much unanswered) is whether a BPF fault handler can resolve vma faults with performance equivalent to hugetlbfs or anonymous mmap performance. If not, the famfs community will assert that BPF would defeat or degrade the purpose of famfs. Added overhead/latency/cache misses in a fault handler will serialize into the stall time that software sees for a virtual address to be resolved - it really is performance critical. If BPF is slower, we'll be able to measure it, but one benchmark or test case does not fit all, so this won't be a one-and-done test...
I'll share performance measurements as soon as I can build Gregory's code, test, get time on a proper big-memory cluster, and measure something that makes sense. This will take some days, but I'm working it.
Hopefully Monday I plan to try to do a substantial on-list reply that attempts to summarize the various objections to my current famfs fuse implementation as well as the open questions and my specific performance and complexity concerns.
Thanks,
John
Quoted 4 lines · John Groves
Quoted 2 lines · David Hildenbrand (Arm)
Quoted 1 line · Gregory Price
On Tue, Apr 14, 2026 at 11:57:40AM -0700, Darrick J. Wong wrote:
Quoted 9 lines
Gregory's code, in the current form, still uses two new fuse messages,
GET_FMAPandGET_DAXDEV, but it makes the fmap message format opaque by removing fmap format structs from the uapi. It also uses two BPF programs. One BPF program parses and validates theGET_FMAPpayload for every file, and hangs it from a 'void *' in eachfuse_inode(just like the current famfs code). The other BPF program is called during vma faults and reads the fuse_inode->'void *' in order to handle faults the same way famfs-fuse does today, but via BPF instead.
I'll just lay out what i've done and why.
For John's sanity, if there are NACKs, knowing sooner rather than later would be a kindness.
=== Problem: Any lookup() in iomap_begin() is too much overhead.
No dax-backed server will want to eat the cost of a lookup() that could be multiple microseconds on what should be a 1-5us soft-fault.
Joanne's prototype had this:
meta = bpf_map_lookup_elem(&inode_map, &nodeid);
But it was offsetting a single pointer dereference:
struct fuse_inode *fi = get_fuse_inode(inode); struct famfs_file_meta *meta = fi->famfs_meta;
Not all O(1) are created equal here.
A single L3 LLC miss plus page table walk can cost you ~100ns. If that pointer was cache-hot, it's almost free.
A pointer chase through any structure is N x ~100ns. This is unlikely to ever be sufficiently cache hot by comparison.
So, lets just avoid this problem altogether.
=== Requirements
1) No hard-coded OMF structures in the FUSE API.
While RAID0 style interleaving isn't exactly fancy or novel, folks think this should not be in the kernel headers.
(I'm not going to argue, I think the argument is pointless)
2) imap_begin() needs metadata accessible on the order of a single pointer dereference - which is what John has implemented.
3) open() needs to validate the metadata and identify DAX devices
a) it needs to validate the DAX devices are available and acquire them / set them up / etc. This is a kernel-side op.
b) it needs to validate the addressing information is valid for the relevant dax devices
Both GET_FMAP and GET_DAXDEV are avoided if the metadata is already cached or the DAXDEV is already setup. So keeping these separate is actually important.
Joanne's code deals with #1 - but it doesn't handle #2 or #3. (It also doesn't handle GET_DAXDEV at all).
John's code mananges #2 and #3 by having the fuse-server pass meta data on open() via GET_FMAP and GET_DAXDEV.
GET_FMAP acquires the meta data on how dax devices are used
GET_DAXDEV just translates an ID to specific dax device. iomap_being() then uses the OMF to do the mapping.
But it does this by hard-coding the format into kernel headers.
=== Observation: Add a BPF dax_fmap_parse() on open()
Pair Joanne's suggestion with John's GET_FMAP/GET_DAXDEV operations.
struct fuse_dax_fmap_ops {
char name[FUSE_DAX_FMAP_OPS_NAME_LEN]; // 16 bytes
int (*dax_fmap_parse)(struct fuse_dax_fmap_parse_ctx *ctx);
int (*iomap_begin)(struct fuse_dax_fmap_resolve_ctx *ctx,
struct fuse_iomap_io *io);
};This parse function is used to do filesystem specific setup the (such as populate the dax bitmap) based on filesystem-specific per-file metadata.
In John's case, essentially all it does is populate the dax bitmap and toss the data onto fi->dax_fmap.meta.
Pseudo code:
fuse_dax_fmap_open(inode):
fmap_size = send_GET_FMAP(inode, fmap_buf)
/* Make space to store the metadata */
meta_buf = kzalloc(meta_size)
ctx = { ... }
kern = { .ctx, .blob = blob, .meta_buf = meta_buf }
/* Parse the metadata: i.e. fill out the daxdev bitmap */
fc->dax_fmap_ops->dax_fmap_parse(&ctx)
/* Call GET_DAXDEV for any new dax devices */
resolve_dev_bitmap(ctx.dev_bitmap)
/* cache the meta data on the inode */
inode_lock()
fi->dax_fmap.meta = meta_buf
... etc etc ...
inode_unlock()And otherwise, imap_begin() works exactly as Joanne proposed, but with in-kernel cached data instead of the bpfmap.
const struct dax_simple_meta *meta = (const struct dax_simple_meta *)
bpf_fuse_dax_resolve_get_meta(ctx, 0, sizeof(*meta));And since both parse() and iomap_begin() are bpf programs - and they're the only consumers of the metadata - FUSE itself no longer needs to know anything about the server's particular strategy to use the dax devices.
struct fuse_inode {
...
#if IS_ENABLED(CONFIG_FUSE_DAX_FMAP)
struct {
void *meta;
u32 meta_size;
u64 file_size;
} dax_fmap;
#endif
};Just a big ol' honkin' void* that otherwise gets ignored.
(Note: while i'm not a BPF wizard, this pattern seems well established in
existing BPF code, i found code in the network stack that caches data on kernel objects this way as well)
==== Caveats
1) We don't know the overhead BPF introduces in the fault path.
My napkin math (and best understanding of BPF) suggests:
1) trampoline / vtable for bpf ops (iomap_begin func)
2) retpoline cost of BPF (assuming this is on, safe assumption)
3) bpf_fuse_dax_resolve_get_meta() overhead (extra pointer deref)
This *should* (i think) amount to an extra pointer dereference, a longjump, and a retpoline, which hopefully is <100ns since any extra pointer derefs here SHOULD be cache-hot (hard to know).
It's not 0 overhead, and if the average fault time is 1us then every additional 10ns not an insignificant cost.
But this is napkin math. John will collect data.
2) FUSE needs to be ok with the BPF-driven changes:
https://github.com/joannekoong/linux/commits/prototype_generic_iomap_dax/
3) FUSE needs to be ok with GET_FMAP/GET_DAXDEV as opaque meta-data handlers for DAX devices.
That means there is no default parser or format. If you don't register ops, these functions are functionally dead.
(probably fine to enforce during init, which is what i did)
4) As John said: MM needs to be good with it.
Any server using DAX like this already essentially has CAP_SYS_RAWIO for DAX, and most likely some form of CAP_SYS_ADMIN.
Additionally, as folks have pointed out, the resolution to PTE is bounded by dax device extents, so it's not entirely arbitrary.
===
As mentioned at the start - you'd be doing John a kindness if there are clear and obvious NACK's to be had here.
~Gregory
Quoted 6 lines · Gregory Price
Quoted 4 lines · John Groves
Quoted 2 lines · David Hildenbrand (Arm)
Quoted 1 line · Gregory Price
On Tue, Apr 14, 2026 at 11:57:40AM -0700, Darrick J. Wong wrote:
Quoted 10 lines
Quoted 9 lines
Gregory's code, in the current form, still uses two new fuse messages,
GET_FMAPandGET_DAXDEV, but it makes the fmap message format opaque by removing fmap format structs from the uapi. It also uses two BPF programs. One BPF program parses and validates theGET_FMAPpayload for every file, and hangs it from a 'void *' in eachfuse_inode(just like the current famfs code). The other BPF program is called during vma faults and reads the fuse_inode->'void *' in order to handle faults the same way famfs-fuse does today, but via BPF instead.
Thanks John for running the benchmarks on your hardware. And thanks Gregory for your work on this too.
Quoted 52 lines
I'll just lay out what i've done and why.
For John's sanity, if there are NACKs, knowing sooner rather than later would be a kindness.
=== Problem: Any
lookup()iniomap_begin()is too much overhead.No dax-backed server will want to eat the cost of a
lookup()that could be multiple microseconds on what should be a 1-5us soft-fault.Joanne's prototype had this:
meta = bpf_map_lookup_elem(&inode_map, &nodeid);But it was offsetting a single pointer dereference:
struct fuse_inode *fi = get_fuse_inode(inode); struct famfs_file_meta *meta = fi->famfs_meta;Not all O(1) are created equal here.
A single L3 LLC miss plus page table walk can cost you ~100ns. If that pointer was cache-hot, it's almost free.
A pointer chase through any structure is N x ~100ns. This is unlikely to ever be sufficiently cache hot by comparison.
So, lets just avoid this problem altogether.
=== Requirements
1) No hard-coded OMF structures in the FUSE API.
While RAID0 style interleaving isn't exactly fancy or novel, folks think this should not be in the kernel headers.
(I'm not going to argue, I think the argument is pointless)
2)
imap_begin()needs metadata accessible on the order of a single pointer dereference - which is what John has implemented.3)
open()needs to validate the metadata and identify DAX devicesa) it needs to validate the DAX devices are available and acquire them / set them up / etc. This is a kernel-side op.
b) it needs to validate the addressing information is valid for the relevant dax devices
Quoted 7 lines
Both
GET_FMAPandGET_DAXDEVare avoided if the metadata is already cached or the DAXDEV is already setup. So keeping these separate is actually important.Joanne's code deals with #1 - but it doesn't handle #2 or #3. (It also doesn't handle
GET_DAXDEVat all).
It handles #3 by removing GET_DAXDEV as a fuse op and having the daxdev initialization / setup routed through FUSE_IOMAP_CONFIG at iomap initialization time instead, which integrates with the generic iomap infrastruture/uapi additions Darrick added in his fuse-iomap series [1].
In this series the GET_DAXDEV op gets sent lazily on file opens but it's still not clear to me why this is necessary. imo device setup should happen logically as part of iomap configuration and it seems more efficient to have devices validated/acquired before any files are opened. I thihnk that makes things a lot simpler on the kernel side in other ways (eg we can get rid of famfs_dax_devlist / famfs_daxdev / famfs_devlist_sem / famfs_update_daxdev_table() / famfs_fuse_get_daxdev() altogether). It also saves the famfs server the roundtrip context switching cost if we get rid of GET_DAXDEV and move it to iomap initialization time, which will improve FUSE_OPEN performance for famfs. Maybe there's something I'm missing here as to why the daxdev initialization has to be done lazily on open?
I think Darrick had also mentioned something earlier about how he thinks GET_DAXDEV should be another application of backing files [2] - I like this idea too, as it gets rid of the GET_DAXDEV op and reuses fuse's existing infrastructure.
[1] https://lore.kernel.org/linux-fsdevel/177188734695.3935739.8198854011004837207.stgit@frogsfrogsfrogs/
[2] https://lore.kernel.org/linux-fsdevel/20260416224331.GD114184@frogsfrogsfrogs/
Quoted 12 lines
John's code mananges #2 and #3 by having the fuse-server pass meta data on
open()viaGET_FMAPandGET_DAXDEV.
GET_FMAPacquires the meta data on how dax devices are used
GET_DAXDEVjust translates an ID to specific dax device.iomap_being()then uses the OMF to do the mapping.But it does this by hard-coding the format into kernel headers.
Quoted 7 lines
=== Observation: Add a BPF
dax_fmap_parse()onopen()Pair Joanne's suggestion with John's GET_FMAP/GET_DAXDEV operations.
struct fuse_dax_fmap_ops { char name[FUSE_DAX_FMAP_OPS_NAME_LEN]; // 16 bytes int (*dax_fmap_parse)(struct fuse_dax_fmap_parse_ctx *ctx);
Just a note for later, if the bpf approach gets pursued further:
instead of making this a dax specific ops, I think this needs to be integrated interface-wise with Darrick's fuse-iomap work since he does the same thing. I think dax_fmap_parse() could be renamed to something like iomap_setup(), where userspace can use this to do any sort of generic setup, whether that's mapping related or dax related or not. In my mind, the dax vs non dax distinction is handled by the fuse iomap plumbing that chooses which iomap entry points to call, but beyond that, the callbacks and struct ops themselves should be generic enough to be shared between the two.
Quoted 32 lines
int (*iomap_begin)(struct
fuse_dax_fmap_resolve_ctx*ctx,
structfuse_iomap_io*io);
};This parse function is used to do filesystem specific setup the (such as populate the dax bitmap) based on filesystem-specific per-file metadata.
In John's case, essentially all it does is populate the dax bitmap and toss the data onto
fi->dax_fmap.meta.Pseudo code:
fuse_dax_fmap_open(inode):fmap_size = send_GET_FMAP(inode, fmap_buf) /* Make space to store the metadata */ meta_buf = kzalloc(meta_size) ctx = { ... } kern = { .ctx, .blob = blob, .meta_buf = meta_buf } /* Parse the metadata: i.e. fill out the daxdev bitmap */ fc->dax_fmap_ops->dax_fmap_parse(&ctx) /* Call GET_DAXDEV for any new dax devices */ resolve_dev_bitmap(ctx.dev_bitmap) /* cache the meta data on the inode */ inode_lock() fi->dax_fmap.meta = meta_buf ... etc etc ... inode_unlock()
Quoted 5 lines
And otherwise,
imap_begin()works exactly as Joanne proposed, but with in-kernel cached data instead of the bpfmap.const struct dax_simple_meta *meta = (const struct dax_simple_meta *) bpf_fuse_dax_resolve_get_meta(ctx, 0, sizeof(*meta));
another note for later, if the benchmarks prove promising and after the LSF discussions we decide to go with this approach: imo we could/should repurpose this into a generic bpf_fuse_iomap_get_inode_meta() that returns a bounded pointer into whatever opaque blob was cached on the inode during iomap_setup(), where it'd be a generic kfunc serving both the dax and non-dax case for any kind of mapping layout
Quoted 5 lines
And since both
parse()andiomap_begin()are bpf programs - and they're the only consumers of the metadata - FUSE itself no longer needs to know anything about the server's particular strategy to use the dax devices.
Quoted 7 lines
struct fuse_inode {
...
#if IS_ENABLED(CONFIG_FUSE_DAX_FMAP)
struct {
void *meta;
u32 meta_size;
u64 file_size;I don't think file_size is needed here? seems like we could just derive this from i_size_read(inode)?
Quoted 1 line
} dax_fmap;
/s/dax_fmap/iomap
Quoted 29 lines
#endif };Just a big ol' honkin' void* that otherwise gets ignored.
(Note: while i'm not a BPF wizard, this pattern seems well established in
existing BPF code, i found code in the network stack that caches data on kernel objects this way as well)==== Caveats
1) We don't know the overhead BPF introduces in the fault path.
My napkin math (and best understanding of BPF) suggests:
1) trampoline / vtable for bpf ops (
iomap_beginfunc)
2) retpoline cost of BPF (assuming this is on, safe assumption)
3)bpf_fuse_dax_resolve_get_meta()overhead (extra pointer deref)This *should* (i think) amount to an extra pointer dereference, a longjump, and a retpoline, which hopefully is <100ns since any extra pointer derefs here SHOULD be cache-hot (hard to know).
It's not 0 overhead, and if the average fault time is 1us then every additional 10ns not an insignificant cost.
But this is napkin math. John will collect data.
Quoted 7 lines
2) FUSE needs to be ok with the BPF-driven changes:
https://github.com/joannekoong/linux/commits/prototype_generic_iomap_dax/
3) FUSE needs to be ok with GET_FMAP/GET_DAXDEV as opaque meta-data handlers for DAX devices.
I think we could kill GET_DAXDEV and for GET_FMAP, we could make this a generic FUSE_IOMAP_GETMAP where the server can set a flag on open to indicate whether the mapping blob should be fetched or not.
Quoted 12 lines
That means there is no default parser or format. If you don't register ops, these functions are functionally dead.
(probably fine to enforce during init, which is what i did)
4) As John said: MM needs to be good with it.
Any server using DAX like this already essentially has
CAP_SYS_RAWIOfor DAX, and most likely some form ofCAP_SYS_ADMIN.
Quoted 7 lines
Additionally, as folks have pointed out, the resolution to PTE is bounded by dax device extents, so it's not entirely arbitrary.
===
As mentioned at the start - you'd be doing John a kindness if there are clear and obvious NACK's to be had here.
I don't have a NACK on what you wrote above, thank you for your work on this and bridging it into John's famfs server.
As I understand it, Amir also scheduled a cross-track FS+MM+IO session at LSF to discuss famfs and dax iomap. Christoph had posted a suggestion in another message about solving this problem with adding generic stride/offset multi-device support to fs/iomap, and I'm hoping the LSF session will shed more light on this, as that to me seems the cleanest solution and would pretty much give everyone what they want (including getting famfs unblocked, as I think with this approach we would just need to figure out the generic stride/offset format for the fuse iomap uapi, and could have the interleaving logic living in fuse initially with fs/iomap migrations done post-merge). In the meantime, I think it's really helpful getting the data points on how bpf performs, thank you for running the benchmarks on your setup, John.
Thanks,
Joanne
Quoted 2 lines
~Gregory
Quoted 6 lines · Joanne Koong
Quoted 4 lines · Gregory Price
struct fuse_dax_fmap_ops { char name[FUSE_DAX_FMAP_OPS_NAME_LEN]; // 16 bytes int (*dax_fmap_parse)(struct fuse_dax_fmap_parse_ctx *ctx);
Quoted 11 lines
Just a note for later, if the bpf approach gets pursued further:
instead of making this a dax specific ops, I think this needs to be integrated interface-wise with Darrick's fuse-iomap work since he does the same thing. I thinkdax_fmap_parse()could be renamed to something likeiomap_setup(), where userspace can use this to do any sort of generic setup, whether that's mapping related or dax related or not. In my mind, the dax vs non dax distinction is handled by the fuse iomap plumbing that chooses which iomap entry points to call, but beyond that, the callbacks and struct ops themselves should be generic enough to be shared between the two.
I think this is reasonable. I'm not a FUSE wizard either, but I would presume the iomap_setup() process would just essentially be John's existing GET_FMAP / GET_DAXDEV code bundled.
GET_DAXDEV happens lazily to save him the round-trips to userland if the DAXDEVs have already been seen previously. I think your proposal does in fact save him further round trips, and it would probably solve the performance impact he saw from porting to FUSE.
Quoted 6 lines
Quoted 5 lines
And otherwise,
imap_begin()works exactly as Joanne proposed, but with in-kernel cached data instead of the bpfmap.const struct dax_simple_meta *meta = (const struct dax_simple_meta *) bpf_fuse_dax_resolve_get_meta(ctx, 0, sizeof(*meta));
Quoted 8 lines
another note for later, if the benchmarks prove promising and after the LSF discussions we decide to go with this approach: imo we could/should repurpose this into a generic
bpf_fuse_iomap_get_inode_meta()that returns a bounded pointer into whatever opaque blob was cached on the inode duringiomap_setup(), where it'd be a generic kfunc serving both the dax and non-dax case for any kind of mapping layout
Note that Christian Brauner just said he preferred not having dedicated bpf storage in struct inode [1].
sans BPF, is there value in such a metadata blob existing?
If there was a generic format, then I suppose the blob storage would not be BPF specific, it would just overload it (simple union).
~Gregory
Quoted 44 lines · Gregory Price
Quoted 6 lines · Joanne Koong
Quoted 4 lines · Gregory Price
struct fuse_dax_fmap_ops { char name[FUSE_DAX_FMAP_OPS_NAME_LEN]; // 16 bytes int (*dax_fmap_parse)(struct fuse_dax_fmap_parse_ctx *ctx);Quoted 11 lines
Just a note for later, if the bpf approach gets pursued further:
instead of making this a dax specific ops, I think this needs to be integrated interface-wise with Darrick's fuse-iomap work since he does the same thing. I thinkdax_fmap_parse()could be renamed to something likeiomap_setup(), where userspace can use this to do any sort of generic setup, whether that's mapping related or dax related or not. In my mind, the dax vs non dax distinction is handled by the fuse iomap plumbing that chooses which iomap entry points to call, but beyond that, the callbacks and struct ops themselves should be generic enough to be shared between the two.I think this is reasonable. I'm not a FUSE wizard either, but I would presume the
iomap_setup()process would just essentially be John's existingGET_FMAP/GET_DAXDEVcode bundled.
GET_DAXDEVhappens lazily to save him the round-trips to userland if the DAXDEVs have already been seen previously. I think your proposal does in fact save him further round trips, and it would probably solve the performance impact he saw from porting to FUSE.Quoted 6 lines
Quoted 5 lines
And otherwise,
imap_begin()works exactly as Joanne proposed, but with in-kernel cached data instead of the bpfmap.const struct dax_simple_meta *meta = (const struct dax_simple_meta *) bpf_fuse_dax_resolve_get_meta(ctx, 0, sizeof(*meta));Quoted 8 lines
another note for later, if the benchmarks prove promising and after the LSF discussions we decide to go with this approach: imo we could/should repurpose this into a generic
bpf_fuse_iomap_get_inode_meta()that returns a bounded pointer into whatever opaque blob was cached on the inode duringiomap_setup(), where it'd be a generic kfunc serving both the dax and non-dax case for any kind of mapping layout
Quoted 7 lines
Note that Christian Brauner just said he preferred not having dedicated bpf storage in struct inode [1].
sans BPF, is there value in such a metadata blob existing?
If there was a generic format, then I suppose the blob storage would not be BPF specific, it would just overload it (simple union).
I'm not sure if this addresses Christian's concerns or not, but the blob would reside within struct fuse_inode not struct inode. I definitely agree with him that this should not touch or add any infra outside fuse.
I hadn't heard of bpf arenas until his comment. If the hashmap overhead is too high for famfs, having a custom in-arena hash table would be much faster I think, as it could be designed to require less pointer chasing and avoid other overhead in the bpf hashmap implementation, though now famfs would have to manage the data structure and complexity itself.
Thanks,
Joanne
Quoted 7 lines · Joanne Koong
On Tue, Apr 21, 2026 at 7:30 AM Gregory Price <[email protected]> wrote:
I'm not sure if this addresses Christian's concerns or not, but the blob would reside within struct
fuse_inodenot struct inode. I definitely agree with him that this should not touch or add any infra outside fuse.
Quoted 7 lines
I hadn't heard of bpf arenas until his comment. If the hashmap overhead is too high for famfs, having a custom in-arena hash table would be much faster I think, as it could be designed to require less pointer chasing and avoid other overhead in the bpf hashmap implementation, though now famfs would have to manage the data structure and complexity itself.
I think if the fuse-inode blob is acceptable, that's highly preferable - and it wouldn't necessarily need to stay specific to bpf. If there was some generic format that folks agreed on as a baseline, that could obviously be worked into the interface.
~Gregory
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · John Groves
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all. You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
A couple of points here, that are really top level observations.
The call path from fuse into famfs largely looks like:
if (passthrough)
return passthrough_call()
else if (virtiofs)
return virtiofs_call()
else if (famfs)
return famfs_call()
So from a hooking in standpoint I was trying to be compliant.
Second point: iomap is an overloaded term. The famfs iomap usage is stolen from xfs' fs-dax iomap call patterns. I *think* that is distinct from the stuff called iomap that handles block I/O. Because maybe not everybody who reads this will understand that famfs is, uh, kinda like hugetlbfs except that the memory is from devdax (in 'famfs' mode, because the old mode stopped working for file-backed maps. Famfs files are never sparse, and they never use the page cache - which is super, super different from a conventional file system.
the famfs_filemap_fault() path calls dax_iomap_fault() path (which I added to devdax in the new famfs mode, because it was in pmem but not devdax) always just updates a page table beause the page is always present. That means that the fault path is SUPER PERFORMANCE CRITICAL because in heavy use there can be millions of these faults per second - and with famfs there is NEVER EVER a read from storage to amortize the call overhead over.
This is a super-important point. famfs_filemap_fault() is a in the vm_operations_struct. It is called to remind the CPU where an address maps to, because the TLB and PTE had been purged (which happens ALL THE TIME).
The ask here is to insert a BPF program as a vma fault handler. Can it work? Probably. Will it perform? I HAVE NO IDEA, BUT THERE ARE REASONS TO WORRY THAT IT MIGHT NOT.
I don't think this suggestion was made from a full understanding of the performance requirements of this code path.
This is why we need a discussion with fs/mm/bpf experts. We should be able to assemble an understanding of what the overhead of calling the BPF program are and how many nanoseconds (or microseconds) that could possibly add. Anything longer than the current famfs_filemap_fault() path is potentially disastrous because the whole point of famfs is to expose memory via files, and avoid sabotaging the performance.
An L3 cache miss costs 100ns in round numbers on fast local DRAM, and 3-5x as long on switched disaggregated memory. We cannot afford an expensive code path resolving these mappings.
This is why, at the last two LSFMMs and in the famfs documentation, I said things like "we're exposing memory, and it must run at memory speeds".
Famfs also registers with the memory provider (devdax in famfs mode) to receive notifications of memory failures, and uses a 'holder_operations' pattern copied from pmem. This stuff is not in generic iomap (correct me if that's wrong).
And finally since I've core dumped quite a bit here, I'll go ahead and add a thought experiment that *might* rule out using a BPF program as a vma fault handler. Could we do that with hugetlbfs without damaging performance for memory-intensive workloads? Hugetlbfs is a pretty solid stand-in for
famfs: it never does data-movement faults, it's never sparse, and it needs to resolve TLB/PTE/PMD/PUD faults FAST.
Quoted 68 lines
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
Quoted 5 lines
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That's totally fair. This process has been very long and grueling, and I'm not always thinking clearly.
Quoted 55 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
Quoted 5 lines
What are the risks of converting to BPF?
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
Quoted 2 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
Quoted 6 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
Quoted 8 lines
Quoted 2 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
--D
And apologies to the polite universe for being a bit raw earlier. Getting this far has been quite a grind...
Thanks,
John
Quoted 157 lines · John Groves
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · John Groves
Quoted 11 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary. This was the main sticking point originally, but there seemed to be no better alternative.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
However with the bpf approach this would be gone, which is great.
Well... you can't get away with having *no* mapping interface at all. You still have to define a UABI that BPF programs can use to convey mapping data into fsdax/iomap. BTF is a nice piece of work that smooths over minor fluctuations in struct layout between a running kernel and a precompiled BPF program, but fundamentally we still need a fuse-native representation.
A couple of points here, that are really top level observations.
The call path from fuse into famfs largely looks like:
if (passthrough)
returnpassthrough_call()
else if (virtiofs)
returnvirtiofs_call()
else if (famfs)
returnfamfs_call()So from a hooking in standpoint I was trying to be compliant.
Second point: iomap is an overloaded term. The famfs iomap usage is stolen from xfs' fs-dax iomap call patterns. I *think* that is distinct from the stuff called iomap that handles block I/O. Because maybe not everybody who reads this will understand that famfs is, uh, kinda like hugetlbfs except that the memory is from devdax (in 'famfs' mode, because the old mode stopped working for file-backed maps. Famfs files are never sparse, and they never use the page cache - which is super, super different from a conventional file system.
the
famfs_filemap_fault()path callsdax_iomap_fault()path (which I added to devdax in the new famfs mode, because it was in pmem but not devdax) always just updates a page table beause the page is always present. That means that the fault path is SUPER PERFORMANCE CRITICAL because in heavy use there can be millions of these faults per second - and with famfs there is NEVER EVER a read from storage to amortize the call overhead over.This is a super-important point.
famfs_filemap_fault()is a in thevm_operations_struct. It is called to remind the CPU where an address maps to, because the TLB and PTE had been purged (which happens ALL THE TIME).The ask here is to insert a BPF program as a vma fault handler. Can it work? Probably. Will it perform? I HAVE NO IDEA, BUT THERE ARE REASONS TO WORRY THAT IT MIGHT NOT.
I don't think this suggestion was made from a full understanding of the performance requirements of this code path.
This is why we need a discussion with
fs/mm/bpfexperts. We should be able to assemble an understanding of what the overhead of calling the BPF program are and how many nanoseconds (or microseconds) that could possibly add. Anything longer than the currentfamfs_filemap_fault()path is potentially disastrous because the whole point of famfs is to expose memory via files, and avoid sabotaging the performance.An L3 cache miss costs 100ns in round numbers on fast local DRAM, and 3-5x as long on switched disaggregated memory. We cannot afford an expensive code path resolving these mappings.
This is why, at the last two LSFMMs and in the famfs documentation, I said things like "we're exposing memory, and it must run at memory speeds".
Famfs also registers with the memory provider (devdax in famfs mode) to receive notifications of memory failures, and uses a '
holder_operations' pattern copied from pmem. This stuff is not in generic iomap (correct me if that's wrong).And finally since I've core dumped quite a bit here, I'll go ahead and add a thought experiment that *might* rule out using a BPF program as a vma fault handler. Could we do that with hugetlbfs without damaging performance for memory-intensive workloads? Hugetlbfs is a pretty solid stand-in for
famfs: it never does data-movement faults, it's never sparse, and it needs to resolve TLB/PTE/PMD/PUD faults FAST.Quoted 68 lines
That last sentence was an indirect way of saying: No, we're not going to export struct iomap to userspace. The fuse-iomap patchset provides all the UABI pieces we need for regular filesystems (ext4) and hardware adjacent filesystems (famfs) to exchange file mapping data with the kernel. This has been out for review since last October, but the lack of engagement with that patchset (or its February resubmission) doesn't leave me with confidence that any of it is going anywhere.
Note: The reason for bolting BPF atop fuse-iomap is so that famfs can upload bpf programs to generate interleaved mappings. It's not so hard to convert famfs' iomapping paths to use fuse-iomap, but I haven't helped him do that because:
a) I have no idea what Miklos' thoughts are about merging any of the famfs stuff.
b) I also have no idea what his thoughts are about fuse-iomap. The sparse replies are not encouraging.
c) It didn't seem fair to John to make him take on a whole new patchset dependency given (a) and (b).
d) Nobody ever replied to my reply to the LSFMM thread about "can we do some code review of fuse iomap without waiting three months for LSFMM?" I've literally done nothing with fuse-iomap for two of the three months requested.
Quoted 2 lines
Quoted 2 lines
So let us please at least have a try at this. I'm not into bpf yet, but willing to learn.
I sent out the patches to enable exactly this sort of experimentation two months ago, and have not received any responses:
I would like to say this as gently as possible: I don't know what the problem here is, Miklos -- are you uninterested in the work? Do you have too many other things to do inside RH that you can't talk about? Is it too difficult to figure out how the iomap stuff fits into the rest of the fuse codebase? Do you need help from the rest of us to get reviews done? Is there something else with which I could help?
Because ... over the past few years, many of my team's filesystem projects have endured monthslong review cycles and often fail to get merged. This has led to burnout and frustration among my teammates such that many of them chose to move on to other things. For the remaining people, it was very difficult to justify continuing headcount when progress on projects is so slow that individuals cannot achieve even one milestone per quarter on any project.
There's now nobody left here but me.
I'm not blaming you (Miklos) for any of this, but that is the current deplorable state of things.
Quoted 11 lines
Quoted 2 lines
Thanks,
MiklosThanks for responding...
My short response: Noooooooooo!!!!!!
I very strongly object to making this a prerequisite to merging. This is an untested idea that will certainly delay us by at least a couple of merge windows when products are shipping now, and the existing approach has been in circulation for a long time. It is TOO LATE!!!!!!
Quoted 8 lines
Quoted 5 lines
/me notes that has "we're shipping so you have to merge it over peoples' concerns" rarely carries the day in LKML land, and has never ended well in the few cases that it happens. As Ted is fond of saying, this is a team sport, not an individual effort. Unfortunately, to abuse your sports metaphor, we all play for the ******* A's.
That's totally fair. This process has been very long and grueling, and I'm not always thinking clearly.
I wish the peer review part were easier. It's stressful enough to get the darned thing to work the way you want it to and not do anything weird... and computers are generally better about that than they were in the 80s.
Quoted 57 lines
Quoted 57 lines
That said, you're clearly pissed at the goalposts changing yet again, and that's really not fair that we collectively keep moving them.
It's a rotten situation that I could have even helped you to solve both our problems via fuse-iomap, but I just couldn't motivate myself to entwine our two projects until the technical direction questions got answered.
Quoted 4 lines
Famfs is not a science project, it's enablement for actual products and early versions are available now!!!
That doesn't mean we couldn't convert later IF THERE ARE NO HIDDEN PROBLEMS.
Heck, the fuse command field is a u32. There are plenty of numberspace left, and the kernel can just *stop issuing them*.
Quoted 5 lines
What are the risks of converting to BPF?
- I don't know how to do it - so it'll be slow (kinda like my fuse learning curve cost about a year because this is not that similar to anything else that was already in fuse.
...and per above, BPF isn't some magic savior that avoids the expansion of the UABI.
Quoted 2 lines
- Those of us who are involved don't fully understand either the security or performance implications of this. It
Correct. I sure think it's swell that people can inject IR programs that jit/link into the kernel. Don't ask which secondary connotation of "swell" I'm talking about.
Quoted 6 lines
- Famfs is enabling access to memory and mapping fault handling must be at "memory speed". We know that BPF walks some data structures when a program executes. That exposes us to additional serialized L3 cache misses each time we service a mapping fault (any TLB & page table miss). This should be studied side-by-side with the existing approach under multiple loads before being adopted for production.
Yes, it should. AFAICT if one switched to a per-inode bpf program, then you could do per-inode bpf programs. Then you don't even need the bpf map, and the ->iomap_begin becomes an indirect call into JITted
x86_64math code.(The downside is that dyn code can't be meaningfully signed, requires clang on the system, and you have to deal with inode eviction issues.)
Quoted 3 lines
- This has never been done in production, and we're throwing it in the way of a project that has been soaking for years and needs to support early shipments of products.
Correct. I haven't even implemented BPF-iomap for fuse4fs. This BPF integration stuff is *highly* experimental code.
Quoted 2 lines
If this is the only path, I'd like to revive famfs as a standalone file system. I'm still maintaining that and it's still in use.
Quoted 8 lines
Quoted 5 lines
Honestly, you should probably just ship that to your users. As long as the ondisk format doesn't change much, switching the implementation at a later date is at least still possible.
--D
And apologies to the polite universe for being a bit raw earlier. Getting this far has been quite a grind...
Oh believe me, I had much angrier things to say elsewhere in 2023-24 about grueling slowass reviews. That is, indirectly, why I'm now working on /this/ project. :(
--D
Miklos Szeredi
maintainerQuoted 3 lines · Darrick J. Wong
Oh believe me, I had much angrier things to say elsewhere in 2023-24 about grueling slowass reviews. That is, indirectly, why I'm now working on /this/ project. :(
I've been there too. Which is not an excuse to be an unresponsive maintainer, but that's unfortunately exactly what seems to have happened.
On the positive side, I really appreciate the energy all of you put into improving fuse.
Some of the reasons for the lack of progress:
- Fuse has grown, and I don't have a full understanding of it, even some of the core. Getting older doesn't help, I'm sure I would've handled this better 20 years ago. Currently working on some cleanups, progress is slow, will post the next batch shortly. Cleaning it up helps in multiple ways: a) I get to know the code better, b) adding new stuff becomes easier.
- The fuse-iomap change is HUGE. By line count it's some 40% of current fuse code. By comparison, when fuse was merged it was 3.5kloc. It doesn't mean I wouldn't like to have it. On the contrary, I think it's a very useful feature and would solve the long time issue with having a way to mount untrusted fs images with reasonable performance.
- There's no such problem with famfs, it's relatively small and self contained and I'd consider it ready (barring any roadblocks on the DAX side). But the famfs specific mapping interface is something that I never did like. Joanne offered to fix this, and I totally agree with her that we should not hurriedly add interfaces that will need to be kept for ever (yes, sometimes even API's are deprecated and removed, but it's much much more painful).
How can this situation be improved?
A dedicated co-maintainer would definitely help, not sure how it would work out in the fuse case. With overlayfs I think it works nicely (at least that's my impression, not sure what Amir thinks ;)
My experience is that face to face discussions at LSFMM will also help move things forward.
Hope this helps.
Thanks,
Miklos
This is the first mail without annoying and pointless full quotes, so chiming in here. Sorry if I missed something important in all the noise.
Quoted 9 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary.
Yes, fuse needing support for a specific file systems sounds like a design mistake.
Quoted 4 lines
This was the main sticking point originally,
but there seemed to be no better alternative.However with the bpf approach this would be gone, which is great.
So what is this bpf magic actually trying to solve?
Quoted 19 lines · Christoph Hellwig
This is the first mail without annoying and pointless full quotes, so chiming in here. Sorry if I missed something important in all the noise.
Quoted 9 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary.
Yes, fuse needing support for a specific file systems sounds like a design mistake.
Quoted 6 lines
Quoted 4 lines
This was the main sticking point originally,
but there seemed to be no better alternative.However with the bpf approach this would be gone, which is great.
So what is this bpf magic actually trying to solve?
It is trying to avoid having famfs-specific implementation details hardcoded permanently into fuse's uapi and kernel code. I really like your suggestion of adding generic stride/offset multi-device support to fs/iomap. That is a much better solution than bpf.
Thanks,
Joanne
Quoted 1 line
Christian Brauner
maintainerQuoted 23 lines · Joanne Koong
Quoted 22 lines · Christoph Hellwig
This is the first mail without annoying and pointless full quotes, so chiming in here. Sorry if I missed something important in all the noise.
Quoted 9 lines · Miklos Szeredi
Quoted 4 lines · Joanne Koong
Overall, my intention with bringing this up is just to make sure we're at least aware of this alternative before anything is merged and permanent. If Miklos and you think we should land this series, then I'm on board with that.
TBH, I'd prefer not to add the famfs specific mapping interface if not absolutely necessary.
Yes, fuse needing support for a specific file systems sounds like a design mistake.
Quoted 3 lines
This was the main sticking point originally,
but there seemed to be no better alternative.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
However with the bpf approach this would be gone, which is great.
So what is this bpf magic actually trying to solve?
It is trying to avoid having famfs-specific implementation details hardcoded permanently into fuse's uapi and kernel code. I really like your suggestion of adding generic stride/offset multi-device support to fs/iomap. That is a much better solution than bpf.
If you go down the bpf route you will just have to use bpf hashmaps to associate the blobs that you need with the relevant data structure and then activate it from whatever hook you need. There's now very flexible hashmap storage that you can autoresize - or you can use bpf arenas. There's a ton of options that don't require modifying core structures.
IOW, I don't want dedicated bpf storage in struct inode. Not just because bpf people consider dedicated blob storage in kernel structures obsolete and recommend to use hashmaps - which is e.g., what I use for another project of mine where I associate metadata with block devices - but also because I very much disagree with bloating generic infra.
Hi John,
I started to do reviews based on design documents for new features. I think in general it is rather hard for humans to kind of reverse engineer the design from the patch series. With AI it got easier, but still should be verified by the author. Could you check if the attached AI generated document is correct?
Thanks,
Bernd
================================================================================
famfs (FUSE-based fabric-attached memory file system) - Design Document
================================================================================
Audience and scope
==================
This document is written for people already familiar with FUSE (lowlevel ops, opcodes, INIT capability negotiation) but NOT necessarily with Linux DAX, devdax, or the kernel's iomap framework. Section 2 is a primer on those.
It covers two trees:
Kernel: /home/bernd/src/linux/linux.git , branch famfs,
commits 4a8ae428c392 .. HEAD (da9edf77cbc4)
libfuse: /home/bernd/src/libfuse/libfuse.git , branch famfs,
commits d75ae2ee .. HEAD (9c65d781)
Kernel files added or changed:
fs/fuse/famfs.c - new, all famfs kernel logic
fs/fuse/famfs_kfmap.h - new, in-memory fmap structures
fs/fuse/fuse_i.h - per-inode/per-conn famfs additions, helpers
fs/fuse/file.c - r/w/mmap dispatch into famfs paths
fs/fuse/inode.c - INIT-flag negotiation, conn teardown wiring
fs/fuse/iomode.c - bypass io-modes for famfs files
fs/fuse/Kconfig, Makefile - new CONFIG_FUSE_FAMFS_DAX
include/uapi/linux/fuse.h - new opcodes, structs, FUSE_DAX_FMAP flag
fs/namei.c - export may_open_dev() Documentation/filesystems/famfs.rst - user/admin documentation
libfuse files added or changed:
include/fuse_kernel.h - mirror of kernel uapi at protocol 7.46
include/fuse_common.h - new FUSE_CAP_DAX_FMAP capability bit
include/fuse_lowlevel.h - new ops: get_fmap(), get_daxdev()
lib/fuse_lowlevel.c - INIT negotiation + opcode dispatch (do_get_fmap, do_get_daxdev)
--------------------------------------------------------------------------------
1. Background and goals
--------------------------------------------------------------------------------
Famfs exposes shared, fabric-attached memory (CXL devdax) as a regular filesystem. The fast path (read/write/mmap-fault) must reach memory without a round trip to the FUSE server: the server only delivers metadata.
Two key observations shape the design:
* Files are NEVER allocated in the kernel. Userspace pre-allocates extents and gives the kernel an "fmap" (file-to-dax-offset map).
* There is NO writeback. Backing memory is the storage; CPU caches are loaded directly from the dax memory.
Consequences in the kernel:
* No page cache is used. noop_dirty_folio is the only address_space op.
* The kernel never grows or shrinks files. Any size change (including truncate) puts the file into an "error" state.
* Reads/writes/mmap dispatch through dax_iomap_*() and the famfs iomap_ops, exactly the way fs-dax filesystems (xfs/ext4) plumb them.
Comparison to other FUSE modes that you may know:
classic FUSE - every read/write/mmap is forwarded to the server.
virtio-fs DAX - the server donates a window of host memory; kernel maps
file ranges into that window via FUSE_SETUPMAPPING / FUSE_REMOVEMAPPING. The server is still the "owner" of the backing memory.
famfs (this) - the server hands the kernel a description of where each
file's bytes live on a real character device (devdax). After that, the server is OUT of the data path entirely.
--------------------------------------------------------------------------------
2. Primer: devdax, DAX and iomap (only what's needed below)
--------------------------------------------------------------------------------
You can skip this section if "iomap_begin", "dax_iomap_rw" and "devdax holder" already mean something to you.
devdax
A character device (/dev/daxN.M) that exposes a contiguous range of physical memory directly to userspace via mmap. There is no page cache and no block device underneath; reads and writes hit RAM/CXL memory directly. Famfs uses devdax devices as its "disks".
DAX (Direct Access)
A kernel pathway that lets a filesystem map file pages straight onto the underlying memory pages (PFNs) without going through the page cache. A file/inode tagged with S_DAX opts in. Reads turn into memcpy from the memory; mmap faults install the memory's PFN directly into the page table (PTE/PMD/PUD).
iomap
A filesystem-agnostic mechanism that says "to do this read/write/fault on this file at this offset and length, here is exactly which device, which device-relative offset, and how many bytes are valid here." Filesystems implement struct iomap_ops, of which the central callback is:
.iomap_begin(inode, file_offset, length, flags,
struct iomap *out, struct iomap *srcmap)
The filesystem fills out with:
out->dax_dev - which DAX device backs this range
out->addr - byte offset within that DAX device
out->offset - file offset (echoed back)
out->length - how many contiguous bytes are valid here
out->type - IOMAP_MAPPED (famfs only ever returns this)
The DAX core then loops, calling iomap_begin repeatedly to walk the requested range and, for each chunk, doing either:
- memcpy to/from dax_dev + addr (read/write)
- or installing the PFN at dax_dev + addr into a page table (faults)
Entry points the famfs code uses:
dax_iomap_rw(iocb, iter, ops) - read/write
dax_iomap_fault(vmf, order, ..., ops) - mmap PTE/PMD/PUD fault
dax holder
DAX devices have a single "holder" - a struct (here struct fuse_conn *) that owns the device. Acquired via fs_dax_get(devp, holder, holder_ops), released via fs_put_dax(devp, holder). The holder gets called back via holder_ops->notify_failure() when the device reports memory poison.
That is the entire iomap-related vocabulary used in this document.
--------------------------------------------------------------------------------
3. Major kernel data structures
--------------------------------------------------------------------------------
(a) fuse_conn additions (fs/fuse/fuse_i.h):
struct fuse_conn {
...
unsigned int famfs_iomap : 1; /* negotiated at INIT */
struct rw_semaphore famfs_devlist_sem; /* protects dax_devlist */
struct famfs_dax_devlist *dax_devlist; /* table of daxdevs */
};
(b) fuse_inode additions:
struct fuse_inode {
...
void *famfs_meta; /* struct famfs_file_meta *, NULL if not famfs */
};
A non-NULL `famfs_meta` is the marker for "this is a famfs file";
`fuse_file_famfs(fi)` is just `READ_ONCE(fi->famfs_meta) != NULL`.(c) Per-file metadata - struct famfs_file_meta (famfs_kfmap.h):
+------------------------------------------------------+
| struct famfs_file_meta |
| bool error |
| enum famfs_file_type file_type |
| size_t file_size |
| enum famfs_extent_type fm_extent_type |
| u64 dev_bitmap |
| union { |
| SIMPLE: |
| size_t fm_nextents |
| struct famfs_meta_simple_ext *se |
| INTERLEAVED: |
| size_t fm_niext |
| struct famfs_meta_interleaved_ext *ie |
| } |
+------------------------------------------------------+ Simple extent: (dev_index, ext_offset, ext_len)
Interleaved extent: (nstrips, chunk_size, nbytes, strips[])
where each strip is a simple extent.
(d) Per-conn dax device table:
+-------------------------+ +------------------------------+
| famfs_dax_devlist | | famfs_daxdev[MAX_DAXDEVS=24] |
| nslots = MAX_DAXDEVS |----->| |
| ndevs | | [0] valid? devp, devno, ... |
| devlist *-------------| | [1] valid? devp, devno, ... |
+-------------------------+ | ... |
+------------------------------+ famfs_daxdev fields:
valid - slot has been populated (after wmb)
error - dax notify_failure() arrived (poison)
dax_err - fs_dax_get() failed; cannot be used
devno, devp - dev_t and dax_device pointer
name - chrdev pathname for diagnostics
--------------------------------------------------------------------------------
4. Capability negotiation (FUSE INIT)
--------------------------------------------------------------------------------
The wire-level capability is FUSE_DAX_FMAP (bit 43 in the 64-bit flags field, protocol 7.46). Both ends must advertise it in INIT for the kernel to enable famfs.
Kernel FUSE server (libfuse)
------ ---------------------
fuse_new_init():
flags |= FUSE_DAX_FMAP -- if capable(CAP_SYS_RAWIO)
----------- FUSE_INIT (in) --------->
libfuse _do_init():
if (inargflags &
FUSE_DAX_FMAP)
conn.capable_ext |=
FUSE_CAP_DAX_FMAP
server's init_done CB
sets:
conn.want_ext |=
FUSE_CAP_DAX_FMAP
libfuse converts that
back to FUSE_DAX_FMAP
in outargflags
<----------- FUSE_INIT (out) ----------
process_init_reply():
if reply.flags & FUSE_DAX_FMAP &&
in.flags also had FUSE_DAX_FMAP:
famfs_init_devlist_sem(fc)
fc->famfs_iomap = 1Both directions must agree. The kernel re-checks the flag in in.flags on the reply path because process_init_reply() does not run in the server's task context, so capable() cannot be re-evaluated then; the bit on the way OUT asserts "the user that mounted us had CAP_SYS_RAWIO".
Kernel file: fs/fuse/inode.c (fuse_new_init, process_init_reply) libfuse file: lib/fuse_lowlevel.c (_do_init)
--------------------------------------------------------------------------------
5. libfuse server-side surface
--------------------------------------------------------------------------------
This is the userspace API a famfs server is expected to implement on top of libfuse's lowlevel API. From a FUSE-developer point of view this is the familiar pattern: two new opcodes, two new callbacks instruct fuse_lowlevel_ops, and a new capability bit.
5.1 Capability bit (include/fuse_common.h)
#define FUSE_CAP_DAX_FMAP (1UL << 32)
This sits in the *extended* capability fields want_ext / capable_ext, not the legacy 32-bit want / capable, because bit 32 is past the end of the original word.
5.2 New lowlevel callbacks (include/fuse_lowlevel.h)
struct fuse_lowlevel_ops {
...
/* Reply: serialized fuse_famfs_fmap_header followed by extents */
void (*get_fmap) (fuse_req_t req, fuse_ino_t ino, size_t size);
/* Reply: serialized fuse_daxdev_out (mainly: char name[256]) */
void (*get_daxdev) (fuse_req_t req, int daxdev_index);
}; Conventional libfuse semantics apply:
- The callback may reply asynchronously.
- Valid completions: fuse_reply_buf() with the serialized response, or fuse_reply_err(req, errno) on failure.
- If the server does not provide either op, libfuse replies with -EOPNOTSUPP automatically.
5.3 Opcode dispatch (lib/fuse_lowlevel.c)
Two entries are added to libfuse's opcode dispatch table:
[FUSE_GET_FMAP] = { do_get_fmap, "GET_FMAP" },
[FUSE_GET_DAXDEV] = { do_get_daxdev, "GET_DAXDEV" }, do_get_fmap:
reads inarg as struct fuse_getxattr_in*, extracts arg->size (the kernel's hint for the maximum reply size it can accept), forwards (req, ino, size) to op.get_fmap. The size is currently fixed at PAGE_SIZE on the kernel side (FMAP_BUFSIZE); a larger variable-size reply protocol is a future TODO.
do_get_daxdev:
ignores inarg. The kernel encodes the device index in nodeid (FUSE_GET_DAXDEV uses nodeid as a small integer, not a real inode), and libfuse forwards it as daxdev_index to op.get_daxdev.
5.4 Wire formats the server must produce
Defined in include/fuse_kernel.h (libfuse's mirror of the kernel uapi):
struct fuse_famfs_fmap_header {
uint8_t file_type; /* enum fuse_famfs_file_type */
uint8_t reserved;
uint16_t fmap_version; /* FAMFS_FMAP_VERSION = 1 */
uint32_t ext_type; /* SIMPLE or INTERLEAVE */
uint32_t nextents;
uint32_t reserved0;
uint64_t file_size;
uint64_t reserved1;
};
struct fuse_famfs_simple_ext {
uint32_t se_devindex; /* index into the per-mount daxdev table */
uint32_t reserved;
uint64_t se_offset; /* PMD-aligned offset in that daxdev */
uint64_t se_len; /* PMD-aligned length */
};
struct fuse_famfs_iext { /* one interleaved extent */
uint32_t ie_nstrips;
uint32_t ie_chunk_size; /* PMD-aligned */
uint64_t ie_nbytes; /* total bytes covered by this extent */
uint64_t reserved;
};
struct fuse_daxdev_out {
uint16_t index;
uint16_t reserved;
uint32_t reserved2;
uint64_t reserved3;
uint64_t reserved4;
char name[256]; /* "/dev/daxN.M" */
}; GET_FMAP reply layout in the buffer (fmap_header followed by extents):
SIMPLE: [ fmap_header ][ simple_ext * nextents ]
INTERLEAVE: [ fmap_header ][ iext, simple_ext*nstrips,
iext, simple_ext*nstrips, ... ]
where there are nextents (iext + its strips) groups.
Alignment rules the server MUST honor (else the kernel rejects the fmap):
* fmap_version == 1
* 1 <= nextents <= FUSE_FAMFS_MAX_EXTENTS (32)
* For each strip extent: ext_offset and ext_len PMD-aligned (2 MiB)
* For interleaved: chunk_size PMD-aligned, nstrips in [1, 32]
* sum of extent lengths >= file_size
GET_DAXDEV reply: a single fuse_daxdev_out where name is the path of a character device that the kernel can kern_path() to a devdax inode.
5.5 What the server is responsible for
In the famfs design, the libfuse-based server still owns:
* Looking up files in the famfs metadata log (or whatever backend userspace uses to track allocations).
* Producing fmaps that exactly describe the file's allocation.
* Producing the "/dev/daxN.M" path for each daxdev index it has used in any fmap.
* All conventional FUSE ops: lookup, getattr, mkdir, unlink, etc.
The server is NOT in the path of any read/write/mmap once the fmap has been delivered. There is no equivalent of FUSE_READ / FUSE_WRITE traffic for famfs files.
--------------------------------------------------------------------------------
6. Open flow - GET_FMAP and (lazy) GET_DAXDEV
--------------------------------------------------------------------------------
When a regular file is opened on a famfs-enabled connection, the kernel pulls the file's fmap from the server, parses it, resolves any unknown daxdev indices via GET_DAXDEV, and installs the result on the inode.
fuse_open(inode, file) [fs/fuse/file.c]
|
+-- fuse_do_open() (regular FUSE open)
|
+-- if (fc->famfs_iomap && S_ISREG)
| fuse_get_fmap(fm, inode) [famfs.c]
| |
| +-- alloc fmap_buf (PAGE_SIZE)
| |
| +-- args.opcode = FUSE_GET_FMAP
| | args.nodeid = ino
| | args.out_argvar = true (variable-size reply)
| +-- fuse_simple_request(fm, &args) ----> server returns
| | fuse_famfs_fmap_header
| | + extents
| +-- famfs_file_init_dax(fm, inode, fmap_buf, fmap_size)
| |
| +-- famfs_fuse_meta_alloc()
| | parses header + extents into struct famfs_file_meta;
| | accumulates meta->dev_bitmap of referenced devindices;
| | validates PMD alignment + total size >= file_size;
| | cmpxchg-installs *metap (race-safe)
| |
| +-- famfs_update_daxdev_table(fm, meta)
| | if (!fc->dax_devlist) cmpxchg-allocate it
| | under famfs_devlist_sem (read):
| | collect indices that are NOT yet ->valid
| | drop lock, then for each index:
| | famfs_fuse_get_daxdev(fm, idx) <see below>
| |
| +-- inode_lock(inode)
| | famfs_meta_set(fi, meta) (cmpxchg, NULL=>meta)
| | if installed: i_size_write, S_DAX, a_ops=famfs_dax_aops
| | inode_unlock(inode)
|
+-- fuse_finish_open(inode, file)
+-- skip page cache invalidation if fuse_file_famfs(fi)
GET_DAXDEV per-index flow:
famfs_fuse_get_daxdev(fm, index):
args.opcode = FUSE_GET_DAXDEV
args.nodeid = index
fuse_simple_request() -----> server returns fuse_daxdev_out{.name = "/dev/daxX.Y"}
under famfs_devlist_sem (write):
if dd->valid: return /* lost race; OK */
famfs_verify_daxdev(name, &dd->devno):
kern_path() + d_backing_inode() + S_ISCHR
may_open_dev() /* exported in fs/namei.c */
dd->devno = inode->i_rdev
dd->name = kstrdup(name)
dd->devp = dax_dev_get(devno)
fs_dax_get(devp, fc, &famfs_fuse_dax_holder_ops)
on failure: dd->dax_err = 1 /* still mark valid */
wmb()
dd->valid = 1--------------------------------------------------------------------------------
7. iomap interaction - the central design point
--------------------------------------------------------------------------------
famfs implements only .iomap_begin. There is no .iomap_end because there is no allocation, dirty tracking, or completion bookkeeping.
const struct iomap_ops famfs_iomap_ops = {
.iomap_begin = famfs_fuse_iomap_begin,
};The dax core (fs/dax.c) calls into famfs_iomap_ops from three entry points:
dax_iomap_rw(iocb, iter, ops) -- read_iter / write_iter
dax_iomap_fault(vmf, order, ...) -- mmap PTE/PMD/PUD faults
For the iomap concepts used here, see the primer in section 2.
7.1 read/write path
fuse_file_read_iter(iocb, to) [fs/fuse/file.c]
if (fuse_file_famfs(fi))
return famfs_fuse_read_iter(iocb, to); [famfs.c]
famfs_fuse_read_iter:
famfs_fuse_rw_prep(iocb, to):
famfs_file_bad(inode)? -> -EIO/-ENXIO
truncate iter to (i_size - ki_pos)
dax_iomap_rw(iocb, to, &famfs_iomap_ops) ===>
+-- repeatedly:
| iomap_begin(...)
| memcpy_from_pmem/to
| advance position
+-- returns bytes copied famfs_fuse_write_iter is symmetric (no FOPEN_DIRECT_IO / passthrough fork; splice paths return -EIO since famfs has no page cache).
7.2 mmap path
fuse_file_mmap(file, vma) [fs/fuse/file.c]
if (fuse_file_famfs(fi))
return famfs_fuse_mmap(file, vma); famfs_fuse_mmap:
famfs_file_bad(inode)
vma->vm_ops = &famfs_file_vm_ops
vm_flags_set(vma, VM_HUGEPAGE) /* prefer 2MiB faults */
famfs_file_vm_ops:
.fault = famfs_filemap_fault (PTE)
.huge_fault = famfs_filemap_huge_fault (PMD/PUD)
.map_pages = filemap_map_pages
.page_mkwrite = famfs_filemap_mkwrite
.pfn_mkwrite = famfs_filemap_mkwrite7.3 fault handler dispatch
__famfs_fuse_filemap_fault(vmf, pe_size, write_fault):
if (!IS_DAX(inode)) return SIGBUS
if (write_fault) sb_start_pagefault, file_update_time ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &famfs_iomap_ops)
|
+-- internally calls famfs_fuse_iomap_begin to learn (dax_dev,
offset, length), then maps the resolved PFN into the VMA.
if (ret & VM_FAULT_NEEDDSYNC) ret = dax_finish_sync_fault(...)
7.4 iomap_begin - the resolver
famfs_fuse_iomap_begin(inode, offset, length, flags, iomap, srcmap)
meta = fi->famfs_meta
WARN_ON(i_size != meta->file_size)
return famfs_fileofs_to_daxofs(inode, iomap, offset, length, flags) famfs_fileofs_to_daxofs (SIMPLE case):
validate dax_devlist + famfs_file_bad
walk meta->se[0..fm_nextents-1]:
if local_offset < se[i].ext_len:
dd = devlist[se[i].dev_index]
famfs_dax_err(dd) -> if errored, set meta->error and return
iomap->addr = se[i].ext_offset + local_offset
iomap->offset = file_offset
iomap->length = min(len, ext_len - local_offset)
iomap->dax_dev= dd->devp
iomap->type = IOMAP_MAPPED
return 0
local_offset -= se[i].ext_len
fall-through: zero-length iomap, return -EIO famfs_fileofs_to_daxofs delegates to famfs_interleave_fileofs_to_daxofs for INTERLEAVED_EXTENT (see section 6).
7.5 The full iomap call graph
user process fs/fuse/famfs.c fs/dax.c
------------ ---------------- --------
read(2)/write(2)
|
v
fuse_file_read_iter / write_iter (file.c)
|
+--> famfs_fuse_{read,write}_iter
|
+--> famfs_fuse_rw_prep (sanity, truncate to i_size)
|
+--> dax_iomap_rw -----------------> iter loop
|
v
iomap_iter()
|
+--> .iomap_begin <----+
| famfs_fuse_iomap_begin
| \ |
| famfs_fileofs_to_daxofs
| [+ interleave variant]
| \
| fc->dax_devlist[idx]
| dd->devp / ext_offset
| /
+--> dax_iomap_iter()
memcpy via dax_direct_access
on iomap->dax_dev / iomap->addr
page fault on mmap region
|
v
.fault / .huge_fault (famfs_file_vm_ops)
|
+--> __famfs_fuse_filemap_fault
|
+--> dax_iomap_fault(vmf, order, ..., &famfs_iomap_ops)
|
+--> .iomap_begin
| famfs_fuse_iomap_begin
| (resolves dax_dev + offset)
+--> dax_insert_pfn / vmf_insert_pfn_pmd--------------------------------------------------------------------------------
8. Interleaved (striped) extents
--------------------------------------------------------------------------------
An interleaved extent stripes a contiguous logical region across N strips on N (typically distinct) dax devices, in fixed-size chunks.
ie_nstrips = N
ie_chunk_size = C (must be PMD-aligned)
ie_nbytes = total logical bytes coveredLogical layout (N=4):
file offset: [0 C ][C 2C][2C 3C][3C 4C][4C ...
| strip 0 | strip 1 | strip 2 | strip 3 | strip 0 ...
| stripe 0 | stripe 0 | stripe 0 | stripe 0 | stripe 1... Resolution arithmetic in famfs_interleave_fileofs_to_daxofs():
chunk_num = local_offset / chunk_size
chunk_offset = local_offset % chunk_size
chunk_remainder = chunk_size - chunk_offset
stripe_num = chunk_num / nstrips
strip_num = chunk_num % nstrips
strip_offset = chunk_offset + stripe_num * chunk_size
iomap->addr = ie_strips[strip_num].ext_offset + strip_offset
iomap->dax_dev = devlist[ie_strips[strip_num].dev_index].devp
iomap->length = min(len, chunk_remainder)
iomap->type = IOMAP_MAPPED
The length is capped at chunk_remainder so the next iomap iteration steps to the next chunk (which usually lives on a different device).
--------------------------------------------------------------------------------
9. Memory-error / failure handling
--------------------------------------------------------------------------------
A famfs file becomes unusable when any one of three conditions is true. They are checked on every read/write/fault by famfs_file_bad() and famfs_dax_err().
Source of error Effect Surface --------------- ------ ------- fs_dax_get() fails dd->dax_err = 1 famfs_dax_err -> -EIO notify_failure() upcall dd->error = true famfs_dax_err -> -EHWPOISON i_size != meta->file_size meta->error = true famfs_file_bad -> -ENXIO IS_DAX(inode) cleared (size change, etc.) famfs_file_bad -> -ENXIO
notify_failure() flow:
devdax layer detects poison / reconfig
|
v
dax_holder_ops->notify_failure(dax_devp, offset, len, mf_flags)
= famfs_dax_notify_failure
fc = dax_holder(dax_devp)
famfs_set_daxdev_err(fc, dax_devp):
under famfs_devlist_sem (write):
find slot whose dd->devp == dax_devp
dd->error = true
pr_err On the next iomap_begin, famfs_dax_err sees dd->error and returns -EHWPOISON; meta->error is also set on that file so subsequent accesses short-circuit via famfs_file_bad without touching dax.
--------------------------------------------------------------------------------
10. Lifetime / teardown
--------------------------------------------------------------------------------
Per-inode:
fuse_alloc_inode (inode.c)
famfs_meta_set(fi, NULL) (init)
fuse_free_inode (inode.c)
if (S_ISREG && fuse_file_famfs(fi))
famfs_meta_free(fi)
-> __famfs_meta_free: frees se/ie arrays + struct
fuse_evict_inode
if (FUSE_IS_VIRTIO_DAX || fuse_file_famfs)
dax_break_layout_final(inode) (stop ongoing dax mappings)Per-connection:
fuse_conn_put -> famfs_teardown(fc):
for each valid slot:
if dd->devp:
if (!dd->dax_err) fs_put_dax(dd->devp, fc) /* drop holder */
put_dax(dd->devp)
kfree(dd->name)
kfree(devlist->devlist)
kfree(devlist)--------------------------------------------------------------------------------
11. Concurrency model
--------------------------------------------------------------------------------
fc->famfs_devlist_sem (rw_semaphore)
readers : iomap_begin paths reading devlist[idx]
famfs_update_daxdev_table while collecting "missing" indices
writers : famfs_fuse_get_daxdev (populating a slot)
famfs_set_daxdev_err (notify_failure)
cmpxchg pairs (NULL -> ptr installation, race-tolerant):
fc->dax_devlist (first-time allocation)
fi->famfs_meta (first GET_FMAP wins, others freed) wmb() before dd->valid=1 ensures readers that observe valid see fully initialized name/devp/devno fields.
--------------------------------------------------------------------------------
12. End-to-end timeline (read on a freshly opened famfs file)
--------------------------------------------------------------------------------
The "fuse server" column is whatever process is using libfuse (with op.get_fmap / op.get_daxdev populated as in section 5).
app fuse/famfs (kernel) fuse server
--- ------------------- -----------
open("/mnt/famfs/x") |
----- VFS open -----> fuse_open |
fuse_do_open ----- OPEN -----> handles
<---- ok --------|
fuse_get_fmap |
- GET_FMAP ----->|
<- fmap reply ---|
famfs_fuse_meta_alloc |
famfs_update_daxdev_table |
[new device idx] |
- GET_DAXDEV --->|
<- daxdev reply -|
dax_dev_get + fs_dax_get |
dd->valid = 1 |
famfs_meta_set(fi, meta) |
inode->i_flags |= S_DAX |
i_data.a_ops = famfs_dax_aops |
<----- fd ------------ |
read(fd, buf, len) |
----- VFS read ----> fuse_file_read_iter |
famfs_fuse_read_iter |
famfs_fuse_rw_prep |
dax_iomap_rw |
.iomap_begin -> |
famfs_fuse_iomap_begin |
famfs_fileofs_to_daxofs |
-> iomap{dax_dev, addr} |
memcpy from dax memory |
<---- bytes ---------- |
| <-- no upcall on fast path
munmap / close
----- VFS release -> fuse_release ----- RELEASE ---> |
<---- ok --------|
unmount
----- umount ------> fuse_conn_put |
famfs_teardown |
fs_put_dax / put_dax all dd's |--------------------------------------------------------------------------------
13. What deliberately is NOT in the kernel
--------------------------------------------------------------------------------
* Allocation and metadata mutation: handled in userspace; the kernel only consumes fmaps as opaque-but-versioned blobs.
* Page cache and writeback: famfs_dax_aops is exclusively noop_dirty_folio.
* Truncate / append: any size change marks the file errored; recovery is a userspace responsibility (typically: re-replay the famfs metadata log).
* fallocate / hole handling: files are never sparse and never have holes, so iomap_begin only ever returns IOMAP_MAPPED (or zero-length on EOF).
* io-modes (FUSE_OPEN_*): bypassed for famfs files in iomode.c since everything is direct-to-dax.
--------------------------------------------------------------------------------
14. Commit-by-commit map back to this design
--------------------------------------------------------------------------------
14.1 Kernel (linux.git, branch famfs)
ac071fbd94a6 Basic fuse kernel ABI -> Section 4 (negotiation),
CONFIG_FUSE_FAMFS_DAX,
fc->famfs_iomap bit
9a06500c1e0f Plumb GET_FMAP message/response -> Section 6 (fuse_get_fmap,
fuse_open hook)
6f4e03a4e8e9 Create files with famfs fmaps -> Section 3 (famfs_file_meta),
Section 6 (famfs_file_init_dax,
famfs_fuse_meta_alloc)
dfc9e12bcb99 GET_DAXDEV msg + daxdev_table -> Section 3 (famfs_dax_devlist),
Section 6.GET_DAXDEV,
famfs_teardown
d79f803dbfd1 Plumb dax iomap + r/w/mmap -> Section 7 (iomap_ops, fault,
rw paths) and Section 8
(interleave resolver)
8731eb03c762 holder_ops for notify_failure() -> Section 9 (memory errors)
6ea21f89b361 DAX address_space_operations -> Section 1 / famfs_dax_aops
fae4d807da34 fmap metadata documentation -> kernel header comment in famfs_kfmap.h (Section 8)
da9edf77cbc4 Documentation/filesystems/famfs -> user-facing docs
14.2 libfuse (libfuse.git, branch famfs)
d75ae2ee fuse_kernel.h: bring up to baseline 6.19
Mechanical sync of include/fuse_kernel.h with the kernel uapi up to 7.45 (everything BEFORE famfs). No new functionality; this is the baseline the famfs commits build on.
e87be376 fuse_kernel.h: add famfs DAX fmap protocol definitions
Adds protocol 7.46:
* FUSE_DAX_FMAP capability bit
* FUSE_GET_FMAP / FUSE_GET_DAXDEV opcodes
* struct fuse_famfs_fmap_header / simple_ext / iext
* struct fuse_get_daxdev_in / fuse_daxdev_out
* enum fuse_famfs_file_type / famfs_ext_type
Pure header; mirrors include/uapi/linux/fuse.h on the kernel. -> Section 5.4 (wire formats).
0b16c7d8 fuse: add famfs DAX fmap support
Wires the protocol into the libfuse lowlevel API:
* include/fuse_common.h: FUSE_CAP_DAX_FMAP (1UL << 32)
* include/fuse_lowlevel.h: op.get_fmap, op.get_daxdev
* lib/fuse_lowlevel.c:
- INIT: capable_ext / want_ext <-> FUSE_DAX_FMAP
- dispatch table entries for GET_FMAP / GET_DAXDEV
- do_get_fmap / do_get_daxdev forward to op callbacks
-> Section 4 (capability), Section 5.1-5.3 (libfuse API),
Section 5.5 (server responsibilities).
d1e6135c build(deps): bump github/codeql-action ... (CI; not relevant) fa03307c doc: replace "futur irrealis"-like tense ... (man pages; not relevant) 9c65d781 Merge branch 'master' into famfs-6.19 (merge commit)
================================================================================
End of document.
================================================================================