STABLE14-ubik-recovery-swap-in-new-fd-20080428

LICENSE IPL10

when recovery is done, forcibly invalidate the old fd


(cherry picked from commit 888bc28b18)
This commit is contained in:
Derrick Brashear 2008-04-28 22:48:25 +00:00
parent 602963f781
commit 19c0fdda30
5 changed files with 25 additions and 3 deletions

View File

@ -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;
}
}
}

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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);