diff options
author | Phil Turnbull <phil.turnbull@oracle.com> | 2016-07-21 13:43:09 -0400 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-11-20 01:01:28 +0000 |
commit | 7334e0adefc28bfa2356414b1d79fc56d6b8e7ed (patch) | |
tree | 3cb7431a9c4990b94f3d6bde5db54a55bde55823 /fs | |
parent | 538cff0a1a08d5bc658351c2cc35456205b5ff92 (diff) |
ceph: Correctly return NXIO errors from ceph_llseek
commit 955818cd5b6c4b58ea574ace4573e7afa4c19c1e upstream.
ceph_llseek does not correctly return NXIO errors because the 'out' path
always returns 'offset'.
Fixes: 06222e491e66 ("fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek")
Signed-off-by: Phil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: Yan, Zheng <zyan@redhat.com>
[bwh: Backported to 3.2:
- We don't use vfs_setpos(); instead set ret = -EINVAL or ret = offset
directly
- Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/file.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index ed72428d9c75..3cdf137e9c5b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -793,17 +793,15 @@ out: static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) { struct inode *inode = file->f_mapping->host; - int ret; + loff_t ret; mutex_lock(&inode->i_mutex); __ceph_do_pending_vmtruncate(inode); if (origin == SEEK_END || origin == SEEK_DATA || origin == SEEK_HOLE) { ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE); - if (ret < 0) { - offset = ret; + if (ret < 0) goto out; - } } switch (origin) { @@ -818,7 +816,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) * write() or lseek() might have altered it */ if (offset == 0) { - offset = file->f_pos; + ret = file->f_pos; goto out; } offset += file->f_pos; @@ -839,7 +837,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) } if (offset < 0 || offset > inode->i_sb->s_maxbytes) { - offset = -EINVAL; + ret = -EINVAL; goto out; } @@ -848,10 +846,11 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) file->f_pos = offset; file->f_version = 0; } + ret = offset; out: mutex_unlock(&inode->i_mutex); - return offset; + return ret; } const struct file_operations ceph_file_fops = { |