From: Derrick Brashear Date: Mon, 28 Apr 2008 22:48:25 +0000 (+0000) Subject: STABLE14-ubik-recovery-swap-in-new-fd-20080428 X-Git-Tag: openafs-stable-1_4_7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=19c0fdda305ca18458cab157b556879d58f147ed;p=packages%2Fo%2Fopenafs.git STABLE14-ubik-recovery-swap-in-new-fd-20080428 LICENSE IPL10 when recovery is done, forcibly invalidate the old fd (cherry picked from commit 888bc28b1886e994d430ddc61657e60a910208a6) --- diff --git a/src/ubik/phys.c b/src/ubik/phys.c index 69153a7bf..5d6269073 100644 --- a/src/ubik/phys.c +++ b/src/ubik/phys.c @@ -130,7 +130,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; } @@ -282,3 +282,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 b59586d25..20ba9f24e 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -648,6 +648,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 041a5b308..7fc21ed5d 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 155b2e7b8..62b8c349f 100644 --- a/src/ubik/ubik.c +++ b/src/ubik/ubik.c @@ -208,7 +208,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 a6febe1dd..547babc4f 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -303,7 +303,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);