From: Jeffrey Altman Date: Fri, 2 Dec 2011 16:14:11 +0000 (-0500) Subject: Windows: buf_CleanAsync is not async; rename it X-Git-Tag: openafs-stable-1_8_0pre1~2991 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=c712403f192bd9932f3ec1dce5fb23461d3d0349 Windows: buf_CleanAsync is not async; rename it buf_CleanAsync() calls cm_BufWrite() which stores the dirty buffers synchronously. There is nothing asynchronous about buf_CleanAsync() so rename it to buf_Clean() and buf_CleanAsyncLocked() to buf_CleanLocked(). Update the comments to remove the references to the asynchronous processing which doesn't exist. That is not to say that the call to buf_Clean() in buf_GetNewLocked() should not be asynchronous; it should. There is no such functionality at the moment. One approach would be to modify buf_IncrSyncer to trigger on an event set by buf_GetNewLocked() instead of the call to buf_Clean(). Another approach would be registering a background store event. In any case, that is for another patchset. Change-Id: I4c6d08d2a81b36f3cc43ada96acfa0ff9db23845 Reviewed-on: http://gerrit.openafs.org/6172 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 96f9f67..6231665 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -267,7 +267,7 @@ buf_Sync(int quitOnShutdown) case vl_unknown: cm_InitReq(&req); req.flags |= CM_REQ_NORETRY; - buf_CleanAsyncLocked(NULL, bp, &req, 0, &dirty); + buf_CleanLocked(NULL, bp, &req, 0, &dirty); wasDirty |= dirty; } cm_PutVolume(volp); @@ -824,7 +824,7 @@ cm_buf_t *buf_FindAll(struct cm_fid *fidp, osi_hyper_t *offsetp, afs_uint32 flag * 'scp' may or may not be NULL. If it is not NULL, the FID for both cm_scache_t * and cm_buf_t must match. */ -afs_uint32 buf_CleanAsyncLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, +afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, afs_uint32 flags, afs_uint32 *pisdirty) { afs_uint32 code = 0; @@ -862,10 +862,10 @@ afs_uint32 buf_CleanAsyncLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, * in fact be the case but we don't know that until we attempt * a FetchStatus on the FID. */ - osi_Log1(buf_logp, "buf_CleanAsyncLocked unable to start I/O - scp not found buf 0x%p", bp); + osi_Log1(buf_logp, "buf_CleanLocked unable to start I/O - scp not found buf 0x%p", bp); code = CM_ERROR_NOSUCHFILE; } else { - osi_Log2(buf_logp, "buf_CleanAsyncLocked starts I/O on scp 0x%p buf 0x%p", scp, bp); + osi_Log2(buf_logp, "buf_CleanLocked starts I/O on scp 0x%p buf 0x%p", scp, bp); offset = bp->offset; LargeIntegerAdd(offset, ConvertLongToLargeInteger(bp->dirty_offset)); @@ -878,7 +878,7 @@ afs_uint32 buf_CleanAsyncLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, code = (*cm_buf_opsp->Writep)(scp, &offset, bp->dirty_length, flags, bp->userp, reqp); - osi_Log3(buf_logp, "buf_CleanAsyncLocked I/O on scp 0x%p buf 0x%p, done=%d", scp, bp, code); + osi_Log3(buf_logp, "buf_CleanLocked I/O on scp 0x%p buf 0x%p, done=%d", scp, bp, code); } lock_ObtainMutex(&bp->mx); /* if the Write routine returns No Such File, clear the dirty flag @@ -1375,16 +1375,18 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *req lock_ReleaseWrite(&buf_globalLock); lock_ReleaseRead(&scp->bufCreateLock); - /* grab required lock and clean; this only - * starts the I/O. By the time we're back, - * it'll still be marked dirty, but it will also - * have the WRITING flag set, so we won't get - * back here. + /* + * grab required lock and clean. + * previously the claim was that the cleaning + * operation was async which it is not. It would + * be a good idea to use an async mechanism here + * but there is none at the moment other than + * the buf_IncrSyncer() thread. */ if (cm_FidCmp(&scp->fid, &bp->fid) == 0) - buf_CleanAsync(scp, bp, reqp, 0, NULL); + buf_Clean(scp, bp, reqp, 0, NULL); else - buf_CleanAsync(NULL, bp, reqp, 0, NULL); + buf_Clean(NULL, bp, reqp, 0, NULL); /* now put it back and go around again */ buf_Release(bp); @@ -1661,14 +1663,14 @@ long buf_Get(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp, cm_buf } /* clean a buffer synchronously */ -afs_uint32 buf_CleanAsync(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, afs_uint32 flags, afs_uint32 *pisdirty) +afs_uint32 buf_Clean(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, afs_uint32 flags, afs_uint32 *pisdirty) { long code; osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); osi_assertx(!(flags & CM_BUF_WRITE_SCP_LOCKED), "scp->rw must not be held when calling buf_CleanAsync"); lock_ObtainMutex(&bp->mx); - code = buf_CleanAsyncLocked(scp, bp, reqp, flags, pisdirty); + code = buf_CleanLocked(scp, bp, reqp, flags, pisdirty); lock_ReleaseMutex(&bp->mx); return code; @@ -1818,7 +1820,7 @@ long buf_CleanAndReset(void) cm_InitReq(&req); req.flags |= CM_REQ_NORETRY; - buf_CleanAsync(NULL, bp, &req, 0, NULL); + buf_Clean(NULL, bp, &req, 0, NULL); buf_CleanWait(NULL, bp, FALSE); /* relock and release buffer */ @@ -2090,7 +2092,7 @@ long buf_FlushCleanPages(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp) lock_ObtainMutex(&bp->mx); /* start cleaning the buffer, and wait for it to finish */ - buf_CleanAsyncLocked(scp, bp, reqp, 0, NULL); + buf_CleanLocked(scp, bp, reqp, 0, NULL); buf_WaitIO(scp, bp); lock_ReleaseMutex(&bp->mx); @@ -2244,7 +2246,7 @@ long buf_CleanVnode(struct cm_scache *scp, cm_user_t *userp, cm_req_t *reqp) */ break; default: - code = buf_CleanAsyncLocked(scp, bp, reqp, 0, &wasDirty); + code = buf_CleanLocked(scp, bp, reqp, 0, &wasDirty); if (bp->flags & CM_BUF_ERROR) { code = bp->error; if (code == 0) diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index 992c4ab..eaedf12 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -177,9 +177,9 @@ extern long buf_GetNewLocked(struct cm_scache *, osi_hyper_t *, cm_req_t *, cm_b extern long buf_Get(struct cm_scache *, osi_hyper_t *, cm_req_t *, cm_buf_t **); -extern afs_uint32 buf_CleanAsyncLocked(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint32 flags, afs_uint32 *); +extern afs_uint32 buf_CleanLocked(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint32 flags, afs_uint32 *); -extern afs_uint32 buf_CleanAsync(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint32 flags, afs_uint32 *); +extern afs_uint32 buf_Clean(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint32 flags, afs_uint32 *); extern void buf_CleanWait(cm_scache_t *, cm_buf_t *, afs_uint32 locked);