convert-linux-macros-for-inodes-appropriately-20020325
authorDerrick Brashear <shadow@dementia.org>
Mon, 25 Mar 2002 18:09:22 +0000 (18:09 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 25 Mar 2002 18:09:22 +0000 (18:09 +0000)
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

src/afs/LINUX/osi_misc.c
src/afs/LINUX/osi_vfsops.c
src/afs/LINUX/osi_vm.c
src/afs/LINUX/osi_vnodeops.c
src/afs/afs.h
src/afs/afs_vcache.c

index 7e63643..b6adbbd 100644 (file)
@@ -300,7 +300,7 @@ void osi_linux_free_inode_pages(void)
 
     for (i=0; i<VCSIZE; i++) {
        for(tvc = afs_vhashT[i]; tvc; tvc=tvc->hnext) {
-           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();
index efe4414..e9d6899 100644 (file)
@@ -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);
index a50cf77..26ac359 100644 (file)
@@ -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
 }
index 4b0c668..f9f5b0b 100644 (file)
@@ -61,7 +61,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;
 
@@ -142,7 +142,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();
 
@@ -250,7 +250,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;
@@ -411,7 +411,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;
 
@@ -447,7 +447,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;
@@ -548,7 +548,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
@@ -583,7 +583,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
@@ -607,7 +607,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;
@@ -645,7 +645,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;
 
@@ -749,7 +749,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
@@ -802,8 +802,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();
 
@@ -869,7 +869,7 @@ static int afs_linux_dentry_revalidate(struct dentry *dp)
     int code;
     cred_t *credp;
     struct vrequest treq;
-    struct inode *ip = AFSTOV(dp->d_inode);
+    struct inode *ip = AFSTOI(dp->d_inode);
 
     unsigned long timeout = 3*HZ; /* 3 seconds */
 
@@ -943,7 +943,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) {
@@ -992,10 +992,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)) {
@@ -1020,7 +1020,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);
@@ -1054,7 +1054,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);
@@ -1069,7 +1069,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);
@@ -1093,7 +1093,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;
@@ -1111,7 +1111,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;
@@ -1120,7 +1120,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();
@@ -1135,7 +1135,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
@@ -1176,7 +1176,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();
 
@@ -1204,7 +1204,7 @@ static int afs_linux_ireadlink(struct inode *ip, char *target, int maxlen,
     struct iovec iov;
 
     setup_uio(&tuio, &iov, target, (afs_offs_t) 0, maxlen, UIO_READ, seg);
-    code = afs_readlink(VTOAFS(ip), &tuio, credp);
+    code = afs_readlink(ITOAFS(ip), &tuio, credp);
     crfree(credp);
 
     if (!code)
@@ -1306,7 +1306,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
@@ -1401,7 +1401,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);
@@ -1419,7 +1419,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;
     afs_offs_t base;
     int code = 0;
@@ -1472,7 +1472,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;
index 9823233..33e861b 100644 (file)
@@ -574,6 +574,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
index a516653..e4ac272 100644 (file)
@@ -578,7 +578,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp,
                continue;
            
            if ( VREFCOUNT(tvc) && tvc->opens == 0 ) {
-               struct inode *ip = AFSTOV(tvc);
+               struct inode *ip = AFSTOI(tvc);
                if (list_empty(&ip->i_dentry)) {
                    vn --;
                }
@@ -952,7 +952,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);