diff mbox

ceph: Correctly return NXIO errors from ceph_llseek.

Message ID 20160721174310.21805-1-phil.turnbull@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

phil.turnbull@oracle.com July 21, 2016, 5:43 p.m. UTC
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>
---
 fs/ceph/file.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Yan, Zheng July 26, 2016, 6:47 a.m. UTC | #1
> On Jul 22, 2016, at 01:43, Phil Turnbull <phil.turnbull@oracle.com> wrote:
> 
> 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>
> ---
> fs/ceph/file.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index ce2f5795e44b..13adb5b2ef29 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -1448,16 +1448,14 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
> {
> 	struct inode *inode = file->f_mapping->host;
> 	loff_t i_size;
> -	int ret;
> +	loff_t ret;
> 
> 	inode_lock(inode);
> 
> 	if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
> 		ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false);
> -		if (ret < 0) {
> -			offset = ret;
> +		if (ret < 0)
> 			goto out;
> -		}
> 	}
> 
> 	i_size = i_size_read(inode);
> @@ -1473,7 +1471,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;
> @@ -1493,11 +1491,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:
> 	inode_unlock(inode);
> -	return offset;
> +	return ret;
> }
> 
> static inline void ceph_zero_partial_page(

applied, thanks

Yan, Zheng

> -- 
> 2.9.0.rc2
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ce2f5795e44b..13adb5b2ef29 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1448,16 +1448,14 @@  static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
 {
 	struct inode *inode = file->f_mapping->host;
 	loff_t i_size;
-	int ret;
+	loff_t ret;
 
 	inode_lock(inode);
 
 	if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
 		ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false);
-		if (ret < 0) {
-			offset = ret;
+		if (ret < 0)
 			goto out;
-		}
 	}
 
 	i_size = i_size_read(inode);
@@ -1473,7 +1471,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;
@@ -1493,11 +1491,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:
 	inode_unlock(inode);
-	return offset;
+	return ret;
 }
 
 static inline void ceph_zero_partial_page(