All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
@ 2021-03-31 19:28 Olga Kornievskaia
  2021-04-01  1:50 ` J. Bruce Fields
  0 siblings, 1 reply; 13+ messages in thread
From: Olga Kornievskaia @ 2021-03-31 19:28 UTC (permalink / raw)
  To: bfields, chuck.lever; +Cc: linux-nfs

From: Olga Kornievskaia <kolga@netapp.com>

According to the RFC 7862, "if the server cannot find a
corresponding sa_what, then the status will still be NFS4_OK,
but sr_eof would be TRUE". If there is a file that ends with
a hole and a SEEK request made for sa_what=SEEK_DATA with
an offset in the middle of the last hole, then the server
has to return OK and set the eof. Currently the linux server
returns ERR_NXIO.

Fixes: 24bab491220fa ("NFSD: Implement SEEK")
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfsd/nfs4proc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index e13c4c81fb89..2e7ceb9f1d5d 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	 *        should ever file->f_pos.
 	 */
 	seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
-	if (seek->seek_pos < 0)
-		status = nfserrno(seek->seek_pos);
-	else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
+	if (seek->seek_pos < 0) {
+		if (whence == SEEK_DATA &&
+		    seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
+			seek->seek_eof = true;
+		else
+			status = nfserrno(seek->seek_pos);
+	} else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
 		seek->seek_eof = true;
 
 out:
-- 
2.18.2


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-03-31 19:28 [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole Olga Kornievskaia
@ 2021-04-01  1:50 ` J. Bruce Fields
  2021-04-01 13:27   ` Olga Kornievskaia
  0 siblings, 1 reply; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-01  1:50 UTC (permalink / raw)
  To: Olga Kornievskaia; +Cc: chuck.lever, linux-nfs

On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> From: Olga Kornievskaia <kolga@netapp.com>
> 
> According to the RFC 7862, "if the server cannot find a
> corresponding sa_what, then the status will still be NFS4_OK,
> but sr_eof would be TRUE". If there is a file that ends with
> a hole and a SEEK request made for sa_what=SEEK_DATA with
> an offset in the middle of the last hole, then the server
> has to return OK and set the eof. Currently the linux server
> returns ERR_NXIO.

Makes sense, but I think you can use the return value from vfs_llseek
instead of checking the file size again.  E.g.:

	seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
	if (seek->seek_pos == -ENXIO)
		seek->seek_eof = true;
	else if (seek->seek_pos < 0)
		status = nfserrno(seek->seek_pos);

--b.

> 
> Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> ---
>  fs/nfsd/nfs4proc.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index e13c4c81fb89..2e7ceb9f1d5d 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>  	 *        should ever file->f_pos.
>  	 */
>  	seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> -	if (seek->seek_pos < 0)
> -		status = nfserrno(seek->seek_pos);
> -	else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> +	if (seek->seek_pos < 0) {
> +		if (whence == SEEK_DATA &&
> +		    seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> +			seek->seek_eof = true;
> +		else
> +			status = nfserrno(seek->seek_pos);
> +	} else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
>  		seek->seek_eof = true;
>  
>  out:
> -- 
> 2.18.2
> 


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-01  1:50 ` J. Bruce Fields
@ 2021-04-01 13:27   ` Olga Kornievskaia
  2021-04-01 21:32     ` Rick Macklem
  2021-04-02 14:32     ` J. Bruce Fields
  0 siblings, 2 replies; 13+ messages in thread
From: Olga Kornievskaia @ 2021-04-01 13:27 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Chuck Lever, linux-nfs

On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
>
> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > From: Olga Kornievskaia <kolga@netapp.com>
> >
> > According to the RFC 7862, "if the server cannot find a
> > corresponding sa_what, then the status will still be NFS4_OK,
> > but sr_eof would be TRUE". If there is a file that ends with
> > a hole and a SEEK request made for sa_what=SEEK_DATA with
> > an offset in the middle of the last hole, then the server
> > has to return OK and set the eof. Currently the linux server
> > returns ERR_NXIO.
>
> Makes sense, but I think you can use the return value from vfs_llseek
> instead of checking the file size again.  E.g.:
>
>         seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
>         if (seek->seek_pos == -ENXIO)
>                 seek->seek_eof = true;

I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
specified seek_offset was beyond the end of the file the server must
return ERR_NXIO and not OK. and (2) for the same reason I need to
check if the requested type was looking for data but didn't find it
because the offset is in the middle of the hole but still within the
file size (thus the need to check if the seek_offset is within the
file size). But I'm happy to check specifically if the seek_pos was
ENXIO (and not the generic negative error) and then also check if
request was for data and request was within file size.

Also while I'm fixing this and have your attention, Can you tell if
the "else if" condition in the original code makes sense to you. I
didn't touch it but I don't think it's correct. "else if
(seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
believe this can ever happen. How can vfs_llseek() ever return a
position that is greater than the size of the file (or actually even
equal to it)?

>         else if (seek->seek_pos < 0)
>                 status = nfserrno(seek->seek_pos);
>
> --b.
>
> >
> > Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> > Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > ---
> >  fs/nfsd/nfs4proc.c | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> > index e13c4c81fb89..2e7ceb9f1d5d 100644
> > --- a/fs/nfsd/nfs4proc.c
> > +++ b/fs/nfsd/nfs4proc.c
> > @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> >        *        should ever file->f_pos.
> >        */
> >       seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> > -     if (seek->seek_pos < 0)
> > -             status = nfserrno(seek->seek_pos);
> > -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > +     if (seek->seek_pos < 0) {
> > +             if (whence == SEEK_DATA &&
> > +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> > +                     seek->seek_eof = true;
> > +             else
> > +                     status = nfserrno(seek->seek_pos);
> > +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> >               seek->seek_eof = true;
> >
> >  out:
> > --
> > 2.18.2
> >
>

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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-01 13:27   ` Olga Kornievskaia
@ 2021-04-01 21:32     ` Rick Macklem
  2021-04-02 21:01       ` J. Bruce Fields
  2021-04-02 14:32     ` J. Bruce Fields
  1 sibling, 1 reply; 13+ messages in thread
From: Rick Macklem @ 2021-04-01 21:32 UTC (permalink / raw)
  To: Olga Kornievskaia, J. Bruce Fields; +Cc: Chuck Lever, linux-nfs

I discussed this on nfsv4@ietf.org some time ago.
The problem with "fixing" the server is that it breaks
the unpatched Linux client.

If the client is careful, it can work correctly for both a Linux
and RFC5661 conformant server. That's what the FreeBSD
client tries to do.
--> I'd suggest that be your main goal.

The FreeBSD server ships "Linux compatible", but there is
a switch to make it RFC5661 compatible.
--> I wouldn't make it default the RFC compatible for
      quite a while after the client that handles RFC compatible
      ships.

I tried to convince folks to "errata" the RFC to Linux
compatible (since Linux was the only shipping 4.2 at
the time, but they did not consider it an "errata").

Just mho, rick

________________________________________
From: Olga Kornievskaia <olga.kornievskaia@gmail.com>
Sent: Thursday, April 1, 2021 9:27 AM
To: J. Bruce Fields
Cc: Chuck Lever; linux-nfs
Subject: Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole

CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to IThelp@uoguelph.ca


On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
>
> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > From: Olga Kornievskaia <kolga@netapp.com>
> >
> > According to the RFC 7862, "if the server cannot find a
> > corresponding sa_what, then the status will still be NFS4_OK,
> > but sr_eof would be TRUE". If there is a file that ends with
> > a hole and a SEEK request made for sa_what=SEEK_DATA with
> > an offset in the middle of the last hole, then the server
> > has to return OK and set the eof. Currently the linux server
> > returns ERR_NXIO.
>
> Makes sense, but I think you can use the return value from vfs_llseek
> instead of checking the file size again.  E.g.:
>
>         seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
>         if (seek->seek_pos == -ENXIO)
>                 seek->seek_eof = true;

I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
specified seek_offset was beyond the end of the file the server must
return ERR_NXIO and not OK. and (2) for the same reason I need to
check if the requested type was looking for data but didn't find it
because the offset is in the middle of the hole but still within the
file size (thus the need to check if the seek_offset is within the
file size). But I'm happy to check specifically if the seek_pos was
ENXIO (and not the generic negative error) and then also check if
request was for data and request was within file size.

Also while I'm fixing this and have your attention, Can you tell if
the "else if" condition in the original code makes sense to you. I
didn't touch it but I don't think it's correct. "else if
(seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
believe this can ever happen. How can vfs_llseek() ever return a
position that is greater than the size of the file (or actually even
equal to it)?

>         else if (seek->seek_pos < 0)
>                 status = nfserrno(seek->seek_pos);
>
> --b.
>
> >
> > Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> > Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > ---
> >  fs/nfsd/nfs4proc.c | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> > index e13c4c81fb89..2e7ceb9f1d5d 100644
> > --- a/fs/nfsd/nfs4proc.c
> > +++ b/fs/nfsd/nfs4proc.c
> > @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> >        *        should ever file->f_pos.
> >        */
> >       seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> > -     if (seek->seek_pos < 0)
> > -             status = nfserrno(seek->seek_pos);
> > -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > +     if (seek->seek_pos < 0) {
> > +             if (whence == SEEK_DATA &&
> > +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> > +                     seek->seek_eof = true;
> > +             else
> > +                     status = nfserrno(seek->seek_pos);
> > +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> >               seek->seek_eof = true;
> >
> >  out:
> > --
> > 2.18.2
> >
>

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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-01 13:27   ` Olga Kornievskaia
  2021-04-01 21:32     ` Rick Macklem
@ 2021-04-02 14:32     ` J. Bruce Fields
  2021-04-09 18:39       ` Olga Kornievskaia
  1 sibling, 1 reply; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-02 14:32 UTC (permalink / raw)
  To: Olga Kornievskaia; +Cc: Chuck Lever, linux-nfs

On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
> On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
> >
> > On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > > From: Olga Kornievskaia <kolga@netapp.com>
> > >
> > > According to the RFC 7862, "if the server cannot find a
> > > corresponding sa_what, then the status will still be NFS4_OK,
> > > but sr_eof would be TRUE". If there is a file that ends with
> > > a hole and a SEEK request made for sa_what=SEEK_DATA with
> > > an offset in the middle of the last hole, then the server
> > > has to return OK and set the eof. Currently the linux server
> > > returns ERR_NXIO.
> >
> > Makes sense, but I think you can use the return value from vfs_llseek
> > instead of checking the file size again.  E.g.:
> >
> >         seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
> >         if (seek->seek_pos == -ENXIO)
> >                 seek->seek_eof = true;
> 
> I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
> specified seek_offset was beyond the end of the file the server must
> return ERR_NXIO and not OK.

OK, never mind.

> and (2) for the same reason I need to
> check if the requested type was looking for data but didn't find it
> because the offset is in the middle of the hole but still within the
> file size (thus the need to check if the seek_offset is within the
> file size). But I'm happy to check specifically if the seek_pos was
> ENXIO (and not the generic negative error) and then also check if
> request was for data and request was within file size.
> 
> Also while I'm fixing this and have your attention, Can you tell if
> the "else if" condition in the original code makes sense to you. I
> didn't touch it but I don't think it's correct. "else if
> (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
> believe this can ever happen. How can vfs_llseek() ever return a
> position that is greater than the size of the file (or actually even
> equal to it)?

I agree, I don't get it either.

--b.

> 
> >         else if (seek->seek_pos < 0)
> >                 status = nfserrno(seek->seek_pos);
> >
> > --b.
> >
> > >
> > > Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> > > Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > > ---
> > >  fs/nfsd/nfs4proc.c | 10 +++++++---
> > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> > > index e13c4c81fb89..2e7ceb9f1d5d 100644
> > > --- a/fs/nfsd/nfs4proc.c
> > > +++ b/fs/nfsd/nfs4proc.c
> > > @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> > >        *        should ever file->f_pos.
> > >        */
> > >       seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> > > -     if (seek->seek_pos < 0)
> > > -             status = nfserrno(seek->seek_pos);
> > > -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > > +     if (seek->seek_pos < 0) {
> > > +             if (whence == SEEK_DATA &&
> > > +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> > > +                     seek->seek_eof = true;
> > > +             else
> > > +                     status = nfserrno(seek->seek_pos);
> > > +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > >               seek->seek_eof = true;
> > >
> > >  out:
> > > --
> > > 2.18.2
> > >
> >
> 


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-01 21:32     ` Rick Macklem
@ 2021-04-02 21:01       ` J. Bruce Fields
       [not found]         ` <CADaq8jeNrA3TexAM0dBxj7LSoooyRna6wU-VomDKovodYTdqKA@mail.gmail.com>
  2021-04-09 20:24         ` Frank Filz
  0 siblings, 2 replies; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-02 21:01 UTC (permalink / raw)
  To: Rick Macklem
  Cc: Olga Kornievskaia, J. Bruce Fields, Chuck Lever, linux-nfs, nfsv4

Adding nfsv4@ietf.org:

On Thu, Apr 01, 2021 at 09:32:05PM +0000, Rick Macklem wrote:
> I discussed this on nfsv4@ietf.org some time ago.
> The problem with "fixing" the server is that it breaks
> the unpatched Linux client.
> 
> If the client is careful, it can work correctly for both a Linux
> and RFC5661 conformant server. That's what the FreeBSD
> client tries to do.
> --> I'd suggest that be your main goal.
> 
> The FreeBSD server ships "Linux compatible", but there is
> a switch to make it RFC5661 compatible.
> --> I wouldn't make it default the RFC compatible for
>       quite a while after the client that handles RFC compatible
>       ships.
> 
> I tried to convince folks to "errata" the RFC to Linux
> compatible (since Linux was the only shipping 4.2 at
> the time, but they did not consider it an "errata").

Previous discussion here:

	https://mailarchive.ietf.org/arch/msg/nfsv4/bPLFnywt1wZ4kolMkzeSYca0qIM/

There's no rejection on that thread, was it elsewhere?

--b.

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

* Re: [nfsv4] [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
       [not found]         ` <CADaq8jeNrA3TexAM0dBxj7LSoooyRna6wU-VomDKovodYTdqKA@mail.gmail.com>
@ 2021-04-05 14:06           ` J. Bruce Fields
  0 siblings, 0 replies; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-05 14:06 UTC (permalink / raw)
  To: David Noveck
  Cc: J. Bruce Fields, Rick Macklem, Olga Kornievskaia, linux-nfs, NFSv4

On Fri, Apr 02, 2021 at 10:58:15PM -0400, David Noveck wrote:
> However, if one had been made, it would have been rejected.   It is not the
> function of the errata mechanism to make substantive protocol changes like
> this, even if the wg thinks the original consensus decision was wrong.  To
> do that you need a standards-track document updating the original one and
> addressimg compatibility issues. Nobody was up for that at the time or
> seems to be now.

Do we have any sort of informal todo list for a 7862bis?

--b.


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-02 14:32     ` J. Bruce Fields
@ 2021-04-09 18:39       ` Olga Kornievskaia
  2021-04-11 16:43         ` Chuck Lever III
  0 siblings, 1 reply; 13+ messages in thread
From: Olga Kornievskaia @ 2021-04-09 18:39 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Chuck Lever, linux-nfs

On Fri, Apr 2, 2021 at 10:32 AM J. Bruce Fields <bfields@redhat.com> wrote:
>
> On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
> > On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
> > >
> > > On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > > > From: Olga Kornievskaia <kolga@netapp.com>
> > > >
> > > > According to the RFC 7862, "if the server cannot find a
> > > > corresponding sa_what, then the status will still be NFS4_OK,
> > > > but sr_eof would be TRUE". If there is a file that ends with
> > > > a hole and a SEEK request made for sa_what=SEEK_DATA with
> > > > an offset in the middle of the last hole, then the server
> > > > has to return OK and set the eof. Currently the linux server
> > > > returns ERR_NXIO.
> > >
> > > Makes sense, but I think you can use the return value from vfs_llseek
> > > instead of checking the file size again.  E.g.:
> > >
> > >         seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
> > >         if (seek->seek_pos == -ENXIO)
> > >                 seek->seek_eof = true;
> >
> > I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
> > specified seek_offset was beyond the end of the file the server must
> > return ERR_NXIO and not OK.
>
> OK, never mind.
>
> > and (2) for the same reason I need to
> > check if the requested type was looking for data but didn't find it
> > because the offset is in the middle of the hole but still within the
> > file size (thus the need to check if the seek_offset is within the
> > file size). But I'm happy to check specifically if the seek_pos was
> > ENXIO (and not the generic negative error) and then also check if
> > request was for data and request was within file size.
> >
> > Also while I'm fixing this and have your attention, Can you tell if
> > the "else if" condition in the original code makes sense to you. I
> > didn't touch it but I don't think it's correct. "else if
> > (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
> > believe this can ever happen. How can vfs_llseek() ever return a
> > position that is greater than the size of the file (or actually even
> > equal to it)?
>
> I agree, I don't get it either.

Any more thoughts about the forward progress of this patch? Are you
interested in taking it?

>
> --b.
>
> >
> > >         else if (seek->seek_pos < 0)
> > >                 status = nfserrno(seek->seek_pos);
> > >
> > > --b.
> > >
> > > >
> > > > Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> > > > Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > > > ---
> > > >  fs/nfsd/nfs4proc.c | 10 +++++++---
> > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> > > > index e13c4c81fb89..2e7ceb9f1d5d 100644
> > > > --- a/fs/nfsd/nfs4proc.c
> > > > +++ b/fs/nfsd/nfs4proc.c
> > > > @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> > > >        *        should ever file->f_pos.
> > > >        */
> > > >       seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> > > > -     if (seek->seek_pos < 0)
> > > > -             status = nfserrno(seek->seek_pos);
> > > > -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > > > +     if (seek->seek_pos < 0) {
> > > > +             if (whence == SEEK_DATA &&
> > > > +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> > > > +                     seek->seek_eof = true;
> > > > +             else
> > > > +                     status = nfserrno(seek->seek_pos);
> > > > +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > > >               seek->seek_eof = true;
> > > >
> > > >  out:
> > > > --
> > > > 2.18.2
> > > >
> > >
> >
>

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

* RE: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-02 21:01       ` J. Bruce Fields
       [not found]         ` <CADaq8jeNrA3TexAM0dBxj7LSoooyRna6wU-VomDKovodYTdqKA@mail.gmail.com>
@ 2021-04-09 20:24         ` Frank Filz
  1 sibling, 0 replies; 13+ messages in thread
From: Frank Filz @ 2021-04-09 20:24 UTC (permalink / raw)
  To: 'J. Bruce Fields', 'Rick Macklem'
  Cc: 'Olga Kornievskaia', 'J. Bruce Fields',
	'Chuck Lever', 'linux-nfs',
	nfsv4

> Adding nfsv4@ietf.org:
> 
> On Thu, Apr 01, 2021 at 09:32:05PM +0000, Rick Macklem wrote:
> > I discussed this on nfsv4@ietf.org some time ago.
> > The problem with "fixing" the server is that it breaks the unpatched
> > Linux client.
> >
> > If the client is careful, it can work correctly for both a Linux and
> > RFC5661 conformant server. That's what the FreeBSD client tries to do.
> > --> I'd suggest that be your main goal.
> >
> > The FreeBSD server ships "Linux compatible", but there is a switch to
> > make it RFC5661 compatible.
> > --> I wouldn't make it default the RFC compatible for
> >       quite a while after the client that handles RFC compatible
> >       ships.
> >
> > I tried to convince folks to "errata" the RFC to Linux compatible
> > (since Linux was the only shipping 4.2 at the time, but they did not
> > consider it an "errata").
> 
> Previous discussion here:
> 
> 	https://mailarchive.ietf.org/arch/msg/nfsv4/bPLFnywt1wZ4kolMkzeSYc
> a0qIM/
> 
> There's no rejection on that thread, was it elsewhere?

Yea, it would be nice to resolve this. I remember having to tweak Ganesha's
implementation to not break the Linux client.

I'm still not sure I got it right...

Frank


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-09 18:39       ` Olga Kornievskaia
@ 2021-04-11 16:43         ` Chuck Lever III
  2021-04-13 15:01           ` J. Bruce Fields
  0 siblings, 1 reply; 13+ messages in thread
From: Chuck Lever III @ 2021-04-11 16:43 UTC (permalink / raw)
  To: Olga Kornievskaia, Bruce Fields; +Cc: Linux NFS Mailing List



> On Apr 9, 2021, at 2:39 PM, Olga Kornievskaia <olga.kornievskaia@gmail.com> wrote:
> 
> On Fri, Apr 2, 2021 at 10:32 AM J. Bruce Fields <bfields@redhat.com> wrote:
>> 
>> On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
>>> On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
>>>> 
>>>> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
>>>>> From: Olga Kornievskaia <kolga@netapp.com>
>>>>> 
>>>>> According to the RFC 7862, "if the server cannot find a
>>>>> corresponding sa_what, then the status will still be NFS4_OK,
>>>>> but sr_eof would be TRUE". If there is a file that ends with
>>>>> a hole and a SEEK request made for sa_what=SEEK_DATA with
>>>>> an offset in the middle of the last hole, then the server
>>>>> has to return OK and set the eof. Currently the linux server
>>>>> returns ERR_NXIO.
>>>> 
>>>> Makes sense, but I think you can use the return value from vfs_llseek
>>>> instead of checking the file size again.  E.g.:
>>>> 
>>>>        seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
>>>>        if (seek->seek_pos == -ENXIO)
>>>>                seek->seek_eof = true;
>>> 
>>> I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
>>> specified seek_offset was beyond the end of the file the server must
>>> return ERR_NXIO and not OK.
>> 
>> OK, never mind.
>> 
>>> and (2) for the same reason I need to
>>> check if the requested type was looking for data but didn't find it
>>> because the offset is in the middle of the hole but still within the
>>> file size (thus the need to check if the seek_offset is within the
>>> file size). But I'm happy to check specifically if the seek_pos was
>>> ENXIO (and not the generic negative error) and then also check if
>>> request was for data and request was within file size.
>>> 
>>> Also while I'm fixing this and have your attention, Can you tell if
>>> the "else if" condition in the original code makes sense to you. I
>>> didn't touch it but I don't think it's correct. "else if
>>> (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
>>> believe this can ever happen. How can vfs_llseek() ever return a
>>> position that is greater than the size of the file (or actually even
>>> equal to it)?
>> 
>> I agree, I don't get it either.
> 
> Any more thoughts about the forward progress of this patch? Are you
> interested in taking it?

Bruce and I discussed this privately a few days back. He asked
that I not merge it until the client compatibility issue is
resolved. Bruce, please chime in if I misunderstood you.


>> --b.
>> 
>>> 
>>>>        else if (seek->seek_pos < 0)
>>>>                status = nfserrno(seek->seek_pos);
>>>> 
>>>> --b.
>>>> 
>>>>> 
>>>>> Fixes: 24bab491220fa ("NFSD: Implement SEEK")
>>>>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
>>>>> ---
>>>>> fs/nfsd/nfs4proc.c | 10 +++++++---
>>>>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>>>> 
>>>>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>>>>> index e13c4c81fb89..2e7ceb9f1d5d 100644
>>>>> --- a/fs/nfsd/nfs4proc.c
>>>>> +++ b/fs/nfsd/nfs4proc.c
>>>>> @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>>>>>       *        should ever file->f_pos.
>>>>>       */
>>>>>      seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
>>>>> -     if (seek->seek_pos < 0)
>>>>> -             status = nfserrno(seek->seek_pos);
>>>>> -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
>>>>> +     if (seek->seek_pos < 0) {
>>>>> +             if (whence == SEEK_DATA &&
>>>>> +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
>>>>> +                     seek->seek_eof = true;
>>>>> +             else
>>>>> +                     status = nfserrno(seek->seek_pos);
>>>>> +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
>>>>>              seek->seek_eof = true;
>>>>> 
>>>>> out:
>>>>> --
>>>>> 2.18.2

--
Chuck Lever




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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-11 16:43         ` Chuck Lever III
@ 2021-04-13 15:01           ` J. Bruce Fields
  2021-04-13 15:31             ` Olga Kornievskaia
  0 siblings, 1 reply; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-13 15:01 UTC (permalink / raw)
  To: Chuck Lever III; +Cc: Olga Kornievskaia, Linux NFS Mailing List

On Sun, Apr 11, 2021 at 04:43:22PM +0000, Chuck Lever III wrote:
> 
> 
> > On Apr 9, 2021, at 2:39 PM, Olga Kornievskaia <olga.kornievskaia@gmail.com> wrote:
> > 
> > On Fri, Apr 2, 2021 at 10:32 AM J. Bruce Fields <bfields@redhat.com> wrote:
> >> 
> >> On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
> >>> On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
> >>>> 
> >>>> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> >>>>> From: Olga Kornievskaia <kolga@netapp.com>
> >>>>> 
> >>>>> According to the RFC 7862, "if the server cannot find a
> >>>>> corresponding sa_what, then the status will still be NFS4_OK,
> >>>>> but sr_eof would be TRUE". If there is a file that ends with
> >>>>> a hole and a SEEK request made for sa_what=SEEK_DATA with
> >>>>> an offset in the middle of the last hole, then the server
> >>>>> has to return OK and set the eof. Currently the linux server
> >>>>> returns ERR_NXIO.
> >>>> 
> >>>> Makes sense, but I think you can use the return value from vfs_llseek
> >>>> instead of checking the file size again.  E.g.:
> >>>> 
> >>>>        seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
> >>>>        if (seek->seek_pos == -ENXIO)
> >>>>                seek->seek_eof = true;
> >>> 
> >>> I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
> >>> specified seek_offset was beyond the end of the file the server must
> >>> return ERR_NXIO and not OK.
> >> 
> >> OK, never mind.
> >> 
> >>> and (2) for the same reason I need to
> >>> check if the requested type was looking for data but didn't find it
> >>> because the offset is in the middle of the hole but still within the
> >>> file size (thus the need to check if the seek_offset is within the
> >>> file size). But I'm happy to check specifically if the seek_pos was
> >>> ENXIO (and not the generic negative error) and then also check if
> >>> request was for data and request was within file size.
> >>> 
> >>> Also while I'm fixing this and have your attention, Can you tell if
> >>> the "else if" condition in the original code makes sense to you. I
> >>> didn't touch it but I don't think it's correct. "else if
> >>> (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
> >>> believe this can ever happen. How can vfs_llseek() ever return a
> >>> position that is greater than the size of the file (or actually even
> >>> equal to it)?
> >> 
> >> I agree, I don't get it either.
> > 
> > Any more thoughts about the forward progress of this patch? Are you
> > interested in taking it?
> 
> Bruce and I discussed this privately a few days back. He asked
> that I not merge it until the client compatibility issue is
> resolved. Bruce, please chime in if I misunderstood you.

Honestly, I haven't even looked at what the issue is.  I think Olga
agreed with Rick that there was one, though?

--b.

> 
> 
> >> --b.
> >> 
> >>> 
> >>>>        else if (seek->seek_pos < 0)
> >>>>                status = nfserrno(seek->seek_pos);
> >>>> 
> >>>> --b.
> >>>> 
> >>>>> 
> >>>>> Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> >>>>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> >>>>> ---
> >>>>> fs/nfsd/nfs4proc.c | 10 +++++++---
> >>>>> 1 file changed, 7 insertions(+), 3 deletions(-)
> >>>>> 
> >>>>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> >>>>> index e13c4c81fb89..2e7ceb9f1d5d 100644
> >>>>> --- a/fs/nfsd/nfs4proc.c
> >>>>> +++ b/fs/nfsd/nfs4proc.c
> >>>>> @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> >>>>>       *        should ever file->f_pos.
> >>>>>       */
> >>>>>      seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> >>>>> -     if (seek->seek_pos < 0)
> >>>>> -             status = nfserrno(seek->seek_pos);
> >>>>> -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> >>>>> +     if (seek->seek_pos < 0) {
> >>>>> +             if (whence == SEEK_DATA &&
> >>>>> +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> >>>>> +                     seek->seek_eof = true;
> >>>>> +             else
> >>>>> +                     status = nfserrno(seek->seek_pos);
> >>>>> +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> >>>>>              seek->seek_eof = true;
> >>>>> 
> >>>>> out:
> >>>>> --
> >>>>> 2.18.2
> 
> --
> Chuck Lever
> 
> 
> 


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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-13 15:01           ` J. Bruce Fields
@ 2021-04-13 15:31             ` Olga Kornievskaia
  2021-04-13 17:30               ` J. Bruce Fields
  0 siblings, 1 reply; 13+ messages in thread
From: Olga Kornievskaia @ 2021-04-13 15:31 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Chuck Lever III, Linux NFS Mailing List

On Tue, Apr 13, 2021 at 11:01 AM J. Bruce Fields <bfields@redhat.com> wrote:
>
> On Sun, Apr 11, 2021 at 04:43:22PM +0000, Chuck Lever III wrote:
> >
> >
> > > On Apr 9, 2021, at 2:39 PM, Olga Kornievskaia <olga.kornievskaia@gmail.com> wrote:
> > >
> > > On Fri, Apr 2, 2021 at 10:32 AM J. Bruce Fields <bfields@redhat.com> wrote:
> > >>
> > >> On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
> > >>> On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
> > >>>>
> > >>>> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > >>>>> From: Olga Kornievskaia <kolga@netapp.com>
> > >>>>>
> > >>>>> According to the RFC 7862, "if the server cannot find a
> > >>>>> corresponding sa_what, then the status will still be NFS4_OK,
> > >>>>> but sr_eof would be TRUE". If there is a file that ends with
> > >>>>> a hole and a SEEK request made for sa_what=SEEK_DATA with
> > >>>>> an offset in the middle of the last hole, then the server
> > >>>>> has to return OK and set the eof. Currently the linux server
> > >>>>> returns ERR_NXIO.
> > >>>>
> > >>>> Makes sense, but I think you can use the return value from vfs_llseek
> > >>>> instead of checking the file size again.  E.g.:
> > >>>>
> > >>>>        seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
> > >>>>        if (seek->seek_pos == -ENXIO)
> > >>>>                seek->seek_eof = true;
> > >>>
> > >>> I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
> > >>> specified seek_offset was beyond the end of the file the server must
> > >>> return ERR_NXIO and not OK.
> > >>
> > >> OK, never mind.
> > >>
> > >>> and (2) for the same reason I need to
> > >>> check if the requested type was looking for data but didn't find it
> > >>> because the offset is in the middle of the hole but still within the
> > >>> file size (thus the need to check if the seek_offset is within the
> > >>> file size). But I'm happy to check specifically if the seek_pos was
> > >>> ENXIO (and not the generic negative error) and then also check if
> > >>> request was for data and request was within file size.
> > >>>
> > >>> Also while I'm fixing this and have your attention, Can you tell if
> > >>> the "else if" condition in the original code makes sense to you. I
> > >>> didn't touch it but I don't think it's correct. "else if
> > >>> (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
> > >>> believe this can ever happen. How can vfs_llseek() ever return a
> > >>> position that is greater than the size of the file (or actually even
> > >>> equal to it)?
> > >>
> > >> I agree, I don't get it either.
> > >
> > > Any more thoughts about the forward progress of this patch? Are you
> > > interested in taking it?
> >
> > Bruce and I discussed this privately a few days back. He asked
> > that I not merge it until the client compatibility issue is
> > resolved. Bruce, please chime in if I misunderstood you.
>
> Honestly, I haven't even looked at what the issue is.  I think Olga
> agreed with Rick that there was one, though?

I agree that the client is broken. I have a client side patch that was
posted alongside the server side patch. I think Trond should be taking
it for whatever the next push will be. But yes the server side needs
to worry about the existing broken clients that are out there
currently. I'm not sure what the implications are. So what happens
with the fixed server is that for the request for DATA in the last
hole, the server would return OK, eof and offset that max_int (-1)
(previously it would be an error). Broken client would return that
address back in the system call. If the application tries to read from
it, it would not get anything (0, oef).

I think I'll repost the v2 and then I'll let you decide when and how
you want to take it. The client will soon be able to handle both but
it doesn't require the server to be fixed.

>
> --b.
>
> >
> >
> > >> --b.
> > >>
> > >>>
> > >>>>        else if (seek->seek_pos < 0)
> > >>>>                status = nfserrno(seek->seek_pos);
> > >>>>
> > >>>> --b.
> > >>>>
> > >>>>>
> > >>>>> Fixes: 24bab491220fa ("NFSD: Implement SEEK")
> > >>>>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > >>>>> ---
> > >>>>> fs/nfsd/nfs4proc.c | 10 +++++++---
> > >>>>> 1 file changed, 7 insertions(+), 3 deletions(-)
> > >>>>>
> > >>>>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> > >>>>> index e13c4c81fb89..2e7ceb9f1d5d 100644
> > >>>>> --- a/fs/nfsd/nfs4proc.c
> > >>>>> +++ b/fs/nfsd/nfs4proc.c
> > >>>>> @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> > >>>>>       *        should ever file->f_pos.
> > >>>>>       */
> > >>>>>      seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence);
> > >>>>> -     if (seek->seek_pos < 0)
> > >>>>> -             status = nfserrno(seek->seek_pos);
> > >>>>> -     else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > >>>>> +     if (seek->seek_pos < 0) {
> > >>>>> +             if (whence == SEEK_DATA &&
> > >>>>> +                 seek->seek_offset < i_size_read(file_inode(nf->nf_file)))
> > >>>>> +                     seek->seek_eof = true;
> > >>>>> +             else
> > >>>>> +                     status = nfserrno(seek->seek_pos);
> > >>>>> +     } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))
> > >>>>>              seek->seek_eof = true;
> > >>>>>
> > >>>>> out:
> > >>>>> --
> > >>>>> 2.18.2
> >
> > --
> > Chuck Lever
> >
> >
> >
>

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

* Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole
  2021-04-13 15:31             ` Olga Kornievskaia
@ 2021-04-13 17:30               ` J. Bruce Fields
  0 siblings, 0 replies; 13+ messages in thread
From: J. Bruce Fields @ 2021-04-13 17:30 UTC (permalink / raw)
  To: Olga Kornievskaia
  Cc: J. Bruce Fields, Chuck Lever III, Linux NFS Mailing List

On Tue, Apr 13, 2021 at 11:31:51AM -0400, Olga Kornievskaia wrote:
> On Tue, Apr 13, 2021 at 11:01 AM J. Bruce Fields <bfields@redhat.com> wrote:
> >
> > On Sun, Apr 11, 2021 at 04:43:22PM +0000, Chuck Lever III wrote:
> > >
> > >
> > > > On Apr 9, 2021, at 2:39 PM, Olga Kornievskaia <olga.kornievskaia@gmail.com> wrote:
> > > >
> > > > On Fri, Apr 2, 2021 at 10:32 AM J. Bruce Fields <bfields@redhat.com> wrote:
> > > >>
> > > >> On Thu, Apr 01, 2021 at 09:27:56AM -0400, Olga Kornievskaia wrote:
> > > >>> On Wed, Mar 31, 2021 at 9:50 PM J. Bruce Fields <bfields@redhat.com> wrote:
> > > >>>>
> > > >>>> On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> > > >>>>> From: Olga Kornievskaia <kolga@netapp.com>
> > > >>>>>
> > > >>>>> According to the RFC 7862, "if the server cannot find a
> > > >>>>> corresponding sa_what, then the status will still be NFS4_OK,
> > > >>>>> but sr_eof would be TRUE". If there is a file that ends with
> > > >>>>> a hole and a SEEK request made for sa_what=SEEK_DATA with
> > > >>>>> an offset in the middle of the last hole, then the server
> > > >>>>> has to return OK and set the eof. Currently the linux server
> > > >>>>> returns ERR_NXIO.
> > > >>>>
> > > >>>> Makes sense, but I think you can use the return value from vfs_llseek
> > > >>>> instead of checking the file size again.  E.g.:
> > > >>>>
> > > >>>>        seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence);
> > > >>>>        if (seek->seek_pos == -ENXIO)
> > > >>>>                seek->seek_eof = true;
> > > >>>
> > > >>> I don't believe this is correct. (1) ENXIO doesn't imply eof. If the
> > > >>> specified seek_offset was beyond the end of the file the server must
> > > >>> return ERR_NXIO and not OK.
> > > >>
> > > >> OK, never mind.
> > > >>
> > > >>> and (2) for the same reason I need to
> > > >>> check if the requested type was looking for data but didn't find it
> > > >>> because the offset is in the middle of the hole but still within the
> > > >>> file size (thus the need to check if the seek_offset is within the
> > > >>> file size). But I'm happy to check specifically if the seek_pos was
> > > >>> ENXIO (and not the generic negative error) and then also check if
> > > >>> request was for data and request was within file size.
> > > >>>
> > > >>> Also while I'm fixing this and have your attention, Can you tell if
> > > >>> the "else if" condition in the original code makes sense to you. I
> > > >>> didn't touch it but I don't think it's correct. "else if
> > > >>> (seek->seek_pos >= i_size_read(file_inode(nf->nf_file)))" I don't
> > > >>> believe this can ever happen. How can vfs_llseek() ever return a
> > > >>> position that is greater than the size of the file (or actually even
> > > >>> equal to it)?
> > > >>
> > > >> I agree, I don't get it either.
> > > >
> > > > Any more thoughts about the forward progress of this patch? Are you
> > > > interested in taking it?
> > >
> > > Bruce and I discussed this privately a few days back. He asked
> > > that I not merge it until the client compatibility issue is
> > > resolved. Bruce, please chime in if I misunderstood you.
> >
> > Honestly, I haven't even looked at what the issue is.  I think Olga
> > agreed with Rick that there was one, though?
> 
> I agree that the client is broken. I have a client side patch that was
> posted alongside the server side patch. I think Trond should be taking
> it for whatever the next push will be. But yes the server side needs
> to worry about the existing broken clients that are out there
> currently. I'm not sure what the implications are. So what happens
> with the fixed server is that for the request for DATA in the last
> hole, the server would return OK, eof and offset that max_int (-1)
> (previously it would be an error). Broken client would return that
> address back in the system call. If the application tries to read from
> it, it would not get anything (0, oef).
> 
> I think I'll repost the v2 and then I'll let you decide when and how
> you want to take it. The client will soon be able to handle both but
> it doesn't require the server to be fixed.

OK.  I don't particularly want to create a situation where a server
upgrade requires a client upgrade, so I don't think we'd want to take it
now, but post it anyway, for posterity's sake--maybe the tradeoffs would
be different in a few years.

--b.

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

end of thread, other threads:[~2021-04-13 17:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 19:28 [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole Olga Kornievskaia
2021-04-01  1:50 ` J. Bruce Fields
2021-04-01 13:27   ` Olga Kornievskaia
2021-04-01 21:32     ` Rick Macklem
2021-04-02 21:01       ` J. Bruce Fields
     [not found]         ` <CADaq8jeNrA3TexAM0dBxj7LSoooyRna6wU-VomDKovodYTdqKA@mail.gmail.com>
2021-04-05 14:06           ` [nfsv4] " J. Bruce Fields
2021-04-09 20:24         ` Frank Filz
2021-04-02 14:32     ` J. Bruce Fields
2021-04-09 18:39       ` Olga Kornievskaia
2021-04-11 16:43         ` Chuck Lever III
2021-04-13 15:01           ` J. Bruce Fields
2021-04-13 15:31             ` Olga Kornievskaia
2021-04-13 17:30               ` 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.