public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-fsdevel@vger.kernel.org,
	Amir Goldstein <amir73il@gmail.com>,
	David Howells <dhowells@redhat.com>,
	Yu-li Lin <yulilin@google.com>,
	Chirantan Ekbote <chirantan@chromium.org>
Subject: Re: [PATCH v2 4/8] ovl: use tmpfile_open() helper
Date: Tue, 20 Sep 2022 02:33:13 +0100	[thread overview]
Message-ID: <YykYWVpNvNm8BzWv@ZenIV> (raw)
In-Reply-To: <20220919141031.1834447-5-mszeredi@redhat.com>

On Mon, Sep 19, 2022 at 04:10:27PM +0200, Miklos Szeredi wrote:
> If tmpfile is used for copy up, then use this helper to create the tmpfile
> and open it at the same time.  This will later allow filesystems such as
> fuse to do this operation atomically.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
>  fs/overlayfs/copy_up.c   | 49 ++++++++++++++++++++++------------------
>  fs/overlayfs/overlayfs.h | 12 ++++++----
>  fs/overlayfs/super.c     | 10 ++++----
>  3 files changed, 40 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> index fdde6c56cc3d..ac087b48b5da 100644
> --- a/fs/overlayfs/copy_up.c
> +++ b/fs/overlayfs/copy_up.c
> @@ -194,16 +194,16 @@ static int ovl_copy_fileattr(struct inode *inode, struct path *old,
>  }
>  
>  static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old,
> -			    struct path *new, loff_t len)
> +			    struct path *new, struct file *new_file, loff_t len)
>  {

Ugh...  Lift opening into both callers and get rid of struct path *new,
please.  Would be much easier to follow that way...

> -	err = ovl_copy_up_inode(c, temp);
> +	err = ovl_copy_up_inode(c, temp, NULL);

FWIW, I would consider passing a struct file * in all cases, with O_PATH
for non-regular ones...

> -	temp = ovl_do_tmpfile(ofs, ofs->workdir, S_IFREG | 0);
> -	ofs->tmpfile = !IS_ERR(temp);
> +	tmpfile = ovl_do_tmpfile(ofs, ofs->workdir, S_IFREG | 0);
> +	ofs->tmpfile = !IS_ERR(tmpfile);
>  	if (ofs->tmpfile)
> -		dput(temp);
> +		fput(tmpfile);

	Careful - that part essentially checks if we have a working
->tmpfile(), but we rely upon more than just having it - we want
dentry-based setxattr() and friends to work after O_TMPFILE.
Are we making that a requirement for ->tmpfile()?  I.e. that
after O_TMPFILE open notify_change() et.al. on its dentry
will work *without* corresponding struct file.  In particular,
fuse seems to check for ATTR_FILE...

  reply	other threads:[~2022-09-20  1:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 14:10 [PATCH v2 0/8] fuse tmpfile Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 1/8] cachefiles: tmpfile error handling cleanup Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 2/8] vfs: add tmpfile_open() helper Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 3/8] cachefiles: use " Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 4/8] ovl: " Miklos Szeredi
2022-09-20  1:33   ` Al Viro [this message]
2022-09-20  8:02     ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 5/8] vfs: make vfs_tmpfile() static Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 6/8] vfs: move open right after ->tmpfile() Miklos Szeredi
2022-09-20  1:40   ` Al Viro
2022-09-20  8:08     ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 7/8] vfs: open inside ->tmpfile() Miklos Szeredi
2022-09-20  1:50   ` Al Viro
2022-09-20  8:44     ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 8/8] fuse: implement ->tmpfile() Miklos Szeredi

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=YykYWVpNvNm8BzWv@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=amir73il@gmail.com \
    --cc=chirantan@chromium.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --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