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

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.