Skip to content
Commit 8885e7f3 authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman
Browse files

direct-io: Fix negative return from dio read beyond eof

commit 74cedf9b

 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: default avatarAvi Kivity <avi@scylladb.com>
Fixes: 9fe55eea


CC: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b824d64b
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment