* Abort transaction: opcode \n
* Write data: opcode, file, position, length, <length> data bytes \n
*/
-int
+static int
udisk_LogOpcode(struct ubik_dbase *adbase, afs_int32 aopcode, int async)
{
struct ubik_stat ustat;
/*!
* \brief Log a commit, never syncing.
*/
-int
+static int
udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
{
afs_int32 code;
/*!
* \brief Log a truncate operation, never syncing.
*/
-int
+static int
udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
afs_int32 alength)
{
/*!
* \brief Write some data to the log, never syncing.
*/
-int
+static int
udisk_LogWriteData(struct ubik_dbase *adbase, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alen)
{
struct ubik_dbase *dbase;
afs_int32 code = 0;
struct ubik_version oldversion, newversion;
+ afs_int32 now = FT_ApproxTime();
if (atrans->flags & TRDONE)
return (UTWOENDS);
/* On the first write to the database. We update the versions */
if (ubeacon_AmSyncSite() && !(urecovery_state & UBIK_RECLABELDB)) {
UBIK_VERSION_LOCK;
+ if (version_globals.ubik_epochTime < UBIK_MILESTONE
+ || version_globals.ubik_epochTime > now) {
+ ubik_print
+ ("Ubik: New database label %d is out of the valid range (%d - %d)\n",
+ version_globals.ubik_epochTime, UBIK_MILESTONE, now);
+ panic("Writing Ubik DB label\n");
+ }
oldversion = dbase->version;
- newversion.epoch = FT_ApproxTime();;
+ newversion.epoch = version_globals.ubik_epochTime;
newversion.counter = 1;
code = (*dbase->setlabel) (dbase, 0, &newversion);
return code;
}
- version_globals.ubik_epochTime = newversion.epoch;
dbase->version = newversion;
UBIK_VERSION_UNLOCK;
code = udisk_LogEnd(dbase, &dbase->version);
if (code) {
dbase->version.counter--;
- return (code);
+ UBIK_VERSION_UNLOCK;
+ return code;
}
UBIK_VERSION_UNLOCK;