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

Chris Friesen chris.friesen at windriver.com
Fri Sep 25 16:48:02 UTC 2015


On 09/24/2015 04:21 PM, Chris Friesen wrote:
> On 09/24/2015 12:18 PM, Chris Friesen wrote:
>
>>
>> I think what happened is that we took the SIGTERM after the open() call in
>> create_iscsi_target(), but before writing anything to the file.
>>
>>          f = open(volume_path, 'w+')
>>          f.write(volume_conf)
>>          f.close()
>>
>> The 'w+' causes the file to be immediately truncated on opening, leading to an
>> empty file.
>>
>> To work around this, I think we need to do the classic "write to a temporary
>> file and then rename it to the desired filename" trick.  The atomicity of the
>> rename ensures that either the old contents or the new contents are present.
>
> I'm pretty sure that upstream code is still susceptible to zeroing out the file
> in the above scenario.  However, it doesn't take an exception--that's due to a
> local change on our part that attempted to fix the below issue.
>
> The stable/kilo code *does* have a problem in that when it regenerates the file
> it's missing the CHAP authentication line (beginning with "incominguser").

I've proposed a change at https://review.openstack.org/#/c/227943/

If anyone has suggestions on how to do this more robustly or more cleanly, 
please let me know.

Chris



More information about the OpenStack-dev mailing list