From: Hugh Dickins Date: Sun, 4 Aug 2013 18:30:25 +0000 (-0700) Subject: tmpfs: fix SEEK_DATA/SEEK_HOLE regression X-Git-Tag: upstream/snapshot3+hdmi~4601 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=387aae6fdd737038e92d7bb40712bdf6dcb11945;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git tmpfs: fix SEEK_DATA/SEEK_HOLE regression Commit 46a1c2c7ae53 ("vfs: export lseek_execute() to modules") broke the tmpfs SEEK_DATA/SEEK_HOLE implementation, because vfs_setpos() converts the carefully prepared -ENXIO to -EINVAL. Other filesystems avoid it in error cases: do the same in tmpfs. Signed-off-by: Hugh Dickins Cc: Jie Liu Cc: Al Viro Signed-off-by: Linus Torvalds --- diff --git a/mm/shmem.c b/mm/shmem.c index a87990c..8335dbd 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1798,7 +1798,8 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) } } - offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE); + if (offset >= 0) + offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE); mutex_unlock(&inode->i_mutex); return offset; }