]> www.infradead.org Git - users/jedix/linux-maple.git/commit
direct-io: Fix negative return from dio read beyond eof
authorJan Kara <jack@suse.cz>
Mon, 30 Nov 2015 17:15:42 +0000 (10:15 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:43:36 +0000 (15:43 -0700)
commit900338c42e449dc1e0a938dc6e369c159f3411bb
tree41b15c0b4c2c81fe098d8825a23c99e2ed804aa5
parent36d8cc5874f6b3017a454fe55b517946bb8f6cc6
direct-io: Fix negative return from dio read beyond eof

Orabug: 23330584

commit 74cedf9b6c603f2278a05bc91b140b32b434d0b5 upstream.

Assume a filesystem with 4KB blocks. When a file has size 1000 bytes and
we issue direct IO read at offset 1024, blockdev_direct_IO() reads the
tail of the last block and the logic for handling short DIO reads in
dio_complete() results in a return value -24 (1000 - 1024) which
obviously confuses userspace.

Fix the problem by bailing out early once we sample i_size and can
reliably check that direct IO read starts beyond i_size.

Reported-by: Avi Kivity <avi@scylladb.com>
Fixes: 9fe55eea7e4b444bafc42fa0000cc2d1d2847275
CC: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8885e7f3d76a9d42eb4fd97a3cfc5a8ac7f6f2ff)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/direct-io.c