]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-adjustable-block-size-20070810
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 10 Aug 2007 21:39:26 +0000 (21:39 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 10 Aug 2007 21:39:26 +0000 (21:39 +0000)
New registry value "BlockSize" can be used to specify an alternative
block size.  The default is 4K.  A larger blocksize will be needed if
you want to support a 6TB cache.

Also extend the service startup timeout hint to two minutes to give
the AFS client service more time to startup successfully when the
cache is really large.

(cherry picked from commit e7ff4185a5e978798b194f8214056425debc8fbc)

src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_memmap.c
src/WINNT/afsd/cm_memmap.h

index 4e397fad7e8312933c99e7e8b89729b5ae20795b..811c4afaae54dd99b8e34b14174756fd9d91cd93 100644 (file)
@@ -541,6 +541,7 @@ int afsd_InitCM(char **reasonP)
     osi_uid_t debugID;
     afs_uint64 cacheBlocks;
     DWORD cacheSize;
+    DWORD blockSize;
     long logChunkSize;
     DWORD stats;
     DWORD dwValue;
@@ -696,13 +697,38 @@ int afsd_InitCM(char **reasonP)
                       logChunkSize);
             logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
         }
-        afsi_log("Chunk size %d", logChunkSize);
     } else {
         logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
-        afsi_log("Default chunk size %d", logChunkSize);
     }
     cm_logChunkSize = logChunkSize;
     cm_chunkSize = 1 << logChunkSize;
+    afsi_log("Chunk size %u (%d)", cm_chunkSize, cm_logChunkSize);
+
+    dummyLen = sizeof(blockSize);
+    code = RegQueryValueEx(parmKey, "blockSize", NULL, NULL,
+                            (BYTE *) &blockSize, &dummyLen);
+    if (code == ERROR_SUCCESS) {
+        if (blockSize < 1 || 
+            (blockSize > 1024 && (blockSize % CM_CONFIGDEFAULT_BLOCKSIZE != 0))) 
+        {
+            afsi_log("Invalid block size %u specified, using default", blockSize);
+            blockSize = CM_CONFIGDEFAULT_BLOCKSIZE;
+        } else {
+            /* 
+             * if the blockSize is less than 1024 we permit the blockSize to be
+             * specified in multiples of the default blocksize
+             */
+            if (blockSize <= 1024)
+                blockSize *= CM_CONFIGDEFAULT_BLOCKSIZE;
+        }
+    } else {
+        blockSize = CM_CONFIGDEFAULT_BLOCKSIZE;
+    }
+    if (blockSize > cm_chunkSize) {
+        afsi_log("Block size cannot be larger than Chunk size.");
+        blockSize = cm_chunkSize;
+    }
+    afsi_log("Block size %u", blockSize);
 
     dummyLen = sizeof(numBkgD);
     code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
@@ -1033,7 +1059,7 @@ int afsd_InitCM(char **reasonP)
     
     RegCloseKey (parmKey);
 
-    cacheBlocks = ((afs_uint64)cacheSize * 1024) / CM_CONFIGDEFAULT_BLOCKSIZE;
+    cacheBlocks = ((afs_uint64)cacheSize * 1024) / blockSize;
         
     /* get network related info */
     cm_noIPAddr = CM_MAXINTERFACE_ADDR;
@@ -1076,7 +1102,7 @@ int afsd_InitCM(char **reasonP)
         
     cm_InitCallback();
         
-    code = cm_InitMappedMemory(virtualCache, cm_CachePath, stats, cm_chunkSize, cacheBlocks);
+    code = cm_InitMappedMemory(virtualCache, cm_CachePath, stats, cm_chunkSize, cacheBlocks, blockSize);
     afsi_log("cm_InitMappedMemory code %x", code);
     if (code != 0) {
         *reasonP = "error initializing cache file";
index 745f4499e127fa68e13e8863697705c8f5a6f548..6e9f9bc08afc2cb727e5fbf76dcab40d50769548 100644 (file)
@@ -1150,7 +1150,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
     ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
     ServiceStatus.dwWin32ExitCode = NO_ERROR;
     ServiceStatus.dwCheckPoint = 1;
-    ServiceStatus.dwWaitHint = 30000;
+    ServiceStatus.dwWaitHint = 120000;
     /* accept Power Events */
     ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT | SERVICE_ACCEPT_PARAMCHANGE;
     SetServiceStatus(StatusHandle, &ServiceStatus);
@@ -1228,13 +1228,13 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         }
         else
         {
-            /* allow another 15 seconds to start */
+            /* allow another 120 seconds to start */
             ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
             ServiceStatus.dwServiceSpecificExitCode = 0;
             ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
             ServiceStatus.dwWin32ExitCode = NO_ERROR;
             ServiceStatus.dwCheckPoint = 2;
-            ServiceStatus.dwWaitHint = 20000;
+            ServiceStatus.dwWaitHint = 120000;
             /* accept Power Events */
             ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT | SERVICE_ACCEPT_PARAMCHANGE;
             SetServiceStatus(StatusHandle, &ServiceStatus);
@@ -1258,8 +1258,8 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         }
 
 #ifndef NOTSERVICE
-        ServiceStatus.dwCheckPoint++;
-        ServiceStatus.dwWaitHint -= 5000;
+        ServiceStatus.dwCheckPoint = 3;
+        ServiceStatus.dwWaitHint = 30000;
         SetServiceStatus(StatusHandle, &ServiceStatus);
 #endif
         code = afsd_InitDaemons(&reason);
@@ -1296,8 +1296,8 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         }
 
 #ifndef NOTSERVICE
-        ServiceStatus.dwCheckPoint++;
-        ServiceStatus.dwWaitHint -= 5000;
+        ServiceStatus.dwCheckPoint = 4;
+        ServiceStatus.dwWaitHint = 15000;
         SetServiceStatus(StatusHandle, &ServiceStatus);
 #endif
 
index 45479e9d378b606e077cc077565909132b135b4b..dafcd3fa0c0e852d7946ead870b6242838593cce 100644 (file)
@@ -622,7 +622,8 @@ GetMachineSid(PBYTE SidBuffer, DWORD SidSize)
 }
 
 int
-cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chunkSize, afs_uint64 cacheBlocks)
+cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chunkSize, 
+                    afs_uint64 cacheBlocks, afs_uint32 blockSize)
 {
     HANDLE hf = INVALID_HANDLE_VALUE, hm;
     PSECURITY_ATTRIBUTES psa;
@@ -641,7 +642,7 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chu
     volumeSerialNumber = GetVolSerialNumber(cachePath);
     GetMachineSid(machineSid, sizeof(machineSid));
 
-    mappingSize = ComputeSizeOfMappingFile(stats, maxVols, maxCells, chunkSize, cacheBlocks, CM_CONFIGDEFAULT_BLOCKSIZE);
+    mappingSize = ComputeSizeOfMappingFile(stats, maxVols, maxCells, chunkSize, cacheBlocks, blockSize);
 
     if ( !virtualCache ) {
         psa = CreateCacheFileSA();
@@ -756,7 +757,7 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chu
                  config_data_p->maxCells == maxCells &&
                  config_data_p->chunkSize == chunkSize &&
                  config_data_p->buf_nbuffers == cacheBlocks &&
-                 config_data_p->blockSize == CM_CONFIGDEFAULT_BLOCKSIZE &&
+                 config_data_p->blockSize == blockSize &&
                  config_data_p->bufferSize == mappingSize)
             {
                 if ( config_data_p->dirty ) {
@@ -849,7 +850,7 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chu
         cm_data.baseAddress = baseAddress;
         cm_data.stats = stats;
         cm_data.chunkSize = chunkSize;
-        cm_data.blockSize = CM_CONFIGDEFAULT_BLOCKSIZE;
+        cm_data.blockSize = blockSize;
         cm_data.bufferSize = mappingSize;
         cm_data.scacheHashTableSize = osi_PrimeLessThan(stats / 2 + 1);
         cm_data.volumeHashTableSize = osi_PrimeLessThan((afs_uint32)(maxVols/7 + 1));
@@ -862,7 +863,7 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chu
 
         cm_data.buf_nbuffers = cacheBlocks;
         cm_data.buf_nOrigBuffers = 0;
-        cm_data.buf_blockSize = CM_BUF_BLOCKSIZE;
+        cm_data.buf_blockSize = blockSize;
         cm_data.buf_hashSize = osi_PrimeLessThan((afs_uint32)(cacheBlocks/7 + 1));
 
         cm_data.mountRootGen = time(NULL);
@@ -899,7 +900,7 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chu
         cm_data.bufHeaderBaseAddress = (cm_buf_t *) baseAddress;
         baseAddress += ComputeSizeOfDataHeaders(cacheBlocks);
         cm_data.bufDataBaseAddress = (char *) baseAddress;
-        baseAddress += ComputeSizeOfDataBuffers(cacheBlocks, CM_CONFIGDEFAULT_BLOCKSIZE);
+        baseAddress += ComputeSizeOfDataBuffers(cacheBlocks, blockSize);
         cm_data.bufEndOfData = (char *) baseAddress;
        cm_data.buf_dirtyListp = NULL;
        cm_data.buf_dirtyListEndp = NULL;
index 1233f87ad6ce5f018b80a9ec4746eac79f954329..fc48e8105d299646ecd41f3cd1ecde5dc26b822b 100644 (file)
@@ -115,5 +115,5 @@ PSECURITY_ATTRIBUTES CreateCacheFileSA();
 VOID  FreeCacheFileSA(PSECURITY_ATTRIBUTES psa);
 int   cm_ShutdownMappedMemory(void);
 int   cm_ValidateMappedMemory(char * cachePath);
-int   cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chunkSize, afs_uint64 cacheBlocks );
+int   cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD chunkSize, afs_uint64 cacheBlocks, afs_uint32 blockSize);
 #endif /* CM_MEMMAP_H */
\ No newline at end of file