Skip to content

Commit

Permalink
NFSv4.2 fix handling of sr_eof in SEEK's reply
Browse files Browse the repository at this point in the history
[ Upstream commit 73f5c88 ]

Currently the client ignores the value of the sr_eof of the SEEK
operation. According to the spec, if the server didn't find the
requested extent and reached the end of the file, the server
would return sr_eof=true. In case the request for DATA and no
data was found (ie in the middle of the hole), then the lseek
expects that ENXIO would be returned.

Fixes: 1c6dcbe ("NFS: Implement SEEK")
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
olgakorn1 authored and gregkh committed May 19, 2021
1 parent 754efbb commit c63e7c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/nfs/nfs42proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,10 @@ static loff_t _nfs42_proc_llseek(struct file *filep,
if (status)
return status;

return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes);
if (whence == SEEK_DATA && res.sr_eof)
return -NFS4ERR_NXIO;
else
return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes);
}

loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
Expand Down

0 comments on commit c63e7c5

Please sign in to comment.