From ff0f4a596554bf4b09224ca000663b596a034013 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 19 Jul 2008 15:47:40 +0000 Subject: [PATCH] windows-volume-vlgetaddrs-deadlock-20080719 LICENSE MIT During cm_InitVolume() clear CM_VOLUMEFLAG_UPDATING_VL if we are reusing the cache data just in case. In cm_UpdateVolumeLocation() add trace logging to the sleeping, waking, and awaking states; move the destruction of the old server list into the region protected by the CM_VOLUMEFLAG_UPDATING_VL flag. --- src/WINNT/afsd/cm_volume.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index 8563783d0..c67b21c6d 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -102,6 +102,7 @@ void cm_InitVolume(int newFile, long maxVols) lock_InitializeRWLock(&volp->rw, "cm_volume_t rwlock"); volp->flags |= CM_VOLUMEFLAG_RESET; + volp->flags &= CM_VOLUMEFLAG_UPDATING_VL; for (volType = RWVOL; volType < NUM_VOL_TYPES; volType++) { volp->vol[volType].state = vl_unknown; volp->vol[volType].serversp = NULL; @@ -184,12 +185,6 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * #endif afs_uint32 volType; - /* clear out old bindings */ - for ( volType = RWVOL; volType < NUM_VOL_TYPES; volType++) { - if (volp->vol[volType].serversp) - cm_FreeServerList(&volp->vol[volType].serversp, CM_FREESERVERLIST_DELETE); - } - #ifdef AFS_FREELANCE_CLIENT if ( cellp->cellID == AFS_FAKE_ROOT_CELL_ID && volp->vol[RWVOL].ID == AFS_FAKE_ROOT_VOL_ID ) { @@ -203,11 +198,24 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * #endif { while (volp->flags & CM_VOLUMEFLAG_UPDATING_VL) { + osi_Log3(afsd_logp, "cm_UpdateVolumeLocation sleeping name %s:%s flags 0x%x", + volp->cellp->name, volp->namep, volp->flags); osi_SleepW((LONG_PTR) &volp->flags, &volp->rw); lock_ObtainWrite(&volp->rw); - - if (!(volp->flags & CM_VOLUMEFLAG_RESET)) + osi_Log3(afsd_logp, "cm_UpdateVolumeLocation awake name %s:%s flags 0x%x", + volp->cellp->name, volp->namep, volp->flags); + if (!(volp->flags & CM_VOLUMEFLAG_RESET)) { + osi_Log3(afsd_logp, "cm_UpdateVolumeLocation nothing to do, waking others name %s:%s flags 0x%x", + volp->cellp->name, volp->namep, volp->flags); + osi_Wakeup((LONG_PTR) &volp->flags); return 0; + } + } + + /* clear out old bindings */ + for ( volType = RWVOL; volType < NUM_VOL_TYPES; volType++) { + if (volp->vol[volType].serversp) + cm_FreeServerList(&volp->vol[volType].serversp, CM_FREESERVERLIST_DELETE); } volp->flags |= CM_VOLUMEFLAG_UPDATING_VL; @@ -576,6 +584,8 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * volp->flags &= ~CM_VOLUMEFLAG_RESET; volp->flags &= ~CM_VOLUMEFLAG_UPDATING_VL; + osi_Log4(afsd_logp, "cm_UpdateVolumeLocation done, waking others name %s:%s flags 0x%x code 0x%x", + volp->cellp->name, volp->namep, volp->flags, code); osi_Wakeup((LONG_PTR) &volp->flags); return code; -- 2.39.5