From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com ([74.125.82.42]:33441 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330AbbKQMwX (ORCPT ); Tue, 17 Nov 2015 07:52:23 -0500 Received: by wmec201 with SMTP id c201so225855379wme.0 for ; Tue, 17 Nov 2015 04:52:22 -0800 (PST) Subject: Re: AIO read returns negative number for bytes read To: Jeff Moyer References: <564883BD.8070607@scylladb.com> Cc: xfs@oss.sgi.com, linux-aio@kvack.org, Steven Whitehouse , Jan Kara , linux-fsdevel@vger.kernel.org From: Avi Kivity Message-ID: <564B2303.7000902@scylladb.com> Date: Tue, 17 Nov 2015 14:52:19 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 11/16/2015 09:27 PM, Jeff Moyer wrote: > Hi Avi, > > Avi Kivity writes: > >> Due to a bug in my program, I initiated a read beyond >> eof. Specifically, the file size is 13002 bytes and the read offset is >> 13312 (0x3400). >> >> I would expect such a read to return 0 bytes read, but io_getevents >> returns -310, which is suspiciously equal to (13002 - 13312). >> >> I attach a reproducer. >> >> 4.2.5-201.fc22.x86_64 >> >> Are my expectations incorrect, or is this a bug in aio or xfs? > Your expectations are correct. The bug was introduced by commit > 9fe55eea7e4b4 (Fix race when checking i_size on direct i/o read). I've > CC'd the patch author and linux-fsdevel. I'm not sure what the right > fix is, given that the size checks were removed from the vfs to fix some > race condition. Unfortunately, the commit message doesn't really do a > good job of explaining the race. In order to save others time, here is > a good explanation of the problem that commit is meant to fix, along > with a reproducer: > http://marc.info/?l=linux-fsdevel&m=138641356614458&w=2 > > Thanks for the great bug report, and sorry I have no solution to > proffer. > Thanks. I will await a fix with interest.