All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	Dave Chinner <david@fromorbit.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: Re: [PATCH 1/4] copy_file_range: refactor vfs_copy_file_range
Date: Thu, 10 May 2018 07:25:53 +0300	[thread overview]
Message-ID: <CAOQ4uxjjx2=viLhxFAdvUWYiu5zRoqjW-62Uh1RoCLZhqCBf0A@mail.gmail.com> (raw)
In-Reply-To: <20180510015820.17700-2-rgoldwyn@suse.de>

On Thu, May 10, 2018 at 4:58 AM, Goldwyn Rodrigues <rgoldwyn@suse.de> wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Preparatory patch to carve out do_copy_file_range() from
> vfs_copy_file_range
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/read_write.c | 60 ++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 34 insertions(+), 26 deletions(-)
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index c4eabbfc90df..525f2a67e15a 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1541,6 +1541,38 @@ COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
>  }
>  #endif
>
> +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)
> +{
> +       ssize_t ret = 0;
> +
> +       if (len == 0)
> +               return 0;
> +
> +       /*
> +        * Try cloning first, this is supported by more file systems, and
> +        * more efficient if both clone and copy are supported (e.g. NFS).
> +        */
> +       if (file_in->f_op->clone_file_range) {
> +               ret = file_in->f_op->clone_file_range(file_in, pos_in,
> +                               file_out, pos_out, len);
> +               if (ret == 0)
> +                       return len;
> +       }
> +
> +       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)
> +                       return ret;
> +       }
> +
> +       ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
> +                       len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
> +       return ret;
> +}
> +
>  /*
>   * 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
> @@ -1579,35 +1611,11 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
>         if (inode_in->i_sb != inode_out->i_sb)
>                 return -EXDEV;
>
> -       if (len == 0)
> -               return 0;
> -
>         file_start_write(file_out);
>
> -       /*
> -        * Try cloning first, this is supported by more file systems, and
> -        * more efficient if both clone and copy are supported (e.g. NFS).
> -        */
> -       if (file_in->f_op->clone_file_range) {
> -               ret = file_in->f_op->clone_file_range(file_in, pos_in,
> -                               file_out, pos_out, len);
> -               if (ret == 0) {
> -                       ret = len;
> -                       goto done;
> -               }
> -       }
> -
> -       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 = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
> -                       len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
> +       ret = do_copy_file_range(file_in, pos_in,
> +                       file_out, pos_out, len, flags);
>
> -done:
>         if (ret > 0) {
>                 fsnotify_access(file_in);
>                 add_rchar(current, ret);
> --
> 2.16.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-05-10  4:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10  1:58 [PATCH v2 0/4] Enable holes in copy_file_range() Goldwyn Rodrigues
2018-05-10  1:58 ` [PATCH 1/4] copy_file_range: refactor vfs_copy_file_range Goldwyn Rodrigues
2018-05-10  4:25   ` Amir Goldstein [this message]
2018-05-10  1:58 ` [PATCH 2/4] copy_file_range: Perform splice if in/out SB are not same Goldwyn Rodrigues
2018-05-10  1:58 ` [PATCH 3/4] copy_file_range: splice with holes Goldwyn Rodrigues
2018-05-10  4:42   ` Amir Goldstein
2018-05-10  5:49     ` Amir Goldstein
2018-05-10  1:58 ` [PATCH 4/4] ovl: Use do_copy_file_range() in copy_up_data() Goldwyn Rodrigues
2018-05-10  4:47 ` [PATCH v2 0/4] Enable holes in copy_file_range() Amir Goldstein
2018-05-10 10:45   ` Anna Schumaker
  -- strict thread matches above, loose matches on Subject: below --
2018-06-14 15:12 [PATCH RESEND v3 " Goldwyn Rodrigues
2018-06-14 15:12 ` [PATCH 1/4] copy_file_range: refactor vfs_copy_file_range Goldwyn Rodrigues
2018-05-14 14:56 [PATCH v3 0/4] Enable holes in copy_file_range() Goldwyn Rodrigues
2018-05-14 14:56 ` [PATCH 1/4] copy_file_range: refactor vfs_copy_file_range Goldwyn Rodrigues
2018-05-08 21:24 [PATCH v1 0/5] Enable holes on copy_file_range() Goldwyn Rodrigues
2018-05-08 21:24 ` [PATCH 1/4] copy_file_range: refactor vfs_copy_file_range Goldwyn Rodrigues
2018-05-09  5:44   ` 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='CAOQ4uxjjx2=viLhxFAdvUWYiu5zRoqjW-62Uh1RoCLZhqCBf0A@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=rgoldwyn@suse.com \
    --cc=rgoldwyn@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.