From 74824da927654469faa3afd458290c5d45e07242 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 24 Apr 2002 02:49:34 +0000 Subject: [PATCH] even though right now a vnode and an inode are basically but not exactly the same, part of the usefulness of this change is the ability to convert to inodes linked from vcaches later. make the macros fit with this view of the fture (cherry picked from commit 39ee79e7c328d86738356aa5a736e24339f8b126) --- src/afs/LINUX/osi_misc.c | 8 ++--- src/afs/LINUX/osi_vfsops.c | 10 +++---- src/afs/LINUX/osi_vm.c | 18 +++++------ src/afs/LINUX/osi_vnodeops.c | 58 ++++++++++++++++++------------------ src/afs/afs.h | 4 +++ src/afs/afs_vcache.c | 2 +- 6 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 43af8f60f..100936103 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -300,7 +300,7 @@ void osi_linux_free_inode_pages(void) for (i=0; ihnext) { - ip = AFSTOV(tvc); + ip = AFSTOI(tvc); #if defined(AFS_LINUX24_ENV) if (ip->i_data.nrpages) { #else @@ -329,7 +329,7 @@ void osi_linux_free_inode_pages(void) void osi_clear_inode(struct inode *ip) { cred_t *credp = crref(); - struct vcache *vc = VTOAFS(ip); + struct vcache *vc = ITOAFS(ip); #if defined(AFS_LINUX24_ENV) if (atomic_read(&ip->i_count) > 1) @@ -405,8 +405,8 @@ void osi_iput(struct inode *ip) void check_bad_parent(struct dentry *dp) { cred_t *credp; - struct vcache *vcp = VTOAFS(dp->d_inode), *avc = NULL; - struct vcache *pvc = VTOAFS(dp->d_parent->d_inode); + struct vcache *vcp = ITOAFS(dp->d_inode), *avc = NULL; + struct vcache *pvc = ITOAFS(dp->d_parent->d_inode); if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) { /* bad parent */ credp = crref(); diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index efe441420..e9d68992c 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -142,9 +142,9 @@ static int afs_root(struct super_block *afsp) /* setup super_block and mount point inode. */ afs_globalVp = tvp; #if defined(AFS_LINUX24_ENV) - afsp->s_root = d_alloc_root(AFSTOV(tvp)); + afsp->s_root = d_alloc_root(AFSTOI(tvp)); #else - afsp->s_root = d_alloc_root(AFSTOV(tvp), NULL); + afsp->s_root = d_alloc_root(AFSTOI(tvp), NULL); #endif afsp->s_root->d_op = &afs_dentry_operations; } else @@ -188,8 +188,8 @@ int afs_notify_change(struct dentry *dp, struct iattr* iattrp) VATTR_NULL(&vattr); iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ update_inode_cache(ip, &vattr); - code = afs_setattr(VTOAFS(ip), &vattr, credp); - afs_CopyOutAttrs(VTOAFS(ip), &vattr); + code = afs_setattr(ITOAFS(ip), &vattr, credp); + afs_CopyOutAttrs(ITOAFS(ip), &vattr); /* Note that the inode may still not have all the correct info. But at * least we've got the newest version of what was supposed to be set. */ @@ -242,7 +242,7 @@ void afs_write_inode(struct inode *ip) void afs_delete_inode(struct inode *ip) { - struct vcache *vc = VTOAFS(ip); + struct vcache *vc = ITOAFS(ip); AFS_GLOCK(); osi_clear_inode(ip); diff --git a/src/afs/LINUX/osi_vm.c b/src/afs/LINUX/osi_vm.c index a50cf7750..26ac35941 100644 --- a/src/afs/LINUX/osi_vm.c +++ b/src/afs/LINUX/osi_vm.c @@ -41,7 +41,7 @@ RCSID("$Header$"); */ int osi_VM_FlushVCache(struct vcache *avc, int *slept) { - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); if (VREFCOUNT(avc) != 0) return EBUSY; @@ -70,7 +70,7 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) */ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { - invalidate_inode_pages(AFSTOV(avc)); + invalidate_inode_pages(AFSTOI(avc)); } /* Flush and invalidate pages, for fsync() with INVAL flag @@ -89,7 +89,7 @@ void osi_VM_FSyncInval(struct vcache *avc) */ void osi_VM_StoreAllSegments(struct vcache *avc) { - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5) /* filemap_fdatasync() only exported in 2.4.5 and above */ @@ -109,15 +109,15 @@ void osi_VM_StoreAllSegments(struct vcache *avc) void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); truncate_inode_pages(&ip->i_data, 0); #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15) - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); truncate_inode_pages(ip, 0); #else - invalidate_inode_pages(AFSTOV(avc)); + invalidate_inode_pages(AFSTOI(avc)); #endif } @@ -130,14 +130,14 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); truncate_inode_pages(&ip->i_data, alen); #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15) - struct inode *ip = AFSTOV(avc); + struct inode *ip = AFSTOI(avc); truncate_inode_pages(ip, alen); #else - invalidate_inode_pages(AFSTOV(avc)); + invalidate_inode_pages(AFSTOI(avc)); #endif } diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 07f4301ee..a3e2262e6 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -60,7 +60,7 @@ static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, loff_t *offp) { ssize_t code; - struct vcache *vcp = VTOAFS(fp->f_dentry->d_inode); + struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode); cred_t *credp = crref(); struct vrequest treq; @@ -104,7 +104,7 @@ static ssize_t afs_linux_write(struct file *fp, const char *buf, size_t count, { ssize_t code = 0; int code2; - struct vcache *vcp = VTOAFS(fp->f_dentry->d_inode); + struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode); struct vrequest treq; cred_t *credp = crref(); @@ -157,7 +157,7 @@ static int afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) { extern struct DirEntry * afs_dir_GetBlob(); - struct vcache *avc = VTOAFS(FILE_INODE(fp)); + struct vcache *avc = ITOAFS(FILE_INODE(fp)); struct vrequest treq; register struct dcache *tdc; int code; @@ -314,7 +314,7 @@ void afs_linux_vma_close(struct vm_area_struct *vmap) if (!vmap->vm_file) return; - vcp = VTOAFS(FILE_INODE(vmap->vm_file)); + vcp = ITOAFS(FILE_INODE(vmap->vm_file)); if (!vcp) return; @@ -350,7 +350,7 @@ void afs_linux_vma_close(struct vm_area_struct *vmap) static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) { - struct vcache *vcp = VTOAFS(FILE_INODE(fp)); + struct vcache *vcp = ITOAFS(FILE_INODE(fp)); cred_t *credp = crref(); struct vrequest treq; int code; @@ -451,7 +451,7 @@ static int afs_linux_release(struct inode *ip, struct file *fp) { int code = 0; cred_t *credp = crref(); - struct vcache *vcp = VTOAFS(ip); + struct vcache *vcp = ITOAFS(ip); AFS_GLOCK(); #ifdef AFS_LINUX24_ENV @@ -486,7 +486,7 @@ static int afs_linux_fsync(struct file *fp, struct dentry *dp) #ifdef AFS_LINUX24_ENV lock_kernel(); #endif - code = afs_fsync(VTOAFS(ip), credp); + code = afs_fsync(ITOAFS(ip), credp); #ifdef AFS_LINUX24_ENV unlock_kernel(); #endif @@ -510,7 +510,7 @@ int afs_linux_file_revalidate(kdev_t dev); static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) { int code = 0; - struct vcache *vcp = VTOAFS(FILE_INODE(fp)); + struct vcache *vcp = ITOAFS(FILE_INODE(fp)); cred_t *credp = crref(); #ifdef AFS_LINUX24_ENV struct flock64 flock; @@ -548,7 +548,7 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) */ int afs_linux_flush(struct file *fp) { - struct vcache *vcp = VTOAFS(FILE_INODE(fp)); + struct vcache *vcp = ITOAFS(FILE_INODE(fp)); int code = 0; cred_t *credp; @@ -652,7 +652,7 @@ static int afs_linux_revalidate(struct dentry *dp) int code; cred_t *credp; struct vrequest treq; - struct vcache *vcp = VTOAFS(dp->d_inode); + struct vcache *vcp = ITOAFS(dp->d_inode); AFS_GLOCK(); #ifdef AFS_LINUX24_ENV @@ -705,8 +705,8 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) struct vcache *lookupvcp = NULL; int code, bad_dentry = 1; struct sysname_info sysState; - struct vcache *vcp = VTOAFS(dp->d_inode); - struct vcache *parentvcp = VTOAFS(dp->d_parent->d_inode); + struct vcache *vcp = ITOAFS(dp->d_inode); + struct vcache *parentvcp = ITOAFS(dp->d_parent->d_inode); AFS_GLOCK(); @@ -772,7 +772,7 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) int code; cred_t *credp; struct vrequest treq; - struct inode *ip = (struct inode *)dp->d_inode; + struct inode *ip = AFSTOI(dp->d_inode); unsigned long timeout = 3*HZ; /* 3 seconds */ @@ -846,7 +846,7 @@ int afs_linux_create(struct inode *dip, struct dentry *dp, int mode) vattr.va_mode = mode; AFS_GLOCK(); - code = afs_create(VTOAFS(dip), name, &vattr, NONEXCL, mode, + code = afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode, (struct vcache**)&ip, credp); if (!code) { @@ -895,10 +895,10 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp) struct vcache *vcp=NULL; const char *comp = dp->d_name.name; AFS_GLOCK(); - code = afs_lookup(VTOAFS(dip), comp, &vcp, credp); + code = afs_lookup(ITOAFS(dip), comp, &vcp, credp); if (vcp) { - struct inode *ip = AFSTOV(vcp); + struct inode *ip = AFSTOI(vcp); /* Reset ops if symlink or directory. */ #if defined(AFS_LINUX24_ENV) if (S_ISREG(ip->i_mode)) { @@ -923,7 +923,7 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp) } dp->d_time = jiffies; dp->d_op = afs_dops; - d_add(dp, AFSTOV(vcp)); + d_add(dp, AFSTOI(vcp)); AFS_GUNLOCK(); crfree(credp); @@ -957,7 +957,7 @@ int afs_linux_link(struct dentry *olddp, struct inode *dip, d_drop(newdp); AFS_GLOCK(); - code = afs_link(VTOAFS(oldip), VTOAFS(dip), name, credp); + code = afs_link(ITOAFS(oldip), ITOAFS(dip), name, credp); AFS_GUNLOCK(); crfree(credp); @@ -972,7 +972,7 @@ int afs_linux_unlink(struct inode *dip, struct dentry *dp) int putback = 0; AFS_GLOCK(); - code = afs_remove(VTOAFS(dip), name, credp); + code = afs_remove(ITOAFS(dip), name, credp); AFS_GUNLOCK(); if (!code) d_drop(dp); @@ -996,7 +996,7 @@ int afs_linux_symlink(struct inode *dip, struct dentry *dp, AFS_GLOCK(); VATTR_NULL(&vattr); - code = afs_symlink(VTOAFS(dip), name, &vattr, target, credp); + code = afs_symlink(ITOAFS(dip), name, &vattr, target, credp); AFS_GUNLOCK(); crfree(credp); return -code; @@ -1014,7 +1014,7 @@ int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) VATTR_NULL(&vattr); vattr.va_mask = ATTR_MODE; vattr.va_mode = mode; - code = afs_mkdir(VTOAFS(dip), name, &vattr, &tvcp, credp); + code = afs_mkdir(ITOAFS(dip), name, &vattr, &tvcp, credp); if (tvcp) { tvcp->v.v_op = &afs_dir_iops; @@ -1023,7 +1023,7 @@ int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) #endif dp->d_op = afs_dops; dp->d_time = jiffies; - d_instantiate(dp, AFSTOV(tvcp)); + d_instantiate(dp, AFSTOI(tvcp)); } AFS_GUNLOCK(); @@ -1038,7 +1038,7 @@ int afs_linux_rmdir(struct inode *dip, struct dentry *dp) const char *name = dp->d_name.name; AFS_GLOCK(); - code = afs_rmdir(VTOAFS(dip), name, credp); + code = afs_rmdir(ITOAFS(dip), name, credp); /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall * that failed because a directory is not empty. So, we map @@ -1079,7 +1079,7 @@ int afs_linux_rename(struct inode *oldip, struct dentry *olddp, d_drop(newdp); } AFS_GLOCK(); - code = afs_rename(VTOAFS(oldip), oldname, VTOAFS(newip), + code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp); AFS_GUNLOCK(); @@ -1107,7 +1107,7 @@ static int afs_linux_ireadlink(struct inode *ip, char *target, int maxlen, struct iovec iov; setup_uio(&tuio, &iov, target, 0, maxlen, UIO_READ, seg); - code = afs_readlink((struct vcache*)ip, &tuio, credp); + code = afs_readlink(ITOAFS(ip), &tuio, credp); crfree(credp); if (!code) @@ -1209,7 +1209,7 @@ int afs_linux_readpage(struct file *fp, struct page *pp) setup_uio(&tuio, &iovec, (char*)address, offset, PAGESIZE, UIO_READ, AFS_UIOSYS); - code = afs_rdwr(VTOAFS(ip), &tuio, UIO_READ, 0, credp); + code = afs_rdwr(ITOAFS(ip), &tuio, UIO_READ, 0, credp); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) unlock_kernel(); #endif @@ -1304,7 +1304,7 @@ int afs_linux_permission(struct inode *ip, int mode) if (mode & MAY_EXEC) tmp |= VEXEC; if (mode & MAY_READ) tmp |= VREAD; if (mode & MAY_WRITE) tmp |= VWRITE; - code = afs_access(VTOAFS(ip), tmp, credp); + code = afs_access(ITOAFS(ip), tmp, credp); AFS_GUNLOCK(); crfree(credp); @@ -1322,7 +1322,7 @@ int afs_linux_writepage_sync(struct inode *ip, struct page *pp, unsigned long offset, unsigned int count) { - struct vcache *vcp = VTOAFS(ip); + struct vcache *vcp = ITOAFS(ip); char *buffer; loff_t base; int code = 0; @@ -1375,7 +1375,7 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset, unsigned int count, int sync) { - struct vcache *vcp = VTOAFS(FILE_INODE(fp)); + struct vcache *vcp = ITOAFS(FILE_INODE(fp)); u8 *page_addr = (u8*) afs_linux_page_address(pp); int code = 0; cred_t *credp; diff --git a/src/afs/afs.h b/src/afs/afs.h index d24c7aaea..0f03fcda6 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -566,6 +566,10 @@ extern afs_uint32 afs_stampValue; /* stamp for pair's usage */ #define VTOAFS(V) ((struct vcache*)(V)) #define AFSTOV(V) (&(V)->v) +#ifdef AFS_LINUX22_ENV +#define ITOAFS(V) ((struct vcache*)(V)) +#define AFSTOI(V) (struct inode *)(&(V)->v) +#endif /* INVARIANTs: (vlruq.next != NULL) == (vlruq.prev != NULL) * nextfree => !vlruq.next && ! vlruq.prev diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 00448ea5c..0ff7f54cb 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -957,7 +957,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp, #endif /* AFS_SGI_ENV */ #if defined(AFS_LINUX22_ENV) { - struct inode *ip = AFSTOV(tvc); + struct inode *ip = AFSTOI(tvc); sema_init(&ip->i_sem, 1); #if defined(AFS_LINUX24_ENV) sema_init(&ip->i_zombie, 1); -- 2.39.5