convert-vcache-casts-to-macros-20020325
authorJohan Danielsson <joda@pdc.kth.se>
Mon, 25 Mar 2002 17:39:55 +0000 (17:39 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 25 Mar 2002 17:39:55 +0000 (17:39 +0000)
convert vcache casting in cache manager to macros

should ease further changes later

54 files changed:
src/afs/AIX/osi_vfsops.c
src/afs/AIX/osi_vm.c
src/afs/AIX/osi_vnodeops.c
src/afs/DARWIN/osi_vfsops.c
src/afs/DARWIN/osi_vm.c
src/afs/DARWIN/osi_vnodeops.c
src/afs/DUX/osi_machdep.h
src/afs/DUX/osi_vfsops.c
src/afs/DUX/osi_vm.c
src/afs/DUX/osi_vnodeops.c
src/afs/FBSD/osi_vfsops.c
src/afs/FBSD/osi_vm.c
src/afs/FBSD/osi_vnodeops.c
src/afs/HPUX/osi_machdep.h
src/afs/HPUX/osi_vfsops.c
src/afs/HPUX/osi_vm.c
src/afs/HPUX/osi_vnodeops.c
src/afs/IRIX/osi_machdep.h
src/afs/IRIX/osi_vfsops.c
src/afs/IRIX/osi_vm.c
src/afs/IRIX/osi_vnodeops.c
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/NBSD/osi_vfsops.c
src/afs/NBSD/osi_vnodeops.c
src/afs/SOLARIS/osi_machdep.h
src/afs/SOLARIS/osi_vfsops.c
src/afs/SOLARIS/osi_vm.c
src/afs/SOLARIS/osi_vnodeops.c
src/afs/UKERNEL/afs_usrops.c
src/afs/UKERNEL/osi_machdep.h
src/afs/UKERNEL/osi_vfsops.c
src/afs/UKERNEL/osi_vnodeops.c
src/afs/VNOPS/afs_vnop_attrs.c
src/afs/VNOPS/afs_vnop_create.c
src/afs/VNOPS/afs_vnop_dirops.c
src/afs/VNOPS/afs_vnop_fid.c
src/afs/VNOPS/afs_vnop_flock.c
src/afs/VNOPS/afs_vnop_link.c
src/afs/VNOPS/afs_vnop_lookup.c
src/afs/VNOPS/afs_vnop_open.c
src/afs/VNOPS/afs_vnop_remove.c
src/afs/VNOPS/afs_vnop_rename.c
src/afs/VNOPS/afs_vnop_strategy.c
src/afs/VNOPS/afs_vnop_symlink.c
src/afs/VNOPS/afs_vnop_write.c
src/afs/afs.h
src/afs/afs_daemons.c
src/afs/afs_nfsdisp.c
src/afs/afs_osi.c
src/afs/afs_pioctl.c
src/afs/afs_vcache.c

index 4a50361..e8712f9 100644 (file)
@@ -124,14 +124,14 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp)
        crfree(credp);
     }
     if (tvp) {
-       VN_HOLD((struct vnode *)tvp);
+       VN_HOLD(AFSTOV(tvp));
 
-       VN_LOCK((struct vnode *)tvp);
-       tvp->v.v_flag |= VROOT;     /* No-op on Ultrix 2.2 */
-       VN_UNLOCK((struct vnode *)tvp);
+       VN_LOCK(AFSTOV(tvp));
+       AFSTOV(tvp)->v_flag |= VROOT;       /* No-op on Ultrix 2.2 */
+       VN_UNLOCK(AFSTOV(tvp));
 
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
        afsp->vfs_mntd = *avpp;   
     }
 
index eb32cd1..0877cb7 100644 (file)
@@ -59,7 +59,7 @@ osi_VM_FlushVCache(avc, slept)
     }
 
     /* Free the alloced gnode that was accompanying the vcache's vnode */
-    aix_gnode_rele((struct vnode *)avc);
+    aix_gnode_rele(AFSTOV(avc));
 
     return 0;
 }
@@ -107,7 +107,7 @@ osi_VM_StoreAllSegments(avc)
            avc->states &= ~CCore;
            avc->opens--;
            avc->execsOrWriters--;
-           AFS_RELE((struct vnode *)avc);      
+           AFS_RELE(AFSTOV(avc));      
            crfree((struct ucred *)avc->linkData);      
            avc->linkData = (char *)0;
        }
index e9017f6..96f523b 100644 (file)
@@ -355,7 +355,7 @@ struct ucred        *cred;
 {
     int                error;
     struct vattr       va;
-    struct vcache *tvp = (struct vcache *)vp;
+    struct vcache *tvp = VTOAFS(vp);
     afs_int32 modes;
 
     AFS_STATCNT(afs_gn_open);
@@ -443,10 +443,10 @@ struct ucred      *cred;
      * we'd never flush the files out to the server! Gross but the simplest
      * solution we came out with */
     if (cred->cr_luid != RMTUSER_REQ) {
-       while ((flags & FNSHARE) && ((struct vcache *)*vpp)->opens) {
+       while ((flags & FNSHARE) && VTOAFS(*vpp)->opens) {
            if (!(flags & FDELAY))
                return ETXTBSY;
-           afs_osi_Sleep(&((struct vcache *)*vpp)->opens);
+           afs_osi_Sleep(&VTOAFS(*vpp)->opens);
        }
        /* Since in the standard copen() for bsd vnode kernels they do an
         * vop_open after the vop_create, we must do the open here since there
@@ -477,7 +477,7 @@ int
 afs_gn_rele(vp)
 struct vnode   *vp;
 {
-   struct vcache *vcp = (struct vcache *)vp;
+   struct vcache *vcp = VTOAFS(vp);
    int         error = 0;
 
     AFS_STATCNT(afs_gn_rele);
@@ -502,7 +502,7 @@ caddr_t             vinfo;          /* Ignored in AFS */
 struct ucred   *cred;
 {
     int                error;
-    struct vcache *tvp = (struct vcache *)vp;
+    struct vcache *tvp = VTOAFS(vp);
 
     AFS_STATCNT(afs_gn_close);
 
@@ -525,7 +525,7 @@ caddr_t             addr;
 u_int          len, off, flag;
 struct ucred   *cred;
 {
-    struct vcache *vcp = (struct vcache *)vp;
+    struct vcache *vcp = VTOAFS(vp);
     struct vrequest treq;
     afs_int32 error;
     AFS_STATCNT(afs_gn_map);
@@ -583,7 +583,7 @@ struct      vnode   *vp;
 int            flag;
 struct ucred   *cred;
 {
-    struct vcache *vcp = (struct vcache *)vp;
+    struct vcache *vcp = VTOAFS(vp);
     AFS_STATCNT(afs_gn_unmap);
     ObtainWriteLock(&vcp->lock, 402);
     if (flag & SHM_RDONLY) {
@@ -731,7 +731,7 @@ struct ucred        *cred;
     struct iovec iov;
     struct uio uio;
     static int fclear_init =0; 
-    register struct vcache *avc = (struct vcache *)vp;
+    register struct vcache *avc = VTOAFS(vp);
 
    AFS_STATCNT(afs_gn_fclear);
     if (!fclear_init) {
@@ -821,7 +821,7 @@ caddr_t             vinfo;      /* Ignored in AFS */
 struct vattr   *vattrp;
 struct ucred   *cred;
 {
-    register struct vcache *vcp = (struct vcache *)vp;   
+    register struct vcache *vcp = VTOAFS(vp);   
     struct vrequest treq;
     int error=0;
     int free_cred = 0;
@@ -950,7 +950,7 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp)
     afs_int32 toffset;
     int mixed = 0;
 #endif /* AFS_64BIT_CLIENT */
-    register struct vcache *vcp = (struct vcache *)vp;
+    register struct vcache *vcp = VTOAFS(vp);
     struct dcache *tdc;
     afs_size_t start_offset;
     afs_int32 save_resid = uiop->afsio_resid;
@@ -1236,7 +1236,7 @@ afs_direct_rdwr(vp, uiop, rw, ioflag, credp)
     register afs_int32 code = 0;
     afs_int32 xfrSize;
     afs_size_t fileSize, xfrOffset, offset, old_offset;
-    struct vcache *vcp = (struct vcache *)vp;
+    struct vcache *vcp = VTOAFS(vp);
     afs_int32 save_resid = uiop->afsio_resid;
     struct vrequest treq;
 
index 8f61253..785e8ce 100644 (file)
@@ -138,11 +138,11 @@ afs_root(struct mount *mp,
     if (tvp) {
         osi_vnhold(tvp,0);
     AFS_GUNLOCK();
-        vn_lock((struct vnode *)tvp, LK_EXCLUSIVE | LK_RETRY, p);
+        vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
     AFS_GLOCK();
        afs_globalVFS = mp;
-       *vpp = (struct vnode *) tvp;
-        tvp->v.v_flag |= VROOT;
+       *vpp = AFSTOV(tvp);
+        AFSTOV(tvp)->v_flag |= VROOT;
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
index a5030b2..caf0889 100644 (file)
@@ -38,7 +38,7 @@ osi_VM_FlushVCache(avc, slept)
     struct vcache *avc;
     int *slept;
 {
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
 #ifdef AFS_DARWIN14_ENV
     if (UBCINFOEXISTS(vp))
        return EBUSY;
@@ -80,7 +80,7 @@ void
 osi_VM_StoreAllSegments(avc)
     struct vcache *avc;
 {
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
     ReleaseWriteLock(&avc->lock);
     AFS_GUNLOCK();
     if (UBCINFOEXISTS(vp)) {
@@ -105,7 +105,7 @@ osi_VM_TryToSmush(avc, acred, sync)
     struct AFS_UCRED *acred;
     int sync;
 {
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
     void *object;
     kern_return_t kret;
     off_t size, lastpg;
@@ -134,7 +134,7 @@ osi_VM_FlushPages(avc, credp)
     struct vcache *avc;
     struct AFS_UCRED *credp;
 {
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
     void *object;
     kern_return_t kret;
     off_t size;
@@ -161,7 +161,7 @@ osi_VM_Truncate(avc, alen, acred)
     int alen;
     struct AFS_UCRED *acred;
 {
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
     if (UBCINFOEXISTS(vp))  {
        ubc_setsize(vp, alen);
     }
@@ -177,7 +177,7 @@ void osi_VM_TryReclaim(avc, slept)
      int *slept;
 {
     struct proc *p=current_proc();
-    struct vnode *vp=(struct vnode *)avc;
+    struct vnode *vp=AFSTOV(avc);
     void *obj;
 
     if (slept)
@@ -276,7 +276,7 @@ void osi_VM_TryReclaim(avc, slept)
 void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) {
 
     void *object;
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
 
 #ifdef AFS_DARWIN14_ENV
     offset=trunc_page(offset);
@@ -322,7 +322,7 @@ void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) {
 }
 int osi_VM_Setup(struct vcache *avc) {
    int error;
-   struct vnode *vp=(struct vnode *)avc;
+   struct vnode *vp=AFSTOV(avc);
 
    if (UBCISVALID(vp) && (avc->states & CStatd)) {
       if (!UBCINFOEXISTS(vp) && !ISSET(vp->v_flag, VTERMINATE)) {
index 7b92105..0aa0102 100644 (file)
@@ -158,7 +158,7 @@ struct vop_lookup_args /* {
     if (flags & ISDOTDOT) 
        VOP_UNLOCK(dvp, 0, p);
     AFS_GLOCK();
-    error = afs_lookup((struct vcache *)dvp, name, &vcp, cnp->cn_cred);
+    error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
         if (flags & ISDOTDOT) 
@@ -172,7 +172,7 @@ struct vop_lookup_args /* {
        *ap->a_vpp = 0;
        return (error);
     }
-    vp = (struct vnode *)vcp;  /* always get a node if no error */
+    vp = AFSTOV(vcp);  /* always get a node if no error */
 
     /* The parent directory comes in locked.  We unlock it on return
        unless the caller wants it left locked.
@@ -224,7 +224,7 @@ afs_vop_create(ap)
 
     /* vnode layer handles excl/nonexcl */
     AFS_GLOCK();
-    error = afs_create((struct vcache *)dvp, name, ap->a_vap, NONEXCL,
+    error = afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL,
                       ap->a_vap->va_mode, &vcp,
                       cnp->cn_cred);
     AFS_GUNLOCK();
@@ -236,11 +236,11 @@ afs_vop_create(ap)
     }
 
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE| LK_RETRY, p);
-        if (UBCINFOMISSING((struct vnode *)vcp) ||
-            UBCINFORECLAIMED((struct vnode *)vcp))
-                ubc_info_init((struct vnode *)vcp);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(*ap->a_vpp, LK_EXCLUSIVE| LK_RETRY, p);
+        if (UBCINFOMISSING(*ap->a_vpp) ||
+            UBCINFORECLAIMED(*ap->a_vpp)
+                ubc_info_init(*ap->a_vpp);
     }
     else *ap->a_vpp = 0;
 
@@ -275,11 +275,11 @@ afs_vop_open(ap)
        } */ *ap;
 {
     int error;
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     AFS_GLOCK();
     error = afs_open(&vc, ap->a_mode, ap->a_cred);
 #ifdef DIAGNOSTIC
-    if ((struct vnode *)vc != ap->a_vp)
+    if (AFSTOV(vc) != ap->a_vp)
        panic("AFS open changed vnode!");
 #endif
     afs_BozonLock(&vc->pvnLock, vc);
@@ -323,7 +323,7 @@ afs_vop_access(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_access((struct vcache *)ap->a_vp, ap->a_mode, ap->a_cred);
+    code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -338,7 +338,7 @@ afs_vop_getattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_getattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -353,7 +353,7 @@ afs_vop_setattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_setattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -367,7 +367,7 @@ afs_vop_read(ap)
        } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
     osi_FlushPages(avc);        /* hold bozon lock, but not basic vnode lock */
@@ -402,7 +402,7 @@ afs_vop_pagein(ap)
     int nocommit = flags & UPL_NOCOMMIT;
 
     int code;
-    struct vcache *tvc=(struct vcache *)vp;
+    struct vcache *tvc=VTOAFS(vp);
 
     if (UBCINVALID(vp)) {
 #if DIAGNOSTIC
@@ -479,7 +479,7 @@ afs_vop_write(ap)
        } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     void *object;
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
@@ -488,7 +488,7 @@ afs_vop_write(ap)
        ubc_clean(ap->a_vp, 1);
     if (UBCINFOEXISTS(ap->a_vp))
        osi_VM_NukePages(ap->a_vp, ap->a_uio->uio_offset, ap->a_uio->uio_resid);
-    code=afs_write((struct vcache *)ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+    code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
     afs_BozonUnlock(&avc->pvnLock, avc);
     AFS_GUNLOCK();
     return code;
@@ -520,7 +520,7 @@ afs_vop_pageout(ap)
     int nocommit = flags & UPL_NOCOMMIT;
 
     int code;
-    struct vcache *tvc=(struct vcache *)vp;
+    struct vcache *tvc=VTOAFS(vp);
 
     if (UBCINVALID(vp)) {
 #if DIAGNOSTIC
@@ -647,7 +647,7 @@ afs_vop_ioctl(ap)
                struct proc *a_p;
        } */ *ap;
 {
-    struct vcache *tvc = (struct vcache *)ap->a_vp;
+    struct vcache *tvc = VTOAFS(ap->a_vp);
     struct afs_ioctl data;
     int error = 0;
   
@@ -717,9 +717,9 @@ afs_vop_fsync(ap)
     AFS_GLOCK();
     /*vflushbuf(vp, wait);*/
     if (ap->a_cred)
-      error=afs_fsync((struct vcache *)vp, ap->a_cred);
+      error=afs_fsync(VTOAFS(vp), ap->a_cred);
     else
-      error=afs_fsync((struct vcache *)vp, &afs_osi_cred);
+      error=afs_fsync(VTOAFS(vp), &afs_osi_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -752,7 +752,7 @@ afs_vop_remove(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error =  afs_remove((struct vcache *)dvp, name, cnp->cn_cred);
+    error =  afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     cache_purge(vp);
     if (!error && UBCINFOEXISTS(vp)) {
@@ -809,7 +809,7 @@ afs_vop_link(ap)
        goto out;
     }
     AFS_GLOCK();
-    error = afs_link((struct vcache *)vp, (struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
     if (dvp != vp)
@@ -901,7 +901,7 @@ abortit:
 
     AFS_GLOCK();
     /* XXX use "from" or "to" creds? NFS uses "to" creds */
-    error = afs_rename((struct vcache *)fdvp, fname, (struct vcache *)tdvp, tname, tcnp->cn_cred);
+    error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
     AFS_GUNLOCK();
 
     VOP_UNLOCK(fvp, 0, p);
@@ -942,7 +942,7 @@ afs_vop_mkdir(ap)
        panic("afs_vop_mkdir: no name");
 #endif
     AFS_GLOCK();
-    error = afs_mkdir((struct vcache *)dvp, name, vap, &vcp, cnp->cn_cred);
+    error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
        VOP_ABORTOP(dvp, cnp);
@@ -951,8 +951,8 @@ afs_vop_mkdir(ap)
        return(error);
     }
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE|LK_RETRY, p);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(*ap->a_vpp, LK_EXCLUSIVE|LK_RETRY, p);
     } else
        *ap->a_vpp = 0;
     DROPNAME();
@@ -983,7 +983,7 @@ afs_vop_rmdir(ap)
     }
 
     AFS_GLOCK();
-    error = afs_rmdir((struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
     vput(dvp);
@@ -1007,7 +1007,7 @@ afs_vop_symlink(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error = afs_symlink((struct vcache *)dvp, name, ap->a_vap, ap->a_target,
+    error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
                        cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
@@ -1033,7 +1033,7 @@ afs_vop_readdir(ap)
           ap->a_ncookies); */
     off=ap->a_uio->uio_offset;
     AFS_GLOCK();
-    error= afs_readdir((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred,
+    error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
                       ap->a_eofflag);
     AFS_GUNLOCK();
     if (!error && ap->a_ncookies != NULL) {
@@ -1079,7 +1079,7 @@ afs_vop_readlink(ap)
     int error;
 /*    printf("readlink %x\n", ap->a_vp);*/
     AFS_GLOCK();
-    error= afs_readlink((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred);
+    error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -1099,7 +1099,7 @@ afs_vop_inactive(ap)
        vprint("afs_vop_inactive(): pushing active", vp);
 
     AFS_GLOCK();
-    afs_InactiveVCache((struct vcache *)vp, 0);   /* decrs ref counts */
+    afs_InactiveVCache(VTOAFS(vp), 0);   /* decrs ref counts */
     AFS_GUNLOCK();
     VOP_UNLOCK(vp, 0, ap->a_p);
     return 0;
@@ -1119,7 +1119,7 @@ afs_vop_reclaim(ap)
 
 #if 0 
     AFS_GLOCK();
-    error = afs_FlushVCache((struct vcache *)vp, &sl); /* tosses our stuff from vnode */
+    error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */
     AFS_GUNLOCK();
     ubc_unlink(vp);
     if (!error && vp->v_data)
@@ -1144,7 +1144,7 @@ afs_vop_lock(ap)
        } */ *ap;
 {
        register struct vnode *vp = ap->a_vp;
-       register struct vcache *avc = (struct vcache *)vp;
+       register struct vcache *avc = VTOAFS(vp);
 
        if (vp->v_tag == VT_NON)
                return (ENOENT);
@@ -1159,7 +1159,7 @@ afs_vop_unlock(ap)
        } */ *ap;
 {
     struct vnode *vp = ap->a_vp;
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
     return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
             &vp->v_interlock, ap->a_p));
 
@@ -1212,7 +1212,7 @@ afs_vop_print(ap)
        } */ *ap;
 {
     register struct vnode *vp = ap->a_vp;
-    register struct vcache *vc = (struct vcache *)ap->a_vp;
+    register struct vcache *vc = VTOAFS(ap->a_vp);
     int s = vc->states;
     char buf[20];
     printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
@@ -1239,7 +1239,7 @@ afs_vop_islocked(ap)
                struct vnode *a_vp;
        } */ *ap;
 {
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     return lockstatus(&vc->rwlock);
 }
 
@@ -1299,7 +1299,7 @@ afs_vop_advlock(ap)
     cr=*p->p_cred->pc_ucred;
     pcred_unlock(p);
     AFS_GLOCK();
-    error= afs_lockctl((struct vcache *)ap->a_vp, ap->a_fl, ap->a_op, &cr,
+    error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr,
                       (int) ap->a_id);
     AFS_GUNLOCK();
     return error;
index 4f76be2..78b2630 100644 (file)
@@ -39,7 +39,7 @@ extern struct timeval time;
 #define afs_bufferpages bufpages
 
 #define osi_vnhold(avc,r)  do { \
-       if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
+       if ((avc)->vrefCount) { VN_HOLD(AFSTOV(avc)); } \
        else osi_Panic("refcnt==0");  } while(0)
 
 #define        gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
index ccdd2aa..2a9d630 100644 (file)
@@ -148,15 +148,16 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp)
        }
     }
     if (tvp) {
+       struct vnode *vp = AFSTOV(tvp);
        AFS_GUNLOCK();
-       VN_HOLD((struct vnode *)tvp);
-       VN_LOCK((struct vnode *)tvp);
-       tvp->v.v_flag |= VROOT;     /* No-op on Ultrix 2.2 */
-       VN_UNLOCK((struct vnode *)tvp);
+       VN_HOLD(vp);
+       VN_LOCK(vp);
+       vp->v_flag |= VROOT;        /* No-op on Ultrix 2.2 */
+       VN_UNLOCK(vp);
        AFS_GLOCK();
 
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = vp;
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
@@ -273,7 +274,7 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp)
     long addr[2];
     register struct cell *tcell;
     int rootvp = 0;
-    struct vcache *avc = (struct vcache *)avn;
+    struct vcache *avc = VTOAFS(avn);
 
     AFS_GLOCK();
     AFS_STATCNT(afs_fid);
@@ -299,7 +300,7 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp)
        fidp->fid_reserved = AFS_XLATOR_MAGIC;
        addr[0] = (long)avc;
        AFS_GUNLOCK();
-       VN_HOLD((struct vnode *)avc);
+       VN_HOLD(AFSTOV(avc));
        AFS_GLOCK();
     }
 
index 3d166f8..7d25912 100644 (file)
@@ -50,7 +50,7 @@ osi_VM_FlushVCache(avc, slept)
        return EBUSY;
 
     AFS_GUNLOCK();
-    ubc_invalidate(((struct vnode *)avc)->v_object, 0, 0, B_INVAL);
+    ubc_invalidate(AFSTOV(avc)->v_object, 0, 0, B_INVAL);
     AFS_GLOCK();
 
     return 0;
@@ -132,7 +132,7 @@ osi_VM_StoreAllSegments(avc)
 {
     ReleaseWriteLock(&avc->lock);
     AFS_GUNLOCK();
-    osi_ubc_flush_dirty_and_wait((struct vnode *)avc, 0);
+    osi_ubc_flush_dirty_and_wait(AFSTOV(avc), 0);
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock,94);
 }
@@ -154,8 +154,8 @@ osi_VM_TryToSmush(avc, acred, sync)
 {
     ReleaseWriteLock(&avc->lock);
     AFS_GUNLOCK();
-    osi_ubc_flush_dirty_and_wait((struct vnode *)avc, 0);
-    ubc_invalidate(((struct vnode *)avc)->v_object, 0, 0, B_INVAL);
+    osi_ubc_flush_dirty_and_wait(AFSTOV(avc), 0);
+    ubc_invalidate(AFSTOV(avc)->v_object, 0, 0, B_INVAL);
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock,59);
 }
@@ -169,8 +169,8 @@ osi_VM_FlushPages(avc, credp)
     struct vcache *avc;
     struct AFS_UCRED *credp;
 {
-    ubc_flush_dirty(((struct vnode *)avc)->v_object, 0);
-    ubc_invalidate(((struct vnode *)avc)->v_object, 0, 0, B_INVAL);
+    ubc_flush_dirty(AFSTOV(avc)->v_object, 0);
+    ubc_invalidate(AFSTOV(avc)->v_object, 0, 0, B_INVAL);
 }
 
 /* Purge pages beyond end-of-file, when truncating a file.
@@ -185,6 +185,6 @@ osi_VM_Truncate(avc, alen, acred)
     int alen;
     struct AFS_UCRED *acred;
 {
-    ubc_invalidate(((struct vnode *)avc)->v_object, alen,
+    ubc_invalidate(AFSTOV(avc)->v_object, alen,
                         MAXINT - alen, B_INVAL);
 }
index 0548bec..0912598 100644 (file)
@@ -516,10 +516,10 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred)
        ReleaseWriteLock(&avc->lock);
        AFS_GUNLOCK();
 #ifdef AFS_DUX50_ENV
-       code = ubc_lookup(((struct vnode *)avc)->v_object, pageBase,
+       code = ubc_lookup(AFSTOV(avc)->v_object, pageBase,
                          PAGE_SIZE, PAGE_SIZE, &page, &flags, NULL);
 #else
-       code = ubc_lookup(((struct vnode *)avc)->v_object, pageBase,
+       code = ubc_lookup(AFSTOV(avc)->v_object, pageBase,
                          PAGE_SIZE, PAGE_SIZE, &page, &flags);
 #endif
        AFS_GLOCK();
@@ -538,7 +538,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred)
             */
            if ((uio->uio_rw == UIO_WRITE) &&
                ((pageOffset == 0 && (size == PAGE_SIZE || fileBase >= avc->m.Length)))) {
-               struct vnode *vp = (struct vnode *)avc;
+               struct vnode *vp = AFSTOV(avc);
                /* we're doing a write operation past eof; no need to read it */
                newpage = 1;
                AFS_GUNLOCK();
@@ -553,7 +553,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred)
                bp = ubc_bufalloc(page, 1, PAGE_SIZE, 1, B_READ);
                AFS_GLOCK();
                bp->b_dev = 0;
-               bp->b_vp = (struct vnode *)avc;
+               bp->b_vp = AFSTOV(avc);
                bp->b_blkno = btodb(pageBase);
                ReleaseWriteLock(&avc->lock);
                code = afs_ustrategy(bp, cred); /* do the I/O */
@@ -595,12 +595,12 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred)
                    /* We released the page, so we can get a null page
                     * list if another thread calls the strategy routine.
                     */
-                   pl = ubc_dirty_kluster(((struct vnode *)avc)->v_object, 
+                   pl = ubc_dirty_kluster(AFSTOV(avc)->v_object, 
                           NULL, toffset, 0, B_WANTED, FALSE, &kpcnt);
                    if (pl) {
                        bp = ubc_bufalloc(pl, 1, PAGE_SIZE, 1, B_WRITE);
                        bp->b_dev = 0;
-                       bp->b_vp = (struct vnode *)avc;
+                       bp->b_vp = AFSTOV(avc);
                        bp->b_blkno = btodb(pageBase);
                        AFS_GLOCK();
                        code = afs_ustrategy(bp, cred); /* do the I/O */
@@ -642,7 +642,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred)
     afs_BozonUnlock(&avc->pvnLock, avc);
     if (DO_FLUSH || (!newpage && (cnt < 10))) {
        AFS_GUNLOCK();
-       ubc_flush_dirty(((struct vnode *)avc)->v_object, flags); 
+       ubc_flush_dirty(AFSTOV(avc)->v_object, flags); 
        AFS_GLOCK();
     }
 
@@ -702,7 +702,7 @@ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred)
 {
     struct vp_mmap_args args;
     register struct vp_mmap_args *ap = &args;
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = AFSTOV(avc);
     int code;
     struct vrequest treq;
 #if    !defined(DYNEL)
@@ -767,7 +767,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz,
     vm_page_t *pagep;
     vm_offset_t off;
 
-   struct vcache *avc =  (struct vcache *)vop->vu_vp;
+   struct vcache *avc =  VTOAFS(vop->vu_vp);
 
     /* first, obtain the proper lock for the VM system */
 
@@ -799,10 +799,10 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz,
        ReleaseWriteLock(&avc->lock);
        AFS_GUNLOCK();
 #ifdef AFS_DUX50_ENV
-       code = ubc_lookup(((struct vnode *)avc)->v_object, off,
+       code = ubc_lookup(AFSTOV(avc)->v_object, off,
                        PAGE_SIZE, PAGE_SIZE, pagep, &flags, NULL);
 #else
-       code = ubc_lookup(((struct vnode *)avc)->v_object, off,
+       code = ubc_lookup(AFSTOV(avc)->v_object, off,
                        PAGE_SIZE, PAGE_SIZE, pagep, &flags);
 #endif
        AFS_GLOCK();
@@ -812,7 +812,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz,
        }
        if(flags & B_NOCACHE) {         /* if (page) */
            if ((rw & B_WRITE) && (offset+len >= avc->m.Length)) {
-               struct vnode *vp = (struct vnode *)avc;
+               struct vnode *vp = AFSTOV(avc);
                /* we're doing a write operation past eof; no need to read it */
                AFS_GUNLOCK();
                ubc_page_zero(*pagep, 0, PAGE_SIZE);
@@ -826,7 +826,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz,
                bp = ubc_bufalloc(*pagep, 1, PAGE_SIZE, 1, B_READ);
                AFS_GLOCK();
                bp->b_dev = 0;
-               bp->b_vp = (struct vnode *)avc;
+               bp->b_vp = AFSTOV(avc);
                bp->b_blkno = btodb(off);
                ReleaseWriteLock(&avc->lock);
                code = afs_ustrategy(bp, cred); /* do the I/O */
@@ -876,8 +876,8 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred)
     struct ucred *cred;
 {
     register afs_int32 code=0;
-    struct vcache *avc = (struct vcache *)vop->vu_vp;
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = vop->vu_vp;
+    struct vcache *avc = VTOAFS(vp);
     int i;
 
     AFS_GLOCK();
@@ -912,7 +912,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred)
        bp = ubc_bufalloc(page, 1, PAGE_SIZE, 1, B_WRITE);
        AFS_GLOCK();
        bp->b_dev = 0;
-       bp->b_vp = (struct vnode *)avc;
+       bp->b_vp = AFSTOV(avc);
        bp->b_blkno = btodb(page->pg_offset);
        ReleaseWriteLock(&avc->lock);
        code = afs_ustrategy(bp, cred); /* do the I/O */
@@ -996,7 +996,7 @@ mp_afs_bread(vp, lbn, bpp, cred)
        uio.afsio_offset = offset;
        uio.afsio_resid = fsbsize;
        *bpp = 0;
-       error = afs_read((struct vcache *)vp, &uio, cred, lbn, bpp, 0);
+       error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0);
        if (error) {
                afs_bread_freebp = bp;
                AFS_GUNLOCK();
index aba84ac..605e399 100644 (file)
@@ -137,10 +137,10 @@ afs_root(struct mount *mp,
     if (tvp) {
         osi_vnhold(tvp,0);
     AFS_GUNLOCK();
-        vn_lock((struct vnode *)tvp, LK_EXCLUSIVE | LK_RETRY, p);
+        vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
     AFS_GLOCK();
        afs_globalVFS = mp;
-       *vpp = (struct vnode *) tvp;
+       *vpp = AFSTOV(tvp);
         tvp->v.v_flag |= VROOT;
     }
 
index e898014..49d87bf 100644 (file)
@@ -165,7 +165,7 @@ osi_VM_TryToSmush(avc, acred, sync)
        vm_object_page_remove(obj, 0, 0, FALSE);
     }
     simple_unlock(&vp->v_interlock);
-    /*vinvalbuf(((struct vnode *)avc),0, NOCRED, curproc, 0,0);*/
+    /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0);*/
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock,59);
 }
@@ -189,7 +189,7 @@ osi_VM_FlushPages(avc, credp)
        vm_object_page_remove(obj, 0, 0, FALSE);
     }
     simple_unlock(&vp->v_interlock);
-    /*vinvalbuf(((struct vnode *)avc),0, NOCRED, curproc, 0,0);*/
+    /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0);*/
 }
 
 /* Purge pages beyond end-of-file, when truncating a file.
@@ -204,5 +204,5 @@ osi_VM_Truncate(avc, alen, acred)
     int alen;
     struct AFS_UCRED *acred;
 {
-    vnode_pager_setsize(((struct vnode *)avc), alen);
+    vnode_pager_setsize(AFSTOV(avc), alen);
 }
index f5d85e2..c48f1c2 100644 (file)
@@ -140,7 +140,7 @@ struct vop_lookup_args /* {
     if (flags & ISDOTDOT) 
        VOP_UNLOCK(dvp, 0, p);
     AFS_GLOCK();
-    error = afs_lookup((struct vcache *)dvp, name, &vcp, cnp->cn_cred);
+    error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
         if (flags & ISDOTDOT) 
@@ -154,7 +154,7 @@ struct vop_lookup_args /* {
        *ap->a_vpp = 0;
        return (error);
     }
-    vp = (struct vnode *)vcp;  /* always get a node if no error */
+    vp = AFSTOV(vcp);  /* always get a node if no error */
 
     /* The parent directory comes in locked.  We unlock it on return
        unless the caller wants it left locked.
@@ -205,7 +205,7 @@ afs_vop_create(ap)
     p=cnp->cn_proc;
 
     AFS_GLOCK();
-    error = afs_create((struct vcache *)dvp, name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
+    error = afs_create(VTOAFS(dvp), name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
                       ap->a_vap->va_mode, &vcp,
                       cnp->cn_cred);
     AFS_GUNLOCK();
@@ -215,8 +215,8 @@ afs_vop_create(ap)
     }
 
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE| LK_RETRY, p);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(AFSTOV(vcp), LK_EXCLUSIVE| LK_RETRY, p);
     }
     else *ap->a_vpp = 0;
 
@@ -267,12 +267,12 @@ afs_vop_open(ap)
 {
     int error;
     int bad;
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     bad=0;
     AFS_GLOCK();
     error = afs_open(&vc, ap->a_mode, ap->a_cred);
 #ifdef DIAGNOSTIC
-    if ((struct vnode *)vc != ap->a_vp)
+    if (AFSTOV(vc) != ap->a_vp)
        panic("AFS open changed vnode!");
 #endif
     afs_BozonLock(&vc->pvnLock, vc);
@@ -316,7 +316,7 @@ afs_vop_access(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_access((struct vcache *)ap->a_vp, ap->a_mode, ap->a_cred);
+    code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -331,7 +331,7 @@ afs_vop_getattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_getattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -346,7 +346,7 @@ afs_vop_setattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_setattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }int
@@ -360,7 +360,7 @@ afs_vop_read(ap)
 } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
     osi_FlushPages(avc);        /* hold bozon lock, but not basic vnode lock */
@@ -385,7 +385,7 @@ afs_vop_getpages(ap)
     struct iovec iov;
     struct buf *bp;
     vm_offset_t kva;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
 
     if (avc->v.v_object == NULL) {
         printf("afs_getpages: called with non-merged cache vnode??\n");
@@ -500,11 +500,11 @@ afs_vop_write(ap)
        } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
     osi_FlushPages(avc);        /* hold bozon lock, but not basic vnode lock */
-    code=afs_write((struct vcache *)ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+    code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
     afs_BozonUnlock(&avc->pvnLock, avc);
     AFS_GUNLOCK();
     return code;
@@ -527,7 +527,7 @@ afs_vop_putpages(ap)
     struct iovec iov;
     struct buf *bp;
     vm_offset_t kva;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
 
     if (avc->v.v_object == NULL) {
         printf("afs_putpages: called with non-merged cache vnode??\n");
@@ -586,7 +586,7 @@ afs_vop_ioctl(ap)
                struct proc *a_p;
        } */ *ap;
 {
-    struct vcache *tvc = (struct vcache *)ap->a_vp;
+    struct vcache *tvc = VTOAFS(ap->a_vp);
     struct afs_ioctl data;
     int error = 0;
   
@@ -655,9 +655,9 @@ afs_vop_fsync(ap)
     AFS_GLOCK();
     /*vflushbuf(vp, wait);*/
     if (ap->a_cred)
-      error=afs_fsync((struct vcache *)vp, ap->a_cred);
+      error=afs_fsync(VTOAFS(vp), ap->a_cred);
     else
-      error=afs_fsync((struct vcache *)vp, &afs_osi_cred);
+      error=afs_fsync(VTOAFS(vp), &afs_osi_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -676,7 +676,7 @@ afs_vop_remove(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error =  afs_remove((struct vcache *)dvp, name, cnp->cn_cred);
+    error =  afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     cache_purge(vp);
     DROPNAME();
@@ -710,7 +710,7 @@ afs_vop_link(ap)
        goto out;
     }
     AFS_GLOCK();
-    error = afs_link((struct vcache *)vp, (struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     if (dvp != vp)
        VOP_UNLOCK(vp,0, p);
@@ -811,7 +811,7 @@ abortit:
 
     AFS_GLOCK();
     /* XXX use "from" or "to" creds? NFS uses "to" creds */
-    error = afs_rename((struct vcache *)fdvp, fname, (struct vcache *)tdvp, tname, tcnp->cn_cred);
+    error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
     AFS_GUNLOCK();
 
     FREE(fname, M_TEMP);
@@ -849,7 +849,7 @@ afs_vop_mkdir(ap)
        panic("afs_vop_mkdir: no name");
 #endif
     AFS_GLOCK();
-    error = afs_mkdir((struct vcache *)dvp, name, vap, &vcp, cnp->cn_cred);
+    error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
        vput(dvp);
@@ -857,8 +857,8 @@ afs_vop_mkdir(ap)
        return(error);
     }
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE|LK_RETRY, p);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(AFSTOV(vcp), LK_EXCLUSIVE|LK_RETRY, p);
     } else
        *ap->a_vpp = 0;
     DROPNAME();
@@ -879,7 +879,7 @@ afs_vop_rmdir(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error = afs_rmdir((struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
     return error;
@@ -901,7 +901,7 @@ afs_vop_symlink(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error = afs_symlink((struct vcache *)dvp, name, ap->a_vap, ap->a_target,
+    error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
                        cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
@@ -925,7 +925,7 @@ afs_vop_readdir(ap)
           ap->a_ncookies); */
     off=ap->a_uio->uio_offset;
     AFS_GLOCK();
-    error= afs_readdir((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred,
+    error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
                       ap->a_eofflag);
     AFS_GUNLOCK();
     if (!error && ap->a_ncookies != NULL) {
@@ -971,7 +971,7 @@ afs_vop_readlink(ap)
     int error;
 /*    printf("readlink %x\n", ap->a_vp);*/
     AFS_GLOCK();
-    error= afs_readlink((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred);
+    error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -991,7 +991,7 @@ afs_vop_inactive(ap)
        vprint("afs_vop_inactive(): pushing active", vp);
 
     AFS_GLOCK();
-    afs_InactiveVCache((struct vcache *)vp, 0);   /* decrs ref counts */
+    afs_InactiveVCache(VTOAFS(vp), 0);   /* decrs ref counts */
     AFS_GUNLOCK();
     VOP_UNLOCK(vp, 0, ap->a_p);
     return 0;
@@ -1011,7 +1011,7 @@ afs_vop_reclaim(ap)
 
 #if 0 
     AFS_GLOCK();
-    error = afs_FlushVCache((struct vcache *)vp, &sl); /* tosses our stuff from vnode */
+    error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */
     AFS_GUNLOCK();
     ubc_unlink(vp);
     if (!error && vp->v_data)
@@ -1036,7 +1036,7 @@ afs_vop_lock(ap)
        } */ *ap;
 {
        register struct vnode *vp = ap->a_vp;
-       register struct vcache *avc = (struct vcache *)vp;
+       register struct vcache *avc = VTOAFS(vp);
 
        if (vp->v_tag == VT_NON)
                return (ENOENT);
@@ -1051,7 +1051,7 @@ afs_vop_unlock(ap)
        } */ *ap;
 {
     struct vnode *vp = ap->a_vp;
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
     return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
             &vp->v_interlock, ap->a_p));
 
@@ -1102,7 +1102,7 @@ afs_vop_print(ap)
        } */ *ap;
 {
     register struct vnode *vp = ap->a_vp;
-    register struct vcache *vc = (struct vcache *)ap->a_vp;
+    register struct vcache *vc = VTOAFS(ap->a_vp);
     int s = vc->states;
     printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
           vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens,
@@ -1118,7 +1118,7 @@ afs_vop_islocked(ap)
                struct vnode *a_vp;
        } */ *ap;
 {
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     return lockstatus(&vc->rwlock, ap->a_p);
 }
 
@@ -1140,7 +1140,7 @@ afs_vop_advlock(ap)
     struct ucred cr;
     cr=*p->p_cred->pc_ucred;
     AFS_GLOCK();
-    error= afs_lockctl((struct vcache *)ap->a_vp, ap->a_fl, ap->a_op, &cr,
+    error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr,
                       (int) ap->a_id);
     AFS_GUNLOCK();
     return error;
index 46a97a2..edc948d 100644 (file)
@@ -32,7 +32,7 @@ extern struct timeval time;
 #define        AFS_UCRED       ucred
 #define        AFS_PROC        proc_t
 
-#define osi_vnhold(avc, r)  do { VN_HOLD((struct vnode *)(avc)); } while(0)
+#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(aresid),0)
 
index 96e0093..26624c3 100644 (file)
@@ -90,11 +90,11 @@ int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1)
        }
     }
     if (tvp) {
-       VN_HOLD((struct vnode *)tvp);
-       SET_V_FLAG( ((struct vnode *)tvp), VROOT);
+       VN_HOLD(AFSTOV(tvp));
+       SET_V_FLAG(AFSTOV(tvp), VROOT);
 
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
index 89b50d1..54d89da 100644 (file)
@@ -68,7 +68,7 @@ osi_VM_TryToSmush(avc, acred, sync)
     struct AFS_UCRED *acred;
     int sync;
 {
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = AFSTOV(avc);
 
     /* Flush the delayed write blocks associated with this vnode
      * from the buffer cache
index 799a998..86de8e4 100644 (file)
@@ -222,7 +222,7 @@ afs_bread(vp, lbn, bpp)
        uio.uio_fpflags = 0;
        *bpp = 0;
 
-       error = afs_read((struct vcache *)vp, &uio, p_cred(u.u_procp),
+       error = afs_read(VTOAFS(vp), &uio, p_cred(u.u_procp),
                         lbn, bpp, 0);
        if (error) {
                afs_bread_freebp = bp;
@@ -270,7 +270,7 @@ afs_inactive(avc, acred)
     register struct vcache *avc;
     struct AFS_UCRED *acred;
 {
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = AFSTOV(avc);
     ulong_t context;
     lock_t *sv_lock;
     if (afs_shuttingdown) return ;
@@ -1982,7 +1982,7 @@ afs_ioctl(vp, com, data, flag, cred)
           afsioctl.out      = ai->out;
           afsioctl.in_size  = ai->in_size;
           afsioctl.out_size = ai->out_size;
-          error = HandleIoctl((struct vcache *)vp, com, &afsioctl);
+          error = HandleIoctl(VTOAFS(vp), com, &afsioctl);
           return(error);
        }
        return(ENOTTY);
@@ -2479,7 +2479,7 @@ afs_hp_strategy(bp)
               we can't read, and finally call iodone(bp).  File is
               in bp->b_vp. Credentials are from u area??
             */
-          code = afs_rdwr((struct vcache *)bp->b_vp,&tuio,UIO_READ,0,kt_cred(t));
+          code = afs_rdwr(VTOAFS(bp->b_vp),&tuio,UIO_READ,0,kt_cred(t));
           if (code == 0) 
              if (tuio.afsio_resid > 0) 
              {
@@ -2489,7 +2489,7 @@ afs_hp_strategy(bp)
 
              }
        } else 
-          code = afs_rdwr((struct vcache *)bp->b_vp,&tuio,UIO_WRITE,0,kt_cred(t));
+          code = afs_rdwr(VTOAFS(bp->b_vp),&tuio,UIO_WRITE,0,kt_cred(t));
 
     /* Remap back to the user's space */
     hdl_remap_bp(bp);
index 2966e90..241f925 100644 (file)
@@ -28,7 +28,7 @@ extern time_t time;
 
 #define        AFS_UCRED       ucred
 
-#define osi_vnhold(avc, r)  do { VN_HOLD((struct vnode *)(avc)); } while(0)
+#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
 
 #undef afs_osi_Alloc_NoSleep
 extern void *afs_osi_Alloc_NoSleep(size_t size);
@@ -379,7 +379,7 @@ extern long afs_global_owner;
 #undef OSI_VC_DECL
 #define OSI_VC_DECL(V)  bhv_desc_t *bhv_##V
 #undef OSI_VC_CONVERT
-#define OSI_VC_CONVERT(V) struct vcache * V = (struct vcache*)BHV_TO_VNODE(bhv_##V);
+#define OSI_VC_CONVERT(V) struct vcache * V = VTOAFS(BHV_TO_VNODE(bhv_##V));
 #undef OSI_VFS_ARG
 #define OSI_VFS_ARG(V) bhv_##V
 #undef OSI_VFS_DECL
index 93d3bd0..e93fe01 100644 (file)
@@ -242,7 +242,7 @@ cred_t *cr;
      * rootvp gets lots of ref counts
      */
     if (rootvp) {
-       tvc = (struct vcache *)rootvp;
+       tvc = VTOAFS(rootvp);
         if (tvc->opens || CheckLock(&tvc->lock) || LockWaiters(&tvc->lock)) {
            ReleaseWriteLock(&afs_xvcache);
            return EBUSY;
@@ -290,13 +290,13 @@ afs_root (OSI_VFS_ARG(afsp), avpp)
     }
     if (tvp) {
        int s;
-       VN_HOLD((struct vnode *)tvp);
-       s = VN_LOCK((struct vnode *)tvp);
-       tvp->v.v_flag |= VROOT; 
-       VN_UNLOCK((struct vnode *)tvp, s);
+       VN_HOLD(AFSTOV(tvp));
+       s = VN_LOCK(AFSTOV(tvp));
+       AFSTOV(tvp)->v_flag |= VROOT;   
+       VN_UNLOCK(AFSTOV(tvp), s);
 
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
index 2ee354c..d53944b 100644 (file)
@@ -156,7 +156,7 @@ osi_VM_TryToSmush(avc, acred, sync)
     osi_Assert(OSI_GET_LOCKID() != avc->vc_rwlockid);
     if (((vnode_t *)avc)->v_type == VREG && AFS_VN_MAPPED(((vnode_t *)avc)))
         remapf(((vnode_t *)avc), 0, 0);
-    PTOSSVP((struct vnode *)avc, (off_t)0, (off_t)MAXLONG);
+    PTOSSVP(AFSTOV(avc), (off_t)0, (off_t)MAXLONG);
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock,62);
 }
@@ -195,10 +195,10 @@ osi_VM_StoreAllSegments(avc)
 
     /* Write out dirty pages list to avoid B_DELWRI buffers. */
     while (VN_GET_DPAGES((vnode_t*)avc)) {
-       pdflush((struct vnode*)avc, 0);
+       pdflush(AFSTOV(avc), 0);
     }
 
-    PFLUSHVP((struct vnode *)avc, (off_t)avc->m.Length, (off_t)0, error);
+    PFLUSHVP(AFSTOV(avc), (off_t)avc->m.Length, (off_t)0, error);
     AFS_GLOCK();
     if (error) {
        /*
index e2838ff..50f6df2 100644 (file)
@@ -349,7 +349,7 @@ static int afsrwvp(register struct vcache *avc,
                   struct cred *cr)
 #endif
 {
-    register struct vnode *vp = (struct vnode *)avc;
+    register struct vnode *vp = AFSTOV(avc);
     struct buf *bp;
     daddr_t bn;
     size_t acnt, cnt;
@@ -887,7 +887,7 @@ static int afs_addmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot,
         struct cred *cr;
 {
     OSI_VC_CONVERT(avc)
-    struct vnode *vp = (struct vnode*)avc;
+    struct vnode *vp = AFSTOV(avc);
 
     if (vp->v_flag & VNOMAP)
        return ENOSYS;
@@ -919,7 +919,7 @@ static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot,
         struct cred *acred;
 {
     OSI_VC_CONVERT(avc)
-    struct vnode *vp = (struct vnode*)avc;
+    struct vnode *vp = AFSTOV(avc);
     register struct brequest *tb;
     struct vrequest treq;
     afs_int32 code;
@@ -1013,7 +1013,7 @@ static int afs_map(OSI_VC_ARG(avc), off, prp, addrp, len, prot, maxprot,
 #endif
 {
     OSI_VC_CONVERT(avc)
-    struct vnode *vp = (struct vnode*)avc;
+    struct vnode *vp = AFSTOV(avc);
     struct vrequest treq;
     int error;
 
@@ -1209,7 +1209,7 @@ afs_reclaim(OSI_VC_DECL(avc), int flag)
 void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
 {
     OSI_VN_CONVERT(vp)
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
 
     if (OSI_GET_LOCKID() == avc->vc_rwlockid) {
        avc->vc_locktrips++;
@@ -1224,7 +1224,7 @@ void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
 void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
 {
     OSI_VN_CONVERT(vp)
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
 
     AFS_ASSERT_GLOCK();
     osi_Assert(OSI_GET_LOCKID() == avc->vc_rwlockid);
@@ -1244,7 +1244,7 @@ void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
  */
 int afs_rwlock_nowait(vnode_t *vp, AFS_RWLOCK_T flag)
 {
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
 
     AFS_ASSERT_GLOCK();
     if (OSI_GET_LOCKID() == avc->vc_rwlockid) {
index 089fdf8..7e63643 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 = (struct inode*)tvc;
+           ip = AFSTOV(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 = (struct vcache*)ip;
+    struct vcache *vc = VTOAFS(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 = (struct vcache*)dp->d_inode, *avc = NULL;
-  struct vcache *pvc = (struct vcache *)dp->d_parent->d_inode;
+  struct vcache *vcp = VTOAFS(dp->d_inode), *avc = NULL;
+  struct vcache *pvc = VTOAFS(dp->d_parent->d_inode);
 
   if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) { /* bad parent */
     credp = crref();
index 66470d6..efe4414 100644 (file)
@@ -134,17 +134,17 @@ static int afs_root(struct super_block *afsp)
 #endif
                
                /* "/afs" is a directory, reset inode ops accordingly. */
-               tvp->v.v_op = &afs_dir_iops;
+               AFSTOV(tvp)->v_op = &afs_dir_iops;
 #if defined(AFS_LINUX24_ENV)
-               tvp->v.v_fop = &afs_dir_fops;
+               AFSTOV(tvp)->v_fop = &afs_dir_fops;
 #endif
 
                /* setup super_block and mount point inode. */
                afs_globalVp = tvp;
 #if defined(AFS_LINUX24_ENV)
-               afsp->s_root = d_alloc_root((struct inode*)&tvp->v);
+               afsp->s_root = d_alloc_root(AFSTOV(tvp));
 #else
-               afsp->s_root = d_alloc_root((struct inode*)tvp, NULL);
+               afsp->s_root = d_alloc_root(AFSTOV(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((struct vcache*)ip, &vattr, credp);
-    afs_CopyOutAttrs((struct vcache*)ip, &vattr);
+    code = afs_setattr(VTOAFS(ip), &vattr, credp);
+    afs_CopyOutAttrs(VTOAFS(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 = (struct vcache*)ip;
+    struct vcache *vc = VTOAFS(ip);
 
     AFS_GLOCK();
     osi_clear_inode(ip);
index cb3b569..a50cf77 100644 (file)
@@ -41,7 +41,7 @@ RCSID("$Header$");
  */
 int osi_VM_FlushVCache(struct vcache *avc, int *slept)
 {
-    struct inode *ip = (struct inode*)avc;
+    struct inode *ip = AFSTOV(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((struct inode *)avc);
+    invalidate_inode_pages(AFSTOV(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 = (struct inode *) avc;
+    struct inode *ip = AFSTOV(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 = (struct inode*)avc;
+    struct inode *ip = AFSTOV(avc);
 
     truncate_inode_pages(&ip->i_data, 0);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = (struct inode*)avc;
+    struct inode *ip = AFSTOV(avc);
 
     truncate_inode_pages(ip, 0);
 #else
-    invalidate_inode_pages((struct inode*)avc);
+    invalidate_inode_pages(AFSTOV(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 = (struct inode*)avc;
+    struct inode *ip = AFSTOV(avc);
 
     truncate_inode_pages(&ip->i_data, alen);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = (struct inode*)avc;
+    struct inode *ip = AFSTOV(avc);
 
     truncate_inode_pages(ip, alen);
 #else
-    invalidate_inode_pages((struct inode*)avc);
+    invalidate_inode_pages(AFSTOV(avc));
 #endif
 }
index 4d36947..4b0c668 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 = (struct vcache*)fp->f_dentry->d_inode;
+    struct vcache *vcp = VTOAFS(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 = (struct vcache *)fp->f_dentry->d_inode;
+    struct vcache *vcp = VTOAFS(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 = (struct vcache*)FILE_INODE(fp);
+    struct vcache *avc = VTOAFS(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 = (struct vcache*)FILE_INODE(vmap->vm_file);
+    vcp = VTOAFS(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 = (struct vcache*)FILE_INODE(fp);
+    struct vcache *vcp = VTOAFS(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 = (struct vcache*)ip;
+    struct vcache *vcp = VTOAFS(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((struct vcache*)ip, credp);
+    code = afs_fsync(VTOAFS(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 = (struct vcache*)FILE_INODE(fp);
+    struct vcache *vcp = VTOAFS(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 = (struct vcache *)FILE_INODE(fp);
+    struct vcache *vcp = VTOAFS(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 = (struct vcache*)dp->d_inode;
+    struct vcache *vcp = VTOAFS(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 = (struct vcache*) dp->d_inode;
-    struct vcache *parentvcp = (struct vcache*) dp->d_parent->d_inode;
+    struct vcache *vcp = VTOAFS(dp->d_inode);
+    struct vcache *parentvcp = VTOAFS(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 = (struct inode *)dp->d_inode;
+    struct inode *ip = AFSTOV(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((struct vcache*)dip, name, &vattr, NONEXCL, mode,
+    code = afs_create(VTOAFS(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((struct vcache *)dip, comp, &vcp, credp);
+    code = afs_lookup(VTOAFS(dip), comp, &vcp, credp);
 
     if (vcp) {
-       struct inode *ip = (struct inode*)vcp;
+       struct inode *ip = AFSTOV(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, (struct inode*)vcp);
+    d_add(dp, AFSTOV(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((struct vcache*)oldip, (struct vcache*)dip, name, credp);
+    code = afs_link(VTOAFS(oldip), VTOAFS(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((struct vcache*)dip, name, credp);
+    code = afs_remove(VTOAFS(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((struct vcache*)dip, name, &vattr, target, credp);
+    code = afs_symlink(VTOAFS(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((struct vcache*)dip, name, &vattr, &tvcp, credp);
+    code = afs_mkdir(VTOAFS(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, (struct inode*)tvcp);
+       d_instantiate(dp, AFSTOV(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((struct vcache*)dip, name, credp);
+    code = afs_rmdir(VTOAFS(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((struct vcache*)oldip, oldname, (struct vcache*)newip,
+    code = afs_rename(VTOAFS(oldip), oldname, VTOAFS(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((struct vcache*)ip, &tuio, credp);
+    code = afs_readlink(VTOAFS(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((struct vcache*)ip, &tuio, UIO_READ, 0, credp);
+    code = afs_rdwr(VTOAFS(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((struct vcache*)ip, tmp, credp);
+    code = afs_access(VTOAFS(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 = (struct vcache *) ip;
+    struct vcache *vcp = VTOAFS(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 = (struct vcache *)FILE_INODE(fp);
+    struct vcache *vcp = VTOAFS(FILE_INODE(fp));
     u8 *page_addr = (u8*) afs_linux_page_address(pp);
     int code = 0;
     cred_t *credp;
index 3ab83bb..2157691 100644 (file)
@@ -265,7 +265,7 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp)
     long addr[2];
     register struct cell *tcell;
     int rootvp = 0;
-    struct vcache *avc = (struct vcache *)avn;
+    struct vcache *avc = VTOAFS(avn);
 
     AFS_GLOCK();
     AFS_STATCNT(afs_fid);
index beacd69..6f5d958 100644 (file)
@@ -752,7 +752,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred)
     vm_page_t *pagep;
     vm_offset_t off;
 
-   struct vcache *avc =  (struct vcache *)vop->vu_vp;
+   struct vcache *avc =  VTOAFS(vop->vu_vp);
 
     /* first, obtain the proper lock for the VM system */
 
@@ -852,7 +852,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred)
     struct ucred *cred;
 {
     register afs_int32 code=0;
-    struct vcache *avc = (struct vcache *)vop->vu_vp;
+    struct vcache *avc = VTOAFS(vop->vu_vp);
     struct vnode *vp = (struct vnode *)avc;
     int i;
 
@@ -972,7 +972,7 @@ mp_afs_bread(vp, lbn, bpp, cred)
        uio.afsio_offset = offset;
        uio.afsio_resid = fsbsize;
        *bpp = 0;
-       error = afs_read((struct vcache *)vp, &uio, cred, lbn, bpp, 0);
+       error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0);
        if (error) {
                afs_bread_freebp = bp;
                AFS_GUNLOCK();
index 934a138..ef27ae5 100644 (file)
@@ -44,7 +44,7 @@
 #undef afs_osi_Alloc_NoSleep
 extern void *afs_osi_Alloc_NoSleep(size_t size);
 
-#define osi_vnhold(avc, r)  do { VN_HOLD((struct vnode *)(avc)); } while(0)
+#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(ioflag),(ulimit),(cr),(aresid))
 
index 009b34a..0707ca1 100644 (file)
@@ -122,13 +122,13 @@ int afs_root (struct vfs *afsp, struct vnode **avpp)
        }
     }
     if (tvp) {
-       VN_HOLD((struct vnode *)tvp);
-       mutex_enter(&(((struct vnode*)tvp)->v_lock));
-       tvp->v.v_flag |= VROOT;
-       mutex_exit(&(((struct vnode*)tvp)->v_lock));
+       VN_HOLD(AFSTOV(tvp));
+       mutex_enter(&AFSTOV(tvp)->v_lock);
+       AFSTOV(tvp)->v_flag |= VROOT;
+       mutex_exit(&AFSTOV(tvp)->v_lock);
 
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
index ecd4bc7..2e610d5 100644 (file)
@@ -50,7 +50,7 @@ osi_VM_GetDownD(avc, adc)
     int code;
 
     AFS_GUNLOCK();
-    code = afs_putpage((struct vnode *)avc,
+    code = afs_putpage(AFSTOV(avc),
                       (offset_t) AFS_CHUNKTOBASE(adc->f.chunk),
                       AFS_CHUNKTOSIZE(adc->f.chunk),
                       B_INVAL, CRED());
@@ -91,11 +91,11 @@ osi_VM_FlushVCache(avc, slept)
        return EBUSY;
 
     AFS_GUNLOCK();
-    pvn_vplist_dirty((struct vnode *)avc, 0, NULL, B_TRUNC|B_INVAL, CRED());
+    pvn_vplist_dirty(AFSTOV(avc), 0, NULL, B_TRUNC|B_INVAL, CRED());
     AFS_GLOCK();
 
     /* Might as well make the obvious check */
-    if (((struct vnode *)avc)->v_pages)
+    if (AFSTOV(avc)->v_pages)
        return EBUSY;   /* should be all gone still */
 
     rw_destroy(&avc->rwlock);
@@ -119,10 +119,10 @@ osi_VM_StoreAllSegments(avc)
 {
     AFS_GUNLOCK();
 #if    defined(AFS_SUN56_ENV)
-    (void) pvn_vplist_dirty((struct vnode *)avc, (u_offset_t)0, afs_putapage,
+    (void) pvn_vplist_dirty(AFSTOV(avc), (u_offset_t)0, afs_putapage,
                            0, CRED());
 #else
-    (void) pvn_vplist_dirty((struct vnode *)avc, 0, afs_putapage, 0, CRED());
+    (void) pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage, 0, CRED());
 #endif
     AFS_GLOCK();
 }
@@ -141,10 +141,10 @@ osi_VM_TryToSmush(avc, acred, sync)
 {
     AFS_GUNLOCK();
 #if    defined(AFS_SUN56_ENV)
-    (void) pvn_vplist_dirty((struct vnode *)avc, (u_offset_t)0, afs_putapage,
+    (void) pvn_vplist_dirty(AFSTOV(avc), (u_offset_t)0, afs_putapage,
                            (sync ? B_INVAL : B_FREE), acred);
 #else
-    (void) pvn_vplist_dirty((struct vnode *)avc, 0, afs_putapage,
+    (void) pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage,
                            (sync ? B_INVAL : B_FREE), acred);
 #endif
     AFS_GLOCK();
@@ -162,7 +162,7 @@ osi_VM_FlushPages(avc, credp)
     extern int afs_pvn_vptrunc;
 
     afs_pvn_vptrunc++;
-    (void) afs_putpage((struct vnode *)avc, (offset_t)0, 0,
+    (void) afs_putpage(AFSTOV(avc), (offset_t)0, 0,
                        B_TRUNC|B_INVAL, credp);
 }
 
@@ -189,7 +189,7 @@ osi_VM_PreTruncate(avc, alen, acred)
 
     ReleaseWriteLock(&avc->lock);
     AFS_GUNLOCK();
-    pp = page_lookup((struct vnode *)avc, alen - pageOffset, SE_EXCL);
+    pp = page_lookup(AFSTOV(avc), alen - pageOffset, SE_EXCL);
     if (pp) {
        pagezero(pp, pageOffset, PAGESIZE - pageOffset);
        page_unlock(pp);
@@ -213,7 +213,7 @@ osi_VM_Truncate(avc, alen, acred)
      * It's OK to specify afs_putapage here, even though we aren't holding
      * the vcache entry lock, because it isn't going to get called.
      */
-    pvn_vplist_dirty((struct vnode *)avc, alen, afs_putapage, B_TRUNC|B_INVAL,
+    pvn_vplist_dirty(AFSTOV(avc), alen, afs_putapage, B_TRUNC|B_INVAL,
                     acred);
 }
 
index d399590..00e74a8 100644 (file)
@@ -125,10 +125,10 @@ int afs_vmread(avp, auio, ioflag, acred)
 {
     register int code;
 
-    if (!RW_READ_HELD(&((struct vcache *)avp)->rwlock))
+    if (!RW_READ_HELD(&(VTOAFS(avp))->rwlock))
        osi_Panic("afs_vmread: !rwlock");
     AFS_GLOCK();
-    code = afs_nfsrdwr((struct vcache *)avp, auio, UIO_READ, ioflag, acred);
+    code = afs_nfsrdwr(VTOAFS(avp), auio, UIO_READ, ioflag, acred);
     AFS_GUNLOCK();
     return code;
 }
@@ -142,10 +142,10 @@ int afs_vmwrite(avp, auio, ioflag, acred)
 {
     register int code;
 
-    if (!RW_WRITE_HELD(&((struct vcache *)avp)->rwlock))
+    if (!RW_WRITE_HELD(&(VTOAFS(avp))->rwlock))
        osi_Panic("afs_vmwrite: !rwlock");
     AFS_GLOCK();
-    code = afs_nfsrdwr((struct vcache *)avp, auio, UIO_WRITE, ioflag, acred);
+    code = afs_nfsrdwr(VTOAFS(avp), auio, UIO_WRITE, ioflag, acred);
     AFS_GUNLOCK();
     return code;
 }
@@ -181,7 +181,7 @@ struct AFS_UCRED *acred;
 
 #if    defined(AFS_SUN56_ENV)
     if (len <= PAGESIZE)
-       code = afs_GetOnePage((struct vnode *) vp, off, len, protp, pl, plsz,
+       code = afs_GetOnePage(vp, off, len, protp, pl, plsz,
                              seg, addr, rw, acred);
 #else
 #ifdef AFS_SUN5_ENV
@@ -195,7 +195,7 @@ struct AFS_UCRED *acred;
 #endif
 #endif
     else {
-       struct vcache *vcp = (struct vcache *)vp;
+       struct vcache *vcp = VTOAFS(vp);
 #ifdef AFS_SUN5_ENV
        ObtainWriteLock(&vcp->vlock, 548);
        vcp->multiPage++;
@@ -203,10 +203,10 @@ struct AFS_UCRED *acred;
 #endif
        afs_BozonLock(&vcp->pvnLock, vcp);
 #if    defined(AFS_SUN56_ENV)
-       code = pvn_getpages(afs_GetOnePage, (struct vnode *) vp, off, 
+       code = pvn_getpages(afs_GetOnePage, vp, off, 
                            len, protp, pl, plsz, seg, addr, rw, acred);
 #else
-       code = pvn_getpages(afs_GetOnePage, (struct vnode *) vp, (u_int)off, 
+       code = pvn_getpages(afs_GetOnePage, vp, (u_int)off, 
                            len, protp, pl, plsz, seg, addr, rw, acred);
 #endif
        afs_BozonUnlock(&vcp->pvnLock, vcp);
@@ -270,7 +270,7 @@ struct AFS_UCRED *acred;
        acred = u.u_cred;               /* better than nothing */
 #endif
 
-    avc = (struct vcache *) vp;        /* cast to afs vnode */
+    avc = VTOAFS(vp);  /* cast to afs vnode */
 
 #ifdef AFS_SUN5_ENV
     if (avc->credp /*&& AFS_NFSXLATORREQ(acred)*/ && AFS_NFSXLATORREQ(avc->credp)) {
@@ -638,7 +638,7 @@ int afs_putpage(vp, off, len, flags, cred)
                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off),
                ICL_TYPE_INT32, (afs_int32) len,
                ICL_TYPE_LONG, (int) flags);
-    avc = (struct vcache *) vp;
+    avc = VTOAFS(vp);
     afs_BozonLock(&avc->pvnLock, avc);
     ObtainSharedLock(&avc->lock,247);
     didWriteLock = 0;
@@ -722,7 +722,7 @@ int afs_putapage(struct vnode *vp, struct page *pages,
                  int flags, struct AFS_UCRED *credp)
 {
     struct buf *tbuf;
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
     afs_int32 code = 0;
     u_int tlen = PAGESIZE;
     afs_offs_t off = (pages->p_offset/PAGESIZE)*PAGESIZE;
@@ -791,7 +791,7 @@ struct AFS_UCRED *cred;
     AFS_STATCNT(afs_putpage);
     wholeEnchilada = (off == 0 && len == 0 && (flags & (B_INVAL|B_ASYNC)) == B_INVAL);
 
-    avc = (struct vcache *) vp;
+    avc = VTOAFS(vp);
     afs_BozonLock(&avc->pvnLock, avc);
     ObtainWriteLock(&avc->lock,248);
 
@@ -1146,9 +1146,9 @@ struct AFS_UCRED *acred;
        ReleaseWriteLock(&avc->lock);   /* uiomove may page fault */
        AFS_GUNLOCK();
 #if    defined(AFS_SUN56_ENV)
-       data = segmap_getmap(segkmap,(struct vnode *)avc,(u_offset_t)pageBase);
+       data = segmap_getmap(segkmap,AFSTOV(avc),(u_offset_t)pageBase);
 #else
-       data = segmap_getmap(segkmap, (struct vnode *) avc, pageBase);
+       data = segmap_getmap(segkmap, AFSTOV(avc), pageBase);
 #endif
 #ifndef        AFS_SUN5_ENV
        code = as_fault(&kas, data+pageOffset, tsize, F_SOFTLOCK, mode);
@@ -1294,7 +1294,7 @@ struct AFS_UCRED *cred;
        struct segvn_crargs crargs;
        register afs_int32 code;
        struct vrequest treq;
-       register struct vcache *avc = (struct vcache *) vp;
+       register struct vcache *avc = VTOAFS(vp);
 
        AFS_STATCNT(afs_map);
 
@@ -1357,7 +1357,7 @@ struct AFS_UCRED *cred;
        } else
            (void) as_unmap(as, *addr, len);    /* unmap old address space use */
        /* setup the create parameter block for the call */
-       crargs.vp = (struct vnode *) avc;
+       crargs.vp = AFSTOV(avc);
        crargs.offset = (u_int)off;
        crargs.cred = cred;
        crargs.type = flags&MAP_TYPE;
@@ -1471,7 +1471,7 @@ void afs_rwlock(vnp, wlock)
     struct vnode *vnp;
     int wlock;
 {
-    rw_enter(&((struct vcache *)vnp)->rwlock, (wlock ? RW_WRITER : RW_READER));
+    rw_enter(&(VTOAFS(vnp))->rwlock, (wlock ? RW_WRITER : RW_READER));
 }
 
 
@@ -1479,7 +1479,7 @@ void afs_rwunlock(vnp, wlock)
     struct vnode *vnp;
     int wlock;
 {
-    rw_exit(&((struct vcache *)vnp)->rwlock);
+    rw_exit(&(VTOAFS(vnp))->rwlock);
 }
 
 
@@ -1543,7 +1543,7 @@ int afs_frlock(vnp, cmd, ap, flag, off,
        AFS_GLOCK();
     }
 
-    code = afs_lockctl((struct vcache *)vnp, ap, cmd, credp);
+    code = afs_lockctl(VTOAFS(vnp), ap, cmd, credp);
     AFS_GUNLOCK();
     return code;
 }
@@ -1574,7 +1574,7 @@ int afs_space(vnp, cmd, ap, flag, off, credp)
        if (!ap->l_len) {
            vattr.va_mask = AT_SIZE;
            vattr.va_size = ap->l_start;
-           code = afs_setattr((struct vcache *)vnp, &vattr, 0, credp);
+           code = afs_setattr(VTOAFS(vnp), &vattr, 0, credp);
        } 
        AFS_GUNLOCK();
     }
@@ -1973,7 +1973,7 @@ gafs_fsync(avc, acred)
 
 void afs_inactive(struct vcache *avc, struct AFS_UCRED *acred)
 {
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = AFSTOV(avc);
     if (afs_shuttingdown) return ;
 
     /*
index 57fcff0..f6bda9e 100644 (file)
@@ -4281,7 +4281,7 @@ int uafs_statmountpoint_r(char *path)
      return -1;
     }
 
-    avc = (struct vcache *) vp;
+    avc = VTOAFS(vp);
 
     r = avc->mvstat;
     VN_RELE(vp);
index b027671..e6d9595 100644 (file)
@@ -36,7 +36,7 @@
 #define        afs_hz      HZ
 #define osi_Time() (time(NULL))
 
-#define osi_vnhold(avc, r)  do { VN_HOLD((struct vnode *)(avc)); } while(0)
+#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
 #define        afs_suser           suser
 
 /*
index e456985..8d94536 100644 (file)
@@ -90,11 +90,11 @@ afs_root (OSI_VFS_ARG(afsp), avpp)
        }
     }
     if (tvp) {
-       VN_HOLD((struct vnode *)tvp);
+       VN_HOLD(AFSTOV(tvp));
 
-       tvp->v.v_flag |= VROOT;     /* No-op on Ultrix 2.2 */
+       AFSTOV(tvp)->v_flag |= VROOT;       /* No-op on Ultrix 2.2 */
        afs_globalVFS = afsp;
-       *avpp = (struct vnode *) tvp;
+       *avpp = AFSTOV(tvp);
     }
 
     afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, *avpp,
index 52f3858..348c929 100644 (file)
@@ -58,7 +58,7 @@ int afs_vrdwr(
 
 int afs_inactive(struct vcache *avc, struct AFS_UCRED *acred)
 {
-    struct vnode *vp = (struct vnode *)avc;
+    struct vnode *vp = AFSTOV(avc);
     if (afs_shuttingdown) return ;
 
     usr_assert(avc->vrefCount == 0);
index 6e191c5..f7de5fe 100644 (file)
@@ -175,7 +175,7 @@ afs_CopyOutAttrs(avc, attrs)
 
 #ifdef AFS_LINUX22_ENV
     /* And linux has it's own stash as well. */
-    vattr2inode((struct inode*)avc, attrs);
+    vattr2inode(AFSTOV(avc), attrs);
 #endif
     return 0;
 }
@@ -279,8 +279,8 @@ afs_getattr(OSI_VC_ARG(avc), attrs, acred)
                    attrs->va_nodeid = ip->i_ino;
                }
 #else
-               if (avc->v.v_flag & VROOT) {
-                   struct vnode *vp = (struct vnode *)avc;
+               if (AFSTOV(avc)->v_flag & VROOT) {
+                   struct vnode *vp = AFSTOV(avc);
 
                    vp = vp->v_vfsp->vfs_vnodecovered;
                    if (vp) {   /* Ignore weird failures */
index 8e3eb32..a385ab8 100644 (file)
@@ -36,7 +36,7 @@ extern afs_rwlock_t afs_xcbhash;
 afs_create(ndp, attrs)
     struct nameidata *ndp;
     struct vattr *attrs; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     enum vcexcl aexcl = NONEXCL; /* XXX - create called properly */
     int amode = 0; /* XXX - checked in higher level */
@@ -89,7 +89,7 @@ afs_create(OSI_VC_ARG(adp), aname, attrs, aexcl, amode, avcp, acred)
      * the reference count on it.
      */
     if (*avcp) {
-       AFS_RELE((struct vnode*)(*avcp));
+       AFS_RELE(AFSTOV(*avcp));
        *avcp = NULL;
     }
 #endif
index 7dcb41b..deac964 100644 (file)
@@ -38,7 +38,7 @@ extern afs_rwlock_t afs_xcbhash;
 afs_mkdir(ndp, attrs)
     struct nameidata *ndp;
     struct vattr *attrs; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     register struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
     struct ucred *acred = ndp->ni_cred;
@@ -171,7 +171,7 @@ done2:
 #ifdef AFS_OSF_ENV
 afs_rmdir(ndp)
     struct nameidata *ndp; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     struct ucred *acred = ndp->ni_cred;
 #else  /* AFS_OSF_ENV */
index 74f2536..d366c40 100644 (file)
@@ -117,7 +117,7 @@ struct fid **fidpp;
        addr[0] = (long)avc;
 #ifndef AFS_AIX41_ENV
        /* No post processing, so don't hold ref count. */
-       VN_HOLD((struct vnode *)avc);
+       VN_HOLD(AFSTOV(avc));
 #endif
     }
 #if    defined(AFS_AIX_ENV) || defined(AFS_SUN54_ENV)
index aba1303..7042b49 100644 (file)
@@ -875,14 +875,14 @@ afs_xflock () {
     /* first determine whether this is any sort of vnode */
     if (fd->f_type == DTYPE_VNODE) {
        /* good, this is a vnode; next see if it is an AFS vnode */
-       tvc = (struct vcache *) fd->f_data;     /* valid, given a vnode */
-       if (IsAfsVnode((struct vnode *)tvc)) {
+       tvc = VTOAFS(fd->f_data);       /* valid, given a vnode */
+       if (IsAfsVnode(AFSTOV(tvc))) {
            /* This is an AFS vnode, so do the work */
 #ifdef AFS_DEC_ENV
            /* find real vcache entry; shouldn't be null if gnode ref count
             * is greater than 0.
             */
-           tvc = (struct vcache *) afs_gntovn(tvc);
+           tvc = VTOAFS(afs_gntovn)(tvc);
            if (!tvc) {
                u.u_error = ENOENT;
                return;
index 29e4829..10dd986 100644 (file)
@@ -34,7 +34,7 @@ extern afs_rwlock_t afs_xcbhash;
 afs_link(avc, ndp)
     register struct vcache *avc;
     struct nameidata *ndp; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     struct ucred *acred = ndp->ni_cred;
 #else  /* AFS_OSF_ENV */
index a7ecd37..f356883 100644 (file)
@@ -935,7 +935,7 @@ afs_lookup(adp, aname, avcp, acred)
 
     AFS_STATCNT(afs_lookup);
 #ifdef AFS_OSF_ENV
-    ndp->ni_dvp = (struct vnode *)adp;
+    ndp->ni_dvp = AFSTOV(adp);
     memcpy(aname, ndp->ni_ptr, ndp->ni_namelen);
     aname[ndp->ni_namelen] = '\0';
 #endif /* AFS_OSF_ENV */
@@ -967,7 +967,7 @@ afs_lookup(adp, aname, avcp, acred)
 #ifdef AFS_OSF_ENV
            extern struct vcache *afs_globalVp;
            if (adp == afs_globalVp) {
-               struct vnode *rvp = (struct vnode *)adp;
+               struct vnode *rvp = AFSTOV(adp);
 /*
                ndp->ni_vp = rvp->v_vfsp->vfs_vnodecovered;
                ndp->ni_dvp = ndp->ni_vp;
index 000b999..d883e46 100644 (file)
@@ -51,7 +51,7 @@ afs_open(avcp, aflags, acred)
     if (code = afs_InitReq(&treq, acred)) return code;
 #ifdef AFS_SGI64_ENV
     /* avcpp can be, but is not necesarily, bhp's vnode. */
-    tvc = (struct vcache *)BHV_TO_VNODE(bhv);
+    tvc = VTOAFS(BHV_TO_VNODE(bhv));
 #else
     tvc = *avcp;
 #endif
index 2438301..1ad449c 100644 (file)
@@ -213,7 +213,7 @@ char *Tnam1;
 #ifdef AFS_OSF_ENV
 afs_remove(ndp)
     struct nameidata *ndp; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     struct ucred *acred = ndp->ni_cred;
 #else  /* AFS_OSF_ENV */
@@ -267,7 +267,7 @@ afs_remove(OSI_VC_ARG(adp), aname, acred)
 tagain:
     code = afs_VerifyVCache(adp, &treq);
 #ifdef AFS_OSF_ENV
-    tvc = (struct vcache *)ndp->ni_vp;  /* should never be null */
+    tvc = VTOAFS(ndp->ni_vp);  /* should never be null */
     if (code) {
        afs_PutVCache(adp, 0);
        afs_PutVCache(tvc, 0);
index f1db550..c8e81e0 100644 (file)
@@ -367,9 +367,9 @@ done:
 #ifdef AFS_OSF_ENV
 afs_rename(fndp, tndp)
     struct nameidata *fndp, *tndp; {
-    register struct vcache *aodp = (struct vcache *)fndp->ni_dvp;
+    register struct vcache *aodp = VTOAFS(fndp->ni_dvp);
     char *aname1 = fndp->ni_dent.d_name;
-    register struct vcache *andp = (struct vcache *)tndp->ni_dvp;
+    register struct vcache *andp = VTOAFS(tndp->ni_dvp);
     char *aname2 = tndp->ni_dent.d_name;
     struct ucred *acred = tndp->ni_cred;
 #else  /* AFS_OSF_ENV */
index ff16704..f153e1c 100644 (file)
@@ -38,7 +38,7 @@ afs_ustrategy(abp)
     register struct buf *abp; {
     register afs_int32 code;
     struct uio tuio;
-    register struct vcache *tvc = (struct vcache *) abp->b_vp;
+    register struct vcache *tvc = VTOAFS(abp->b_vp);
     register afs_int32 len = abp->b_bcount;
 #if    !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
 #ifdef AFS_AIX41_ENV
@@ -101,9 +101,9 @@ afs_ustrategy(abp)
        /* are user's credentials valid here?  probably, but this
             sure seems like the wrong things to do. */
 #if    defined(AFS_SUN5_ENV)
-       code = afs_nlrdwr((struct vcache *) abp->b_vp, &tuio, UIO_READ, 0, credp);
+       code = afs_nlrdwr(VTOAFS(abp->b_vp), &tuio, UIO_READ, 0, credp);
 #else
-       code = afs_rdwr((struct vcache *) abp->b_vp, &tuio, UIO_READ, 0, credp);
+       code = afs_rdwr(VTOAFS(abp->b_vp), &tuio, UIO_READ, 0, credp);
 #endif
        if (code == 0) {
            if (tuio.afsio_resid > 0)
@@ -163,7 +163,7 @@ afs_ustrategy(abp)
        len = MIN(len, tvc->m.Length - dbtob(abp->b_blkno));
 #endif
 #ifdef AFS_ALPHA_ENV
-       len = MIN(abp->b_bcount, ((struct vcache *)abp->b_vp)->m.Length - dbtob(abp->b_blkno));
+       len = MIN(abp->b_bcount, (VTOAFS(abp->b_vp))->m.Length - dbtob(abp->b_blkno));
 #endif /* AFS_ALPHA_ENV */
        tuio.afsio_resid = len;
 #if defined(AFS_FBSD_ENV)
@@ -175,9 +175,9 @@ afs_ustrategy(abp)
        /* are user's credentials valid here?  probably, but this
             sure seems like the wrong things to do. */
 #if    defined(AFS_SUN5_ENV)
-       code = afs_nlrdwr((struct vcache *) abp->b_vp, &tuio, UIO_WRITE, 0, credp);
+       code = afs_nlrdwr(VTOAFS(abp->b_vp), &tuio, UIO_WRITE, 0, credp);
 #else
-       code = afs_rdwr((struct vcache *) abp->b_vp, &tuio, UIO_WRITE, 0, credp);
+       code = afs_rdwr(VTOAFS(abp->b_vp), &tuio, UIO_WRITE, 0, credp);
 #endif
     }
 #if    !defined(AFS_AIX32_ENV) && !defined(AFS_SUN5_ENV)
@@ -191,7 +191,7 @@ afs_ustrategy(abp)
     if (code && !(abp->b_flags & B_READ)) {
        /* prevent ubc from retrying writes */
        AFS_GUNLOCK();
-       ubc_invalidate(((struct vnode *)tvc)->v_object,
+       ubc_invalidate(AFSTOV(tvc)->v_object,
                       (vm_offset_t)dbtob(abp->b_blkno),
                       PAGE_SIZE, B_INVAL);
        AFS_GLOCK();
index 637eb83..fe6a32b 100644 (file)
@@ -46,7 +46,7 @@ afs_symlink
     struct nameidata *ndp;
     struct vattr *attrs;
     register char *atargetName; {
-    register struct vcache *adp = (struct vcache *)ndp->ni_dvp;
+    register struct vcache *adp = VTOAFS(ndp->ni_dvp);
     char *aname = ndp->ni_dent.d_name;
     struct ucred *acred = ndp->ni_cred;
 #else  /* AFS_OSF_ENV */
index c598b64..2a97d4a 100644 (file)
@@ -59,7 +59,7 @@ register struct vrequest *treq;
         * top level code.  */
        avc->opens--;
        avc->execsOrWriters--;
-       AFS_RELE((struct vnode *)avc); /* VN_HOLD at set CCore(afs_FakeClose)*/
+       AFS_RELE(AFSTOV(avc)); /* VN_HOLD at set CCore(afs_FakeClose)*/
        crfree((struct AFS_UCRED *)avc->linkData);      /* "crheld" in afs_FakeClose */
        avc->linkData = (char *)0;
     }
@@ -735,9 +735,9 @@ afs_closex(afd)
      * close the file and release the lock when done.  Otherwise, just
      * let the regular close code work.      */
     if (afd->f_type == DTYPE_VNODE) {
-       tvc = (struct vcache *) afd->f_data;
-       if (IsAfsVnode((struct vnode *)tvc)) {
-           VN_HOLD((struct vnode *) tvc);
+       tvc = VTOAFS(afd->f_data);
+       if (IsAfsVnode(AFSTOV(tvc))) {
+           VN_HOLD(AFSTOV(tvc));
            flags = afd->f_flag & (FSHLOCK | FEXLOCK);
            afd->f_flag &= ~(FSHLOCK | FEXLOCK);
            code = vno_close(afd);
@@ -751,7 +751,7 @@ afs_closex(afd)
 #ifdef AFS_DEC_ENV
            grele((struct gnode *) tvc);
 #else
-           AFS_RELE((struct vnode *) tvc);
+           AFS_RELE(AFSTOV(tvc));
 #endif
            closeDone = 1;
        }
index 3b33e2a..9823233 100644 (file)
@@ -572,6 +572,9 @@ struct      vtodc
 extern afs_uint32 afs_stampValue;              /* stamp for pair's usage */
 #define        MakeStamp()     (++afs_stampValue)
 
+#define VTOAFS(V) ((struct vcache*)(V))
+#define AFSTOV(V) (&(V)->v)
+
 /* INVARIANTs: (vlruq.next != NULL) == (vlruq.prev != NULL)
  *             nextfree => !vlruq.next && ! vlruq.prev
  * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree)
@@ -707,9 +710,9 @@ struct vcache {
 #ifdef AFS_SGI64_ENV
 #include <ksys/behavior.h>
 #define AFS_RWLOCK(V,F) \
-       afs_rwlock(&(((struct vcache *)(V))->vc_bhv_desc), (F));
+       afs_rwlock(&VTOAFS(V)->vc_bhv_desc, (F));
 #define AFS_RWUNLOCK(V,F) \
-       afs_rwunlock(&(((struct vcache *)(V))->vc_bhv_desc), (F));
+       afs_rwunlock(&VTOAFS(V)->vc_bhv_desc, (F));
 
 #else
 #define AFS_RWLOCK(V,F) afs_rwlock((vnode_t *)(V), (F) )
@@ -954,7 +957,7 @@ struct dcache {
        avc->states |= CCore;   /* causes close to be called later */ \
                                                                       \
        /* The cred and vnode holds will be released in afs_FlushActiveVcaches */  \
-       VN_HOLD((struct vnode *)avc);   /* So it won't disappear */           \
+       VN_HOLD(AFSTOV(avc));   /* So it won't disappear */           \
        CRKEEP(avc, acred); /* Should use a better place for the creds */ \
     }                                                                         \
     else {                                                                    \
index b3ad91e..159acd5 100644 (file)
@@ -339,7 +339,7 @@ afs_CheckRootVolume () {
            mp = (struct mount *) afs_globalVFS->vfs_data ;
            mp->m_rootgp = gget(mp, 0, 0, (char *)rootgp);
            afs_unlock(mp->m_rootgp);   /* unlock basic gnode */
-           afs_vrele((struct vcache *) rootgp);  /* zap afs_root's vnode hold */
+           afs_vrele(VTOAFS(rootgp));  /* zap afs_root's vnode hold */
        }
     }
 #endif
@@ -390,9 +390,9 @@ void BPath(ab)
        return;
     }
 #ifdef AFS_DEC_ENV
-    tvc = (struct vcache *) afs_gntovn(tvn);
+    tvc = VTOAFS(afs_gntovn(tvn));
 #else
-    tvc = (struct vcache *) tvn;
+    tvc = VTOAFS(tvn);
 #endif
     /* here we know its an afs vnode, so we can get the data for the chunk */
     tdc = afs_GetDCache(tvc, ab->size_parm[0], &treq, &offset, &len, 1);
@@ -543,7 +543,7 @@ struct brequest *afs_BQueue(aopcode, avc, dontwait, ause, acred, asparm0, asparm
 #ifdef AFS_DEC_ENV
                avc->vrefCount++;
 #else
-               VN_HOLD((struct vnode *)avc);
+               VN_HOLD(AFSTOV(avc));
 #endif
            }
            tb->refCount = ause+1;
@@ -775,7 +775,7 @@ afs_BioDaemon (nbiods)
            AFS_GLOCK();
            continue;
        }
-       vcp = (struct vcache *)bp->b_vp;
+       vcp = VTOAFS(bp->b_vp);
        if (bp->b_flags & B_PFSTORE) {  /* XXXX */
            ObtainWriteLock(&vcp->lock,404);        
            if (vcp->v.v_gnode->gn_mwrcnt) {
@@ -1124,7 +1124,7 @@ afs_BioDaemon (nbiods)
            splx(s);
            continue;
        }
-       vcp = (struct vcache *)bp->b_vp;
+       vcp = VTOAFS(bp->b_vp);
        if (bp->b_flags & B_PFSTORE) {
            ObtainWriteLock(&vcp->lock,210);        
            if (vcp->v.v_gnode->gn_mwrcnt) {
index 1f2815d..6255a8c 100644 (file)
@@ -296,7 +296,7 @@ afs_nfs2_smallfidder(struct nfsdiropres *dr)
 #endif
 
     AFS_GLOCK();
-    vcp = (struct vcache *)addr[0];
+    vcp = VTOAFS((struct vnode*)addr[0]);
 
     /* See also afs_osi_vget */
     if (addr[1] == AFS_XLATOR_MAGIC)
@@ -318,7 +318,7 @@ afs_nfs2_smallfidder(struct nfsdiropres *dr)
 
        /* If we have a ref, release it */
        if (vcp->vrefCount >= 1) 
-           AFS_RELE((struct vnode *) vcp);
+           AFS_RELE(AFSTOV(vcp));
     } 
     AFS_GUNLOCK();
 }
@@ -731,7 +731,7 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp int status)
 #endif
 
     AFS_GLOCK();
-    vcp = (struct vcache *)addr[0];
+    vcp = VTOAFS((struct vnode*)addr[0]);
 
     /* See also afs_osi_vget */
     if (addr[1] == AFS_XLATOR_MAGIC)
@@ -753,7 +753,7 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp int status)
 
        /* If we have a ref, release it */
        if (vcp->vrefCount >= 1) 
-           AFS_RELE((struct vnode *) vcp);
+           AFS_RELE(AFSTOV(vcp));
     } 
     AFS_GUNLOCK();
 }
index 7e81433..d536f20 100644 (file)
@@ -91,10 +91,10 @@ register struct vcache *avc; {
     if (avc->opens > 0 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc))) return 1;
 #else
 #if defined(AFS_SGI_ENV)
-    if ((avc->opens > 0) || AFS_VN_MAPPED((struct vnode *)avc))
+    if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc)))
         return 1;
 #else
-    if (avc->opens > 0 || (avc->v.v_flag & VTEXT)) return(1);
+    if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT)) return(1);
 #endif
 #endif /* AFS_MACH_ENV */
 #endif
index e714562..ee43ba6 100644 (file)
@@ -495,7 +495,7 @@ afs_xioctl ()
 #endif
       /* first determine whether this is any sort of vnode */
 #ifdef AFS_LINUX22_ENV
-      tvc = (struct vcache *)ip;
+      tvc = VTOAFS(ip);
       {
 #else
 #ifdef AFS_SUN5_ENV
@@ -505,14 +505,14 @@ afs_xioctl ()
 #endif
        /* good, this is a vnode; next see if it is an AFS vnode */
 #if    defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV)
-       tvc = (struct vcache *) fd->f_vnode;    /* valid, given a vnode */
+       tvc = VTOAFS(fd->f_vnode);      /* valid, given a vnode */
 #else
-       tvc = (struct vcache *) fd->f_data;     /* valid, given a vnode */
+       tvc = VTOAFS((struct vnode*)fd->f_data);        /* valid, given a vnode */
 #endif
 #endif /* AFS_LINUX22_ENV */
-       if (tvc && IsAfsVnode((struct vnode *)tvc)) {
+       if (tvc && IsAfsVnode(AFSTOV(tvc))) {
 #ifdef AFS_DEC_ENV
-         tvc = (struct vcache *) afs_gntovn((struct gnode *) tvc);
+         tvc = VTOAFS(afs_gntovn((struct gnode *) tvc));
          if (!tvc) {   /* shouldn't happen with held gnodes */
            u.u_error = ENOENT;
            return;
@@ -2667,7 +2667,7 @@ struct AFS_UCRED *acred;
        for(tvc = afs_vhashT[i]; tvc; tvc=tvc->hnext) {
            if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
 #if    defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
-               VN_HOLD((struct vnode *)tvc);
+               VN_HOLD(AFSTOV(tvc));
 #else
 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
                osi_vnhold(tvc, 0);
index 55b8dcd..a516653 100644 (file)
@@ -132,7 +132,7 @@ int afs_FlushVCache(struct vcache *avc, int *slept)
               ICL_TYPE_INT32, avc->states);
 #ifdef  AFS_OSF_ENV
     AFS_GUNLOCK();
-    VN_LOCK((struct vnode *)avc);
+    VN_LOCK(AFSTOV(avc));
     AFS_GLOCK();
 #endif
 
@@ -214,15 +214,15 @@ int afs_FlushVCache(struct vcache *avc, int *slept)
     afs_vcount--;
     vSetType(avc, VREG);
     if (VREFCOUNT(avc) > 0) {
-        VN_UNLOCK((struct vnode *)avc);
-        AFS_RELE((struct vnode *)avc);
+        VN_UNLOCK(AFSTOV(avc));
+        AFS_RELE(AFSTOV(avc));
     } else {
        if (afs_norefpanic) {
          printf ("flush vc refcnt < 1");
          afs_norefpanic++;
          (void) vgone(avc, VX_NOSLEEP, (struct vnodeops *) 0);
          AFS_GLOCK();
-         VN_UNLOCK((struct vnode *)avc);
+         VN_UNLOCK(AFSTOV(avc));
        }
        else osi_Panic ("flush vc refcnt < 1");
     }
@@ -232,7 +232,7 @@ int afs_FlushVCache(struct vcache *avc, int *slept)
 
 bad:
 #ifdef AFS_OSF_ENV
-    VN_UNLOCK((struct vnode *)avc);
+    VN_UNLOCK(AFSTOV(avc));
 #endif
     return code;
 
@@ -578,7 +578,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp,
                continue;
            
            if ( VREFCOUNT(tvc) && tvc->opens == 0 ) {
-               struct inode *ip = (struct inode*)tvc;
+               struct inode *ip = AFSTOV(tvc);
                if (list_empty(&ip->i_dentry)) {
                    vn --;
                }
@@ -812,7 +812,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp,
     hzero(tvc->m.DataVersion);         /* in case we copy it into flushDV */
 #ifdef AFS_OSF_ENV
     /* Hold it for the LRU (should make count 2) */
-    VN_HOLD((struct vnode *)tvc);
+    VN_HOLD(AFSTOV(tvc));
 #else  /* AFS_OSF_ENV */
     VREFCOUNT_SET(tvc, 1);     /* us */
 #endif /* AFS_OSF_ENV */
@@ -881,12 +881,12 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp,
     AFS_VN_INIT_BUF_LOCK(&(tvc->v));
 #endif
 #else
-    SetAfsVnode((struct vnode *)tvc);
+    SetAfsVnode(AFSTOV(tvc));
 #endif /* AFS_SGI64_ENV */
 #ifdef AFS_DARWIN_ENV
     tvc->v.v_ubcinfo = UBC_INFO_NULL;
     lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0);
-    cache_purge((struct vnode *)tvc); 
+    cache_purge(AFSTOV(tvc)); 
     tvc->v.v_data=tvc;
     tvc->v.v_tag=VT_AFS;
     /* VLISTNONE(&tvc->v); */
@@ -896,7 +896,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp,
 #endif 
 #ifdef AFS_FBSD_ENV
     lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0);
-    cache_purge((struct vnode *)tvc); 
+    cache_purge(AFSTOV(tvc)); 
     tvc->v.v_data=tvc;
     tvc->v.v_tag=VT_AFS;
     tvc->v.v_usecount++; /* steal an extra ref for now so vfree never happens */
@@ -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 = (struct inode*)tvc;
+       struct inode *ip = AFSTOV(tvc);
        sema_init(&ip->i_sem, 1);
 #if defined(AFS_LINUX24_ENV)
        sema_init(&ip->i_zombie, 1);
@@ -1150,7 +1150,7 @@ afs_FlushActiveVcaches(doflocks)
 #ifdef AFS_GFS_ENV
                    VREFCOUNT_DEC(tvc);
 #else
-                   AFS_RELE((struct vnode *)tvc);
+                   AFS_RELE(AFSTOV(tvc));
 #endif
                    /* Matches write code setting CCore flag */
                    crfree(cred);
@@ -1937,7 +1937,7 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid,
             * can be safely implemented */
            int vg;
            AFS_GUNLOCK();
-            vg = vget((struct vnode *)tvc);   /* this bumps ref count */
+            vg = vget(AFSTOV(tvc));   /* this bumps ref count */
            AFS_GLOCK();
            if (vg)
                 continue;
@@ -2384,7 +2384,7 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 lockit,
             /* Grab this vnode, possibly reactivating from the free list */
            int vg;
            AFS_GUNLOCK();
-            vg = vget((struct vnode *)tvc);
+            vg = vget(AFSTOV(tvc));
            AFS_GLOCK();
            if (vg)
                 continue;
@@ -2506,7 +2506,7 @@ afs_int32 afs_NFSFindVCache(avcp, afid, lockit)
             /* Grab this vnode, possibly reactivating from the free list */
            int vg;
            AFS_GUNLOCK();
-            vg = vget((struct vnode *)tvc);
+            vg = vget(AFSTOV(tvc));
            AFS_GLOCK();
            if (vg) {
                /* This vnode no longer exists. */
@@ -2518,8 +2518,8 @@ afs_int32 afs_NFSFindVCache(avcp, afid, lockit)
                /* Duplicates */
 #ifdef AFS_OSF_ENV
                /* Drop our reference counts. */
-               vrele((struct vnode *)tvc);
-               vrele((struct vnode *)found_tvc);
+               vrele(AFSTOV(tvc));
+               vrele(AFSTOV(found_tvc));
 #endif
                afs_duplicate_nfs_fids++;
                ReleaseSharedLock(&afs_xvcache);
@@ -2688,7 +2688,7 @@ void shutdown_vcache(void)
                tvc->mvid = (struct VenusFid*)0;
            }
 #ifdef AFS_AIX_ENV
-           aix_gnode_rele((struct vnode *)tvc);
+           aix_gnode_rele(AFSTOV(tvc));
 #endif
            if (tvc->linkData) {
                afs_osi_Free(tvc->linkData, strlen(tvc->linkData)+1);