[OpenAFS-devel] PATCH: break up cache into reasonable subdirs for large cache sizes

Ted McCabe ted@MIT.EDU
Tue, 10 Jul 2001 12:30:39 -0400


At 10:21 AM -0400 7/7/01, Derek Atkins wrote:
>Here is the patch for afsd that breaks up the cache into multiple
>subdirs of a more reasonable size.  Using this patch I could create
>a 3GB cache in under 3 minutes on a Linux ext2 FS.  I also added the
>afsd parameter '-files_per_dir' which can set the log(2) size of the
>subdirs.  The default is 11 (2048 files).
>
>This patch is against the 1.0.4 release.
>
>Enjoy.
>
>-derek

I have one question: is there some reason that the default is 
different from the case where the provided arg is bad?  I believe the 
two should be identical - perhaps the check for the arg shouldn't 
stomp on the var before it checks for validity?

>--- src/afsd/afsd.c-orig	Mon Apr 23 03:29:03 2001
>+++ src/afsd/afsd.c	Sat Jul  7 10:17:47 2001
>@@ -202,6 +204,8 @@
>  int createAndTrunc = O_CREAT | O_TRUNC; /*Create & truncate on open*/
>  int ownerRWmode	= 0600;			/*Read/write OK by owner*/
>  static int filesSet = 0;		/*True if number of files 
>explicitly set*/
>+static int expFilesPerDir = 11;
>+static int nFilesPerDir;		/* # files per cache dir (2048) */
>  static int nDaemons = 2;		/* Number of background daemons */
>  static int chunkSize = 0;               /* 2^chunkSize bytes per chunk */
>  static int dCacheSize = 300;            /* # of dcache entries */

...stuff deleted

>@@ -896,6 +1039,14 @@
>  	/* -mem_alloc_sleep */
>  	cacheFlags |= AFSCALL_INIT_MEMCACHE_SLEEP;
>      }
>+    if (as->parms[24].items) {
>+        /* -files_per_subdir */
>+	expFilesPerDir = atoi(as->parms[24].items->data);
>+	if (expFilesPerDir < 2 || expFilesPerDir > 30) {
>+	    printf("afsd:invalid cache subdir size spec'd, forcing 
>one subdir\n");
>+	    expFilesPerDir = 30;
>+	}
>+    }
>
>      /*
>       * Pull out all the configuration info for the workstation's 
>AFS cache and
>@@ -925,7 +1076,7 @@

    --Ted