On Thu, 16 Sep 2010, Graham Leggett wrote:
The alternative is to change the format of the disk cache so that the .data
file has a temporary filename, for example XYZ.data.12367 instead of just
XYZ.data, and then to key the string "12367" in the header file. The new data
file can be written alongside the old one if necessary at leisure, and only
when the header file is renamed into place will the new data file come into
effect. This avoids locks entirely.
I personally favor designs needs at most O_EXCL style write locking.
Having been bitten by various lock-related issues over the years I'm
in favor of a explicit-lock-free design if it can be done cleanly and
with good performance.
If going this route, I'd suggest to put the entire path to the data
file in the header and not just a uniqifying string (to make it easier
to split hashing of header and data in the future).
/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | [email protected]
---------------------------------------------------------------------------
Fight War, Not Wars!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=