> -----Original Message----- > From: Zach Brown [mailto:zab@xxxxxxxxx] > Sent: Thursday, August 21, 2014 2:44 AM > To: Ma, Jianpeng > Cc: viro@xxxxxxxxxxxxxxxxxx; Sage Weil; Mark Kirkwood; linux-aio@xxxxxxxxx; > linux-fsdevel@xxxxxxxxxxxxxxx > Subject: Re: [HELP]: about aio+dio > > On Wed, Aug 20, 2014 at 04:05:01AM +0000, Ma, Jianpeng wrote: > > Hi all, > > At present, I met a problem. > > Open(block, DIRECT_IO) > > Io_submit()--->write operation > > Close() > > Exit(0) > > > > After exit(), we found the content of block changed. If we only use aio, the > bug can't reproduce. > > > > Q1: Is close() wait until all aio to complete? Is exit() to wait until aio to > complete? > > exit(). Can you explain in detail? If you can point the code, I think it better. Jianpeng > > > Q2:Who may change the content? The program don't change. > > buf=good > io_submit(buf) > buf=bad > io_getevents() > > Could end up with bad on disk. > > > Q3:My guess: only using aio, after io_submit, the content already copy to > kernel from use-space. But for direct, kernel can't copy. > > Later kernel do direct_io but the content changed. > > I think your guess here is correct. > > The program can't rely on the buffer in the iocb being copied during submission. > It has to assume that the buffer can be referenced at any point during the > lifetime of the asynchronous io. Any modificatoins to the buffers after > submission but before getting a completion event could be seen by the async > write and could end up on disk. > > If the program assumed that the buffer was always copied during submission > then it would work for buffered io today because it isn't asynchronous, but it > would break for O_DIRECT which often dmas directly from the pages mapped > at the iocb addresses during the async write. And it might break in the future > if buffered io was ever made asynchronous. > > - z -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html