mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
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 <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com> Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
parent
2575d87824
commit
4e3400414f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user