All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about NFSv4.2 server-side copy implementation
@ 2017-02-14 20:07 Mora, Jorge
  2017-02-15 10:36 ` Kinglong Mee
  2017-02-17 20:02 ` J. Bruce Fields
  0 siblings, 2 replies; 7+ messages in thread
From: Mora, Jorge @ 2017-02-14 20:07 UTC (permalink / raw)
  To: linux-nfs

Hello,
=20
The NFSv4.2 spec (RFC 7862) on section 15.2.3 (COPY description) says the f=
ollowing:
=20
If the source offset or the source offset plus count is greater than
the size of the source file, the operation MUST fail with
NFS4ERR_INVAL.
=20
I can understand failing with NFS4ERR_INVAL when the source offset is beyon=
d the end of the file,
but do you think failing with NFS4ERR_INVAL is too strict when the source o=
ffset plus the count is beyond the end of the file?
What is the rationalization for failing on this specific instance?
Why not return a short copy instead?
Can the COPY return a count less than what it requested (a short copy)?
=20
As of right now, the implementation on the Linux server adheres to the spec=
 but copy_file_range succeeds
when it is called against the local file system, NFSv4.x or NFSv3.
For the local file system, NFSv4.x or NFSv3 copy_file_range falls back to r=
egular copy by
reading from the source file and then writing to the destination file but I=
 do believe the
syscall should be consistent regardless of the underlying file system.
=20
=20
--Jorge

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-14 20:07 Question about NFSv4.2 server-side copy implementation Mora, Jorge
@ 2017-02-15 10:36 ` Kinglong Mee
  2017-02-15 15:00   ` Trond Myklebust
  2017-02-15 15:40   ` Olga Kornievskaia
  2017-02-17 20:02 ` J. Bruce Fields
  1 sibling, 2 replies; 7+ messages in thread
From: Kinglong Mee @ 2017-02-15 10:36 UTC (permalink / raw)
  To: Mora, Jorge, linux-nfs; +Cc: Kinglong Mee

On 2/15/2017 04:07, Mora, Jorge wrote:
> Hello,
>  
> The NFSv4.2 spec (RFC 7862) on section 15.2.3 (COPY description) says the following:
>  
> If the source offset or the source offset plus count is greater than
> the size of the source file, the operation MUST fail with
> NFS4ERR_INVAL.
>  
> I can understand failing with NFS4ERR_INVAL when the source offset is beyond the end of the file,

Yes, that's right.

> but do you think failing with NFS4ERR_INVAL is too strict when the source offset plus the count is beyond the end of the file?
> What is the rationalization for failing on this specific instance?
> Why not return a short copy instead?

The man-pages of copy_file_range description as,

       EINVAL Requested range extends beyond the end of the  source  file;  or
              the flags argument is not 0.

So, the specific instance you said isn't allowed.

> Can the COPY return a count less than what it requested (a short copy)?

Yes, the return value of copy_file_range is,

RETURN VALUE
       Upon successful completion, copy_file_range() will return the number of
       bytes copied between files.  This could be less than the length  origi‐
       nally requested.

>  
> As of right now, the implementation on the Linux server adheres to the spec but copy_file_range succeeds
> when it is called against the local file system, NFSv4.x or NFSv3.

NFSv3 doesn't support copy_file_range, and only NFSv4.2 supports copy_file_range.

> For the local file system, NFSv4.x or NFSv3 copy_file_range falls back to regular copy by
> reading from the source file and then writing to the destination file but I do believe the
> syscall should be consistent regardless of the underlying file system.
>  
>  
> --Jorge
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-15 10:36 ` Kinglong Mee
@ 2017-02-15 15:00   ` Trond Myklebust
  2017-02-15 15:40   ` Olga Kornievskaia
  1 sibling, 0 replies; 7+ messages in thread
From: Trond Myklebust @ 2017-02-15 15:00 UTC (permalink / raw)
  To: kinglongmee, Jorge.Mora, linux-nfs

T24gV2VkLCAyMDE3LTAyLTE1IGF0IDE4OjM2ICswODAwLCBLaW5nbG9uZyBNZWUgd3JvdGU6DQo+
IE9uIDIvMTUvMjAxNyAwNDowNywgTW9yYSwgSm9yZ2Ugd3JvdGU6DQo+ID4gSGVsbG8sDQo+ID4g
wqANCj4gPiBUaGUgTkZTdjQuMiBzcGVjIChSRkMgNzg2Mikgb24gc2VjdGlvbiAxNS4yLjMgKENP
UFkgZGVzY3JpcHRpb24pDQo+ID4gc2F5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b24gb24gdGhlIElFVEYgbWFpbGluZyBsaXN0LiBU
aGlzDQptaWdodCBiZSBhIGNhbmRpZGF0ZSBmb3IgYSBORlN2NC4yIHByb3RvY29sIGVycmF0YS4N
Cg0KQ2hlZXJzDQogIFRyb25kDQotLSANClRyb25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVu
dCBtYWludGFpbmVyLCBQcmltYXJ5RGF0YQ0KdHJvbmQubXlrbGVidXN0QHByaW1hcnlkYXRhLmNv
bQ0K


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-15 10:36 ` Kinglong Mee
  2017-02-15 15:00   ` Trond Myklebust
@ 2017-02-15 15:40   ` Olga Kornievskaia
  1 sibling, 0 replies; 7+ messages in thread
From: Olga Kornievskaia @ 2017-02-15 15:40 UTC (permalink / raw)
  To: Kinglong Mee; +Cc: Mora, Jorge, linux-nfs

On Wed, Feb 15, 2017 at 5:36 AM, Kinglong Mee <kinglongmee@gmail.com> wrote=
:
> On 2/15/2017 04:07, Mora, Jorge wrote:
>> Hello,
>>
>> The NFSv4.2 spec (RFC 7862) on section 15.2.3 (COPY description) says th=
e following:
>>
>> If the source offset or the source offset plus count is greater than
>> the size of the source file, the operation MUST fail with
>> NFS4ERR_INVAL.
>>
>> I can understand failing with NFS4ERR_INVAL when the source offset is be=
yond the end of the file,
>
> Yes, that's right.
>
>> but do you think failing with NFS4ERR_INVAL is too strict when the sourc=
e offset plus the count is beyond the end of the file?
>> What is the rationalization for failing on this specific instance?
>> Why not return a short copy instead?
>
> The man-pages of copy_file_range description as,
>
>        EINVAL Requested range extends beyond the end of the  source  file=
;  or
>               the flags argument is not 0.
>
> So, the specific instance you said isn't allowed.
>
>> Can the COPY return a count less than what it requested (a short copy)?
>
> Yes, the return value of copy_file_range is,
>
> RETURN VALUE
>        Upon successful completion, copy_file_range() will return the numb=
er of
>        bytes copied between files.  This could be less than the length  o=
rigi=E2=80=90
>        nally requested.
>
>>
>> As of right now, the implementation on the Linux server adheres to the s=
pec but copy_file_range succeeds
>> when it is called against the local file system, NFSv4.x or NFSv3.
>
> NFSv3 doesn't support copy_file_range, and only NFSv4.2 supports copy_fil=
e_range.

copy_file_range() can be called with two file description that are
from the NFSv3 mounts and currently as you point NFSv3 does not
support copy_file_range() vfs_copy_file_range() will fall back into
doing "normal" copy via do_splice_direct() what happens here is that
NFSv3 will not fail with EINVAL and instead will return a partial
copy. Thus as Jorge points out, we have inconsistent results of a copy
being done via an NFS protocol v3 vs 4.2 protocol (if we were to
enforce the rule that the spec says).


>> For the local file system, NFSv4.x or NFSv3 copy_file_range falls back t=
o regular copy by
>> reading from the source file and then writing to the destination file bu=
t I do believe the
>> syscall should be consistent regardless of the underlying file system.
>>
>>
>> --Jorge
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-14 20:07 Question about NFSv4.2 server-side copy implementation Mora, Jorge
  2017-02-15 10:36 ` Kinglong Mee
@ 2017-02-17 20:02 ` J. Bruce Fields
  2017-02-17 21:10   ` Olga Kornievskaia
  1 sibling, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2017-02-17 20:02 UTC (permalink / raw)
  To: Mora, Jorge; +Cc: linux-nfs

On Tue, Feb 14, 2017 at 08:07:48PM +0000, Mora, Jorge wrote:
> I can understand failing with NFS4ERR_INVAL when the source offset is beyond the end of the file,
> but do you think failing with NFS4ERR_INVAL is too strict when the source offset plus the count is beyond the end of the file?
> What is the rationalization for failing on this specific instance?
> Why not return a short copy instead?
> Can the COPY return a count less than what it requested (a short copy)?
>  
> As of right now, the implementation on the Linux server adheres to the spec

That's weird, do you have network traces showing that, or is it possible
the EINVAL is happening on the client side?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-17 20:02 ` J. Bruce Fields
@ 2017-02-17 21:10   ` Olga Kornievskaia
  2017-02-17 21:21     ` J. Bruce Fields
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2017-02-17 21:10 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Mora, Jorge, linux-nfs

On Fri, Feb 17, 2017 at 3:02 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> On Tue, Feb 14, 2017 at 08:07:48PM +0000, Mora, Jorge wrote:
>> I can understand failing with NFS4ERR_INVAL when the source offset is beyond the end of the file,
>> but do you think failing with NFS4ERR_INVAL is too strict when the source offset plus the count is beyond the end of the file?
>> What is the rationalization for failing on this specific instance?
>> Why not return a short copy instead?
>> Can the COPY return a count less than what it requested (a short copy)?
>>
>> As of right now, the implementation on the Linux server adheres to the spec
>
> That's weird, do you have network traces showing that, or is it possible
> the EINVAL is happening on the client side?
>
> From a quick look at the server code I can't see where it would be
> generating that EINVAL, but I haven't tested this case and I could be
> overlooking something....
>

I think the current upstream COPY does not fail with EINVAL. The new
code that Jorge was testing does adhere to the spec and fails with
EINVAL.

Bruce, it looks to me that current upstream CLONE in this situation
will return EINVAL (I see that on the network trace since the client
will first try to do CLONE and if it can't it'll do COPY).

But we are trying to get some consistency in errors.


> --b.
>
>> but copy_file_range succeeds
>>
>> when it is called against the local file system, NFSv4.x or NFSv3.
>> For the local file system, NFSv4.x or NFSv3 copy_file_range falls back to regular copy by
>> reading from the source file and then writing to the destination file but I do believe the
>> syscall should be consistent regardless of the underlying file system.
>>
>>
>> --Jorge
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about NFSv4.2 server-side copy implementation
  2017-02-17 21:10   ` Olga Kornievskaia
@ 2017-02-17 21:21     ` J. Bruce Fields
  0 siblings, 0 replies; 7+ messages in thread
From: J. Bruce Fields @ 2017-02-17 21:21 UTC (permalink / raw)
  To: Olga Kornievskaia; +Cc: Mora, Jorge, linux-nfs

On Fri, Feb 17, 2017 at 04:10:45PM -0500, Olga Kornievskaia wrote:
> On Fri, Feb 17, 2017 at 3:02 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> > On Tue, Feb 14, 2017 at 08:07:48PM +0000, Mora, Jorge wrote:
> >> I can understand failing with NFS4ERR_INVAL when the source offset is beyond the end of the file,
> >> but do you think failing with NFS4ERR_INVAL is too strict when the source offset plus the count is beyond the end of the file?
> >> What is the rationalization for failing on this specific instance?
> >> Why not return a short copy instead?
> >> Can the COPY return a count less than what it requested (a short copy)?
> >>
> >> As of right now, the implementation on the Linux server adheres to the spec
> >
> > That's weird, do you have network traces showing that, or is it possible
> > the EINVAL is happening on the client side?
> >
> > From a quick look at the server code I can't see where it would be
> > generating that EINVAL, but I haven't tested this case and I could be
> > overlooking something....
> >
> 
> I think the current upstream COPY does not fail with EINVAL. The new
> code that Jorge was testing does adhere to the spec and fails with
> EINVAL.
> 
> Bruce, it looks to me that current upstream CLONE in this situation
> will return EINVAL (I see that on the network trace since the client
> will first try to do CLONE and if it can't it'll do COPY).

OK, I see, in fs/read_write.c:vfs_clone_file_range(),

	if (pos_in + len > i_size_read(inode_in))
		return -EINVAL;

And since a copy can be implemented under the covers as a clone, we can
hit that case in copy too.

(Though vfs_copy_file_range calls ->clone_file_range directly instead of
calling vfs_clone_file_range, so it's up to individual filesystems
whether they EINVAL in that case--the one I checked (btrfs) did, and I
think it makes sense for clone as it's an all-or-nothing operation.)

So maybe we have to allow this EINVAL behavior on copy, but it still
looks wrong to me to require it.

--b.


> 
> But we are trying to get some consistency in errors.
> 
> 
> > --b.
> >
> >> but copy_file_range succeeds
> >>
> >> when it is called against the local file system, NFSv4.x or NFSv3.
> >> For the local file system, NFSv4.x or NFSv3 copy_file_range falls back to regular copy by
> >> reading from the source file and then writing to the destination file but I do believe the
> >> syscall should be consistent regardless of the underlying file system.
> >>
> >>
> >> --Jorge
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-02-17 21:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-14 20:07 Question about NFSv4.2 server-side copy implementation Mora, Jorge
2017-02-15 10:36 ` Kinglong Mee
2017-02-15 15:00   ` Trond Myklebust
2017-02-15 15:40   ` Olga Kornievskaia
2017-02-17 20:02 ` J. Bruce Fields
2017-02-17 21:10   ` Olga Kornievskaia
2017-02-17 21:21     ` J. Bruce Fields

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.