ubik: remove unused OLD_URECOVERY code
[openafs.git] / src / ubik / remote.c
index 55d714f..a256a8a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -10,6 +10,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
 
 #include <sys/types.h>
 #include <string.h>
@@ -47,9 +48,9 @@ static void printServerInfo(void);
 struct ubik_trans *ubik_currentTrans = 0;
 
 int
-ubik_CheckAuth(register struct rx_call *acall)
+ubik_CheckAuth(struct rx_call *acall)
 {
-    register afs_int32 code;
+    afs_int32 code;
     if (ubik_CheckRXSecurityProc) {
        code = (*ubik_CheckRXSecurityProc) (ubik_CheckRXSecurityRock, acall);
        return code;
@@ -62,26 +63,15 @@ ubik_CheckAuth(register struct rx_call *acall)
  * sync site is executing a write transaction.
  */
 afs_int32
-SDISK_Begin(register struct rx_call *rxcall, struct ubik_tid *atid)
+SDISK_Begin(struct rx_call *rxcall, struct ubik_tid *atid)
 {
-    register afs_int32 code;
+    afs_int32 code;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
     }
     DBHOLD(ubik_dbase);
-    urecovery_CheckTid(atid);
-    if (ubik_currentTrans) {
-       /* If the thread is not waiting for lock - ok to end it */
-#if !defined(UBIK_PAUSE)
-       if (ubik_currentTrans->locktype != LOCKWAIT) {
-#endif /* UBIK_PAUSE */
-           udisk_end(ubik_currentTrans);
-#if !defined(UBIK_PAUSE)
-       }
-#endif /* UBIK_PAUSE */
-       ubik_currentTrans = (struct ubik_trans *)0;
-    }
+    urecovery_CheckTid(atid, 1);
     code = udisk_begin(ubik_dbase, UBIK_WRITETRANS, &ubik_currentTrans);
     if (!code && ubik_currentTrans) {
        /* label this trans with the right trans id */
@@ -94,10 +84,10 @@ SDISK_Begin(register struct rx_call *rxcall, struct ubik_tid *atid)
 
 
 afs_int32
-SDISK_Commit(register struct rx_call *rxcall, struct ubik_tid *atid)
+SDISK_Commit(struct rx_call *rxcall, struct ubik_tid *atid)
 {
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
+    afs_int32 code;
+    struct ubik_dbase *dbase;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -119,7 +109,7 @@ SDISK_Commit(register struct rx_call *rxcall, struct ubik_tid *atid)
 
     DBHOLD(dbase);
 
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        ReleaseWriteLock(&dbase->cache_lock);
@@ -137,10 +127,10 @@ SDISK_Commit(register struct rx_call *rxcall, struct ubik_tid *atid)
 }
 
 afs_int32
-SDISK_ReleaseLocks(register struct rx_call *rxcall, struct ubik_tid *atid)
+SDISK_ReleaseLocks(struct rx_call *rxcall, struct ubik_tid *atid)
 {
-    register struct ubik_dbase *dbase;
-    register afs_int32 code;
+    struct ubik_dbase *dbase;
+    afs_int32 code;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -156,7 +146,7 @@ SDISK_ReleaseLocks(register struct rx_call *rxcall, struct ubik_tid *atid)
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -176,10 +166,10 @@ SDISK_ReleaseLocks(register struct rx_call *rxcall, struct ubik_tid *atid)
 }
 
 afs_int32
-SDISK_Abort(register struct rx_call *rxcall, struct ubik_tid *atid)
+SDISK_Abort(struct rx_call *rxcall, struct ubik_tid *atid)
 {
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
+    afs_int32 code;
+    struct ubik_dbase *dbase;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -195,7 +185,7 @@ SDISK_Abort(register struct rx_call *rxcall, struct ubik_tid *atid)
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -217,11 +207,11 @@ SDISK_Abort(register struct rx_call *rxcall, struct ubik_tid *atid)
 
 /* apos and alen are not used */
 afs_int32
-SDISK_Lock(register struct rx_call *rxcall, struct ubik_tid *atid, 
+SDISK_Lock(struct rx_call *rxcall, struct ubik_tid *atid,
           afs_int32 afile, afs_int32 apos, afs_int32 alen, afs_int32 atype)
-{      
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
+{
+    afs_int32 code;
+    struct ubik_dbase *dbase;
     struct ubik_trans *ubik_thisTrans;
 
     if ((code = ubik_CheckAuth(rxcall))) {
@@ -239,7 +229,7 @@ SDISK_Lock(register struct rx_call *rxcall, struct ubik_tid *atid,
     }
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -265,7 +255,7 @@ SDISK_Lock(register struct rx_call *rxcall, struct ubik_tid *atid,
  * \brief Write a vector of data
  */
 afs_int32
-SDISK_WriteV(register struct rx_call *rxcall, struct ubik_tid *atid, 
+SDISK_WriteV(struct rx_call *rxcall, struct ubik_tid *atid,
             iovec_wrt *io_vector, iovec_buf *io_buffer)
 {
     afs_int32 code, i, offset;
@@ -286,7 +276,7 @@ SDISK_WriteV(register struct rx_call *rxcall, struct ubik_tid *atid,
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -314,11 +304,11 @@ SDISK_WriteV(register struct rx_call *rxcall, struct ubik_tid *atid,
 }
 
 afs_int32
-SDISK_Write(register struct rx_call *rxcall, struct ubik_tid *atid, 
-           afs_int32 afile, afs_int32 apos, register bulkdata *adata)
+SDISK_Write(struct rx_call *rxcall, struct ubik_tid *atid,
+           afs_int32 afile, afs_int32 apos, bulkdata *adata)
 {
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
+    afs_int32 code;
+    struct ubik_dbase *dbase;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -333,7 +323,7 @@ SDISK_Write(register struct rx_call *rxcall, struct ubik_tid *atid,
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -346,11 +336,11 @@ SDISK_Write(register struct rx_call *rxcall, struct ubik_tid *atid,
 }
 
 afs_int32
-SDISK_Truncate(register struct rx_call *rxcall, struct ubik_tid *atid, 
+SDISK_Truncate(struct rx_call *rxcall, struct ubik_tid *atid,
               afs_int32 afile, afs_int32 alen)
 {
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
+    afs_int32 code;
+    struct ubik_dbase *dbase;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -365,7 +355,7 @@ SDISK_Truncate(register struct rx_call *rxcall, struct ubik_tid *atid,
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;
@@ -376,10 +366,10 @@ SDISK_Truncate(register struct rx_call *rxcall, struct ubik_tid *atid,
 }
 
 afs_int32
-SDISK_GetVersion(register struct rx_call *rxcall, 
-                register struct ubik_version *aversion)
+SDISK_GetVersion(struct rx_call *rxcall,
+                struct ubik_version *aversion)
 {
-    register afs_int32 code;
+    afs_int32 code;
 
     if ((code = ubik_CheckAuth(rxcall))) {
        return code;
@@ -413,12 +403,12 @@ SDISK_GetVersion(register struct rx_call *rxcall,
 }
 
 afs_int32
-SDISK_GetFile(register struct rx_call *rxcall, register afs_int32 file, 
+SDISK_GetFile(struct rx_call *rxcall, afs_int32 file,
              struct ubik_version *version)
 {
-    register afs_int32 code;
-    register struct ubik_dbase *dbase;
-    register afs_int32 offset;
+    afs_int32 code;
+    struct ubik_dbase *dbase;
+    afs_int32 offset;
     struct ubik_stat ubikstat;
     char tbuffer[256];
     afs_int32 tlen;
@@ -428,7 +418,7 @@ SDISK_GetFile(register struct rx_call *rxcall, register afs_int32 file,
        return code;
     }
 /* temporarily disabled because it causes problems for migration tool.  Hey, it's just
- * a sanity check, anyway. 
+ * a sanity check, anyway.
     if (ubeacon_AmSyncSite()) {
       return UDEADLOCK;
     }
@@ -472,25 +462,23 @@ SDISK_GetFile(register struct rx_call *rxcall, register afs_int32 file,
 }
 
 afs_int32
-SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file, 
+SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
               afs_int32 length, struct ubik_version *avers)
 {
-    register afs_int32 code;
+    afs_int32 code;
     struct ubik_dbase *dbase = NULL;
     char tbuffer[1024];
     afs_int32 offset;
     struct ubik_version tversion;
-    register int tlen;
+    int tlen;
     struct rx_peer *tpeer;
     struct rx_connection *tconn;
     afs_uint32 otherHost = 0;
     char hoststr[16];
-#ifndef OLD_URECOVERY
     char pbuffer[1028];
-    int flen, fd = -1;
+    int fd = -1;
     afs_int32 epoch = 0;
     afs_int32 pass;
-#endif
 
     /* send the file back to the requester */
 
@@ -528,16 +516,8 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
               afs_inet_ntoa_r(otherHost, hoststr));
 
     offset = 0;
-#ifdef OLD_URECOVERY
-    (*dbase->truncate) (dbase, file, 0);       /* truncate first */
-    tversion.counter = 0;
-#else
-    epoch =
-#endif
-    tversion.epoch = 0;                /* start off by labelling in-transit db as invalid */
+    epoch = tversion.epoch = 0;                /* start off by labelling in-transit db as invalid */
     (*dbase->setlabel) (dbase, file, &tversion);       /* setlabel does sync */
-#ifndef OLD_URECOVERY
-    flen = length;
     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
     if (fd < 0) {
@@ -550,11 +530,10 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
        goto failed;
     }
     pass = 0;
-#endif
     memcpy(&ubik_dbase->version, &tversion, sizeof(struct ubik_version));
     while (length > 0) {
        tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
-#if !defined(OLD_URECOVERY) && !defined(AFS_PTHREAD_ENV)
+#if !defined(AFS_PTHREAD_ENV)
        if (pass % 4 == 0)
            IOMGR_Poll();
 #endif
@@ -566,12 +545,8 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
            close(fd);
            goto failed;
        }
-#ifdef OLD_URECOVERY
-       code = (*dbase->write) (dbase, file, tbuffer, offset, tlen);
-#else
        code = write(fd, tbuffer, tlen);
        pass++;
-#endif
        if (code != tlen) {
            DBRELE(dbase);
            ubik_dprint("write failed error=%d\n", code);
@@ -582,17 +557,12 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
        offset += tlen;
        length -= tlen;
     }
-#ifndef OLD_URECOVERY
     code = close(fd);
     if (code)
        goto failed;
-#endif     
 
     /* sync data first, then write label and resync (resync done by setlabel call).
      * This way, good label is only on good database. */
-#ifdef OLD_URECOVERY
-    (*ubik_dbase->sync) (dbase, file);
-#else
     afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #ifdef AFS_NT40_ENV
     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
@@ -601,19 +571,16 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
        code = rename(tbuffer, pbuffer);
     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #endif
-    if (!code) 
+    if (!code)
        code = rename(pbuffer, tbuffer);
     if (!code) {
-       (*ubik_dbase->open) (ubik_dbase, 0);
-#endif
+       (*ubik_dbase->open) (ubik_dbase, file);
        code = (*ubik_dbase->setlabel) (dbase, file, avers);
-#ifndef OLD_URECOVERY
     }
 #ifdef AFS_NT40_ENV
     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     unlink(pbuffer);
 #endif
-#endif
     memcpy(&ubik_dbase->version, avers, sizeof(struct ubik_version));
     udisk_Invalidate(dbase, file);     /* new dbase, flush disk buffers */
 #ifdef AFS_PTHREAD_ENV
@@ -624,14 +591,12 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
     DBRELE(dbase);
   failed:
     if (code) {
-#ifndef OLD_URECOVERY
        unlink(pbuffer);
        /* Failed to sync. Allow reads again for now. */
        if (dbase != NULL) {
            tversion.epoch = epoch;
            (*dbase->setlabel) (dbase, file, &tversion);
        }
-#endif
        ubik_print
            ("Ubik: Synchronize database with server %s failed (error = %d)\n",
             afs_inet_ntoa_r(otherHost, hoststr), code);
@@ -643,7 +608,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
 
 
 afs_int32
-SDISK_Probe(register struct rx_call *rxcall)
+SDISK_Probe(struct rx_call *rxcall)
 {
     return 0;
 }
@@ -655,8 +620,8 @@ SDISK_Probe(register struct rx_call *rxcall)
  * \return zero on success, else 1.
  */
 afs_int32
-SDISK_UpdateInterfaceAddr(register struct rx_call *rxcall, 
-                         UbikInterfaceAddr *inAddr, 
+SDISK_UpdateInterfaceAddr(struct rx_call *rxcall,
+                         UbikInterfaceAddr *inAddr,
                          UbikInterfaceAddr *outAddr)
 {
     struct ubik_server *ts, *tmp;
@@ -737,8 +702,8 @@ printServerInfo(void)
 }
 
 afs_int32
-SDISK_SetVersion(struct rx_call *rxcall, struct ubik_tid *atid, 
-                struct ubik_version *oldversionp, 
+SDISK_SetVersion(struct rx_call *rxcall, struct ubik_tid *atid,
+                struct ubik_version *oldversionp,
                 struct ubik_version *newversionp)
 {
     afs_int32 code = 0;
@@ -763,7 +728,7 @@ SDISK_SetVersion(struct rx_call *rxcall, struct ubik_tid *atid,
 
     dbase = ubik_currentTrans->dbase;
     DBHOLD(dbase);
-    urecovery_CheckTid(atid);
+    urecovery_CheckTid(atid, 0);
     if (!ubik_currentTrans) {
        DBRELE(dbase);
        return USYNC;