From nobody Mon Feb 9 16:17:36 2026 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63BB839449B for ; Wed, 7 Jan 2026 15:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800065; cv=none; b=fKZxM5hsN+zkoysGspzChnKGuNQ/+OHnzq3iPcrE6ZdzIjuL7TqsQjiVx0yx63REbqBA3pHuVcO19ZKNYpc9YKow1V6CT4mFxdnAh11gV4sYTRZ3P1wn8Vfc7F8O+AgKAJJGO0ySrf5B6r431PX0GYMooSAwCrIjEh3lknYKhhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800065; c=relaxed/simple; bh=PCnUhHjPjtOchfmyY/COLS4ltzYEGwOIYlwWEM8c7sc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ca3Znm1jW7iqr+E+aKla3B7fbwkahRxWnBXG5Gev04JMMuwuxZP3Aw6WhYfGEEFNtrQ0iHkysGshaSNr+S4AxXOkqQ9sJh1zEghRNTmehncPtWb8adehXnX2WqR2n5QpYd1ZYCfg7cw7qEk13rY+PWY9S9NMtxxZy6pAZ8ZFtAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KjG555wt; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KjG555wt" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-455bef556a8so1445560b6e.1 for ; Wed, 07 Jan 2026 07:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767800061; x=1768404861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=GtZa5/+fDcb2v1caKx2aWM14flK3GsHU5CozFLRvBAM=; b=KjG555wtAlNSH05hSqF1h+h9VXHwSKBp7/8X+M1k57h/N/I3tBXyStzNjm4tFHUYrC tjFFIk6K5PjAbjXNvWqDPjFb2tAbRrXOuuUoJT7aJpDC76cT8KxxB49DLuzpkQnrotzp 6GgMc8pNG6WxoapSyJgYsuYggjbYhOtWocAOoo0p8bOr1gIw1km2lUm6D8VKKNIWSRSG kSM+Ed6qb4kWjyr82KpXOIHo7HqOHpDSQ4CsF8Dawfhqbo4Garn3Gnpqwwoee9jSRzuJ BefrFjoVDWjQmURHlSir3gd7p/OO9JMAQelMkhUQdhqfLlS/frnpecVTijWBA8Ze1Y4e xOEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767800061; x=1768404861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GtZa5/+fDcb2v1caKx2aWM14flK3GsHU5CozFLRvBAM=; b=i0rXjrMsh8m06Onkml2NeQW6M49FajszdkFhWC6apfbkXGuyN/oqqH/BAOYfHPpxda DgaWznOBhNjEKhfdJ+NzanVgIB5dqwWM3lqEKdfBNjNg1+CWArBJygWV2cZXRDUCBbRV +zVJfuHfCkoPKZBrAD5GrzoJ90OiCoRWAbMPHpce0srsnXP0CC3WqhC+U0ovoQjsL6LP pvYJBK3vhes0TYSD4/u1ZSkGsCjYu6PkEKfZwQNa47J7ZIkP6LazZE1+s0kyK56hF09v On04VykqUgSWqQlq0eAXyBkrpfwM27JzH5cglHXHzDTYeUj8lVM3UAUgE9dHyDpYjFow b3qw== X-Forwarded-Encrypted: i=1; AJvYcCUIUR2ptVNnAd8wSDbQR1DdW1NXsZDMdAbMW5FEimY5yyE5z5Xw7osHPPkmwQLA54Tue8ThWr0c4O0ls2w=@vger.kernel.org X-Gm-Message-State: AOJu0YxPpryf9Q6fM/D6Kg9R0RR8OqIYD+MU6G4mZ+QEsHrf1gxWWwYO BN//sf6CnsesYwCQ0o8HcslXy7zmD0Hn04TD9CVMY/lKKxsUvQrwFqxB X-Gm-Gg: AY/fxX4sg6HAU2d1EPBTwyo/BMtmnwSPtnnmzBAUybHDH31QngR7LdF8Fch90Jx/Jx3 UlFk/DX3HFHZXD9CmjqawasfxhzNoe2+DhP9PdLxSx4puyhQLgEL2LkxAugXSQ6bvDm30/7sTXP uizFaAWEo7TZbBy6kwWuRW12JhjKREJ8y3GdP/LIMvfokMtPpH9JIhIpUj7u6Eeo0gi74HJUNYQ M8Noa77R465/vzFb8A/RRuukINVfkkAkYc0WKzRuvvs/gyy05CLg2m0WzCYo+MVfU02ZZmOsO5K ckFfI0B+DHvraM+Fyo0AQ9AIhtcO7QfInk1ZwTGKlNe6gS3zUKb5UAZqcqeA56MP4Yorc8YqTnV t4leDk6mfj+I9KTqkX6cgAgLmIKmTLlvnIEtYupw4677h6weAYHL//qKKpuDp82bAa/GMtJpH6q eMyYjZBPMs8a5qPKv5ieEL2TCWnMuz1jEDFQEZLy6xSmeh X-Google-Smtp-Source: AGHT+IHwCw+2kouS0gewRU1M+KsK1d+ZYKglvGvcMRJpE25Q1Aws6HPVpW7a/OLQu64TjuYD5OcbVw== X-Received: by 2002:a05:6808:5192:b0:459:b40f:8404 with SMTP id 5614622812f47-45a6bd3d92fmr1103755b6e.29.1767800061183; Wed, 07 Jan 2026 07:34:21 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:a917:5124:7300:7cef]) by smtp.gmail.com with ESMTPSA id 5614622812f47-45a5e2f1de5sm2398106b6e.22.2026.01.07.07.34.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 07 Jan 2026 07:34:20 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Miklos Szeredi , Dan Williams , Bernd Schubert , Alison Schofield Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , David Hildenbrand , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Bagas Sanjaya , Chen Linxuan , James Morse , Fuad Tabba , Sean Christopherson , Shivank Garg , Ackerley Tng , Gregory Price , Aravind Ramesh , Ajay Joshi , venkataravis@micron.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, John Groves Subject: [PATCH V3 14/21] famfs_fuse: Plumb the GET_FMAP message/response Date: Wed, 7 Jan 2026 09:33:23 -0600 Message-ID: <20260107153332.64727-15-john@groves.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260107153332.64727-1-john@groves.net> References: <20260107153244.64703-1-john@groves.net> <20260107153332.64727-1-john@groves.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: John Groves --- MAINTAINERS | 8 +++++ fs/fuse/Makefile | 1 + fs/fuse/famfs.c | 74 +++++++++++++++++++++++++++++++++++++++ fs/fuse/file.c | 14 +++++++- fs/fuse/fuse_i.h | 47 ++++++++++++++++++++++++- fs/fuse/inode.c | 8 ++++- fs/fuse/iomode.c | 2 +- include/uapi/linux/fuse.h | 7 ++++ 8 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 fs/fuse/famfs.c diff --git a/MAINTAINERS b/MAINTAINERS index 90429cb06090..526309943026 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10374,6 +10374,14 @@ F: fs/fuse/ F: include/uapi/linux/fuse.h F: tools/testing/selftests/filesystems/fuse/ =20 +FUSE [FAMFS Fabric-Attached Memory File System] +M: John Groves +M: John Groves +L: linux-cxl@vger.kernel.org +L: linux-fsdevel@vger.kernel.org +S: Supported +F: fs/fuse/famfs.c + FUTEX SUBSYSTEM M: Thomas Gleixner M: Ingo Molnar diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile index 22ad9538dfc4..3f8dcc8cbbd0 100644 --- a/fs/fuse/Makefile +++ b/fs/fuse/Makefile @@ -17,5 +17,6 @@ fuse-$(CONFIG_FUSE_DAX) +=3D dax.o fuse-$(CONFIG_FUSE_PASSTHROUGH) +=3D passthrough.o backing.o fuse-$(CONFIG_SYSCTL) +=3D sysctl.o fuse-$(CONFIG_FUSE_IO_URING) +=3D dev_uring.o +fuse-$(CONFIG_FUSE_FAMFS_DAX) +=3D famfs.o =20 virtiofs-y :=3D virtio_fs.o diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c new file mode 100644 index 000000000000..0f7e3f00e1e7 --- /dev/null +++ b/fs/fuse/famfs.c @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2025 Micron Technology, Inc. + * + * This file system, originally based on ramfs the dax support from xfs, + * is intended to allow multiple host systems to mount a common file system + * view of dax files that map to shared memory. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "fuse_i.h" + + +#define FMAP_BUFSIZE PAGE_SIZE + +int +fuse_get_fmap(struct fuse_mount *fm, struct inode *inode) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + size_t fmap_bufsize =3D FMAP_BUFSIZE; + u64 nodeid =3D get_node_id(inode); + ssize_t fmap_size; + void *fmap_buf; + int rc; + + FUSE_ARGS(args); + + /* Don't retrieve if we already have the famfs metadata */ + if (fi->famfs_meta) + return 0; + + fmap_buf =3D kcalloc(1, FMAP_BUFSIZE, GFP_KERNEL); + if (!fmap_buf) + return -EIO; + + args.opcode =3D FUSE_GET_FMAP; + args.nodeid =3D nodeid; + + /* Variable-sized output buffer + * this causes fuse_simple_request() to return the size of the + * output payload + */ + args.out_argvar =3D true; + args.out_numargs =3D 1; + args.out_args[0].size =3D fmap_bufsize; + args.out_args[0].value =3D fmap_buf; + + /* Send GET_FMAP command */ + rc =3D fuse_simple_request(fm, &args); + if (rc < 0) { + pr_err("%s: err=3D%d from fuse_simple_request()\n", + __func__, rc); + return rc; + } + fmap_size =3D rc; + + /* We retrieved the "fmap" (the file's map to memory), but + * we haven't used it yet. A call to famfs_file_init_dax() will be added + * here in a subsequent patch, when we add the ability to attach + * fmaps to files. + */ + + kfree(fmap_buf); + return 0; +} diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 093569033ed1..1f64bf68b5ee 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -277,6 +277,16 @@ static int fuse_open(struct inode *inode, struct file = *file) err =3D fuse_do_open(fm, get_node_id(inode), file, false); if (!err) { ff =3D file->private_data; + + if ((fm->fc->famfs_iomap) && (S_ISREG(inode->i_mode))) { + /* Get the famfs fmap - failure is fatal */ + err =3D fuse_get_fmap(fm, inode); + if (err) { + fuse_sync_release(fi, ff, file->f_flags); + goto out_nowrite; + } + } + err =3D 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); } =20 +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) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 84d0ee2a501d..691c7850cf4e 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -223,6 +223,14 @@ struct fuse_inode { * so preserve the blocksize specified by the server. */ u8 cached_i_blkbits; + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + /* Pointer to the file's famfs metadata. Primary content is the + * in-memory version of the fmap - the map from file's offset range + * to DAX memory + */ + void *famfs_meta; +#endif }; =20 /** FUSE inode state bits */ @@ -1525,11 +1533,14 @@ void fuse_free_conn(struct fuse_conn *fc); =20 /* dax.c */ =20 +static inline int fuse_file_famfs(struct fuse_inode *fi); /* forward */ + /* This macro is used by virtio_fs, but now it also needs to filter for * "not famfs" */ #define FUSE_IS_VIRTIO_DAX(fuse_inode) (IS_ENABLED(CONFIG_FUSE_DAX) \ - && IS_DAX(&fuse_inode->inode)) + && IS_DAX(&fuse_inode->inode) \ + && !fuse_file_famfs(fuse_inode)) =20 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); @@ -1654,4 +1665,38 @@ static inline void famfs_teardown(struct fuse_conn *= fc) #endif } =20 +static inline struct fuse_backing *famfs_meta_set(struct fuse_inode *fi, + void *meta) +{ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + return xchg(&fi->famfs_meta, meta); +#else + return NULL; +#endif +} + +static inline void famfs_meta_free(struct fuse_inode *fi) +{ + /* Stub wil be connected in a subsequent commit */ +} + +static inline int fuse_file_famfs(struct fuse_inode *fi) +{ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + return (READ_ONCE(fi->famfs_meta) !=3D NULL); +#else + return 0; +#endif +} + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) +int fuse_get_fmap(struct fuse_mount *fm, struct inode *inode); +#else +static inline int +fuse_get_fmap(struct fuse_mount *fm, struct inode *inode) +{ + return 0; +} +#endif + #endif /* _FS_FUSE_I_H */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 2e0844aabbae..9e121a1d63b7 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -120,6 +120,9 @@ static struct inode *fuse_alloc_inode(struct super_bloc= k *sb) if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_inode_backing_set(fi, NULL); =20 + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + famfs_meta_set(fi, NULL); + return &fi->inode; =20 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)); =20 + if (S_ISREG(inode->i_mode) && fuse_file_famfs(fi)) + famfs_meta_free(fi); + kmem_cache_free(fuse_inode_cachep, fi); } =20 @@ -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); =20 - if (FUSE_IS_VIRTIO_DAX(fi)) + if (FUSE_IS_VIRTIO_DAX(fi) || fuse_file_famfs(fi)) dax_break_layout_final(inode); =20 truncate_inode_pages_final(&inode->i_data); diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c index 31ee7f3304c6..948148316ef0 100644 --- a/fs/fuse/iomode.c +++ b/fs/fuse/iomode.c @@ -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; =20 /* diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 5e2c93433823..bfb92a4aa8a9 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -669,6 +669,9 @@ enum fuse_opcode { FUSE_STATX =3D 52, FUSE_COPY_FILE_RANGE_64 =3D 53, =20 + /* Famfs / devdax opcodes */ + FUSE_GET_FMAP =3D 54, + /* CUSE specific operations */ CUSE_INIT =3D 4096, =20 @@ -1313,4 +1316,8 @@ struct fuse_uring_cmd_req { uint8_t padding[6]; }; =20 +/* Famfs fmap message components */ + +#define FAMFS_FMAP_MAX 32768 /* Largest supported fmap message */ + #endif /* _LINUX_FUSE_H */ --=20 2.49.0