linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Aurélien Aptel" <aaptel-IBi9RG/b67k@public.gmane.org>,
	linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Subject: Re: [PATCH] Introduce cifs_copy_file_range()
Date: Wed, 08 Feb 2017 22:20:42 +0530	[thread overview]
Message-ID: <1486572642.16541.11.camel@redhat.com> (raw)
In-Reply-To: <mpsfujoiuoc.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>

On Wed, 2017-02-08 at 16:11 +0100, Aurélien Aptel wrote:
> Hi Sachin,
> 
> Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> > The patch introduces the file_operations helper
> > cifs_copy_file_range().
> > 
> > The vfs helper vfs_copy_file_range() first calls clone_file_range
> > which for cifs uses
> > SMB2_ioctl(.., FSCTL_DUPLICATE_EXTENTS_TO_FILE, ..)
> > to do a server side copy of the file. This ioctl is only supported
> > on
> > SMB3 and later versions.
> > 
> > Once this call fails, vfs_copy_file_range() calls copy_file_range()
> > corresponding to the cifs filesystem which is introduced by this
> > patch.
> > This calls the more widely available
> > SMB2_ioctl(.., FSCTL_SRV_COPYCHUNK_WRITE, ..)
> 
> Sounds good.
> 
> > The upstream changes in this area was first made by the commit
> > 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
> > This commit also introduces the ioctls FICLONE and FICLONERANGE
> > which
> 
> IIUC it also allows the copy_file_range syscall defined in
> fs/read_write.c to take advantage of the dup extents fsctl, if
> available, nice!

This already works with duplicate extents ie. the feature is only
implemented using the 
FSCTL_DUPLICATE_EXTENTS_TO_FILE
which at the moment only on Win 2016 with ReFs on SMB3+ versions.

This patch uses FSCTL_SRV_COPYCHUNK_WRITE as fall back when duplicate
extents is not available. This cifs ioctl is supported on SMB2+
versions and is even used as a fall back for SMB3 when the backing
filesystem support for duplicate extents is not available.

> 
> Now, I wonder if there is a way to implement the FIDEDUPERANGE ioctl
> in
> SMB3, which does the same thing as a clone but it exits early if the
> destination does not already match the source.

I guess this is similar to the copy_on_share() flag COPY_FR_DEDUP
https://lwn.net/Articles/659523/
flags for copy_on_share() aren't implemented on the syscall yet. I
guess that would be the way to go once those flags are used. We can use
the ioctl method to implement it for the time being.

removes the need for separate cifs ioctls to perform server side
copies
> > and hence can be removed.
> 
> Isn't this breaking userspace? I understand it was a private ioctl
> only
> availaible in SMB3 so it's not a big issue but

Yes. This is removed since we can now use the syscall to do the same
thing. I am not aware of any utility which uses this. I am not sure if
we need to first deprecate it before we remove it outright. Steve, can
you please provide some advice here. 

> 
> > @@ -250,9 +146,6 @@ long cifs_ioctl(struct file *filep, unsigned
> > int command, unsigned long arg)
> >  				cifs_dbg(FYI, "set compress flag
> > rc %d\n", rc);
> >  			}
> >  			break;
> > -		case CIFS_IOC_COPYCHUNK_FILE:
> > -			rc = cifs_ioctl_clone(xid, filep, arg);
> > -			break;
> >  		case CIFS_IOC_SET_INTEGRITY:
> >  			if (pSMBFile == NULL)
> >  				break;
> 
> I believe the ioctl will return -ENOTTY now. I remember this story
> when
> an error code was changed: https://lkml.org/lkml/2012/12/23/75 *gulp*
> Maybe I'm overthinking this.
> 
> Cheers,
> 

Sachin Prabhu

  parent reply	other threads:[~2017-02-08 16:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 11:33 [PATCH] Introduce cifs_copy_file_range() Sachin Prabhu
     [not found] ` <20170207113311.11474-1-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-02-08 15:11   ` Aurélien Aptel
     [not found]     ` <mpsfujoiuoc.fsf-zpEvHKhluMwYitT5tn2FcQ@public.gmane.org>
2017-02-08 16:50       ` Sachin Prabhu [this message]
     [not found]         ` <1486572642.16541.11.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-02-08 17:31           ` Steve French
2017-02-08 23:44   ` Pavel Shilovsky
     [not found]     ` <CAKywueSujBajRf1_-_Fq8fTum6ALWWKs6exUqFCa1bnBch2H1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-09  5:38       ` Sachin Prabhu

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=1486572642.16541.11.camel@redhat.com \
    --to=sprabhu-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=aaptel-IBi9RG/b67k@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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).