Windows: Enforce free space checks every 1MB
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 11 Mar 2013 04:43:26 +0000 (00:43 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 12 Mar 2013 13:52:43 +0000 (06:52 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_vnodeops.c

index 963140e..50fa010 100644 (file)
@@ -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;