[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxhnCh_Mm0DGgqwA5Vr4yySgSovesTqbnNH7Y_PXE9fzpg@mail.gmail.com>
Date: Sat, 5 Jul 2025 09:58:57 +0200
From: Amir Goldstein <amir73il@...il.com>
To: John Groves <John@...ves.net>
Cc: Dan Williams <dan.j.williams@...el.com>, Miklos Szeredi <miklos@...redi.hu>,
Bernd Schubert <bschubert@....com>, John Groves <jgroves@...ron.com>, Jonathan Corbet <corbet@....net>,
Vishal Verma <vishal.l.verma@...el.com>, Dave Jiang <dave.jiang@...el.com>,
Matthew Wilcox <willy@...radead.org>, Jan Kara <jack@...e.cz>,
Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>,
"Darrick J . Wong" <djwong@...nel.org>, Randy Dunlap <rdunlap@...radead.org>,
Jeff Layton <jlayton@...nel.org>, Kent Overstreet <kent.overstreet@...ux.dev>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
nvdimm@...ts.linux.dev, linux-cxl@...r.kernel.org,
linux-fsdevel@...r.kernel.org, Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Stefan Hajnoczi <shajnocz@...hat.com>, Joanne Koong <joannelkoong@...il.com>,
Josef Bacik <josef@...icpanda.com>, Aravind Ramesh <arramesh@...ron.com>,
Ajay Joshi <ajayjoshi@...ron.com>
Subject: Re: [RFC V2 12/18] famfs_fuse: Plumb the GET_FMAP message/response
On Sat, Jul 5, 2025 at 2:06 AM John Groves <John@...ves.net> wrote:
>
> On 25/07/04 03:30PM, John Groves wrote:
> > On 25/07/04 10:54AM, Amir Goldstein wrote:
> > > On Thu, Jul 3, 2025 at 8:51 PM John Groves <John@...ves.net> wrote:
> > > >
> > > > 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.
> > > >
> > > > GET_FMAP has a variable-size response payload, and the allocated size
> > > > is sent in the in_args[0].size field. If the fmap would overflow the
> > > > message, the fuse server sends a reply of size 'sizeof(uint32_t)' which
> > > > specifies the size of the fmap message. Then the kernel can realloc a
> > > > large enough buffer and try again.
> > > >
> > > > Signed-off-by: John Groves <john@...ves.net>
> > > > ---
> > > > fs/fuse/file.c | 84 +++++++++++++++++++++++++++++++++++++++
> > > > fs/fuse/fuse_i.h | 36 ++++++++++++++++-
> > > > fs/fuse/inode.c | 19 +++++++--
> > > > fs/fuse/iomode.c | 2 +-
> > > > include/uapi/linux/fuse.h | 18 +++++++++
> > > > 5 files changed, 154 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > > > index 93b82660f0c8..8616fb0a6d61 100644
> > > > --- a/fs/fuse/file.c
> > > > +++ b/fs/fuse/file.c
> > > > @@ -230,6 +230,77 @@ static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
> > > > fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
> > > > }
> > > >
> > > > +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)
> > >
> > > We generally try to avoid #ifdef blocks in c files
> > > keep them mostly in h files and use in c files
> > > if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX))
> > >
> > > also #if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)
> > > it a bit strange for a bool Kconfig because it looks too
> > > much like the c code, so I prefer
> > > #ifdef CONFIG_FUSE_FAMFS_DAX
> > > when you have to use it
> > >
> > > If you need entire functions compiled out, why not put them in famfs.c?
> >
> > Perhaps moving fuse_get_fmap() to famfs.c is the best approach. Will try that
> > first.
> >
> > Regarding '#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)', vs.
> > '#ifdef CONFIG_FUSE_FAMFS_DAX' vs. '#if CONFIG_FUSE_FAMFS_DAX'...
> >
> > I've learned to be cautious there because the latter two are undefined if
> > CONFIG_FUSE_FAMFS_DAX=m. I've been burned by this.
Yes, that's a risk, but as the code is shaping up right now,
I do not foresee FAMFS becoming a module(?)
> >
> > My original thinking was that famfs made sense as a module, but I'm leaning
> > the other way now - and in this series fs/fuse/Kconfig makes it a bool -
> > meaning all three macro tests will work because a bool can't be set to 'm'.
> >
> > So to the extent that I need conditional compilation macros I can switch
> > to '#ifdef...'.
>
> Doh. Spirit of full disclosure: this commit doesn't build if
> CONFIG_FUSE_FAMFS_DAX is not set (!=y). So the conditionals are at
> risk if getting worse, not better. Working on it...
>
You're probably going to need to add stub inline functions
for all the functions from famfs.c and a few more wrappers
I guess.
The right amount of ifdefs in C files is really a matter of judgement,
but the fewer the better for code flow clarity.
Thanks,
Amir.
Powered by blists - more mailing lists