ubik: Make udisk_Log* functions static
[openafs.git] / src / ubik / disk.c
index b0da8dc..a091e7f 100644 (file)
@@ -109,7 +109,7 @@ udisk_Debug(struct ubik_debug *aparm)
  * 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;
@@ -139,7 +139,7 @@ udisk_LogOpcode(struct ubik_dbase *adbase, afs_int32 aopcode, int async)
 /*!
  * \brief Log a commit, never syncing.
  */
-int
+static int
 udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
 {
     afs_int32 code;
@@ -171,7 +171,7 @@ udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
 /*!
  * \brief Log a truncate operation, never syncing.
  */
-int
+static int
 udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
                  afs_int32 alength)
 {
@@ -201,7 +201,7 @@ udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
 /*!
  * \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)
 {
@@ -866,6 +866,7 @@ udisk_commit(struct ubik_trans *atrans)
     struct ubik_dbase *dbase;
     afs_int32 code = 0;
     struct ubik_version oldversion, newversion;
+    afs_int32 now = FT_ApproxTime();
 
     if (atrans->flags & TRDONE)
        return (UTWOENDS);
@@ -876,8 +877,15 @@ udisk_commit(struct ubik_trans *atrans)
        /* 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);
@@ -886,7 +894,6 @@ udisk_commit(struct ubik_trans *atrans)
                return code;
            }
 
-           version_globals.ubik_epochTime = newversion.epoch;
            dbase->version = newversion;
            UBIK_VERSION_UNLOCK;
 
@@ -910,7 +917,8 @@ udisk_commit(struct ubik_trans *atrans)
        code = udisk_LogEnd(dbase, &dbase->version);
        if (code) {
            dbase->version.counter--;
-           return (code);
+           UBIK_VERSION_UNLOCK;
+           return code;
        }
        UBIK_VERSION_UNLOCK;