From: Asanka Herath Date: Thu, 29 Jul 2004 15:34:21 +0000 (+0000) Subject: virtual-cache-file-20040729 X-Git-Tag: BP-openafs-stable-1_4_x~55 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=46bafc8a620ba956f057b47a32287a87a857e407;p=packages%2Fo%2Fopenafs.git virtual-cache-file-20040729 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. --- diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index a72fd81e0..a3d36719f 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -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); diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 389c7f647..e8580339c 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -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; diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index f37094f6a..8840aae66 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -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 \