[libvirt] [PATCH] iohelper: fsync() at the end

Michal Privoznik mprivozn at redhat.com
Thu Nov 1 11:05:57 UTC 2012


On 01.11.2012 11:58, Daniel P. Berrange wrote:
> On Thu, Nov 01, 2012 at 11:26:18AM +0100, Michal Privoznik wrote:
>> Currently, when we are doing (managed) save, we insert the
>> iohelper between the qemu and OS. The pipe is created, the
>> writing end is passed to qemu and the reading end to the
>> iohelper. It reads data and write them into given file. However,
>> with write() being asynchronous data may still be in OS
>> caches and hence in some (corner) cases, all migration data
>> may have been read and written (not physically though). So
>> qemu will report success, as well as iohelper. However, with
>> some non local filesystems, where ENOSPACE is polled every X
>> time units, we may get into situation where all operations
>> succeeded but data hasn't reached the disk. And in fact will
>> never do. Therefore we ought sync caches to make sure data
>> has reached the block device on remote host.
>> ---
>>
>> For more information follow:
>> https://bugzilla.redhat.com/show_bug.cgi?id=866369
>>
>>  src/util/iohelper.c |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/util/iohelper.c b/src/util/iohelper.c
>> index c6542ed..aad5cb8 100644
>> --- a/src/util/iohelper.c
>> +++ b/src/util/iohelper.c
>> @@ -179,6 +179,12 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
>>          }
>>      }
>>  
>> +    /* Ensure all data is written */
>> +    if (fsync(fdout) < 0) {
>> +        virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
>> +        goto cleanup;
>> +    }
>> +
> 
> I wonder if perhaps we can use fdatasync(), or do we really need the
> full fsync() ?
> 
> 
> Daniel
> 

Yeah, I'll respin v2 since we need to do this only on network
filesystems. Okay, not all of them, but especially NFS and probably
iSCSI don't pre-allocate blocks on write().

Michal




More information about the libvir-list mailing list