<div dir="ltr"><div><div>Dietmar,<br><br>fsync esures that data reaches underlying hardware but it does not help being sure that buffer is not changed until it is fully written.<br><br></div>I will describe my understanding here why we get this problem with O_DIRECT and don't have without.<br><br></div>** Without O_DIRECT **<div><div><div><div><div><div>1. Application tries to write data from buffer</div><div>2. Data from buffer goes to host cache<br></div><div>3. RAID writers get data from host cache and put to /dev/loop1 and /dev/loop2</div><div>Even if buffer changes data in host cache will not be changed so RAID is consistent.<br><br>** With O_DIRECT **<br>1. Application tries to write data from buffer<br>2. RAID writers get data from application (!!!)  bufferand put to /dev/loop1 and /dev/loop2<br></div><div>if meanwhile data in buffer is changed (this change can be done in different posix thread) then we have different data reachs /dev/loop1 and /dev/loop2<br><br></div><div>Resume: when working in O_DIRECT mode QEMU has to wait until "write" system call is finished before changing this buffer OR QEMU has to create new buffer every time OR ... other ideas?<br></div><div><br></div><div>Stanislav<br></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 10:31 AM, Dietmar Maurer <span dir="ltr"><<a href="mailto:dietmar@proxmox.com" target="_blank">dietmar@proxmox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">> I have just done the same test with mdadm and not DRBD. And what I found<br>
> that this problem was reproducible on the software raid too, just as it was<br>
> claimed by Lars Ellenberg. It means that problem is not only related to<br>
> DRBD but to O_DIRECT mode generally when we don't use host cache and a<br>
> block device reads data directly from userspace.<br>
<br>
</span>We simply think the behavior is correct. If you want to be sure data is<br>
on disk you have to call fsync.<br>
<br>
</blockquote></div><br></div></div></div></div></div></div></div></div>