[openstack-dev] [cinder] should we use fsync when writing iscsi config file?

Julien Danjou julien at danjou.info
Sat Sep 26 08:48:39 UTC 2015


On Tue, Sep 22 2015, Chris Friesen wrote:

> On 09/22/2015 05:48 PM, Joshua Harlow wrote:
>> A present:
>>
>>  >>> import contextlib
>>  >>> import os
>>  >>>
>>  >>> @contextlib.contextmanager
>> ... def synced_file(path, mode='wb'):
>> ...   with open(path, mode) as fh:
>> ...      yield fh
>> ...      os.fdatasync(fh.fileno())
>> ...
>>  >>> with synced_file("/tmp/b.txt") as fh:
>> ...    fh.write("b")
>
> Isn't that missing an "fh.flush()" somewhere before the fdatasync()?

Unless proven otherwise, close() does a flush().

-- 
Julien Danjou
;; Free Software hacker
;; http://julien.danjou.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150926/d152929f/attachment.pgp>


More information about the OpenStack-dev mailing list