From eecf7a1372f8fcb01d73b628850b488414d9ca3a Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 11 Mar 2013 00:43:26 -0400 Subject: [PATCH] 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 --- src/WINNT/afsd/cm_vnodeops.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 963140e63c..50fa010f47 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;