From a4dc1317caa6d75ec30dc862bbc66d822fcaed1e Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 24 Dec 2007 05:19:09 +0000 Subject: [PATCH] DEVEL15-windows-update-volume-status-20071223 LICENSE MIT Refactor cm_UpdateVolumeStatus. Revise behavior to treat volid 0 as update the volume status for all volumes in the volume group. (cherry picked from commit 815cd6f19ec37330e7829506c1208c9426b3a41f) --- src/WINNT/afsd/cm_volume.c | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index cafae60f44..3b9ff16953 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -1119,24 +1119,16 @@ void cm_CheckOfflineVolumes(void) lock_ReleaseWrite(&cm_volumeLock); } -void -cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID) + +static void +cm_UpdateVolumeStatusInt(cm_volume_t *volp, struct cm_vol_state *statep) { - struct cm_vol_state * statep = NULL; enum volstatus newStatus; cm_serverRef_t *tsrp; cm_server_t *tsp; int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1; - if (volp->rw.ID == volID) { - statep = &volp->rw; - } else if (volp->ro.ID == volID) { - statep = &volp->ro; - } else if (volp->bk.ID == volID) { - statep = &volp->bk; - } - - if (!statep) { + if (!volp || !statep) { #ifdef DEBUG DebugBreak(); #endif @@ -1173,13 +1165,39 @@ cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID) else newStatus = vl_online; - if (statep->ID && statep->state != newStatus) cm_VolumeStatusNotification(volp, statep->ID, statep->state, newStatus); statep->state = newStatus; } +void +cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID) +{ + + if (volp->rw.ID == volID) { + cm_UpdateVolumeStatusInt(volp, &volp->rw); + } else if (volp->ro.ID == volID) { + cm_UpdateVolumeStatusInt(volp, &volp->ro); + } else if (volp->bk.ID == volID) { + cm_UpdateVolumeStatusInt(volp, &volp->bk); + } else { + /* + * If we are called with volID == 0 then something has gone wrong. + * Most likely a race occurred in the server volume list maintenance. + * Since we don't know which volume's status should be updated, + * just update all of them that are known to exist. Better to be + * correct than fast. + */ + if (volp->rw.ID != 0) + cm_UpdateVolumeStatusInt(volp, &volp->rw); + if (volp->ro.ID != 0) + cm_UpdateVolumeStatusInt(volp, &volp->ro); + if (volp->bk.ID != 0) + cm_UpdateVolumeStatusInt(volp, &volp->bk); + } +} + /* ** Finds all volumes that reside on this server and reorders their ** RO list according to the changed rank of server.