libafs: initialize free dcache list for memcache
[openafs.git] / src / afs / afs_memcache.c
index d2a063b..c12ae07 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -35,8 +35,9 @@ afs_InitMemCache(int blkCount, int blkSize, int flags)
        memCacheBlkSize = blkSize;
 
     memMaxBlkNumber = blkCount;
-    memCache = (struct memCacheEntry *)
+    memCache =
        afs_osi_Alloc(memMaxBlkNumber * sizeof(struct memCacheEntry));
+    osi_Assert(memCache != NULL);
 
     for (index = 0; index < memMaxBlkNumber; index++) {
        char *blk;
@@ -49,15 +50,16 @@ afs_InitMemCache(int blkCount, int blkSize, int flags)
        (memCache + index)->data = blk;
        memset((memCache + index)->data, 0, memCacheBlkSize);
     }
-#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS)
+#if defined(AFS_HAVE_VXFS)
     afs_InitDualFSCacheOps((struct vnode *)0);
 #endif
-
+    for (index = 0; index < blkCount; index++)
+       afs_InitCacheFile(NULL, 0);
     return 0;
 
   nomem:
-    printf("afsd:  memCache allocation failure at %d KB.\n",
-          (index * memCacheBlkSize) / 1024);
+    afs_warn("afsd:  memCache allocation failure at %d KB.\n",
+            (index * memCacheBlkSize) / 1024);
     while (--index >= 0) {
        afs_osi_Free((memCache + index)->data, memCacheBlkSize);
        (memCache + index)->data = NULL;
@@ -87,13 +89,13 @@ afs_MemCacheOpen(afs_dcache_id_t *ainode)
 }
 
 /*
- * this routine simulates a read in the Memory Cache 
+ * this routine simulates a read in the Memory Cache
  */
 int
-afs_MemReadBlk(register struct osi_file *fP, int offset, void *dest,
+afs_MemReadBlk(struct osi_file *fP, int offset, void *dest,
               int size)
 {
-    register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
+    struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
     int bytesRead;
 
     ObtainReadLock(&mceP->afs_memLock);
@@ -117,10 +119,10 @@ afs_MemReadBlk(register struct osi_file *fP, int offset, void *dest,
 }
 
 /*
- * this routine simulates a readv in the Memory Cache 
+ * this routine simulates a readv in the Memory Cache
  */
 int
-afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset,
+afs_MemReadvBlk(struct memCacheEntry *mceP, int offset,
                struct iovec *iov, int nio, int size)
 {
     int i;
@@ -156,7 +158,7 @@ afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset,
 int
 afs_MemReadUIO(afs_dcache_id_t *ainode, struct uio *uioP)
 {
-    register struct memCacheEntry *mceP =
+    struct memCacheEntry *mceP =
        (struct memCacheEntry *)afs_MemCacheOpen(ainode);
     int length = mceP->size - AFS_UIO_OFFSET(uioP);
     afs_int32 code;
@@ -170,10 +172,10 @@ afs_MemReadUIO(afs_dcache_id_t *ainode, struct uio *uioP)
 }
 
 int
-afs_MemWriteBlk(register struct osi_file *fP, int offset, void *src,
+afs_MemWriteBlk(struct osi_file *fP, int offset, void *src,
                int size)
 {
-    register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
+    struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
     struct iovec tiov;
 
     tiov.iov_base = src;
@@ -183,7 +185,7 @@ afs_MemWriteBlk(register struct osi_file *fP, int offset, void *src,
 
 /*XXX: this extends a block arbitrarily to support big directories */
 int
-afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset,
+afs_MemWritevBlk(struct memCacheEntry *mceP, int offset,
                 struct iovec *iov, int nio, int size)
 {
     int i;
@@ -228,9 +230,9 @@ afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset,
 }
 
 int
-afs_MemWriteUIO(afs_dcache_id_t *ainode, struct uio *uioP)
+afs_MemWriteUIO(struct vcache *avc, afs_dcache_id_t *ainode, struct uio *uioP)
 {
-    register struct memCacheEntry *mceP =
+    struct memCacheEntry *mceP =
        (struct memCacheEntry *)afs_MemCacheOpen(ainode);
     afs_int32 code;
 
@@ -268,9 +270,9 @@ afs_MemWriteUIO(afs_dcache_id_t *ainode, struct uio *uioP)
 }
 
 int
-afs_MemCacheTruncate(register struct osi_file *fP, int size)
+afs_MemCacheTruncate(struct osi_file *fP, int size)
 {
-    register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
+    struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
     AFS_STATCNT(afs_MemCacheTruncate);
 
     ObtainWriteLock(&mceP->afs_memLock, 313);
@@ -300,7 +302,7 @@ afs_MemCacheTruncate(register struct osi_file *fP, int size)
 void
 shutdown_memcache(void)
 {
-    register int index;
+    int index;
 
     if (cacheDiskType != AFS_FCACHE_TYPE_MEM)
        return;