From 888bc28b1886e994d430ddc61657e60a910208a6 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 28 Apr 2008 22:48:00 +0000 Subject: [PATCH] ubik-recovery-swap-in-new-fd-20080428 LICENSE IPL10 when recovery is done, forcibly invalidate the old fd --- src/ubik/phys.c | 19 ++++++++++++++++++- src/ubik/recovery.c | 2 ++ src/ubik/remote.c | 2 ++ src/ubik/ubik.c | 2 +- src/ubik/ubik.p.h | 3 ++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/ubik/phys.c b/src/ubik/phys.c index 403afb583..04fd0b18f 100644 --- a/src/ubik/phys.c +++ b/src/ubik/phys.c @@ -137,7 +137,7 @@ uphys_close(register int afd) return EBADF; tfd = fdcache; for (i = 0; i < MAXFDCACHE; i++, tfd++) { - if (tfd->fd == afd) { + if (tfd->fd == afd && tfd->fileID != -10000) { tfd->refCount--; return 0; } @@ -289,3 +289,20 @@ uphys_sync(register struct ubik_dbase *adbase, afs_int32 afile) uphys_close(fd); return code; } + +void +uphys_invalidate(register struct ubik_dbase *adbase, afs_int32 afid) +{ + register int i; + register struct fdcache *tfd; + + /* scan file descr cache */ + for (tfd = fdcache, i = 0; i < MAXFDCACHE; i++, tfd++) { + if (afid == tfd->fileID) { + tfd->fileID = -10000; + if (tfd->fd >= 0 && tfd->refCount == 0) + close(tfd->fd); + return; + } + } +} diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index b0ba2fbc6..eecef90cd 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -662,6 +662,8 @@ urecovery_Interact(void *dummy) #endif if (!code) code = rename(pbuffer, tbuffer); + if (!code) + code = (*ubik_dbase->open) (ubik_dbase, 0); if (!code) #endif /* after data is good, sync disk with correct label */ diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 1ec219986..06965ae96 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -615,6 +615,8 @@ SDISK_SendFile(rxcall, file, length, avers) #endif if (!code) code = rename(pbuffer, tbuffer); + if (!code) + code = (*ubik_dbase->open) (ubik_dbase, 0); if (!code) #endif code = (*ubik_dbase->setlabel) (dbase, file, avers); diff --git a/src/ubik/ubik.c b/src/ubik/ubik.c index 843abb7f8..68b127fd9 100644 --- a/src/ubik/ubik.c +++ b/src/ubik/ubik.c @@ -220,7 +220,7 @@ ubik_ServerInitCommon(afs_int32 myHost, short myPort, tdb->read = uphys_read; tdb->write = uphys_write; tdb->truncate = uphys_truncate; - tdb->open = 0; /* this function isn't used any more */ + tdb->open = uphys_invalidate; /* this function isn't used any more */ tdb->sync = uphys_sync; tdb->stat = uphys_stat; tdb->getlabel = uphys_getlabel; diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index 905819b52..6cb8cde63 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -311,7 +311,8 @@ extern int uphys_getlabel(register struct ubik_dbase *adbase, afs_int32 afile, extern int uphys_setlabel(register struct ubik_dbase *adbase, afs_int32 afile, struct ubik_version *aversion); extern int uphys_sync(register struct ubik_dbase *adbase, afs_int32 afile); - +extern void uphys_invalidate(register struct ubik_dbase *adbase, + afs_int32 afid); /* recovery.c */ extern int urecovery_ResetState(void); -- 2.39.5