From 8f95dc9eb92cb31f9d29eb87daac747f53b5a1cc Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 8 Feb 2013 17:26:32 -0600 Subject: [PATCH 1/1] afs: Move SetupVolume tv initialization after loop The fields in tv are not used by the loop looking for the given volume on disk. If we wait until after that loop to initialize the fields in tv, it is easier to handle errors encountered in the loop. This should incur no functional change. Change-Id: Ib678542bfebaa89ecfa4aad39230fc502ec83edb Reviewed-on: http://gerrit.openafs.org/9093 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear --- src/afs/afs_volume.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 3cf7a2e..9953f5a 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -584,12 +584,8 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, return NULL; } memset(tv, 0, sizeof(struct volume)); - tv->cell = tcell->cellNum; - AFS_RWLOCK_INIT(&tv->lock, "volume lock"); - tv->next = afs_volumes[i]; /* thread into list */ - afs_volumes[i] = tv; - tv->volume = volid; - for (j = fvTable[FVHash(tv->cell, volid)]; j != 0; j = tf->next) { + + for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = tf->next) { if (afs_FVIndex != j) { struct osi_file *tfile; tfile = osi_UFSOpen(&volumeInode); @@ -602,9 +598,16 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, afs_FVIndex = j; } tf = &staticFVolume; - if (tf->cell == tv->cell && tf->volume == volid) + if (tf->cell == tcell->cellNum && tf->volume == volid) break; } + + tv->cell = tcell->cellNum; + AFS_RWLOCK_INIT(&tv->lock, "volume lock"); + tv->next = afs_volumes[i]; /* thread into list */ + afs_volumes[i] = tv; + tv->volume = volid; + if (tf && (j != 0)) { tv->vtix = afs_FVIndex; tv->mtpoint = tf->mtpoint; -- 1.9.4