linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Dave Chinner <david@fromorbit.com>,
	Christoph Hellwig <hch@lst.de>,
	Olga Kornievskaia <olga.kornievskaia@gmail.com>,
	Luis Henriques <lhenriques@suse.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org,
	ceph-devel@vger.kernel.org, linux-api@vger.kernel.org,
	Dave Chinner <dchinner@redhat.com>
Subject: Re: [PATCH v2 2/8] vfs: no fallback for ->copy_file_range
Date: Tue, 28 May 2019 09:09:30 -0700	[thread overview]
Message-ID: <20190528160930.GA5221@magnolia> (raw)
In-Reply-To: <20190526061100.21761-3-amir73il@gmail.com>

On Sun, May 26, 2019 at 09:10:53AM +0300, Amir Goldstein wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Now that we have generic_copy_file_range(), remove it as a fallback
> case when offloads fail. This puts the responsibility for executing
> fallbacks on the filesystems that implement ->copy_file_range and
> allows us to add operational validity checks to
> generic_copy_file_range().
> 
> Rework vfs_copy_file_range() to call a new do_copy_file_range()
> helper to exceute the copying callout, and move calls to

    execute ^^^^^^^

> generic_file_copy_range() into filesystem methods where they
> currently return failures.
> 
> [Amir] overlayfs is not responsible of executing the fallback.
> It is the responsibility of the underlying filesystem.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Seems fine to me otherwise...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/ceph/file.c    | 21 ++++++++++++++++++---
>  fs/cifs/cifsfs.c  |  4 ++++
>  fs/fuse/file.c    | 21 ++++++++++++++++++---
>  fs/nfs/nfs4file.c | 20 +++++++++++++++++---
>  fs/read_write.c   | 25 ++++++++++++++++---------
>  5 files changed, 73 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 305daf043eb0..e87f7b2023af 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -1889,9 +1889,9 @@ static int is_file_size_ok(struct inode *src_inode, struct inode *dst_inode,
>  	return 0;
>  }
>  
> -static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
> -				    struct file *dst_file, loff_t dst_off,
> -				    size_t len, unsigned int flags)
> +static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
> +				      struct file *dst_file, loff_t dst_off,
> +				      size_t len, unsigned int flags)
>  {
>  	struct inode *src_inode = file_inode(src_file);
>  	struct inode *dst_inode = file_inode(dst_file);
> @@ -2100,6 +2100,21 @@ static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
>  	return ret;
>  }
>  
> +static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
> +				    struct file *dst_file, loff_t dst_off,
> +				    size_t len, unsigned int flags)
> +{
> +	ssize_t ret;
> +
> +	ret = __ceph_copy_file_range(src_file, src_off, dst_file, dst_off,
> +				     len, flags);
> +
> +	if (ret == -EOPNOTSUPP)
> +		ret = generic_copy_file_range(src_file, src_off, dst_file,
> +					      dst_off, len, flags);
> +	return ret;
> +}
> +
>  const struct file_operations ceph_file_fops = {
>  	.open = ceph_open,
>  	.release = ceph_release,
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index f5fcd6360056..c65823270313 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -1148,6 +1148,10 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
>  	rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
>  					len, flags);
>  	free_xid(xid);
> +
> +	if (rc == -EOPNOTSUPP)
> +		rc = generic_copy_file_range(src_file, off, dst_file,
> +					     destoff, len, flags);
>  	return rc;
>  }
>  
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 3959f08279e6..e03901ae729b 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -3097,9 +3097,9 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
>  	return err;
>  }
>  
> -static ssize_t fuse_copy_file_range(struct file *file_in, loff_t pos_in,
> -				    struct file *file_out, loff_t pos_out,
> -				    size_t len, unsigned int flags)
> +static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
> +				      struct file *file_out, loff_t pos_out,
> +				      size_t len, unsigned int flags)
>  {
>  	struct fuse_file *ff_in = file_in->private_data;
>  	struct fuse_file *ff_out = file_out->private_data;
> @@ -3173,6 +3173,21 @@ static ssize_t fuse_copy_file_range(struct file *file_in, loff_t pos_in,
>  	return err;
>  }
>  
> +static ssize_t fuse_copy_file_range(struct file *src_file, loff_t src_off,
> +				    struct file *dst_file, loff_t dst_off,
> +				    size_t len, unsigned int flags)
> +{
> +	ssize_t ret;
> +
> +	ret = __fuse_copy_file_range(src_file, src_off, dst_file, dst_off,
> +				     len, flags);
> +
> +	if (ret == -EOPNOTSUPP)
> +		ret = generic_copy_file_range(src_file, src_off, dst_file,
> +					      dst_off, len, flags);
> +	return ret;
> +}
> +
>  static const struct file_operations fuse_file_operations = {
>  	.llseek		= fuse_file_llseek,
>  	.read_iter	= fuse_file_read_iter,
> diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
> index cf42a8b939e3..4842f3ab3161 100644
> --- a/fs/nfs/nfs4file.c
> +++ b/fs/nfs/nfs4file.c
> @@ -129,9 +129,9 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
>  }
>  
>  #ifdef CONFIG_NFS_V4_2
> -static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
> -				    struct file *file_out, loff_t pos_out,
> -				    size_t count, unsigned int flags)
> +static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
> +				      struct file *file_out, loff_t pos_out,
> +				      size_t count, unsigned int flags)
>  {
>  	if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY))
>  		return -EOPNOTSUPP;
> @@ -140,6 +140,20 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
>  	return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
>  }
>  
> +static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
> +				    struct file *file_out, loff_t pos_out,
> +				    size_t count, unsigned int flags)
> +{
> +	ssize_t ret;
> +
> +	ret = __nfs4_copy_file_range(file_in, pos_in, file_out, pos_out, count,
> +				     flags);
> +	if (ret == -EOPNOTSUPP)
> +		ret = generic_copy_file_range(file_in, pos_in, file_out,
> +					      pos_out, count, flags);
> +	return ret;
> +}
> +
>  static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
>  {
>  	loff_t ret;
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 676b02fae589..b63dcb4e4fe9 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1595,6 +1595,19 @@ ssize_t generic_copy_file_range(struct file *file_in, loff_t pos_in,
>  }
>  EXPORT_SYMBOL(generic_copy_file_range);
>  
> +static ssize_t do_copy_file_range(struct file *file_in, loff_t pos_in,
> +				  struct file *file_out, loff_t pos_out,
> +				  size_t len, unsigned int flags)
> +{
> +	if (file_out->f_op->copy_file_range)
> +		return file_out->f_op->copy_file_range(file_in, pos_in,
> +						       file_out, pos_out,
> +						       len, flags);
> +
> +	return generic_copy_file_range(file_in, pos_in, file_out, pos_out, len,
> +				       flags);
> +}
> +
>  /*
>   * copy_file_range() differs from regular file read and write in that it
>   * specifically allows return partial success.  When it does so is up to
> @@ -1655,15 +1668,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
>  		}
>  	}
>  
> -	if (file_out->f_op->copy_file_range) {
> -		ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
> -						      pos_out, len, flags);
> -		if (ret != -EOPNOTSUPP)
> -			goto done;
> -	}
> -
> -	ret = generic_copy_file_range(file_in, pos_in, file_out, pos_out, len,
> -				      flags);
> +	ret = do_copy_file_range(file_in, pos_in, file_out, pos_out, len,
> +				flags);
> +	WARN_ON_ONCE(ret == -EOPNOTSUPP);
>  done:
>  	if (ret > 0) {
>  		fsnotify_access(file_in);
> -- 
> 2.17.1
> 

  reply	other threads:[~2019-05-28 16:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-26  6:10 [PATCH v2 0/8] Fixes for major copy_file_range() issues Amir Goldstein
2019-05-26  6:10 ` [PATCH v2 1/8] vfs: introduce generic_copy_file_range() Amir Goldstein
2019-05-28 16:11   ` Darrick J. Wong
2019-05-26  6:10 ` [PATCH v2 2/8] vfs: no fallback for ->copy_file_range Amir Goldstein
2019-05-28 16:09   ` Darrick J. Wong [this message]
2019-05-26  6:10 ` [PATCH v2 3/8] vfs: introduce generic_file_rw_checks() Amir Goldstein
2019-05-28 16:14   ` Darrick J. Wong
2019-05-26  6:10 ` [PATCH v2 4/8] vfs: add missing checks to copy_file_range Amir Goldstein
2019-05-28 16:18   ` Darrick J. Wong
2019-05-28 16:26     ` Amir Goldstein
2019-05-28 16:31       ` Darrick J. Wong
2019-05-28 16:39         ` Amir Goldstein
2019-05-26  6:10 ` [PATCH v2 5/8] vfs: copy_file_range needs to strip setuid bits Amir Goldstein
2019-05-28 16:25   ` Darrick J. Wong
2019-05-31 19:34   ` J. Bruce Fields
2019-05-26  6:10 ` [PATCH v2 6/8] vfs: copy_file_range should update file timestamps Amir Goldstein
2019-05-27 14:35   ` Luis Henriques
2019-05-27 22:05     ` Dave Chinner
2019-05-28  8:53       ` Luis Henriques
2019-05-28 16:30   ` Darrick J. Wong
2019-05-28 16:36     ` Amir Goldstein
2019-05-26  6:10 ` [PATCH v2 7/8] vfs: allow copy_file_range to copy across devices Amir Goldstein
2019-05-28 16:34   ` Darrick J. Wong
2019-05-26  6:10 ` [PATCH v2 8/8] vfs: remove redundant checks from generic_remap_checks() Amir Goldstein
2019-05-28 16:37   ` Darrick J. Wong
2019-05-26  6:11 ` [PATCH v2 9/8] man-pages: copy_file_range updates Amir Goldstein
2019-05-28 16:48   ` Darrick J. Wong
2019-05-29 16:20     ` Amir Goldstein

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=20190528160930.GA5221@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=david@fromorbit.com \
    --cc=dchinner@redhat.com \
    --cc=hch@lst.de \
    --cc=lhenriques@suse.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=olga.kornievskaia@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).