* [PATCH 0/1] cloner: add support for clone_file_range for cifs
@ 2018-09-11 5:28 Ronnie Sahlberg
2018-09-11 5:28 ` [PATCH] " Ronnie Sahlberg
0 siblings, 1 reply; 4+ messages in thread
From: Ronnie Sahlberg @ 2018-09-11 5:28 UTC (permalink / raw)
To: fstests
This is a trivial patch that adds support for copy_file_range for cifs.
This uses the copy_file_range interface which cifs.ko supports.
Note that cloner.c uses an ioctl() for copying an entire file. This is
an older interface from before cifs.ko added proper copy_file_range
support but both interfaces eventually end up in the same codepaths
and use the same SMB2 commands on the wire.
Could argue that we could/should use copy_file_range() for the whole file
case as well but there is no harm leaving it as-is using the older interface.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] cloner: add support for clone_file_range for cifs
2018-09-11 5:28 [PATCH 0/1] cloner: add support for clone_file_range for cifs Ronnie Sahlberg
@ 2018-09-11 5:28 ` Ronnie Sahlberg
2018-09-11 7:02 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Ronnie Sahlberg @ 2018-09-11 5:28 UTC (permalink / raw)
To: fstests
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
src/cloner.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/cloner.c b/src/cloner.c
index ffad82f0..9f9156e5 100644
--- a/src/cloner.c
+++ b/src/cloner.c
@@ -120,6 +120,18 @@ clone_file_range_btrfs(int src_fd, int dst_fd, uint64_t src_off,
}
static int
+clone_file_range_cifs(int fd_in, int fd_out, loff_t off_in,
+ loff_t off_out, size_t len)
+{
+ int ret;
+
+ ret = copy_file_range(fd_in, &off_in, fd_out, &off_out, len, 0);
+ if (ret < 0)
+ ret = errno;
+ return 0;
+}
+
+static int
clone_file_range(unsigned int fs_type, int src_fd, int dst_fd, uint64_t src_off,
uint64_t dst_off, uint64_t len)
{
@@ -128,7 +140,9 @@ clone_file_range(unsigned int fs_type, int src_fd, int dst_fd, uint64_t src_off,
return clone_file_range_btrfs(src_fd, dst_fd, src_off, dst_off,
len);
break;
- case CIFS_MAGIC_NUMBER: /* only supports full file server-side copies */
+ case CIFS_MAGIC_NUMBER:
+ return clone_file_range_cifs(src_fd, dst_fd, src_off, dst_off,
+ len);
default:
return ENOTSUP;
break;
--
2.13.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cloner: add support for clone_file_range for cifs
2018-09-11 5:28 ` [PATCH] " Ronnie Sahlberg
@ 2018-09-11 7:02 ` Christoph Hellwig
2018-09-11 7:26 ` ronnie sahlberg
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2018-09-11 7:02 UTC (permalink / raw)
To: Ronnie Sahlberg; +Cc: fstests
On Tue, Sep 11, 2018 at 03:28:06PM +1000, Ronnie Sahlberg wrote:
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
> src/cloner.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/src/cloner.c b/src/cloner.c
> index ffad82f0..9f9156e5 100644
> --- a/src/cloner.c
> +++ b/src/cloner.c
> @@ -120,6 +120,18 @@ clone_file_range_btrfs(int src_fd, int dst_fd, uint64_t src_off,
> }
>
> static int
> +clone_file_range_cifs(int fd_in, int fd_out, loff_t off_in,
> + loff_t off_out, size_t len)
> +{
> + int ret;
> +
> + ret = copy_file_range(fd_in, &off_in, fd_out, &off_out, len, 0);
> + if (ret < 0)
> + ret = errno;
> + return 0;
> +}
This is weird. cloner seems to test clone, in which case it should
test FICLONE (BTRFS_IOC_CLONE) / FICLONERANGE(BTRFS_IOC_CLONE_RANGE).
But it seems to check file system magic numbers which is rather bogus
to start with. I think the right fix here is to remove all the magic
number checks, always try FICLONE, and also remove support for the
odd legacy cifs ioctl.
> {
> @@ -128,7 +140,9 @@ clone_file_range(unsigned int fs_type, int src_fd, int dst_fd, uint64_t src_off,
> return clone_file_range_btrfs(src_fd, dst_fd, src_off, dst_off,
> len);
> break;
> - case CIFS_MAGIC_NUMBER: /* only supports full file server-side copies */
> + case CIFS_MAGIC_NUMBER:
> + return clone_file_range_cifs(src_fd, dst_fd, src_off, dst_off,
> + len);
> default:
> return ENOTSUP;
> break;
And independent break after a return is just insane. Someone needs
to fix this program to stop the eye bleeding..
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cloner: add support for clone_file_range for cifs
2018-09-11 7:02 ` Christoph Hellwig
@ 2018-09-11 7:26 ` ronnie sahlberg
0 siblings, 0 replies; 4+ messages in thread
From: ronnie sahlberg @ 2018-09-11 7:26 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Ronnie Sahlberg, fstests
On Tue, Sep 11, 2018 at 5:02 PM, Christoph Hellwig <hch@infradead.org> wrote:
> On Tue, Sep 11, 2018 at 03:28:06PM +1000, Ronnie Sahlberg wrote:
>> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
>> ---
>> src/cloner.c | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/cloner.c b/src/cloner.c
>> index ffad82f0..9f9156e5 100644
>> --- a/src/cloner.c
>> +++ b/src/cloner.c
>> @@ -120,6 +120,18 @@ clone_file_range_btrfs(int src_fd, int dst_fd, uint64_t src_off,
>> }
>>
>> static int
>> +clone_file_range_cifs(int fd_in, int fd_out, loff_t off_in,
>> + loff_t off_out, size_t len)
>> +{
>> + int ret;
>> +
>> + ret = copy_file_range(fd_in, &off_in, fd_out, &off_out, len, 0);
>> + if (ret < 0)
>> + ret = errno;
>> + return 0;
>> +}
>
> This is weird. cloner seems to test clone, in which case it should
> test FICLONE (BTRFS_IOC_CLONE) / FICLONERANGE(BTRFS_IOC_CLONE_RANGE).
>
> But it seems to check file system magic numbers which is rather bogus
> to start with. I think the right fix here is to remove all the magic
> number checks, always try FICLONE, and also remove support for the
> odd legacy cifs ioctl.
Thanks. That is a lot bigger change but it is the right thing to do.
Please disregard this patch and I will make a new patch with your suggestions.
>
>> {
>> @@ -128,7 +140,9 @@ clone_file_range(unsigned int fs_type, int src_fd, int dst_fd, uint64_t src_off,
>> return clone_file_range_btrfs(src_fd, dst_fd, src_off, dst_off,
>> len);
>> break;
>> - case CIFS_MAGIC_NUMBER: /* only supports full file server-side copies */
>> + case CIFS_MAGIC_NUMBER:
>> + return clone_file_range_cifs(src_fd, dst_fd, src_off, dst_off,
>> + len);
>> default:
>> return ENOTSUP;
>> break;
>
> And independent break after a return is just insane. Someone needs
> to fix this program to stop the eye bleeding..
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-11 12:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-11 5:28 [PATCH 0/1] cloner: add support for clone_file_range for cifs Ronnie Sahlberg
2018-09-11 5:28 ` [PATCH] " Ronnie Sahlberg
2018-09-11 7:02 ` Christoph Hellwig
2018-09-11 7:26 ` ronnie sahlberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox