ubik recovery kill duplicate code
authorDerrick Brashear <shadow@dementia.org>
Mon, 30 Aug 2010 16:32:58 +0000 (12:32 -0400)
committerDerrick Brashear <shadow@dementia.org>
Mon, 30 Aug 2010 17:31:28 +0000 (10:31 -0700)
if recovery wants to invalidate transaction unconditionally and
has code duplication from urecovery_checkTid, just make checkTid
do what we want

Change-Id: I345560c496d4cb4506de6db79357b99c616ffbbe
Reviewed-on: http://gerrit.openafs.org/2628
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/ubik/recovery.c
src/ubik/remote.c
src/ubik/ubik.p.h
src/ubik/vote.c

index cfa6e4a..b6195c3 100644 (file)
@@ -156,13 +156,13 @@ urecovery_AbortAll(struct ubik_dbase *adbase)
  * \brief this routine aborts the current remote transaction, if any, if the tid is wrong
  */
 int
-urecovery_CheckTid(struct ubik_tid *atid)
+urecovery_CheckTid(struct ubik_tid *atid, int abortalways)
 {
     if (ubik_currentTrans) {
        /* there is remote write trans, see if we match, see if this
         * is a new transaction */
        if (atid->epoch != ubik_currentTrans->tid.epoch
-           || atid->counter > ubik_currentTrans->tid.counter) {
+           || 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)
index 45404ec..b395539 100644 (file)
@@ -70,18 +70,7 @@ SDISK_Begin(struct rx_call *rxcall, struct ubik_tid *atid)
        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 */
@@ -119,7 +108,7 @@ SDISK_Commit(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);
@@ -156,7 +145,7 @@ SDISK_ReleaseLocks(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;
@@ -195,7 +184,7 @@ SDISK_Abort(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;
@@ -239,7 +228,7 @@ SDISK_Lock(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;
@@ -286,7 +275,7 @@ SDISK_WriteV(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;
@@ -333,7 +322,7 @@ SDISK_Write(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;
@@ -365,7 +354,7 @@ SDISK_Truncate(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;
@@ -763,7 +752,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;
index 17622be..3c1da29 100644 (file)
@@ -396,7 +396,7 @@ extern int urecovery_LostServer(void);
 extern int urecovery_AllBetter(struct ubik_dbase *adbase,
                               int areadAny);
 extern int urecovery_AbortAll(struct ubik_dbase *adbase);
-extern int urecovery_CheckTid(struct ubik_tid *atid);
+extern int urecovery_CheckTid(struct ubik_tid *atid, int abortalways);
 extern int urecovery_Initialize(struct ubik_dbase *adbase);
 extern void *urecovery_Interact(void *);
 extern int DoProbe(struct ubik_server *server);
index 13af885..71aed1b 100644 (file)
@@ -339,7 +339,7 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
        lastYesState = astate;  /* remember if site is a sync site */
        ubik_dbVersion = *avers;        /* resync value */
        ubik_dbTid = *atid;     /* transaction id, if any, of active trans */
-       urecovery_CheckTid(atid);       /* check if current write trans needs aborted */
+       urecovery_CheckTid(atid, 0);    /* check if current write trans needs aborted */
     }
     return vote;
 }