From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f43.google.com ([209.85.218.43]:36508 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753315AbbK3RQD (ORCPT ); Mon, 30 Nov 2015 12:16:03 -0500 Received: by oiww189 with SMTP id w189so99215929oiw.3 for ; Mon, 30 Nov 2015 09:16:02 -0800 (PST) Subject: Re: [PATCH] direct-io: Fix negative return from dio read beyond eof To: Jan Kara References: <1447964734-16010-1-git-send-email-jack@suse.cz> <20151130131033.GB4522@quack.suse.cz> Cc: linux-fsdevel@vger.kernel.org, Jeff Moyer , Avi Kivity , stable@vger.kernel.org, Steven Whitehouse From: Jens Axboe Message-ID: <565C8450.1090101@kernel.dk> Date: Mon, 30 Nov 2015 10:16:00 -0700 MIME-Version: 1.0 In-Reply-To: <20151130131033.GB4522@quack.suse.cz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 11/30/2015 06:10 AM, Jan Kara wrote: > On Thu 19-11-15 21:25:34, Jan Kara wrote: >> 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 >> Fixes: 9fe55eea7e4b444bafc42fa0000cc2d1d2847275 >> CC: stable@vger.kernel.org >> CC: Steven Whitehouse >> Signed-off-by: Jan Kara >> --- >> 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