From: Douglas Engert Date: Sun, 30 Nov 2008 20:21:08 +0000 (+0000) Subject: DEVEL15-solaris-fs-agnostic-cache-20081130 X-Git-Tag: openafs-devel-1_5_56~42 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=625ec1a639cf30501c91398b301f51ee04656248;p=packages%2Fo%2Fopenafs.git DEVEL15-solaris-fs-agnostic-cache-20081130 LICENSE IPL10 FIXES 123677 make the cache able to be filesystem-agnostic so a ZFS cache is possible (cherry picked from commit 29457b1ca71518b29bb9e9e934c58e6fa4b9877a) --- diff --git a/src/afs/SOLARIS/osi_file.c b/src/afs/SOLARIS/osi_file.c index ac92916cf..54385a240 100644 --- a/src/afs/SOLARIS/osi_file.c +++ b/src/afs/SOLARIS/osi_file.c @@ -175,22 +175,85 @@ void * osi_UfsOpen(afs_int32 ainode) #endif { +#ifdef AFS_CACHE_VNODE_PATH + struct vnode *vp; +#else struct inode *ip; +#endif register struct osi_file *afile = NULL; afs_int32 code = 0; +#ifdef AFS_CACHE_VNODE_PATH int dummy; + char fname[1024]; + char namebuf[1024]; + struct pathname lookpn; +#endif + struct osi_stat tstat; afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); + +/* + * AFS_CACHE_VNODE_PATH can be used with any file system, including ZFS or tmpfs. + * The ainode is not an inode number but a signed index used to generate file names. + */ +#ifdef AFS_CACHE_VNODE_PATH + 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: + dummy = ainode / afs_numfilesperdir; + snprintf(fname, 1024, "%s/D%d/V%d", afs_cachebasedir, dummy, ainode); + } + + /* Can not use vn_open or lookupname, they use user's CRED() + * We need to run as root So must use low level lookuppnvp + * assume fname starts with / + */ + + code = pn_get_buf(fname, AFS_UIOSYS, &lookpn, namebuf, sizeof(namebuf)); + if (code != 0) + osi_Panic("UfsOpen: pn_get_buf failed %ld %s %ld", code, fname, ainode); + + VN_HOLD(rootdir); /* released in loopuppnvp */ + code = lookuppnvp(&lookpn, NULL, FOLLOW, NULL, &vp, + rootdir, rootdir, &afs_osi_cred); + if (code != 0) + osi_Panic("UfsOpen: lookuppnvp failed %ld %s %ld", code, fname, ainode); + +#ifdef AFS_SUN511_ENV + code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred, NULL); +#else + code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred); +#endif + + if (code != 0) + osi_Panic("UfsOpen: VOP_OPEN failed %ld %s %ld", code, fname, ainode); + +#else code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip, CRED(), &dummy); +#endif AFS_GLOCK(); if (code) { osi_FreeSmallSpace(afile); - osi_Panic("UfsOpen: igetinode failed"); + osi_Panic("UfsOpen: igetinode failed %ld %s %ld", code, fname, ainode); } +#ifdef AFS_CACHE_VNODE_PATH + afile->vnode = vp; + code = afs_osi_Stat(afile, &tstat); + afile->size = tstat.size; +#else afile->vnode = ITOV(ip); afile->size = VTOI(afile->vnode)->i_size; +#endif afile->offset = 0; afile->proc = (int (*)())0; afile->inum = ainode; /* for hint validity checking */ @@ -304,12 +367,14 @@ void osi_DisableAtimes(struct vnode *avp) { if (afs_CacheFSType == AFS_SUN_UFS_CACHE) { +#ifndef AFS_CACHE_VNODE_PATH struct inode *ip = VTOI(avp); rw_enter(&ip->i_contents, RW_READER); mutex_enter(&ip->i_tlock); ip->i_flag &= ~IACC; mutex_exit(&ip->i_tlock); rw_exit(&ip->i_contents); +#endif } } diff --git a/src/config/param.sun4x_510.h b/src/config/param.sun4x_510.h index 8a78eeb11..148beb1d4 100644 --- a/src/config/param.sun4x_510.h +++ b/src/config/param.sun4x_510.h @@ -34,6 +34,8 @@ #define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */ #endif /* AFS_NAMEI_ENV */ +#define AFS_CACHE_VNODE_PATH 1 + #include #define AFS_GLOBAL_SUNLOCK 1 /* For global locking */ diff --git a/src/config/param.sun4x_511.h b/src/config/param.sun4x_511.h index 118b24e21..58d36b94d 100644 --- a/src/config/param.sun4x_511.h +++ b/src/config/param.sun4x_511.h @@ -35,6 +35,8 @@ #define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */ #endif /* AFS_NAMEI_ENV */ +#define AFS_CACHE_VNODE_PATH 1 + #include #define AFS_GLOBAL_SUNLOCK 1 /* For global locking */ diff --git a/src/config/param.sunx86_510.h b/src/config/param.sunx86_510.h index a2ddf196c..409c6dcee 100644 --- a/src/config/param.sunx86_510.h +++ b/src/config/param.sunx86_510.h @@ -38,6 +38,8 @@ #define AFS_HAVE_FLOCK_SYSID 1 +#define AFS_CACHE_VNODE_PATH 1 + #include #define AFS_GLOBAL_SUNLOCK 1 /* For global locking */ diff --git a/src/config/param.sunx86_511.h b/src/config/param.sunx86_511.h index a93467218..b947f427f 100644 --- a/src/config/param.sunx86_511.h +++ b/src/config/param.sunx86_511.h @@ -39,6 +39,8 @@ #define AFS_HAVE_FLOCK_SYSID 1 +#define AFS_CACHE_VNODE_PATH 1 + #include #define AFS_GLOBAL_SUNLOCK 1 /* For global locking */