tmpfs: fix SEEK_DATA/SEEK_HOLE regression
authorHugh Dickins <hughd@google.com>
Sun, 4 Aug 2013 18:30:25 +0000 (11:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 4 Aug 2013 18:40:17 +0000 (11:40 -0700)
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 <hughd@google.com>
Cc: Jie Liu <jeff.liu@oracle.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/shmem.c

index a87990cf9f94019c70d7263d247c1c94945aee5b..8335dbd3fc358ed1fe9d6521785ecee1dc031313 100644 (file)
@@ -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;
 }