From: Michael Meffie Date: Sat, 8 Mar 2014 17:35:23 +0000 (-0500) Subject: libafs: put volume disk cache i/o in afs_UFSGetVolSlot X-Git-Tag: upstream/1.8.0_pre1^2~753 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=bbda24f9d324493e3f59c216a465fb2383d8f557;p=packages%2Fo%2Fopenafs.git libafs: put volume disk cache i/o in afs_UFSGetVolSlot Move the reading of the volume items file to the afs_UFSGetVolSlot() to make it more clear the volume items file is not accessed when memcache is in effect. This changes the afs_GetVolSlot to return an intialized volume slot, if one can be gotten. Change-Id: I0c76ca8c8e1cc19677ce950bfb454755bbbee86a Reviewed-on: http://gerrit.openafs.org/10878 Tested-by: BuildBot Reviewed-by: D Brashear --- diff --git a/src/afs/afs_chunkops.h b/src/afs/afs_chunkops.h index 3babf8979..1cedc7da7 100644 --- a/src/afs/afs_chunkops.h +++ b/src/afs/afs_chunkops.h @@ -61,7 +61,7 @@ struct afs_cacheOps { int (*vreadUIO) (afs_dcache_id_t *, struct uio *); int (*vwriteUIO) (struct vcache *, afs_dcache_id_t *, struct uio *); struct dcache *(*GetDSlot) (afs_int32 aslot, int indexvalid, int datavalid); - struct volume *(*GetVolSlot) (void); + struct volume *(*GetVolSlot) (afs_int32 volid, struct cell *cell); int (*HandleLink) (struct vcache * avc, struct vrequest * areq); }; @@ -71,7 +71,7 @@ struct afs_cacheOps { #define afs_CFileRead(file, offset, data, size) (*(afs_cacheType->fread))(file, offset, data, size) #define afs_CFileWrite(file, offset, data, size) (*(afs_cacheType->fwrite))(file, offset, data, size) #define afs_CFileClose(handle) (*(afs_cacheType->close))(handle) -#define afs_GetVolSlot() (*(afs_cacheType->GetVolSlot))() +#define afs_GetVolSlot(volid, cell) (*(afs_cacheType->GetVolSlot))((volid),(cell)) #define afs_HandleLink(avc, areq) (*(afs_cacheType->HandleLink))(avc, areq) /* Use afs_GetValidDSlot to get a dcache from a dcache slot number when we diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 9a8cce3f3..42875d135 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1388,7 +1388,7 @@ extern void LockAndInstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, struct cell *tcell, struct vrequest *areq); extern void afs_ResetVolumeInfo(struct volume *tv); -extern struct volume *afs_MemGetVolSlot(void); +extern struct volume *afs_MemGetVolSlot(afs_int32 volid, struct cell *cell); extern void afs_ResetVolumes(struct server *srvp, struct volume *tv); extern struct volume *afs_GetVolume(struct VenusFid *afid, struct vrequest *areq, @@ -1397,7 +1397,7 @@ extern struct volume *afs_GetVolumeByName(char *aname, afs_int32 acell, int agood, struct vrequest *areq, afs_int32 locktype); -extern struct volume *afs_UFSGetVolSlot(void); +extern struct volume *afs_UFSGetVolSlot(afs_int32 volid, struct cell *cell); extern void afs_CheckVolumeNames(int flags); /* Prototypes for generated files that aren't really in src/afs/ */ diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 249179408..92b6e17ff 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -144,7 +144,7 @@ afs_InitVolSlot(struct volume *tv, struct fvolume *tf, afs_int32 volid, * @return */ struct volume * -afs_UFSGetVolSlot(void) +afs_UFSGetVolSlot(afs_int32 volid, struct cell *tcell) { struct volume *tv = NULL, **lv; struct osi_file *tfile; @@ -153,6 +153,8 @@ afs_UFSGetVolSlot(void) struct volume *bestVp, *oldLp = NULL, **bestLp = NULL; char *oldname = NULL; afs_int32 oldvtix = -2; /* Initialize to a value that doesn't occur */ + struct fvolume *tf = NULL; + int j = 0; AFS_STATCNT(afs_UFSGetVolSlot); if (!afs_freeVolList) { @@ -236,6 +238,36 @@ afs_UFSGetVolSlot(void) tv = afs_freeVolList; afs_freeVolList = tv->next; } + + /* read volume item data from disk for the gotten slot */ + for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = tf->next) { + if (afs_FVIndex != j) { + tfile = osi_UFSOpen(&volumeInode); + code = + afs_osi_Read(tfile, sizeof(struct fvolume) * j, + &staticFVolume, sizeof(struct fvolume)); + osi_UFSClose(tfile); + if (code != sizeof(struct fvolume)) { + afs_warn("afs_SetupVolume: error %d reading volumeinfo\n", + (int)code); + /* put tv back on the free list; the data in it is not valid */ + tv->next = afs_freeVolList; + afs_freeVolList = tv; + /* staticFVolume contents are not valid */ + afs_FVIndex = -1; + return NULL; + } + afs_FVIndex = j; + } + if (j != 0) { /* volume items record 0 is not used */ + tf = &staticFVolume; + if (tf->cell == tcell->cellNum && tf->volume == volid) { + break; + } + } + } + + afs_InitVolSlot(tv, tf, volid, tcell); return tv; error: @@ -270,7 +302,7 @@ afs_UFSGetVolSlot(void) * @return */ struct volume * -afs_MemGetVolSlot(void) +afs_MemGetVolSlot(afs_int32 volid, struct cell *tcell) { struct volume *tv; @@ -286,6 +318,8 @@ afs_MemGetVolSlot(void) } tv = afs_freeVolList; afs_freeVolList = tv->next; + + afs_InitVolSlot(tv, NULL, volid, tcell); return tv; } /*afs_MemGetVolSlot */ @@ -576,7 +610,7 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, struct uvldbentry *uve = (struct uvldbentry *)ve; int whichType; /* which type of volume to look for */ - int i, j, err = 0; + int i; if (!volid) { int len; @@ -611,44 +645,11 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, } } if (!tv) { - struct fvolume *tf = 0; - - tv = afs_GetVolSlot(); + tv = afs_GetVolSlot(volid, tcell); if (!tv) { ReleaseWriteLock(&afs_xvolume); return NULL; } - - for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = tf->next) { - if (afs_FVIndex != j) { - struct osi_file *tfile; - tfile = osi_UFSOpen(&volumeInode); - err = - afs_osi_Read(tfile, sizeof(struct fvolume) * j, - &staticFVolume, sizeof(struct fvolume)); - osi_UFSClose(tfile); - if (err != sizeof(struct fvolume)) { - afs_warn("afs_SetupVolume: error %d reading volumeinfo\n", - (int)err); - /* put tv back on the free list; the data in it is not valid */ - tv->next = afs_freeVolList; - afs_freeVolList = tv; - /* staticFVolume contents are not valid */ - afs_FVIndex = -1; - ReleaseWriteLock(&afs_xvolume); - return NULL; - } - afs_FVIndex = j; - } - if (j != 0) { /* volume items record 0 is not used */ - tf = &staticFVolume; - if (tf->cell == tcell->cellNum && tf->volume == volid) { - break; - } - } - } - - afs_InitVolSlot(tv, tf, volid, tcell); tv->next = afs_volumes[i]; /* thread into list */ afs_volumes[i] = tv; }