Commit c9b75650 authored by Phil Turnbull's avatar Phil Turnbull Committed by Ben Hutchings

ceph: Correctly return NXIO errors from ceph_llseek

commit 955818cd upstream.

ceph_llseek does not correctly return NXIO errors because the 'out' path
always returns 'offset'.

Fixes: 06222e49 ("fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek")
Signed-off-by: default avatarPhil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: default avatarYan, Zheng <zyan@redhat.com>
[bwh: Backported to 3.16; adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 5e7fbb17
......@@ -985,16 +985,14 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
int ret;
loff_t ret;
mutex_lock(&inode->i_mutex);
if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
if (ret < 0) {
offset = ret;
if (ret < 0)
goto out;
}
}
switch (whence) {
......@@ -1009,7 +1007,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
* write() or lseek() might have altered it
*/
if (offset == 0) {
offset = file->f_pos;
ret = file->f_pos;
goto out;
}
offset += file->f_pos;
......@@ -1029,11 +1027,11 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
break;
}
offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
ret = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
out:
mutex_unlock(&inode->i_mutex);
return offset;
return ret;
}
static inline void ceph_zero_partial_page(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment