ubik: remove unused UBIK_PAUSE code
[openafs.git] / src / ubik / recovery.c
index 89f3843..2b3cc76 100644 (file)
@@ -31,6 +31,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/afsutil.h>
+#include <afs/cellconfig.h>
 
 #define UBIK_INTERNALS
 #include "ubik.h"
@@ -84,13 +85,15 @@ urecovery_ResetState(void)
  * \brief sync site
  *
  * routine called when a non-sync site server goes down; restarts recovery
- * process to send missing server the new db when it comes back up.
+ * process to send missing server the new db when it comes back up for
+ * non-sync site servers.
  *
  * \note This routine should not do anything with variables used by non-sync site servers.
  */
 int
-urecovery_LostServer(void)
+urecovery_LostServer(struct ubik_server *ts)
 {
+    ubeacon_ReinitServer(ts);
 #if !defined(AFS_PTHREAD_ENV)
     /*  No corresponding LWP_WaitProcess found anywhere for this -- klm */
     LWP_NoYieldSignal(&urecovery_state);
@@ -165,13 +168,9 @@ urecovery_CheckTid(struct ubik_tid *atid, int abortalways)
            || atid->counter > ubik_currentTrans->tid.counter || abortalways) {
            /* don't match, abort it */
            /* 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;
        }
     }
@@ -289,6 +288,9 @@ ReplayLog(struct ubik_dbase *adbase)
                code = (*adbase->setlabel) (adbase, 0, &version);
                if (code)
                    return code;
+               ubik_print("Successfully replayed log for interrupted "
+                          "transaction; db version is now %ld.%ld\n",
+                          (long) version.epoch, (long) version.counter);
                logIsGood = 1;
                break;          /* all done now */
            } else if (opcode == LOGTRUNCATE) {
@@ -462,11 +464,9 @@ urecovery_Interact(void *dummy)
     struct ubik_stat ubikstat;
     struct in_addr inAddr;
     char hoststr[16];
-#ifndef OLD_URECOVERY
     char pbuffer[1028];
     int fd = -1;
     afs_int32 pass;
-#endif
 
     /* otherwise, begin interaction */
     urecovery_state = 0;
@@ -562,17 +562,8 @@ urecovery_Interact(void *dummy)
            urecovery_state |= UBIK_RECFOUNDDB;
            urecovery_state &= ~UBIK_RECSENTDB;
        }
-#if defined(UBIK_PAUSE)
-       /* it's not possible for UBIK_RECFOUNDDB not to be set here.
-        * However, we might have lost UBIK_RECSYNCSITE, and that
-        * IS important.
-        */
-       if (!(urecovery_state & UBIK_RECSYNCSITE))
-           continue;           /* lost sync */
-#else
        if (!(urecovery_state & UBIK_RECFOUNDDB))
            continue;           /* not ready */
-#endif /* UBIK_PAUSE */
 
        /* If we, the sync site, do not have the best db version, then
         * go and get it from the server that does.
@@ -605,15 +596,6 @@ urecovery_Interact(void *dummy)
                goto FetchEndCall;
            }
 
-#ifdef OLD_URECOVERY
-           /* Truncate the file first */
-           code = (*ubik_dbase->truncate) (ubik_dbase, file, 0);
-           if (code) {
-               ubik_dprint("truncate io error=%d\n", code);
-               goto FetchEndCall;
-           }
-           tversion.counter = 0;
-#endif
            /* give invalid label during file transit */
            tversion.epoch = 0;
            code = (*ubik_dbase->setlabel) (ubik_dbase, file, &tversion);
@@ -621,7 +603,6 @@ urecovery_Interact(void *dummy)
                ubik_dprint("setlabel io error=%d\n", code);
                goto FetchEndCall;
            }
-#ifndef OLD_URECOVERY
            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) {
@@ -633,7 +614,6 @@ urecovery_Interact(void *dummy)
                close(fd);
                goto FetchEndCall;
            }
-#endif
 
            pass = 0;
            while (length > 0) {
@@ -649,14 +629,8 @@ urecovery_Interact(void *dummy)
                    close(fd);
                    goto FetchEndCall;
                }
-#ifdef OLD_URECOVERY
-               nbytes =
-                   (*ubik_dbase->write) (ubik_dbase, file, tbuffer, offset,
-                                         tlen);
-#else
                nbytes = write(fd, tbuffer, tlen);
                pass++;
-#endif
                if (nbytes != tlen) {
                    code = UIOERROR;
                    close(fd);
@@ -665,11 +639,9 @@ urecovery_Interact(void *dummy)
                offset += tlen;
                length -= tlen;
            }
-#ifndef OLD_URECOVERY
            code = close(fd);
            if (code)
                goto FetchEndCall;
-#endif
            code = EndDISK_GetFile(rxcall, &tversion);
          FetchEndCall:
            tcode = rx_EndCall(rxcall, code);
@@ -680,9 +652,6 @@ urecovery_Interact(void *dummy)
                urecovery_state |= UBIK_RECHAVEDB;
                memcpy(&ubik_dbase->version, &tversion,
                       sizeof(struct ubik_version));
-#ifdef OLD_URECOVERY
-               (*ubik_dbase->sync) (ubik_dbase, 0);    /* get data out first */
-#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);
@@ -695,27 +664,22 @@ urecovery_Interact(void *dummy)
                    code = rename(pbuffer, tbuffer);
                if (!code) {
                    (*ubik_dbase->open) (ubik_dbase, file);
-#endif
                    /* after data is good, sync disk with correct label */
                    code =
                        (*ubik_dbase->setlabel) (ubik_dbase, 0,
                                                 &ubik_dbase->version);
-#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
            }
            if (code) {
-#ifndef OLD_URECOVERY
                unlink(pbuffer);
                /*
                 * We will effectively invalidate the old data forever now.
                 * Unclear if we *should* but we do.
                 */
-#endif
                ubik_dbase->version.epoch = 0;
                ubik_dbase->version.counter = 0;
                ubik_print("Ubik: Synchronize database failed (error = %d)\n",
@@ -732,10 +696,6 @@ urecovery_Interact(void *dummy)
 #endif
            DBRELE(ubik_dbase);
        }
-#if defined(UBIK_PAUSE)
-       if (!(urecovery_state & UBIK_RECSYNCSITE))
-           continue;           /* lost sync */
-#endif /* UBIK_PAUSE */
        if (!(urecovery_state & UBIK_RECHAVEDB))
            continue;           /* not ready */