Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote:
> From: Olga Kornievskaia <kolga@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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
> 




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux