From: Michael Meffie Date: Sat, 8 Mar 2014 19:30:27 +0000 (-0500) Subject: libafs: afs_SetupVolSlot function X-Git-Tag: upstream/1.8.0_pre1^2~752 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d07fb827a6d142142216b3effd32814cd721cc06;p=packages%2Fo%2Fopenafs.git libafs: afs_SetupVolSlot function Move the code block to get and setup volume slots out of afs_SetupVolume to a new local function called afs_SetupVolSlot. This new function acquires the afs_xvolume lock and releases it before returning. Change-Id: I1bd33f13e0525f9ff050d7e161cf29a511e5c4b8 Reviewed-on: http://gerrit.openafs.org/10879 Tested-by: BuildBot Reviewed-by: D Brashear --- diff --git a/src/afs/afs_stats.h b/src/afs/afs_stats.h index 687244b49..9a96b4155 100644 --- a/src/afs/afs_stats.h +++ b/src/afs/afs_stats.h @@ -658,7 +658,8 @@ struct afs_MeanStats { AFS_CS(PSetTokens2) /* afs_pioctl.c */ \ AFS_CS(PPrefetchFromTape) /* afs_pioctl.c */ \ AFS_CS(PFlushAllVolumeData) /* afs_pioctl.c */ \ - AFS_CS(afs_InitVolSlot) /* afs_volume.c */ + AFS_CS(afs_InitVolSlot) /* afs_volume.c */ \ + AFS_CS(afs_SetupVolSlot) /* afs_volume.c */ struct afs_CMCallStats { #define AFS_CS(call) afs_int32 C_ ## call; diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 92b6e17ff..827ff1259 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -324,6 +324,46 @@ afs_MemGetVolSlot(afs_int32 volid, struct cell *tcell) } /*afs_MemGetVolSlot */ +/*! + * Setup a volume slot for cell:volume. + * + * Find the volume slot for the cell:volume, otherwise get + * and initialize a new slot. + * + * \param volid volume id + * \param cell cell + * \return volume + */ +static struct volume * +afs_SetupVolSlot(afs_int32 volid, struct cell *tcell) +{ + struct volume *tv; + int i; + + AFS_STATCNT(afs_SetupVolSlot); + ObtainWriteLock(&afs_xvolume, 108); + i = VHash(volid); + for (tv = afs_volumes[i]; tv; tv = tv->next) { + if (tv->volume == volid && tv->cell == tcell->cellNum) { + break; + } + } + if (!tv) { + tv = afs_GetVolSlot(volid, tcell); + if (!tv) { + ReleaseWriteLock(&afs_xvolume); + return NULL; + } + tv->next = afs_volumes[i]; /* thread into list */ + afs_volumes[i] = tv; + } + tv->refCount++; + tv->states &= ~VRecheck; /* just checked it */ + tv->accessTime = osi_Time(); + ReleaseWriteLock(&afs_xvolume); + return tv; +} + /*! * Reset volume information for all volume structs that * point to a speicific server, skipping a given volume if provided. @@ -636,27 +676,11 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, } /* end of if (volid == 0) */ } /* end of if (!volid) */ - - ObtainWriteLock(&afs_xvolume, 108); - i = VHash(volid); - for (tv = afs_volumes[i]; tv; tv = tv->next) { - if (tv->volume == volid && tv->cell == tcell->cellNum) { - break; - } - } + tv = afs_SetupVolSlot(volid, tcell); if (!tv) { - tv = afs_GetVolSlot(volid, tcell); - if (!tv) { - ReleaseWriteLock(&afs_xvolume); - return NULL; - } - tv->next = afs_volumes[i]; /* thread into list */ - afs_volumes[i] = tv; + return NULL; } - tv->refCount++; - tv->states &= ~VRecheck; /* just checked it */ - tv->accessTime = osi_Time(); - ReleaseWriteLock(&afs_xvolume); + if (type == 2) { LockAndInstallUVolumeEntry(tv, uve, tcell->cellNum, tcell, areq); } else if (type == 1)