From 2285341b5f009329d84f1ccdb6bcadcb6a507047 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 16 Oct 2009 15:31:02 -0400 Subject: [PATCH 1/1] Windows: mark volume status online during cm_MergeStatus During cm_MergeStatus, if the volume status is not vl_online mark it vl_online. The volume must be online because an AFSFetchStatus was just processed. This change reduces the amount of work that must be performed by the daemon thread's volume status check. LICENSE MIT Reviewed-on: http://gerrit.openafs.org/669 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/cm_scache.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 9028d8c..bee91c4 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -1514,6 +1514,8 @@ void cm_MergeStatus(cm_scache_t *dscp, cm_user_t *userp, cm_req_t *reqp, afs_uint32 flags) { afs_uint64 dataVersion; + struct cm_volume *volp = NULL; + struct cm_cell *cellp = NULL; // yj: i want to create some fake status for the /afs directory and the // entries under that directory @@ -1579,7 +1581,7 @@ void cm_MergeStatus(cm_scache_t *dscp, scp->parentVnode = 0; scp->parentUnique = 0; } - return; + goto done; } else { scp->flags &= ~CM_SCACHEFLAG_EACCESS; } @@ -1591,18 +1593,14 @@ void cm_MergeStatus(cm_scache_t *dscp, if (!(flags & CM_MERGEFLAG_FORCE) && dataVersion < scp->dataVersion && scp->dataVersion != CM_SCACHE_VERSION_BAD) { - struct cm_cell *cellp; cellp = cm_FindCellByID(scp->fid.cell, 0); if (scp->cbServerp) { - struct cm_volume *volp = NULL; cm_FindVolumeByID(cellp, scp->fid.volume, userp, reqp, CM_GETVOL_FLAG_CREATE, &volp); osi_Log2(afsd_logp, "old data from server %x volume %s", scp->cbServerp->addr.sin_addr.s_addr, volp ? volp->namep : "(unknown)"); - if (volp) - cm_PutVolume(volp); } osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d", scp, scp->dataVersion, dataVersion); @@ -1634,7 +1632,7 @@ void cm_MergeStatus(cm_scache_t *dscp, * infinite loop. So we just grin and bear it. */ if (!(scp->flags & CM_SCACHEFLAG_RO)) - return; + goto done; } scp->volumeCreationDate = volsyncp->spare1; /* volume creation date */ @@ -1766,6 +1764,29 @@ void cm_MergeStatus(cm_scache_t *dscp, * have completed yet. */ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_FETCHSTATUS); + + /* + * We just successfully merged status on the stat cache object. + * This means that the associated volume must be online. + */ + if (!volp) { + if (!cellp) + cellp = cm_FindCellByID(scp->fid.cell, 0); + cm_FindVolumeByID(cellp, scp->fid.volume, userp, reqp, 0, &volp); + } + if (volp) { + cm_vol_state_t *statep = cm_VolumeStateByID(volp, scp->fid.volume); + if (statep->state != vl_online) { + lock_ObtainWrite(&volp->rw); + cm_VolumeStatusNotification(volp, statep->ID, statep->state, vl_online); + statep->state = vl_online; + lock_ReleaseWrite(&volp->rw); + } + } + done: + if (volp) + cm_PutVolume(volp); + } /* note that our stat cache info is incorrect, so force us eventually -- 1.9.4