From: Derrick Brashear Date: Wed, 10 Oct 2007 18:43:35 +0000 (+0000) Subject: STABLE14-darwin90-disk-cache-20071010 X-Git-Tag: openafs-stable-1_4_5-pre1~5 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=4a3ee37fe1704e818af22b84c458de85bf012668;p=packages%2Fo%2Fopenafs.git STABLE14-darwin90-disk-cache-20071010 FIXES 43303 support disk cache in darwin90 (cherry picked from commit 63e1761b992e25fa305e6d621b31bd1113f5cbe7) --- diff --git a/src/afs/DARWIN/osi_file.c b/src/afs/DARWIN/osi_file.c index 279187bef..eddbb5c47 100644 --- a/src/afs/DARWIN/osi_file.c +++ b/src/afs/DARWIN/osi_file.c @@ -141,6 +141,9 @@ osi_UFSOpen(afs_int32 ainode) extern int cacheDiskType; afs_int32 code = 0; int dummy; + char fname[1024]; + struct osi_stat tstat; + AFS_STATCNT(osi_UFSOpen); if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); @@ -154,6 +157,28 @@ osi_UFSOpen(afs_int32 ainode) } afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); +#ifdef AFS_CACHE_VNODE_PATH + if (ainode < 0) { + switch (ainode) { + case AFS_CACHE_CELLS_INODE: + snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CellItems"); + break; + case AFS_CACHE_ITEMS_INODE: + snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CacheItems"); + break; + case AFS_CACHE_VOLUME_INODE: + snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "VolumeItems"); + break; + default: + osi_Panic("Invalid negative inode"); + } + } else { + dummy = ainode / afs_numfilesperdir; + snprintf(fname, 1024, "%s/D%d/V%d", afs_cachebasedir, dummy, ainode); + } + + code = vnode_open(fname, O_RDWR, 0, 0, &vp, afs_osi_ctxtp); +#else #ifndef AFS_DARWIN80_ENV if (afs_CacheFSType == AFS_APPL_HFS_CACHE) code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */ @@ -165,6 +190,7 @@ osi_UFSOpen(afs_int32 ainode) #ifndef AFS_DARWIN80_ENV else panic("osi_UFSOpen called before cacheops initialized\n"); +#endif #endif AFS_GLOCK(); if (code) { @@ -172,10 +198,15 @@ osi_UFSOpen(afs_int32 ainode) osi_Panic("UFSOpen: igetinode failed"); } afile->vnode = vp; - afile->size = va.va_size; afile->offset = 0; afile->proc = (int (*)())0; afile->inum = ainode; /* for hint validity checking */ +#ifndef AFS_CACHE_VNODE_PATH + afile->size = va.va_size; +#else + code = afs_osi_Stat(afile, &tstat); + afile->size = tstat.size; +#endif return (void *)afile; } diff --git a/src/afs/afs.h b/src/afs/afs.h index 6ff9ede78..f5f6b5df4 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -268,6 +268,9 @@ enum { AFS_GCPAGS_NOTCOMPILED = 0, AFS_GCPAGS_OK = extern afs_int32 afs_gcpags; extern afs_int32 afs_gcpags_procsize; extern afs_int32 afs_bkvolpref; +extern char afs_cachebasedir[1024]; +extern afs_int32 afs_numcachefiles; +extern afs_int32 afs_numfilesperdir; struct unixuser { struct unixuser *next; /* next hash pointer */ diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index f042c8778..1b04bd0cb 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -104,6 +104,9 @@ static int afs_Go_Done = 0; extern struct interfaceAddr afs_cb_interface; static int afs_RX_Running = 0; static int afs_InitSetup_done = 0; +afs_int32 afs_numcachefiles = -1; +afs_int32 afs_numfilesperdir = -1; +char afs_cachebasedir[1024]; afs_int32 afs_rx_deadtime = AFS_RXDEADTIME; afs_int32 afs_rx_harddead = AFS_HARDDEADTIME; @@ -502,6 +505,17 @@ afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, } #endif +static void +wait_for_cachedefs(void) { +#ifdef AFS_CACHE_VNODE_PATH + while ((afs_numcachefiles < 1) || (afs_numfilesperdir < 1) || + (afs_cachebasedir[0] != '/')) { + printf("afs: waiting for cache parameter definitions\n"); + afs_osi_Sleep(&afs_initState); + } +#endif +} + /* leaving as is, probably will barf if we add prototypes here since it's likely being called with partial list */ int @@ -821,6 +835,12 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6) #ifdef AFS_DARWIN80_ENV put_vfs_context(); #endif + } else if (parm == AFSOP_CACHEDIRS) { + afs_numfilesperdir = parm2; + afs_osi_Wakeup(&afs_initState); + } else if (parm == AFSOP_CACHEFILES) { + afs_numcachefiles = parm2; + afs_osi_Wakeup(&afs_initState); } else if (parm == AFSOP_ROOTVOLUME) { /* wait for basic init */ while (afs_initState < AFSOP_START_BKG) @@ -834,7 +854,7 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6) code = 0; } else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO || parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG - || parm == AFSOP_CELLINFO) { + || parm == AFSOP_CELLINFO || parm == AFSOP_CACHEBASEDIR) { char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ); code = 0; @@ -850,20 +870,47 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6) #ifdef AFS_DARWIN80_ENV get_vfs_context(); #endif - if (parm == AFSOP_CACHEFILE) + if (parm == AFSOP_CACHEBASEDIR) { + strncpy(afs_cachebasedir, tbuffer, 1024); + afs_cachebasedir[1023] = '\0'; + afs_osi_Wakeup(&afs_initState); + } else if (parm == AFSOP_CACHEFILE) { + wait_for_cachedefs(); code = afs_InitCacheFile(tbuffer, 0); - else if (parm == AFSOP_CACHEINFO) + } else if (parm == AFSOP_CACHEINFO) { + wait_for_cachedefs(); code = afs_InitCacheInfo(tbuffer); - else if (parm == AFSOP_VOLUMEINFO) + } else if (parm == AFSOP_VOLUMEINFO) { + wait_for_cachedefs(); code = afs_InitVolumeInfo(tbuffer); - else if (parm == AFSOP_CELLINFO) + } else if (parm == AFSOP_CELLINFO) { + wait_for_cachedefs(); code = afs_InitCellInfo(tbuffer); + } #ifdef AFS_DARWIN80_ENV put_vfs_context(); #endif } osi_FreeSmallSpace(tbuffer); } else if (parm == AFSOP_GO) { +#ifdef AFS_CACHE_VNODE_PATH + afs_int32 dummy; + + wait_for_cachedefs(); + +#ifdef AFS_DARWIN80_ENV + get_vfs_context(); +#endif + if ((afs_numcachefiles > 0) && (afs_numfilesperdir > 0) && + (afs_cachebasedir[0] == '/')) { + for (dummy = 0; dummy < afs_numcachefiles; dummy++) { + code = afs_InitCacheFile(NULL, dummy); + } + } +#ifdef AFS_DARWIN80_ENV + put_vfs_context(); +#endif +#endif /* the generic initialization calls come here. One parameter: should we do the * set-time operation on this workstation */ if (afs_Go_Done) diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index b2503aefd..21b4382d9 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -244,8 +244,12 @@ afs_InitCellInfo(char *afile) ino_t inode; int code; +#ifdef AFS_CACHE_VNODE_PATH + return afs_cellname_init(AFS_CACHE_CELLS_INODE, code); +#else code = LookupInodeByPath(afile, &inode, NULL); return afs_cellname_init(inode, code); +#endif } /* @@ -286,6 +290,8 @@ afs_InitVolumeInfo(char *afile) * it in the cache... */ code = LookupInodeByPath(afile, &volumeInode, &volumeVnode); +#elif defined(AFS_CACHE_VNODE_PATH) + volumeInode = AFS_CACHE_VOLUME_INODE; #else code = LookupInodeByPath(afile, &volumeInode, NULL); #endif @@ -416,11 +422,15 @@ afs_InitCacheInfo(register char *afile) #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV) afs_InitDualFSCacheOps(filevp); #endif - cacheInode = afs_vnodeToInumber(filevp); - cacheDev.dev = afs_vnodeToDev(filevp); +#ifndef AFS_CACHE_VNODE_PATH #ifndef AFS_DARWIN80_ENV afs_cacheVfsp = filevp->v_vfsp; #endif + cacheInode = afs_vnodeToInumber(filevp); +#else + cacheInode = AFS_CACHE_ITEMS_INODE; +#endif + cacheDev.dev = afs_vnodeToDev(filevp); #endif /* AFS_LINUX20_ENV */ AFS_RELE(filevp); #endif /* AFS_LINUX22_ENV */ diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 6794431b4..752af69c8 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -332,8 +332,10 @@ int *dir_for_V = NULL; /* Array: dir of each cache file. * -2: file exists in top-level * >=0: file exists in Dxxx */ +#ifndef AFS_CACHE_VNODE_PATH AFSD_INO_T *inode_for_V; /* Array of inodes for desired * cache files */ +#endif int missing_DCacheFile = 1; /*Is the DCACHEFILE missing? */ int missing_VolInfoFile = 1; /*Is the VOLINFOFILE missing? */ int missing_CellInfoFile = 1; /*Is the CELLINFOFILE missing? */ @@ -1003,7 +1005,9 @@ doSweepAFSCache(vFilesFound, directory, dirNum, maxDir) * file's inode, directory, and bump the number of files found * total and in this directory. */ +#ifndef AFS_CACHE_VNODE_PATH inode_for_V[vFileNum] = currp->d_ino; +#endif dir_for_V[vFileNum] = dirNum; /* remember this directory */ if (!maxDir) { @@ -1140,7 +1144,9 @@ doSweepAFSCache(vFilesFound, directory, dirNum, maxDir) vFileNum); else { struct stat statb; +#ifndef AFS_CACHE_VNODE_PATH assert(inode_for_V[vFileNum] == (AFSD_INO_T) 0); +#endif sprintf(vFilePtr, "D%d/V%d", thisDir, vFileNum); if (afsd_verbose) printf("%s: Creating '%s'\n", rn, fullpn_VFile); @@ -1151,7 +1157,9 @@ doSweepAFSCache(vFilesFound, directory, dirNum, maxDir) if (CreateCacheFile(fullpn_VFile, &statb)) printf("%s: Can't create '%s'\n", rn, fullpn_VFile); else { +#ifndef AFS_CACHE_VNODE_PATH inode_for_V[vFileNum] = statb.st_ino; +#endif dir_for_V[vFileNum] = thisDir; cache_dir_list[thisDir]++; (*vFilesFound)++; @@ -1903,6 +1911,7 @@ mainproc(struct cmd_syndesc *as, char *arock) cacheStatEntries); } +#ifndef AFS_CACHE_VNODE_PATH /* * Create and zero the inode table for the desired cache files. */ @@ -1917,6 +1926,7 @@ mainproc(struct cmd_syndesc *as, char *arock) if (afsd_debug) printf("%s: %d inode_for_V entries at 0x%x, %d bytes\n", rn, cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T))); +#endif /* * Set up all the pathnames we'll need for later. @@ -2097,6 +2107,23 @@ mainproc(struct cmd_syndesc *as, char *arock) rn, vFilesFound, cacheFiles, cacheIteration); } while ((vFilesFound < cacheFiles) && (cacheIteration < MAX_CACHE_LOOPS)); +#ifdef AFS_CACHE_VNODE_PATH + if (afsd_debug) + printf + ("%s: Calling AFSOP_CACHEBASEDIR with '%s'\n", + rn, cacheBaseDir); + call_syscall(AFSOP_CACHEBASEDIR, cacheBaseDir); + if (afsd_debug) + printf + ("%s: Calling AFSOP_CACHEDIRS with %d dirs\n", + rn, nFilesPerDir); + call_syscall(AFSOP_CACHEDIRS, nFilesPerDir); + if (afsd_debug) + printf + ("%s: Calling AFSOP_CACHEFILES with %d files\n", + rn, cacheFiles); + call_syscall(AFSOP_CACHEFILES, cacheFiles); +#endif } else if (afsd_verbose) printf("%s: Using memory cache, not swept\n", rn); @@ -2231,6 +2258,7 @@ mainproc(struct cmd_syndesc *as, char *arock) if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) call_syscall(AFSOP_VOLUMEINFO, fullpn_VolInfoFile); +#ifndef AFS_CACHE_VNODE_PATH /* * Give the kernel the names of the AFS files cached on the workstation's * disk. @@ -2249,7 +2277,7 @@ mainproc(struct cmd_syndesc *as, char *arock) call_syscall(AFSOP_CACHEINODE, inode_for_V[currVFile]); #endif } - +#endif /*end for */ /* diff --git a/src/config/afs_args.h b/src/config/afs_args.h index 7d306f683..47ce0db27 100644 --- a/src/config/afs_args.h +++ b/src/config/afs_args.h @@ -86,6 +86,14 @@ /* For SGI, this can't interfere with any of the 64 bit inode calls. */ #define AFSOP_RXLISTENER_DAEMON 48 /* starts kernel RX listener */ +/* skip 64 bit calls */ +#define AFSOP_CACHEBASEDIR 50 /* cache base dir */ +#define AFSOP_CACHEDIRS 51 /* number of files per dir */ +#define AFSOP_CACHEFILES 52 /* number of files */ + +#define AFSOP_SETINT 60 /* we should just set key/value pairs + for things which are just ints */ + /* these are for initialization flags */ #define AFSCALL_INIT_MEMCACHE 0x1 @@ -220,4 +228,10 @@ struct afssysargs { #define SYSCALL_DEV_FNAME "/dev/openafs_ioctl" #endif +#ifdef AFS_CACHE_VNODE_PATH +#define AFS_CACHE_CELLS_INODE -2 +#define AFS_CACHE_ITEMS_INODE -3 +#define AFS_CACHE_VOLUME_INODE -4 +#endif + #endif /* _AFS_ARGS_H_ */ diff --git a/src/config/param.ppc_darwin_90.h b/src/config/param.ppc_darwin_90.h index ac74560cd..a62b8556e 100644 --- a/src/config/param.ppc_darwin_90.h +++ b/src/config/param.ppc_darwin_90.h @@ -30,6 +30,7 @@ #define AFS_SYSCALL 230 #define AFS_NAMEI_ENV 1 #define DARWIN_REFBASE 3 +#define AFS_CACHE_VNODE_PATH /* File system entry (used if mount.h doesn't define MOUNT_AFS */ #define AFS_MOUNT_AFS "afs" diff --git a/src/config/param.x86_darwin_90.h b/src/config/param.x86_darwin_90.h index ac74560cd..a62b8556e 100644 --- a/src/config/param.x86_darwin_90.h +++ b/src/config/param.x86_darwin_90.h @@ -30,6 +30,7 @@ #define AFS_SYSCALL 230 #define AFS_NAMEI_ENV 1 #define DARWIN_REFBASE 3 +#define AFS_CACHE_VNODE_PATH /* File system entry (used if mount.h doesn't define MOUNT_AFS */ #define AFS_MOUNT_AFS "afs" diff --git a/src/packaging/MacOS/buildpkg.sh b/src/packaging/MacOS/buildpkg.sh index d7f6db023..2b5405879 100644 --- a/src/packaging/MacOS/buildpkg.sh +++ b/src/packaging/MacOS/buildpkg.sh @@ -122,11 +122,7 @@ if [ $firstpass = yes ]; then else echo /Network/afs:/var/db/openafs/cache:30000 > $PKGROOT/private/var/db/openafs/etc/cacheinfo.sample fi - if [ $majorvers -ge 9 ]; then - echo '-memcache -afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > $PKGROOT/private/var/db/openafs/etc/config/afsd.options.sample - else echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > $PKGROOT/private/var/db/openafs/etc/config/afsd.options.sample - fi strip -X -S $PKGROOT/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.kext/Contents/MacOS/afs