From: Jeffrey Altman Date: Fri, 16 Apr 2010 04:09:25 +0000 (-0400) Subject: Windows: wait for I/O on buffers to complete in cm_SetupStoreBIOD X-Git-Tag: openafs-devel-1_5_74~13 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5a253b19117e4f42c0db91ca3a45843462c0266c;p=packages%2Fo%2Fopenafs.git Windows: wait for I/O on buffers to complete in cm_SetupStoreBIOD cm_SetupStoreBIOD constructs a list of dirty buffers for a file that are to be written to the file server. When constructing the list, if when determining the first dirty buffer we come across a buffer that is already actively involved in an I/O operation, call buf_WaitIO() to wait until the buffer is no longer busy before continuing. This reduces lock contention and synchronization conflicts. LICENSE MIT Change-Id: Icd79b9578b7411b138f14257bcb885249960eab0 Reviewed-on: http://gerrit.openafs.org/1760 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index 32dcf2994..ba311d5ed 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -936,8 +936,15 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize, /* get buffer mutex and scp mutex safely */ lock_ReleaseWrite(&scp->rw); lock_ObtainMutex(&bufp->mx); - lock_ObtainWrite(&scp->rw); + /* + * if the buffer is actively involved in I/O + * we wait for the I/O to complete. + */ + if (bufp->flags & (CM_BUF_WRITING|CM_BUF_READING)) + buf_WaitIO(scp, bufp); + + lock_ObtainWrite(&scp->rw); flags = CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS | CM_SCACHESYNC_STOREDATA | CM_SCACHESYNC_BUFLOCKED; code = cm_SyncOp(scp, bufp, userp, reqp, 0, flags); if (code) {