From 4e3400414f676b9a0033f041f81671534ffdab99 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 5 Jul 2012 18:21:51 -0400 Subject: [PATCH] Windows: Apply cm_GetVolServerList() to cm_Analyze() Using cm_GetVolServerList() it is possible to simplify the logic in cm_Analyze(). It is no longer necessary for cm_Analyze() to call cm_GetServerList() which must obtain its own reference the the cm_volume_t object via a fileId lookup. This reduces lock contention and makes the code a bit more readable. Change-Id: I3a39458676af06fd473489d639bf9d2fe80c0b9d Reviewed-on: http://gerrit.openafs.org/7723 Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_conn.c | 126 +++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 1494e77c5b..3043d5d492 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -421,7 +421,7 @@ cm_Analyze(cm_conn_t *connp, &volp); if (code == 0) { if (cm_UpdateVolumeLocation(cellp, userp, reqp, volp) == 0) { - code = cm_GetServerList(fidp, userp, reqp, &replicated, &serverspp); + code = cm_GetVolServerList(volp, fidp->volume, userp, reqp, &replicated, &serverspp); if (code == 0) { if (!cm_IsServerListEmpty(*serverspp)) retry = 1; @@ -466,24 +466,24 @@ cm_Analyze(cm_conn_t *connp, format = "All servers are offline when accessing cell %s volume %d."; LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume); - if (!serversp) { - code = cm_GetServerList(fidp, userp, reqp, &replicated, &serverspp); - if (code == 0) { - serversp = *serverspp; - free_svr_list = 1; - } - } - cm_ResetServerBusyStatus(serversp); - if (free_svr_list) { - cm_FreeServerList(serverspp, 0); - free_svr_list = 0; - serversp = NULL; - } - code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp); if (code == 0) { + if (!serversp) { + code = cm_GetVolServerList(volp, fidp->volume, userp, reqp, &replicated, &serverspp); + if (code == 0) { + serversp = *serverspp; + free_svr_list = 1; + } + } + cm_ResetServerBusyStatus(serversp); + if (free_svr_list) { + cm_FreeServerList(serverspp, 0); + free_svr_list = 0; + serversp = NULL; + } + /* * Do not perform a cm_CheckOfflineVolume() if cm_Analyze() * was called by cm_CheckOfflineVolumeState(). @@ -517,24 +517,24 @@ cm_Analyze(cm_conn_t *connp, format = "All servers are busy when accessing cell %s volume %d."; LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume); - if (!serversp) { - code = cm_GetServerList(fidp, userp, reqp, &replicated, &serverspp); - if (code == 0) { - serversp = *serverspp; - free_svr_list = 1; - } - } - cm_ResetServerBusyStatus(serversp); - if (free_svr_list) { - cm_FreeServerList(serverspp, 0); - free_svr_list = 0; - serversp = NULL; - } - code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp); if (code == 0) { + if (!serversp) { + code = cm_GetVolServerList(volp, fidp->volume, userp, reqp, &replicated, &serverspp); + if (code == 0) { + serversp = *serverspp; + free_svr_list = 1; + } + } + cm_ResetServerBusyStatus(serversp); + if (free_svr_list) { + cm_FreeServerList(serverspp, 0); + free_svr_list = 0; + serversp = NULL; + } + if (timeLeft > 7) { thrd_Sleep(5000); statep = cm_VolumeStateByID(volp, fidp->volume); @@ -563,44 +563,19 @@ cm_Analyze(cm_conn_t *connp, /* special codes: VBUSY and VRESTARTING */ else if (errorCode == VBUSY || errorCode == VRESTARTING) { - if (!serversp && fidp) { - code = cm_GetServerList(fidp, userp, reqp, &replicated, &serverspp); - if (code == 0) { - serversp = *serverspp; - free_svr_list = 1; - } - } - - switch ( errorCode ) { - case VBUSY: - msgID = MSG_SERVER_REPORTS_VBUSY; - format = "Server %s reported busy when accessing volume %d in cell %s."; - break; - case VRESTARTING: - msgID = MSG_SERVER_REPORTS_VRESTARTING; - format = "Server %s reported restarting when accessing volume %d in cell %s."; - break; - } - - if (serverp && fidp) { - /* Log server being offline for this volume */ - sprintf(addr, "%d.%d.%d.%d", - ((serverp->addr.sin_addr.s_addr & 0xff)), - ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), - ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), - ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); - - osi_Log3(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume, cellp->name); - LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume, cellp->name); - } - - cm_SetServerBusyStatus(serversp, serverp); - - if (fidp) { /* File Server query */ + if (fidp) { code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp); if (code == 0) { + if (!serversp) { + code = cm_GetVolServerList(volp, fidp->volume, userp, reqp, &replicated, &serverspp); + if (code == 0) { + serversp = *serverspp; + free_svr_list = 1; + } + } + statep = cm_VolumeStateByID(volp, fidp->volume); if (statep) @@ -613,6 +588,31 @@ cm_Analyze(cm_conn_t *connp, } } + if (serverp) { + /* Log server being offline for this volume */ + sprintf(addr, "%d.%d.%d.%d", + ((serverp->addr.sin_addr.s_addr & 0xff)), + ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), + ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), + ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); + + switch ( errorCode ) { + case VBUSY: + msgID = MSG_SERVER_REPORTS_VBUSY; + format = "Server %s reported busy when accessing volume %d in cell %s."; + break; + case VRESTARTING: + msgID = MSG_SERVER_REPORTS_VRESTARTING; + format = "Server %s reported restarting when accessing volume %d in cell %s."; + break; + } + + osi_Log3(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume, cellp->name); + LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume, cellp->name); + + cm_SetServerBusyStatus(serversp, serverp); + } + if (free_svr_list) { cm_FreeServerList(serverspp, 0); serversp = NULL;