[pve-devel] Default cache mode for VM hard drives

Stanislav German-Evtushenko ginermail at gmail.com
Thu May 28 15:32:07 CEST 2015


On Thu, May 28, 2015 at 4:17 PM, Eneko Lacunza <elacunza at binovo.es> wrote:
> On 28/05/15 15:01, Stanislav German-Evtushenko wrote:
>>>
>>> Note that without O_DIRECT you won't get a "correct" result either; disk
>>> may end not containing the data in the buffer when write was called.
>>> Softmirror data will be identically uncertain :)
>>
>> You are right. That is why I suppose there is a bug (operations with
>> buffer are not ensured to be thread-safe) in QEMU-KVM.
>>
> What does it mean that operations with buffer are not ensured to be
> thread-safe in qemu?
>
> O_DIRECT doesn't guarantee that buffer reading is finished when write
> returns if I read "man -s 2 open" correctly.

The statement seems to be not correct.
O_DIRECT does not guarantee that data reaches the undererying hardware
on return but it does guarantee that reading from buffer is finished.
Consinder the following examples.

This is okay:
0. set_buffer
1. write_with_o_direct_from_buffer
2. change_buffer
3. write_with_o_direct_from_buffer
4. change_buffer
5. write_with_o_direct_from_buffer
6. ...

This is not okay and this is what is actually happening:
0. set_buffer
1. start_writing_with_o_direct_from_buffer
2. change_buffer (we can do this only in another thread)
3. finish_writing_with_o_direct_from_buffer
4. change_buffer
5. start_writing_with_o_direct_from_buffer
6. change_buffer (we can do this only in another thread)
7. finish_writing_with_o_direct_from_buffer
8 ...

Stanislav


More information about the pve-devel mailing list