]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSv4.2 fix handling of sr_eof in SEEK's reply
authorOlga Kornievskaia <kolga@netapp.com>
Wed, 31 Mar 2021 19:30:25 +0000 (15:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:29:40 +0000 (10:29 +0200)
[ Upstream commit 73f5c88f521a630ea1628beb9c2d48a2e777a419 ]

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: 1c6dcbe5ceff8 ("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>
fs/nfs/nfs42proc.c

index 7add6332016a0c79a6fc332fbd697a9e7d21bef5..b85f7d56a155c3c7d2d318a6f9c231b09178bef1 100644 (file)
@@ -665,7 +665,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)