vlserver: fix vldb header initialization
authorMichael Meffie <mmeffie@sinenomine.net>
Sat, 28 Jul 2012 15:37:59 +0000 (11:37 -0400)
committerDerrick Brashear <shadow@dementix.org>
Tue, 14 Aug 2012 13:20:16 +0000 (06:20 -0700)
commit355b8c73ed5adc5c182cf29561cc360ef4674f9e
treef0afd2f9720f585add7d1ee86b6b4a18ed859e7f
parentfdd3b0fb1f8e6948c651d7f1822d17a78668e5ff
vlserver: fix vldb header initialization

Avoid creating new vldb files with zeroed header data.

The code path is as follows; The call to Init_VLdbase makes several
passes. On the first pass, the header is found to be empty, and so a
write lock is obtained on the second pass.  On this second pass,
UpdateCache creates a newly initialized header and writes it to the
db.  The rd_cheader is set to the newly created header data, and the
wr_cheader is still cleared at this point.

When the transaction on the second pass ended in Init_VLdbase, the
data is committed and vlsynccache() is called.  In this call to
vlsynccache(), the cleared write header buffer (wr_cheader) is
copied over the newly initialized rd_cheader buffer.  Init_VLdbase
then returns to the caller, and if the caller writes to the db, the
header on disk is then cleared.

Instead of initializing the read header buffer when rebuilding the
db header, initialize the write header buffer. When the ubik
transaction is ended, the call to vlsynccache() updates the contents
of the read header buffer with contents of the new/rebuilt header.

This error was introduced with commits:
  a0f416e3504929b304fefb5ca65e2d6a254ade2e
  1f532d099b8b084d43dd0140890448464325b602

Change-Id: If9c178bf28c55c50311554b12ffff9404785d052
Reviewed-on: http://gerrit.openafs.org/7894
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/vlserver/vlprocs.c
src/vlserver/vlutils.c