public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Horst Birthelmer <horst@birthelmer.de>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: Horst Birthelmer <horst@birthelmer.com>,
	 Miklos Szeredi <miklos@szeredi.hu>,
	Bernd Schubert <bschubert@ddn.com>,
	linux-kernel@vger.kernel.org,  linux-fsdevel@vger.kernel.org,
	Horst Birthelmer <hbirthelmer@ddn.com>
Subject: Re: Re: [PATCH v4 2/3] fuse: create helper functions for filling in fuse args for open and getattr
Date: Thu, 15 Jan 2026 09:06:16 +0100	[thread overview]
Message-ID: <aWifE9GaESLJ3MW5@fedora> (raw)
In-Reply-To: <CAJnrk1aS=zJvBNwUFmM+vos36i3nY2UaZzZv96vDikuHr8SLqA@mail.gmail.com>

On Wed, Jan 14, 2026 at 06:37:48PM -0800, Joanne Koong wrote:
> On Fri, Jan 9, 2026 at 10:27 AM Horst Birthelmer <horst@birthelmer.com> wrote:
> >
> > From: Horst Birthelmer <hbirthelmer@ddn.com>
> >
> > create fuse_getattr_args_fill() and fuse_open_args_fill() to fill in
> > the parameters for the open and getattr calls.
> >
> > This is in preparation for implementing open+getattr and does not
> > represent any functional change.
> >
> > Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
> > ---
> >  fs/fuse/dir.c    |  9 +--------
> >  fs/fuse/file.c   | 42 ++++++++++++++++++++++++++++++++++--------
> >  fs/fuse/fuse_i.h |  8 ++++++++
> >  3 files changed, 43 insertions(+), 16 deletions(-)
> >
> > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> > index 4b6b3d2758ff..ca8b69282c60 100644
> > --- a/fs/fuse/dir.c
> > +++ b/fs/fuse/dir.c
> > @@ -1493,14 +1493,7 @@ static int fuse_do_getattr(struct mnt_idmap *idmap, struct inode *inode,
> >                 inarg.getattr_flags |= FUSE_GETATTR_FH;
> >                 inarg.fh = ff->fh;
> >         }
> > -       args.opcode = FUSE_GETATTR;
> > -       args.nodeid = get_node_id(inode);
> > -       args.in_numargs = 1;
> > -       args.in_args[0].size = sizeof(inarg);
> > -       args.in_args[0].value = &inarg;
> > -       args.out_numargs = 1;
> > -       args.out_args[0].size = sizeof(outarg);
> > -       args.out_args[0].value = &outarg;
> > +       fuse_getattr_args_fill(&args, get_node_id(inode), &inarg, &outarg);
> >         err = fuse_simple_request(fm, &args);
> >         if (!err) {
> >                 if (fuse_invalid_attr(&outarg.attr) ||
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index 01bc894e9c2b..53744559455d 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -23,6 +23,39 @@
> >  #include <linux/task_io_accounting_ops.h>
> >  #include <linux/iomap.h>
> >
> > +/*
> > + * Helper function to initialize fuse_args for OPEN/OPENDIR operations
> > + */
> > +void fuse_open_args_fill(struct fuse_args *args, u64 nodeid, int opcode,
> > +                        struct fuse_open_in *inarg, struct fuse_open_out *outarg)
> > +{
> > +       args->opcode = opcode;
> > +       args->nodeid = nodeid;
> > +       args->in_numargs = 1;
> > +       args->in_args[0].size = sizeof(*inarg);
> > +       args->in_args[0].value = inarg;
> > +       args->out_numargs = 1;
> > +       args->out_args[0].size = sizeof(*outarg);
> > +       args->out_args[0].value = outarg;
> > +}
> > +
> > +/*
> > + * Helper function to initialize fuse_args for GETATTR operations
> > + */
> > +void fuse_getattr_args_fill(struct fuse_args *args, u64 nodeid,
> > +                            struct fuse_getattr_in *inarg,
> > +                            struct fuse_attr_out *outarg)
> > +{
> > +       args->opcode = FUSE_GETATTR;
> > +       args->nodeid = nodeid;
> > +       args->in_numargs = 1;
> > +       args->in_args[0].size = sizeof(*inarg);
> > +       args->in_args[0].value = inarg;
> > +       args->out_numargs = 1;
> > +       args->out_args[0].size = sizeof(*outarg);
> > +       args->out_args[0].value = outarg;
> > +}
> 
> sorry to be so nitpicky but I think we should move this to the
> fuse/dir.c file since that's where the main fuse_do_getattr() function
> lives

That is true. I kept it here since this is the 'second home' and the patch was smaller but that's an easy fix.

> 
> > +
> >  static int fuse_send_open(struct fuse_mount *fm, u64 nodeid,
> >                           unsigned int open_flags, int opcode,
> >                           struct fuse_open_out *outargp)
> > @@ -40,14 +73,7 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid,
> >                 inarg.open_flags |= FUSE_OPEN_KILL_SUIDGID;
> >         }
> >
> > -       args.opcode = opcode;
> > -       args.nodeid = nodeid;
> > -       args.in_numargs = 1;
> > -       args.in_args[0].size = sizeof(inarg);
> > -       args.in_args[0].value = &inarg;
> > -       args.out_numargs = 1;
> > -       args.out_args[0].size = sizeof(*outargp);
> > -       args.out_args[0].value = outargp;
> > +       fuse_open_args_fill(&args, nodeid, opcode, &inarg, outargp);
> >
> >         return fuse_simple_request(fm, &args);
> >  }
> > diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> > index 6dddbe2b027b..98ea41f76623 100644
> > --- a/fs/fuse/fuse_i.h
> > +++ b/fs/fuse/fuse_i.h
> > @@ -1179,6 +1179,14 @@ struct fuse_io_args {
> >  void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
> >                          size_t count, int opcode);
> >
> > +/*
> > + * Helper functions to initialize fuse_args for common operations
> > + */
> > +void fuse_open_args_fill(struct fuse_args *args, u64 nodeid, int opcode,
> > +                        struct fuse_open_in *inarg, struct fuse_open_out *outarg);
> 
> I don't think we need this for fuse_open_args_fill() here since it'll
> be used only in the scope of fuse/file.c
> 

That is true. This was a premature optimization on my part since I have a strong suspicion that we will be using more open calls in other compounds.
I agree, let's keep it clean for the moment.

> Thanks,
> Joanne
> 
> > +void fuse_getattr_args_fill(struct fuse_args *args, u64 nodeid,
> > +                           struct fuse_getattr_in *inarg,
> > +                           struct fuse_attr_out *outarg);
> >
> >  struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
> >  void fuse_file_free(struct fuse_file *ff);
> >
> > --
> > 2.51.0
> >

Thanks,
Horst

  reply	other threads:[~2026-01-15  8:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 18:26 [PATCH v4 0/3] fuse: compound commands Horst Birthelmer
2026-01-09 18:26 ` [PATCH v4 1/3] fuse: add compound command to combine multiple requests Horst Birthelmer
2026-01-15  2:40   ` Joanne Koong
2026-01-15  8:01     ` Horst Birthelmer
2026-01-09 18:27 ` [PATCH v4 2/3] fuse: create helper functions for filling in fuse args for open and getattr Horst Birthelmer
2026-01-15  2:37   ` Joanne Koong
2026-01-15  8:06     ` Horst Birthelmer [this message]
2026-01-09 18:27 ` [PATCH v4 3/3] fuse: add an implementation of open+getattr Horst Birthelmer
2026-01-15  2:29   ` Joanne Koong
2026-01-15  8:19     ` Horst Birthelmer
2026-01-15 13:38     ` Horst Birthelmer
2026-01-15 13:41       ` Bernd Schubert
2026-01-15 13:46         ` Horst Birthelmer
2026-01-15 15:11           ` Luis Henriques
2026-01-15 15:25             ` Horst Birthelmer
2026-01-15 17:14               ` Luis Henriques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWifE9GaESLJ3MW5@fedora \
    --to=horst@birthelmer.de \
    --cc=bschubert@ddn.com \
    --cc=hbirthelmer@ddn.com \
    --cc=horst@birthelmer.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox