From: Marc Dionne Date: Sat, 8 Nov 2008 16:34:24 +0000 (+0000) Subject: linux-fh-based-cache-20081108 X-Git-Tag: openafs-devel-1_5_61~703 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=4eab64ebd81305845d10c4a5fdfd1861bc41520b linux-fh-based-cache-20081108 LICENSE IPL10 FIXES 123620 use linux fh (exportfs api) to do cache file access. conditionalize based on configure switch. --- diff --git a/acinclude.m4 b/acinclude.m4 index 319c5fe..ebd18d8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1150,6 +1150,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) if test "x$ac_cv_linux_have_kmem_cache_t" = "xyes" ; then AC_DEFINE(KMEM_CACHE_TAKES_DTOR, 1, [define if kmem_cache_create takes a destructor argument]) fi + if test "$enable_linux_fh" = "yes"; then + AC_DEFINE(LINUX_USE_FH, 1, [define if you want to open cache files by file handle instead of inode numbers]) + fi if test "x$ac_cv_linux_kernel_page_follow_link" = "xyes" -o "x$ac_cv_linux_func_i_put_link_takes_cookie" = "xyes"; then AC_DEFINE(USABLE_KERNEL_PAGE_SYMLINK_CACHE, 1, [define if your kernel has a usable symlink cache API]) else diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 6015358..31194f6 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -36,14 +36,18 @@ extern struct super_block *afs_cacheSBp; #if defined(AFS_LINUX26_ENV) void * +#if defined(LINUX_USE_FH) +osi_UFSOpen_fh(struct fid *fh, int fh_type) +#else osi_UFSOpen(afs_int32 ainode) +#endif { register struct osi_file *afile = NULL; extern int cacheDiskType; struct inode *tip = NULL; struct dentry *dp = NULL; struct file *filp = NULL; -#if !defined(HAVE_IGET) +#if !defined(HAVE_IGET) || defined(LINUX_USE_FH) struct fid fid; #endif AFS_STATCNT(osi_UFSOpen); @@ -70,24 +74,36 @@ osi_UFSOpen(afs_int32 ainode) dp = d_alloc_anon(tip); #else +#if defined(LINUX_USE_FH) + dp = afs_cacheSBp->s_export_op->fh_to_dentry(afs_cacheSBp, fh, sizeof(struct fid), fh_type); +#else fid.i32.ino = ainode; fid.i32.gen = 0; dp = afs_cacheSBp->s_export_op->fh_to_dentry(afs_cacheSBp, &fid, sizeof(fid), FILEID_INO32_GEN); +#endif if (!dp) - osi_Panic("Can't get dentry for inode %d\n", ainode); + osi_Panic("Can't get dentry\n"); tip = dp->d_inode; #endif tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR); if (IS_ERR(filp)) +#if defined(LINUX_USE_FH) + osi_Panic("Can't open file\n"); +#else osi_Panic("Can't open inode %d\n", ainode); +#endif afile->filp = filp; afile->size = FILE_INODE(filp)->i_size; AFS_GLOCK(); afile->offset = 0; afile->proc = (int (*)())0; +#if defined(LINUX_USE_FH) + afile->inum = tip->i_ino; /* for hint validity checking */ +#else afile->inum = ainode; /* for hint validity checking */ +#endif return (void *)afile; } #else @@ -143,6 +159,23 @@ osi_UFSOpen(afs_int32 ainode) } #endif +#if defined(LINUX_USE_FH) +int +osi_get_fh(struct dentry *dp, struct fid *fh, int *max_len) { + int fh_type; + + if (dp->d_sb->s_export_op->encode_fh) { + fh_type = dp->d_sb->s_export_op->encode_fh(dp, (__u32 *)fh, max_len, 0); + } else { + fh_type = FILEID_INO32_GEN; + fh->i32.ino = dp->d_inode->i_ino; + fh->i32.gen = dp->d_inode->i_generation; + } + dput(dp); + return(fh_type); +} +#endif + int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { @@ -372,6 +405,11 @@ int osi_InitCacheInfo(char *aname) { int code; +#if defined(LINUX_USE_FH) + int max_len = sizeof(struct fid); +#else + extern ino_t cacheInode; +#endif struct dentry *dp; extern ino_t cacheInode; extern struct osi_dev cacheDev; @@ -382,7 +420,17 @@ osi_InitCacheInfo(char *aname) if (code) return ENOENT; +#if defined(LINUX_USE_FH) + if (dp->d_sb->s_export_op->encode_fh) { + cacheitems_fh_type = dp->d_sb->s_export_op->encode_fh(dp, (__u32 *)&cacheitems_fh, &max_len, 0); + } else { + cacheitems_fh_type = FILEID_INO32_GEN; + cacheitems_fh.i32.ino = dp->d_inode->i_ino; + cacheitems_fh.i32.gen = dp->d_inode->i_generation; + } +#else cacheInode = dp->d_inode->i_ino; +#endif cacheDev.dev = dp->d_inode->i_sb->s_dev; afs_fsfragsize = dp->d_inode->i_sb->s_blocksize - 1; afs_cacheSBp = dp->d_inode->i_sb; diff --git a/src/afs/VNOPS/afs_vnop_read.c b/src/afs/VNOPS/afs_vnop_read.c index 313c186..f7c2929 100644 --- a/src/afs/VNOPS/afs_vnop_read.c +++ b/src/afs/VNOPS/afs_vnop_read.c @@ -806,8 +806,11 @@ afs_UFSRead(register struct vcache *avc, struct uio *auio, usedihint++; } else #endif /* IHINT */ - +#if defined(LINUX_USE_FH) + tfile = (struct osi_file *)osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type); +#else tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode); +#endif #ifdef AFS_DARWIN80_ENV trimlen = len; tuiop = afsio_darwin_partialcopy(auio, trimlen); diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index 484068c..23425b5 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -336,7 +336,11 @@ afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) rbuf = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); tlen = len; ObtainReadLock(&tdc->lock); +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type); +#else tfile = osi_UFSOpen(tdc->f.inode); +#endif code = afs_osi_Read(tfile, -1, rbuf, tlen); osi_UFSClose(tfile); ReleaseReadLock(&tdc->lock); diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index 7da9946..5b08d42 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -543,7 +543,11 @@ afs_UFSWrite(register struct vcache *avc, struct uio *auio, int aio, tdc->f.states |= DWriting; tdc->dflags |= DFEntryMod; } +#if defined(LINUX_USE_FH) + tfile = (struct osi_file *)osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type); +#else tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode); +#endif len = totalLength; /* write this amount by default */ offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); max = AFS_CHUNKTOSIZE(tdc->f.chunk); /* max size of this chunk */ diff --git a/src/afs/afs.h b/src/afs/afs.h index bf2bb77..811e2cd 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -1005,6 +1005,10 @@ struct buffer { afs_int32 fid; /* is adc->index, the cache file number */ afs_inode_t inode; /* is adc->f.inode, the inode number of the cac\ he file */ +#if defined(LINUX_USE_FH) + struct fid fh; /* Opaque file handle */ + int fh_type; /* Opaque file handle type */ +#endif afs_int32 page; afs_int32 accesstime; struct buffer *hashNext; @@ -1027,6 +1031,10 @@ struct fcache { afs_inode_t inode; /* Unix inode for this chunk */ afs_int32 chunkBytes; /* Num bytes in this chunk */ char states; /* Has this chunk been modified? */ +#if defined(LINUX_USE_FH) + struct fid fh; /* File handle */ + int fh_type; /* File handle type */ +#endif }; #endif diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c index 3f3e5de..66b203f 100644 --- a/src/afs/afs_buffer.c +++ b/src/afs/afs_buffer.c @@ -231,7 +231,11 @@ DRead(register struct dcache *adc, register int page) MReleaseWriteLock(&tb->lock); return NULL; } +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&adc->f.fh, adc->f.fh_type); +#else tfile = afs_CFileOpen(adc->f.inode); +#endif code = afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data, AFS_BUFFER_PAGESIZE); @@ -343,7 +347,11 @@ afs_newslot(struct dcache *adc, afs_int32 apage, register struct buffer *lp) if (lp->dirty) { /* see DFlush for rationale for not getting and locking the dcache */ - tfile = afs_CFileOpen(lp->inode); +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&lp->fh, lp->fh_type); +#else + tfile = afs_CFileOpen(lp->inode); +#endif afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data, AFS_BUFFER_PAGESIZE); lp->dirty = 0; @@ -353,7 +361,12 @@ afs_newslot(struct dcache *adc, afs_int32 apage, register struct buffer *lp) /* Now fill in the header. */ lp->fid = adc->index; +#if defined(LINUX_USE_FH) + memcpy(&lp->fh, &adc->f.fh, sizeof(struct fid)); + lp->fh_type = adc->f.fh_type; +#else lp->inode = adc->f.inode; +#endif lp->page = apage; lp->accesstime = timecounter++; FixupBucket(lp); /* move to the right hash bucket */ @@ -490,7 +503,11 @@ DFlush(void) * we cannot lock afs_xdcache). In addition, we cannot obtain * a dcache lock while holding the tb->lock of the same file * since that can deadlock with DRead/DNew */ +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&tb->fh, tb->fh_type); +#else tfile = afs_CFileOpen(tb->inode); +#endif afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data, AFS_BUFFER_PAGESIZE); tb->dirty = 0; /* Clear the dirty flag */ diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index 38e83c2..54ecfb8 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -215,8 +215,14 @@ afs_LookupAFSDB(char *acellName) */ struct cell_name *afs_cellname_head; /* Export for kdump */ +#if defined(LINUX_USE_FH) +struct fid afs_cellname_fh; +int afs_cellname_fh_type; +static int afs_cellname_fh_set; +#else static ino_t afs_cellname_inode; static int afs_cellname_inode_set; +#endif static int afs_cellname_dirty; static afs_int32 afs_cellnum_next; @@ -301,7 +307,11 @@ afs_cellname_ref(struct cell_name *cn) * \return 0 for success. < 0 for error. */ int +#if defined(LINUX_USE_FH) +afs_cellname_init(struct fid *fh, int fh_type, int lookupcode) +#else afs_cellname_init(ino_t inode, int lookupcode) +#endif { struct osi_file *tfile; int cc, off = 0; @@ -320,14 +330,24 @@ afs_cellname_init(ino_t inode, int lookupcode) return lookupcode; } +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(fh, fh_type); +#else tfile = osi_UFSOpen(inode); +#endif if (!tfile) { ReleaseWriteLock(&afs_xcell); return EIO; } +#if defined(LINUX_USE_FH) + memcpy(&afs_cellname_fh, fh, sizeof(struct fid)); + afs_cellname_fh_type = fh_type; + afs_cellname_fh_set = 1; +#else afs_cellname_inode = inode; afs_cellname_inode_set = 1; +#endif while (1) { afs_int32 cellnum, clen, magic; @@ -388,7 +408,11 @@ afs_cellname_write(void) struct cell_name *cn; int off; +#if defined(LINUX_USE_FH) + if (!afs_cellname_dirty || !afs_cellname_fh_set) +#else if (!afs_cellname_dirty || !afs_cellname_inode_set) +#endif return 0; if (afs_initState != 300) return 0; @@ -396,7 +420,11 @@ afs_cellname_write(void) ObtainWriteLock(&afs_xcell, 693); afs_cellname_dirty = 0; off = 0; +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&afs_cellname_fh, afs_cellname_fh_type); +#else tfile = osi_UFSOpen(afs_cellname_inode); +#endif if (!tfile) { ReleaseWriteLock(&afs_xcell); return EIO; diff --git a/src/afs/afs_chunkops.h b/src/afs/afs_chunkops.h index 53dc1fb..9b1608f 100644 --- a/src/afs/afs_chunkops.h +++ b/src/afs/afs_chunkops.h @@ -55,8 +55,12 @@ struct afs_cacheOps { #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV) void *(*open) (ino_t ainode); #else +#if defined(LINUX_USE_FH) + void *(*open) (struct fid *fh, int fh_type); +#else void *(*open) (afs_int32 ainode); #endif +#endif int (*truncate) (struct osi_file * fp, afs_int32 len); int (*fread) (struct osi_file * fp, int offset, void *buf, afs_int32 len); int (*fwrite) (struct osi_file * fp, afs_int32 offset, void *buf, @@ -84,7 +88,11 @@ struct afs_cacheOps { }; /* Ideally we should have used consistent naming - like COP_OPEN, COP_TRUNCATE, etc. */ +#if defined(LINUX_USE_FH) +#define afs_CFileOpen(fh, fh_type) (void *)(*(afs_cacheType->open))(fh, fh_type) +#else #define afs_CFileOpen(inode) (void *)(*(afs_cacheType->open))(inode) +#endif #define afs_CFileTruncate(handle, size) (*(afs_cacheType->truncate))((handle), size) #define afs_CFileRead(file, offset, data, size) (*(afs_cacheType->fread))(file, offset, data, size) #define afs_CFileWrite(file, offset, data, size) (*(afs_cacheType->fwrite))(file, offset, data, size) diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 6f411e3..7663d70 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -54,7 +54,12 @@ afs_int32 afs_discardDCList; /*!< Discarded disk cache entries */ afs_int32 afs_discardDCCount; /*!< Count of elts in discardDCList */ struct dcache *afs_freeDSList; /*!< Free list for disk slots */ struct dcache *afs_Initial_freeDSList; /*!< Initial list for above */ -ino_t cacheInode; /*!< Inode for CacheItems file */ +#if defined(LINUX_USE_FH) +struct fid cacheitems_fh; +int cacheitems_fh_type; +#else +ino_t cacheInode; /*!< Inode for CacheItems file */ +#endif struct osi_file *afs_cacheInodep = 0; /*!< file for CacheItems inode */ struct afs_q afs_DLRU; /*!< dcache LRU */ afs_int32 afs_dhashsize = 1024; @@ -103,7 +108,11 @@ int dcacheDisabled = 0; static int afs_UFSCacheFetchProc(), afs_UFSCacheStoreProc(); struct afs_cacheOps afs_UfsCacheOps = { +#if defined(LINUX_USE_FH) + osi_UFSOpen_fh, +#else osi_UFSOpen, +#endif osi_UFSTruncate, afs_osi_Read, afs_osi_Write, @@ -1088,7 +1097,11 @@ afs_FreeDiscardedDCache(void) /* * Truncate the element to reclaim its space */ +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else tfile = afs_CFileOpen(tdc->f.inode); +#endif afs_CFileTruncate(tfile, 0); afs_CFileClose(tfile); afs_AdjustSize(tdc, 0); @@ -1716,7 +1729,11 @@ struct dcache *afs_AllocDCache(struct vcache *avc, afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded; if (lock & 2) { /* Truncate the chunk so zeroes get filled properly */ +#if defined(LINUX_USE_FH) + file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else file = afs_CFileOpen(tdc->f.inode); +#endif afs_CFileTruncate(file, 0); afs_CFileClose(file); afs_AdjustSize(tdc, 0); @@ -2134,7 +2151,11 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, /* no data in file to read at this position */ UpgradeSToWLock(&tdc->lock, 607); +#if defined(LINUX_USE_FH) + file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else file = afs_CFileOpen(tdc->f.inode); +#endif afs_CFileTruncate(file, 0); afs_CFileClose(file); afs_AdjustSize(tdc, 0); @@ -2321,7 +2342,11 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, * fetch the whole file. */ DZap(tdc); /* pages in cache may be old */ +#if defined(LINUX_USE_FH) + file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else file = afs_CFileOpen(tdc->f.inode); +#endif afs_RemoveVCB(&avc->fid); tdc->f.states |= DWriting; tdc->dflags |= DFFetching; @@ -3288,6 +3313,9 @@ afs_InitCacheFile(char *afile, ino_t ainode) struct osi_file *tfile; struct osi_stat tstat; register struct dcache *tdc; +#if defined(LINUX_USE_FH) + int max_len = sizeof(struct fid); +#endif AFS_STATCNT(afs_InitCacheFile); index = afs_stats_cmperf.cacheNumEntries; @@ -3315,8 +3343,11 @@ afs_InitCacheFile(char *afile, ino_t ainode) * UFS file system, and just record the inode number. */ #ifdef AFS_LINUX22_ENV - tdc->f.inode = VTOI(filevp->d_inode)->i_number; - dput(filevp); +#if defined(LINUX_USE_FH) + tdc->f.fh_type = osi_get_fh(filevp, &tdc->f.fh, &max_len); +#else + tdc->f.inode = VTOI(filevp->d_inode)->i_number; +#endif #else tdc->f.inode = afs_vnodeToInumber(filevp); AFS_RELE(filevp); @@ -3327,7 +3358,11 @@ afs_InitCacheFile(char *afile, ino_t ainode) fileIsBad = 0; if ((tdc->f.states & DWriting) || tdc->f.fid.Fid.Volume == 0) fileIsBad = 1; - tfile = osi_UFSOpen(tdc->f.inode); +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type); +#else + tfile = osi_UFSOpen(ainode); +#endif code = afs_osi_Stat(tfile, &tstat); if (code) osi_Panic("initcachefile stat"); diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index b3a8b67..97cebb7 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -252,9 +252,19 @@ afs_InitCellInfo(char *afile) { ino_t inode; int code; +#if defined(LINUX_USE_FH) + struct fid fh; + int fh_type; + int max_len = sizeof(struct fid); + struct dentry *dp; +#endif #ifdef AFS_CACHE_VNODE_PATH return afs_cellname_init(AFS_CACHE_CELLS_INODE, code); +#elif defined(LINUX_USE_FH) + code = gop_lookupname(afile, AFS_UIOSYS, 0, &dp); + fh_type = osi_get_fh(dp, &fh, &max_len); + return afs_cellname_init(&fh, fh_type, code); #else code = LookupInodeByPath(afile, &inode, NULL); return afs_cellname_init(inode, code); @@ -282,6 +292,10 @@ afs_InitVolumeInfo(char *afile) { int code; struct osi_file *tfile; +#if defined(LINUX_USE_FH) + int max_len = sizeof(struct fid); + struct dentry *dp; +#endif AFS_STATCNT(afs_InitVolumeInfo); #if defined(AFS_XBSD_ENV) @@ -301,12 +315,19 @@ afs_InitVolumeInfo(char *afile) code = LookupInodeByPath(afile, &volumeInode, &volumeVnode); #elif defined(AFS_CACHE_VNODE_PATH) volumeInode = AFS_CACHE_VOLUME_INODE; +#elif defined(LINUX_USE_FH) + code = gop_lookupname(afile, AFS_UIOSYS, 0, &dp); + volumeinfo_fh_type = osi_get_fh(dp, &volumeinfo_fh, &max_len); #else code = LookupInodeByPath(afile, &volumeInode, NULL); #endif if (code) return code; +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&volumeinfo_fh, volumeinfo_fh_type); +#else tfile = afs_CFileOpen(volumeInode); +#endif afs_CFileTruncate(tfile, 0); afs_CFileClose(tfile); return 0; @@ -443,7 +464,11 @@ afs_InitCacheInfo(register char *afile) #endif /* AFS_LINUX20_ENV */ AFS_RELE(filevp); #endif /* AFS_LINUX22_ENV */ +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&cacheitems_fh, cacheitems_fh_type); +#else tfile = osi_UFSOpen(cacheInode); +#endif afs_osi_Stat(tfile, &tstat); cacheInfoModTime = tstat.mtime; code = afs_osi_Read(tfile, -1, &theader, sizeof(theader)); @@ -668,8 +693,9 @@ shutdown_cache(void) cacheDev.held_vnode = NULL; } #endif +#if !defined(LINUX_USE_FH) cacheInode = volumeInode = (ino_t) 0; - +#endif cacheInfoModTime = 0; afs_fsfragsize = 1023; diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 70d1271..c3d4a6e 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -129,7 +129,11 @@ extern struct afs_q CellLRU; extern void afs_CellInit(void); extern void shutdown_cell(void); +#if defined(LINUX_USE_FH) +extern int afs_cellname_init(struct fid *fh, int fh_type, int lookupcode); +#else extern int afs_cellname_init(ino_t inode, int lookupcode); +#endif extern int afs_cellname_write(void); extern afs_int32 afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags, char *linkedcname, u_short fsport, @@ -232,7 +236,12 @@ extern int cacheDiskType; extern afs_uint32 afs_tpct1, afs_tpct2, splitdcache; extern unsigned char *afs_indexFlags; extern struct afs_cacheOps *afs_cacheType; +#if defined(LINUX_USE_FH) +extern struct fid cacheitems_fh; +extern int cacheitems_fh_type; +#else extern ino_t cacheInode; +#endif extern struct osi_file *afs_cacheInodep; extern void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags); @@ -628,8 +637,13 @@ extern int afs_osicred_initialized; #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV) extern void *osi_UFSOpen(ino_t ainode); #else +#if defined(LINUX_USE_FH) +extern void *osi_UFSOpen_fh(struct fid *fh, int fh_type); +extern int osi_get_fh(struct dentry *dp, struct fid *fh, int *max_len); +#else extern void *osi_UFSOpen(afs_int32 ainode); #endif +#endif extern int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat); extern int osi_UFSClose(register struct osi_file *afile); @@ -1112,7 +1126,12 @@ extern afs_int32 afs_FVIndex; extern afs_int32 afs_volCounter; extern afs_rwlock_t afs_xvolume; extern struct volume *afs_volumes[NVOLS]; +#if defined(LINUX_USE_FH) +extern struct fid volumeinfo_fh; +extern int volumeinfo_fh_type; +#else extern ino_t volumeInode; +#endif extern struct volume *afs_FindVolume(struct VenusFid *afid, afs_int32 locktype); extern struct volume *afs_freeVolList; diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index 449ae40..35235fe 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -432,7 +432,11 @@ afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, shouldwake = &nomore; } } +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else tfile = afs_CFileOpen(tdc->f.inode); +#endif #ifndef AFS_NOSTATS xferP = &(afs_stats_cmfullperf.rpc. @@ -1045,7 +1049,11 @@ afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, ObtainSharedLock(&tdc->lock, 672); if (newSize < tdc->f.chunkBytes) { UpgradeSToWLock(&tdc->lock, 673); +#if defined(LINUX_USE_FH) + tfile = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type); +#else tfile = afs_CFileOpen(tdc->f.inode); +#endif afs_CFileTruncate(tfile, newSize); afs_CFileClose(tfile); afs_AdjustSize(tdc, newSize); diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 50cf2c4..de5c48f 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -58,7 +58,12 @@ RCSID #endif /* vlserver error base define */ /* Exported variables */ -ino_t volumeInode; /** Inode for VolumeItems file */ +#if defined(LINUX_USE_FH) +struct fid volumeinfo_fh; /* File handle for VolumeItems file */ +int volumeinfo_fh_type; +#else +ino_t volumeInode; /* Inode for VolumeItems file */ +#endif afs_rwlock_t afs_xvolume; /** allocation lock for volumes */ struct volume *afs_freeVolList; struct volume *afs_volumes[NVOLS]; @@ -159,7 +164,11 @@ afs_UFSGetVolSlot(void) * next chain */ if (afs_FVIndex != tv->vtix) { +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&volumeinfo_fh, volumeinfo_fh_type); +#else tfile = osi_UFSOpen(volumeInode); +#endif code = afs_osi_Read(tfile, sizeof(struct fvolume) * tv->vtix, &staticFVolume, sizeof(struct fvolume)); @@ -176,7 +185,11 @@ afs_UFSGetVolSlot(void) staticFVolume.dotdot = tv->dotdot; staticFVolume.rootVnode = tv->rootVnode; staticFVolume.rootUnique = tv->rootUnique; +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&volumeinfo_fh, volumeinfo_fh_type); +#else tfile = osi_UFSOpen(volumeInode); +#endif code = afs_osi_Write(tfile, sizeof(struct fvolume) * afs_FVIndex, &staticFVolume, sizeof(struct fvolume)); @@ -545,7 +558,11 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell, for (j = fvTable[FVHash(tv->cell, volid)]; j != 0; j = tf->next) { if (afs_FVIndex != j) { struct osi_file *tfile; - tfile = osi_UFSOpen(volumeInode); +#if defined(LINUX_USE_FH) + tfile = osi_UFSOpen_fh(&volumeinfo_fh, volumeinfo_fh_type); +#else + tfile = osi_UFSOpen(volumeInode); +#endif err = afs_osi_Read(tfile, sizeof(struct fvolume) * j, &staticFVolume, sizeof(struct fvolume)); diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index 6949b9d..06e230f 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -120,6 +120,9 @@ struct xfs_inode_info { #ifdef COMPLETION_H_EXISTS #include #endif +#if defined(LINUX_USE_FH) +#include +#endif #else /* AFS_LINUX22_ENV */ #if defined(AFS_DARWIN_ENV) diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 07d6958..72e1857 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -339,7 +339,7 @@ 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 +#if !defined(AFS_CACHE_VNODE_PATH) && !defined(LINUX_USE_FH) AFSD_INO_T *inode_for_V; /* Array of inodes for desired * cache files */ #endif @@ -1014,7 +1014,7 @@ 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 +#if !defined(AFS_CACHE_VNODE_PATH) && !defined(LINUX_USE_FH) inode_for_V[vFileNum] = currp->d_ino; #endif dir_for_V[vFileNum] = dirNum; /* remember this directory */ @@ -1153,7 +1153,7 @@ doSweepAFSCache(vFilesFound, directory, dirNum, maxDir) vFileNum); else { struct stat statb; -#ifndef AFS_CACHE_VNODE_PATH +#if !defined(AFS_CACHE_VNODE_PATH) && !defined(LINUX_USE_FH) assert(inode_for_V[vFileNum] == (AFSD_INO_T) 0); #endif sprintf(vFilePtr, "D%d/V%d", thisDir, vFileNum); @@ -1166,7 +1166,7 @@ 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 +#if !defined(AFS_CACHE_VNODE_PATH) && !defined(LINUX_USE_FH) inode_for_V[vFileNum] = statb.st_ino; #endif dir_for_V[vFileNum] = thisDir; @@ -1268,6 +1268,7 @@ CheckCacheBaseDir(char *dir) if (res != 0) { return "unable to statfs cache base directory"; } +#if !defined(LINUX_USE_FH) if (statfsbuf.f_type == 0x52654973) { /* REISERFS_SUPER_MAGIC */ return "cannot use reiserfs as cache partition"; } else if (statfsbuf.f_type == 0x58465342) { /* XFS_SUPER_MAGIC */ @@ -1277,6 +1278,7 @@ CheckCacheBaseDir(char *dir) } else if (statfsbuf.f_type != 0xEF53) { return "must use ext2 or ext3 for cache partition"; } +#endif } #endif @@ -1936,7 +1938,7 @@ mainproc(struct cmd_syndesc *as, void *arock) cacheStatEntries); } -#ifndef AFS_CACHE_VNODE_PATH +#if !defined(AFS_CACHE_VNODE_PATH) && !defined(LINUX_USE_FH) /* * Create and zero the inode table for the desired cache files. */ @@ -2307,8 +2309,13 @@ mainproc(struct cmd_syndesc *as, void *arock) (afs_uint32) (inode_for_V[currVFile] >> 32), (afs_uint32) (inode_for_V[currVFile] & 0xffffffff)); #else +#if defined(LINUX_USE_FH) + sprintf(fullpn_VFile, "%s/D%d/V%d", cacheBaseDir, dir_for_V[currVFile], currVFile); + call_syscall(AFSOP_CACHEFILE, fullpn_VFile); +#else call_syscall(AFSOP_CACHEINODE, inode_for_V[currVFile]); #endif +#endif } #endif