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

Chris Friesen chris.friesen at windriver.com
Tue Sep 22 21:52:16 UTC 2015


Hi,

I recently had an issue with one file out of a dozen or so in 
"/opt/cgcs/cinder/data/volumes/" being present but of size zero.  I'm running 
stable/kilo if it makes a difference.

Looking at the code in volume.targets.tgt.TgtAdm.create_iscsi_target(), I'm 
wondering if we should do a fsync() before the close().  The way it stands now, 
it seems like it might be possible to write the file, start making use of it, 
and then take a power outage before it actually gets written to persistent 
storage.  When we come back up we could have an instance expecting to make use 
of it, but no target information in the on-disk copy of the file.

Even then, fsync() explicitly says that it doesn't ensure that the directory 
changes have reached disk...for that another explicit fsync() on the file 
descriptor for the directory is needed.

So I think for robustness we'd want to add

f.flush()
os.fsync(f.fileno())

between the existing f.write() and f.close(), and then add something like:

f = open(volumes_dir, 'w+')
os.fsync(f.fileno())
f.close()

Thoughts?

Chris



More information about the OpenStack-dev mailing list