]> git.baikalelectronics.ru Git - kernel.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)
committerJens Axboe <axboe@fb.com>
Mon, 30 Nov 2015 17:15:42 +0000 (10:15 -0700)
commit98f7cd87f35f26404ccacbb0c039a3d75ad16d45
tree0d4412cee169295a290867b72545b65c742527a8
parent56371cc152f2728ea8c725e8c3cd2b34e8399895
direct-io: Fix negative return from dio read beyond eof

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: 5c1f0e738af4dcff5abf344585ea225dfbbde221
CC: stable@vger.kernel.org
CC: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/direct-io.c