From: Jeffrey Altman Date: Mon, 11 Mar 2013 04:43:26 +0000 (-0400) Subject: Windows: Enforce free space checks every 1MB X-Git-Tag: upstream/1.8.0_pre1^2~1304 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=eecf7a1372f8fcb01d73b628850b488414d9ca3a;p=packages%2Fo%2Fopenafs.git Windows: Enforce free space checks every 1MB Instead of performing a free space (or quota) check on every extending write, perform the check only when the file length is increased beyond the next 1MB boundary. The file server permits 1MB quota over runs and issuing the volume status rpc to the file server is extremely expensive. Especially for append only applications that write just a few bytes at a time. Change-Id: I74ff17ba5a95adb41350add24bc09a74c950a4fb Reviewed-on: http://gerrit.openafs.org/9555 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 963140e63..50fa010f4 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -2909,9 +2909,22 @@ long cm_SetLength(cm_scache_t *scp, osi_hyper_t *sizep, cm_user_t *userp, * Dropping it is ok because we are holding scp->bufCreateLock * which prevents the size of the file from changing. */ - lock_ReleaseWrite(&scp->rw); - available = cm_IsSpaceAvailable(&scp->fid, sizep, userp, reqp); - lock_ObtainWrite(&scp->rw); + afs_uint64 nextChunk = scp->length.QuadPart; + + nextChunk -= (nextChunk & 0xFFFFF); + nextChunk += 0x100000; + + if (sizep->QuadPart > nextChunk) { + lock_ReleaseWrite(&scp->rw); + available = cm_IsSpaceAvailable(&scp->fid, sizep, userp, reqp); + lock_ObtainWrite(&scp->rw); + } else { + /* + * The file server permits 1MB quota overruns so only check + * when the file size increases by at least that much. + */ + available = 1; + } if (available) { scp->length = *sizep; scp->mask |= CM_SCACHEMASK_LENGTH;