]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
virtual-cache-file-20040729
authorAsanka Herath <asanka@mit.edu>
Thu, 29 Jul 2004 15:34:21 +0000 (15:34 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 29 Jul 2004 15:34:21 +0000 (15:34 +0000)
This is a variation of Joe Buehler's request.
New registry key "NonPersistentCache" places the cache file into the
Windows paging file.  One limitation of doing so is that the page file
cannot be grown with "fs setcachesize" and the associated ioctl.

src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_buf.h

index a72fd81e0f3e145ce1f82b30de3393f521d3e854..a3d36719f99b38074e4bfe5f405082df49984949 100644 (file)
@@ -369,6 +369,7 @@ int afsd_InitCM(char **reasonP)
     long maxcpus;
        long ltt, ltto;
     long rx_mtu, rx_nojumbo;
+    long virtualCache;
        char rootCellName[256];
        struct rx_service *serverp;
        static struct rx_securityClass *nullServerSecurityClassp;
@@ -599,6 +600,16 @@ int afsd_InitCM(char **reasonP)
                afsi_log("Default cache path %s", cm_CachePath);
        }
 
+    dummyLen = sizeof(virtualCache);
+    code = RegQueryValueEx(parmKey, "NonPersistentCaching", NULL, NULL,
+        &virtualCache, &dummyLen);
+    if (code == ERROR_SUCCESS && virtualCache) {
+        buf_cacheType = CM_BUF_CACHETYPE_VIRTUAL;
+    } else {
+        buf_cacheType = CM_BUF_CACHETYPE_FILE;
+    }
+    afsi_log("Cache type is %s", ((buf_cacheType == CM_BUF_CACHETYPE_FILE)?"FILE":"VIRTUAL"));
+
        dummyLen = sizeof(traceOnPanic);
        code = RegQueryValueEx(parmKey, "TrapOnPanic", NULL, NULL,
                                (BYTE *) &traceOnPanic, &dummyLen);
index 389c7f6474ae96b20ebb5750c9272a71718fcbab..e8580339cdda66f08f84edb3f4a4163e3c3323a1 100644 (file)
@@ -75,6 +75,7 @@ long buf_nbuffers = CM_BUF_BUFFERS;
 long buf_nOrigBuffers;
 long buf_bufferSize = CM_BUF_SIZE;
 long buf_hashSize = CM_BUF_HASHSIZE;
+int buf_cacheType = CM_BUF_CACHETYPE_FILE;
 
 #ifndef DJGPP
 static
@@ -295,6 +296,7 @@ long buf_Init(cm_buf_ops_t *opsp)
                sectorSize = 1;
 
 #ifndef DJGPP
+        if(buf_cacheType == CM_BUF_CACHETYPE_FILE) {
                /* Reserve buffer space by mapping cache file */
                psa = CreateCacheFileSA();
                hf = CreateFile(cm_CachePath,
@@ -309,6 +311,9 @@ long buf_Init(cm_buf_ops_t *opsp)
                        return CM_ERROR_INVAL;
                }
                FreeCacheFileSA(psa);
+        } else { /* buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL */
+            hf = INVALID_HANDLE_VALUE;
+        }
                CacheHandle = hf;
                hm = CreateFileMapping(hf,
                        NULL,
@@ -327,7 +332,7 @@ long buf_Init(cm_buf_ops_t *opsp)
                        0, 0,
                        buf_nbuffers * buf_bufferSize);
                if (data == NULL) {
-                       CloseHandle(hf);
+                       if(hf != INVALID_HANDLE_VALUE) CloseHandle(hf);
                        CloseHandle(hm);
                        return CM_ERROR_INVAL;
                }
@@ -404,6 +409,15 @@ long buf_AddBuffers(long nbuffers)
     afsi_log("%d buffers being added to the existing cache of size %d",
               nbuffers, buf_nbuffers);
 
+    if (buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL) {
+        /* The size of a virtual cache cannot be changed after it has
+         * been created.  Subsequent calls to MapViewofFile() with
+         * an existing mapping object name would not allow the 
+         * object to be resized.  Return failure immediately.
+        */
+        return CM_ERROR_INVAL;
+    }
+
        /*
         * Cache file mapping constrained by
         * system allocation granularity;
index f37094f6ae5bc18ad6a2b53ea0a2d85edd85c6f9..8840aae6607f0aab3462c80c91f143e3f6b0d6e8 100644 (file)
@@ -32,6 +32,11 @@ extern long buf_bufferSize;
 #define CM_BUF_HASHSIZE        1024
 extern long buf_hashSize;
 
+/* cache type */
+#define CM_BUF_CACHETYPE_FILE 1
+#define CM_BUF_CACHETYPE_VIRTUAL 2
+extern int buf_cacheType;
+
 /* force it to be signed so that mod comes out positive or 0 */
 #define BUF_HASH(fidp,offsetp) ((((fidp)->vnode+((fidp)->unique << 5)  \
                                +(fidp)->volume+(fidp)->cell            \