From 759487038bbaccf59e49f973b627ee20f555e7b3 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 30 Aug 2010 12:32:58 -0400 Subject: [PATCH] ubik recovery kill duplicate code 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 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/ubik/recovery.c | 4 ++-- src/ubik/remote.c | 29 +++++++++-------------------- src/ubik/ubik.p.h | 2 +- src/ubik/vote.c | 2 +- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index cfa6e4ab2..b6195c359 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -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) diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 45404ecf5..b395539fe 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -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; diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index 17622be14..3c1da2913 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -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); diff --git a/src/ubik/vote.c b/src/ubik/vote.c index 13af88532..71aed1be0 100644 --- a/src/ubik/vote.c +++ b/src/ubik/vote.c @@ -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; } -- 2.39.5