Thread (11 messages) 11 messages, 4 authors, 2016-01-27

Re: [PATCH] direct-io: Fix negative return from dio read beyond eof

From: Jens Axboe <axboe@kernel.dk>
Date: 2015-11-30 17:16:03
Also in: linux-fsdevel

On 11/30/2015 06:10 AM, Jan Kara wrote:
On Thu 19-11-15 21:25:34, Jan Kara wrote:
quoted
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 <redacted>
Fixes: 9fe55eea7e4b444bafc42fa0000cc2d1d2847275
CC: stable@vger.kernel.org
CC: Steven Whitehouse <redacted>
Signed-off-by: Jan Kara <jack@suse.cz>
---
  fs/direct-io.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)

Avi, this patch fixes the issue for me.
Jens, can you pick up this fix please? Thanks!
Yup, added for 4.4, thanks!

-- 
Jens Axboe
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help