]> 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)
commit8b7328800d325c7ae7f03a0bbcaa76dfee1bddc3
tree0d4412cee169295a290867b72545b65c742527a8
parent9f172cdc9380ccf8d48193dfe917a4c7e52a617b
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: e7edf43218a322af89065e8bd576500d524ee89c
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