public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Yu-li Lin <yulilin@google.com>,
	chirantan@chromium.org, dgreid@chromium.org,
	fuse-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org,
	suleiman@chromium.org
Subject: Re: [PATCH 2/2] fuse: Implement O_TMPFILE support
Date: Tue, 13 Sep 2022 02:51:21 +0100	[thread overview]
Message-ID: <Yx/iGX+xGdqlnH73@ZenIV> (raw)
In-Reply-To: <YxYbCt4/S4r2JHw2@miu.piliscsaba.redhat.com>

On Mon, Sep 05, 2022 at 05:51:38PM +0200, Miklos Szeredi wrote:
> On Wed, Aug 31, 2022 at 02:30:40PM -0700, Yu-li Lin wrote:
> > Thanks for the reference. IIUC, the consensus is to make it atomic,
> > although there's no agreement on how it should be done. Does that mean
> > we should hold off on
> > this patch until atomic temp files are figured out higher in the stack
> > or do you have thoughts on how the fuse uapi should look like prior to
> > the vfs/refactoring decision?
> 
> Here's a patch refactoring the tmpfile kapi to return an open file instead of a
> dentry.
> 
> Comments?

First and foremost: how many operations the interested filesystems (cifs,
for one) are capable of for such beasts?  I can believe that FUSE can handle
that, but can something like cifs do it?  Their protocol is pathname-based, IIRC;
can they really handle that kind of files without something like sillyrename?
Because if sillyrename and its analogues are in the game, we have seriously
changed rules re directory locking, and we'd better figure that out first.

IOW, I would really like to see proposed instances for FUSE and CIFS - the shape
of the series seriously depends upon that.  Before we commit to calling conventions
changes.

That aside, some notes on the patch:

* file->f_path.dentry all over the place is ugly and wrong.  If nothing else,
d_tmpfile() could be converted to taking struct file * - nothing outside of
->tmpfile() instances is using it.
* finish_tmpfile() parts would be less noisy if it was finish_tmpfile(file, errror),
starting with if (error) return error;
* a bit of weirdness in ext4:
>  	err = dquot_initialize(dir);
>  	if (err)
> -		return err;
> +		goto out;
Huh?  Your out: starts with if (err) return err;  Sure, compiler
will figure it out, but what have human readers done to you?
* similar in shmem:
> +out:
> +	if (error)
> +		return error;
> +
> +	return finish_tmpfile(file);
>  out_iput:
>  	iput(inode);
> -	return error;
> +	goto out;
How the hell would it ever get to out_iput: with error == 0?
* in your vfs_tmpfile() wrapper
> +	child = ERR_CAST(file);
> +	if (!IS_ERR(file)) {
> +		error = vfs_tmpfile_new(mnt_userns, path, file, mode);
> +		child = error ? ERR_PTR(error) : dget(file->f_path.dentry);
> +		fput(file);
> +	}
> +	return child;
This really ought to be
	if (IS_ERR(file))
		return ERR_CAST(file);
	...
IS_ERR() comes with implicit unlikely()...


Next, there are users outside of do_o_tmpfile().  The one in cachefiles
is a prime candidate for combining with open - the stuff done between
vfs_tmpfile() and opening the sucker consists of
	* cachefiles_ondemand_init_object() - takes no cleanup on
later failure exits, doesn't know anything about dentry created.  Might
as well be done before vfs_tmpfile().
	* cachefiles_mark_inode_in_use() - which really can't fail there,
and the only thing being done is marking the sucker with S_KERNEL_FILE.
Could be done after opening just as well.
	* vfs_truncate() used to expand to required size.  Trivially done
after opening, and we probably want struct file there - there's a reason
why ftruncate(2) sets ATTR_FILE/ia_file...  We are unlikely to use
anything like FUSE for cachefiles, but leaving traps like that is a bad
idea.
IOW, cachefiles probably wants a preliminary patch series that would
massage it to the "tmpfile right next to open, the use struct file"
form.


Another user is overlayfs, and that's going to get painful.  It checks for
->tmpfile() working and if it does work, we use it for copyup.  The trouble
is, will e.g. FUSE be ready to handle things like setxattr on such dentries?
It's not just a matter of copying the data - there we would be quite fine
with opened file; it's somewhat clumsy since copyup is done for FIFOs, etc.,
but that could be dealt with.  But things like setting metadata are done
by dentry there.  And with your patch the file will have been closed by
the time we get to that part.  Can e.g. FUSE deal with that?

  parent reply	other threads:[~2022-09-13  1:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 10:03 [PATCH 0/2] Support for O_TMPFILE in fuse Chirantan Ekbote
2020-11-09 10:03 ` [PATCH 1/2] uapi/fuse.h: Add message definitions for O_TMPFILE Chirantan Ekbote
2020-11-09 10:03 ` [PATCH 2/2] fuse: Implement O_TMPFILE support Chirantan Ekbote
2020-11-09 11:37   ` Miklos Szeredi
2020-11-10  3:33     ` Chirantan Ekbote
2020-11-10  7:52       ` Miklos Szeredi
2020-11-13  5:19         ` Chirantan Ekbote
2020-11-13 10:52           ` Miklos Szeredi
2020-11-13 12:28             ` Al Viro
2020-11-13 13:54               ` Miklos Szeredi
2022-08-31  2:57                 ` Yu-Li Lin
2022-08-31 12:19                   ` Miklos Szeredi
2022-08-31 21:30                     ` Yu-li Lin
2022-09-05 15:51                       ` Miklos Szeredi
2022-09-06  4:58                         ` Amir Goldstein
2022-09-06  5:29                           ` Al Viro
2022-09-06  7:23                             ` Miklos Szeredi
2022-09-13  1:51                         ` Al Viro [this message]
2022-09-13 10:20                           ` Miklos Szeredi
2022-09-18 13:17                             ` [fuse-devel] " Stef Bon

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=Yx/iGX+xGdqlnH73@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=chirantan@chromium.org \
    --cc=dgreid@chromium.org \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=suleiman@chromium.org \
    --cc=yulilin@google.com \
    /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