xfs
[Top] [All Lists]

Re: AIO read returns negative number for bytes read

To: Jan Kara <jack@xxxxxxx>
Subject: Re: AIO read returns negative number for bytes read
From: Avi Kivity <avi@xxxxxxxxxxxx>
Date: Thu, 19 Nov 2015 17:32:58 +0200
Cc: Jeff Moyer <jmoyer@xxxxxxxxxx>, xfs@xxxxxxxxxxx, linux-aio@xxxxxxxxx, Steven Whitehouse <swhiteho@xxxxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scylladb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=JGnywJthk26vODPOMcL+0YQlde0Z56vD4kqTJRM2lYs=; b=epqEWjHxhSwlQZ82JpfSBObYBLGzpn04QOPwdCWNU6GzmDbFOwRiEqpseUXS2Fqy0W MZlZJQ71S4uEYJZep9IqC5tH1ZJzS/c+p03b+/sDHVo1ysmoq8JBGC5KCs5LYUxX77Mp yG1SGvHpuFW5O9y3e2scDkoYOWORjjZkhmlWizaMAe3Yv1IlpKPQWIolh9UIxsNiHFAH W9hu7yx9clfVPY3rYllYdQ8Lv3Bon7ArvnojXXdFDwUXRCTenbuwCCEljLYAG7G7K+QH p38Gz2cu7jmEs3/TgHxUjwCZHqpvx9w3uCEEGkN0QuO12svcy0NuDRo+WrZOPsOy3lFm 0m2Q==
In-reply-to: <20151119153004.GB25804@xxxxxxxxxxxxx>
References: <564883BD.8070607@xxxxxxxxxxxx> <x497flhsq1c.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <564B2303.7000902@xxxxxxxxxxxx> <20151119153004.GB25804@xxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
On 11/19/2015 05:30 PM, Jan Kara wrote:
On Tue 17-11-15 14:52:19, Avi Kivity wrote:

On 11/16/2015 09:27 PM, Jeff Moyer wrote:
Hi Avi,

Avi Kivity <avi@xxxxxxxxxxxx> 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.
Can you please post the reproduce here as well? I couldn't easily find it
with google.



Attached.

I am told that a simple synchronous O_DIRECT read beyond unaligned eof suffices as well.

Attachment: aio_read_fails.c
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>