Write an existing index object from memory back to disk using an atomic file lock.
an existing index object
0 on success, otherwise an error code