Re: [PATCH 2/2] fuse: Implement O_TMPFILE support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 9, 2020 at 8:37 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>
> On Mon, Nov 9, 2020 at 11:04 AM Chirantan Ekbote <chirantan@xxxxxxxxxxxx> wrote:
> >
> > Implement support for O_TMPFILE by re-using the existing infrastructure
> > for mkdir, symlink, mknod, etc. The server should reply to the tmpfile
> > request by sending a fuse_entry_out describing the newly created
> > tmpfile.
> >
> > Signed-off-by: Chirantan Ekbote <chirantan@xxxxxxxxxxxx>
> > ---
> >  fs/fuse/dir.c  | 21 +++++++++++++++++++++
> >  fs/fuse/file.c |  3 ++-
> >  2 files changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> > index ff7dbeb16f88d..1ab52e7ec1625 100644
> > --- a/fs/fuse/dir.c
> > +++ b/fs/fuse/dir.c
> > @@ -751,6 +751,26 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode)
> >         return create_new_entry(fm, &args, dir, entry, S_IFDIR);
> >  }
> >
> > +static int fuse_tmpfile(struct inode *dir, struct dentry *entry, umode_t mode)
> > +{
> > +       struct fuse_tmpfile_in inarg;
> > +       struct fuse_mount *fm = get_fuse_mount(dir);
> > +       FUSE_ARGS(args);
> > +
> > +       if (!fm->fc->dont_mask)
> > +               mode &= ~current_umask();
> > +
> > +       memset(&inarg, 0, sizeof(inarg));
> > +       inarg.mode = mode;
> > +       inarg.umask = current_umask();
> > +       args.opcode = FUSE_TMPFILE;
> > +       args.in_numargs = 1;
> > +       args.in_args[0].size = sizeof(inarg);
> > +       args.in_args[0].value = &inarg;
> > +
> > +       return create_new_entry(fm, &args, dir, entry, S_IFREG);
> > +}
> > +
> >  static int fuse_symlink(struct inode *dir, struct dentry *entry,
> >                         const char *link)
> >  {
> > @@ -1818,6 +1838,7 @@ static const struct inode_operations fuse_dir_inode_operations = {
> >         .listxattr      = fuse_listxattr,
> >         .get_acl        = fuse_get_acl,
> >         .set_acl        = fuse_set_acl,
> > +       .tmpfile        = fuse_tmpfile,
> >  };
> >
> >  static const struct file_operations fuse_dir_operations = {
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index c03034e8c1529..8ecf85699a014 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -39,7 +39,8 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, struct file *file,
> >         FUSE_ARGS(args);
> >
> >         memset(&inarg, 0, sizeof(inarg));
> > -       inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY);
> > +       inarg.flags =
> > +               file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TMPFILE);
>
> Why did you add this?   At this stage O_TMPFILE should not be in the
> flags, since that case was handled via the ->tmpfile() path.
>

That's not the behavior I observed.  Without this, the O_TMPFILE flag
gets passed through to the server.  The call stack is:

- do_filp_open
    - path_openat
        - do_tmpfile
            - vfs_tmpfile
                - dir->i_op->tmpfile
            - finish_open
                - do_dentry_open
                    - f->f_op->open

and I didn't see O_TMPFILE being removed anywhere in there.

Chirantan



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux