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;
}
}
/* Free the alloced gnode that was accompanying the vcache's vnode */
- aix_gnode_rele((struct vnode *)avc);
+ aix_gnode_rele(AFSTOV(avc));
return 0;
}
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;
}
{
int error;
struct vattr va;
- struct vcache *tvp = (struct vcache *)vp;
+ struct vcache *tvp = VTOAFS(vp);
afs_int32 modes;
AFS_STATCNT(afs_gn_open);
* 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
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);
struct ucred *cred;
{
int error;
- struct vcache *tvp = (struct vcache *)vp;
+ struct vcache *tvp = VTOAFS(vp);
AFS_STATCNT(afs_gn_close);
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);
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) {
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) {
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;
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;
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;
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,
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;
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)) {
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;
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;
int alen;
struct AFS_UCRED *acred;
{
- struct vnode *vp=(struct vnode *)avc;
+ struct vnode *vp=AFSTOV(avc);
if (UBCINFOEXISTS(vp)) {
ubc_setsize(vp, alen);
}
int *slept;
{
struct proc *p=current_proc();
- struct vnode *vp=(struct vnode *)avc;
+ struct vnode *vp=AFSTOV(avc);
void *obj;
if (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);
}
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)) {
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)
*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.
/* 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();
}
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;
} */ *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);
{
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;
}
{
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;
}
{
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;
}
} */ *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 */
int nocommit = flags & UPL_NOCOMMIT;
int code;
- struct vcache *tvc=(struct vcache *)vp;
+ struct vcache *tvc=VTOAFS(vp);
if (UBCINVALID(vp)) {
#if DIAGNOSTIC
} */ *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);
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;
int nocommit = flags & UPL_NOCOMMIT;
int code;
- struct vcache *tvc=(struct vcache *)vp;
+ struct vcache *tvc=VTOAFS(vp);
if (UBCINVALID(vp)) {
#if DIAGNOSTIC
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;
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;
}
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)) {
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)
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);
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);
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();
}
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);
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();
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) {
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;
}
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;
#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)
} */ *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);
} */ *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));
} */ *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,
struct vnode *a_vp;
} */ *ap;
{
- struct vcache *vc = (struct vcache *)ap->a_vp;
+ struct vcache *vc = VTOAFS(ap->a_vp);
return lockstatus(&vc->rwlock);
}
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;
#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) \
}
}
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,
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);
fidp->fid_reserved = AFS_XLATOR_MAGIC;
addr[0] = (long)avc;
AFS_GUNLOCK();
- VN_HOLD((struct vnode *)avc);
+ VN_HOLD(AFSTOV(avc));
AFS_GLOCK();
}
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;
{
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);
}
{
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);
}
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.
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);
}
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();
*/
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();
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 */
/* 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 */
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();
}
{
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)
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 */
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();
}
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);
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 */
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();
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 */
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();
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;
}
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);
}
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.
int alen;
struct AFS_UCRED *acred;
{
- vnode_pager_setsize(((struct vnode *)avc), alen);
+ vnode_pager_setsize(AFSTOV(avc), alen);
}
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)
*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.
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();
}
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;
{
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);
{
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;
}
{
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;
}
{
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
} */ *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 */
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");
} */ *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;
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");
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;
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;
}
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();
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);
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);
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);
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();
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;
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();
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) {
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;
}
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;
#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)
} */ *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);
} */ *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));
} */ *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,
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);
}
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;
#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)
}
}
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,
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
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;
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 ;
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);
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)
{
}
} 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);
#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);
#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
* 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;
}
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,
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);
}
/* 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) {
/*
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;
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;
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;
#endif
{
OSI_VC_CONVERT(avc)
- struct vnode *vp = (struct vnode*)avc;
+ struct vnode *vp = AFSTOV(avc);
struct vrequest treq;
int error;
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++;
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);
*/
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) {
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
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)
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();
#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
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.
*/
void afs_delete_inode(struct inode *ip)
{
- struct vcache *vc = (struct vcache*)ip;
+ struct vcache *vc = VTOAFS(ip);
AFS_GLOCK();
osi_clear_inode(ip);
*/
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;
*/
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
*/
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 */
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
}
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
}
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;
{
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();
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;
if (!vmap->vm_file)
return;
- vcp = (struct vcache*)FILE_INODE(vmap->vm_file);
+ vcp = VTOAFS(FILE_INODE(vmap->vm_file));
if (!vcp)
return;
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;
{
int code = 0;
cred_t *credp = crref();
- struct vcache *vcp = (struct vcache*)ip;
+ struct vcache *vcp = VTOAFS(ip);
AFS_GLOCK();
#ifdef AFS_LINUX24_ENV
#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
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;
*/
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;
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
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();
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 */
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) {
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)) {
}
dp->d_time = jiffies;
dp->d_op = afs_dops;
- d_add(dp, (struct inode*)vcp);
+ d_add(dp, AFSTOV(vcp));
AFS_GUNLOCK();
crfree(credp);
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);
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);
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;
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;
#endif
dp->d_op = afs_dops;
dp->d_time = jiffies;
- d_instantiate(dp, (struct inode*)tvcp);
+ d_instantiate(dp, AFSTOV(tvcp));
}
AFS_GUNLOCK();
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
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();
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)
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
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);
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;
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;
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);
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 */
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;
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();
#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))
}
}
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,
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());
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);
{
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();
}
{
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();
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);
}
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);
* 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);
}
{
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;
}
{
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;
}
#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
#endif
#endif
else {
- struct vcache *vcp = (struct vcache *)vp;
+ struct vcache *vcp = VTOAFS(vp);
#ifdef AFS_SUN5_ENV
ObtainWriteLock(&vcp->vlock, 548);
vcp->multiPage++;
#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);
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)) {
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;
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;
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);
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);
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);
} 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;
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));
}
struct vnode *vnp;
int wlock;
{
- rw_exit(&((struct vcache *)vnp)->rwlock);
+ rw_exit(&(VTOAFS(vnp))->rwlock);
}
AFS_GLOCK();
}
- code = afs_lockctl((struct vcache *)vnp, ap, cmd, credp);
+ code = afs_lockctl(VTOAFS(vnp), ap, cmd, credp);
AFS_GUNLOCK();
return code;
}
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();
}
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 ;
/*
return -1;
}
- avc = (struct vcache *) vp;
+ avc = VTOAFS(vp);
r = avc->mvstat;
VN_RELE(vp);
#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
/*
}
}
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,
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);
#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;
}
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 */
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 */
* the reference count on it.
*/
if (*avcp) {
- AFS_RELE((struct vnode*)(*avcp));
+ AFS_RELE(AFSTOV(*avcp));
*avcp = NULL;
}
#endif
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;
#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 */
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)
/* 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;
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 */
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 */
#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;
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
#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 */
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);
#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 */
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
/* 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)
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)
/* 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)
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();
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 */
* 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;
}
* 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);
#ifdef AFS_DEC_ENV
grele((struct gnode *) tvc);
#else
- AFS_RELE((struct vnode *) tvc);
+ AFS_RELE(AFSTOV(tvc));
#endif
closeDone = 1;
}
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)
#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) )
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 { \
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
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);
#ifdef AFS_DEC_ENV
avc->vrefCount++;
#else
- VN_HOLD((struct vnode *)avc);
+ VN_HOLD(AFSTOV(avc));
#endif
}
tb->refCount = ause+1;
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) {
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) {
#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)
/* If we have a ref, release it */
if (vcp->vrefCount >= 1)
- AFS_RELE((struct vnode *) vcp);
+ AFS_RELE(AFSTOV(vcp));
}
AFS_GUNLOCK();
}
#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)
/* If we have a ref, release it */
if (vcp->vrefCount >= 1)
- AFS_RELE((struct vnode *) vcp);
+ AFS_RELE(AFSTOV(vcp));
}
AFS_GUNLOCK();
}
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
#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
#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;
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);
ICL_TYPE_INT32, avc->states);
#ifdef AFS_OSF_ENV
AFS_GUNLOCK();
- VN_LOCK((struct vnode *)avc);
+ VN_LOCK(AFSTOV(avc));
AFS_GLOCK();
#endif
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");
}
bad:
#ifdef AFS_OSF_ENV
- VN_UNLOCK((struct vnode *)avc);
+ VN_UNLOCK(AFSTOV(avc));
#endif
return code;
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 --;
}
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 */
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); */
#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 */
#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);
#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);
* 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;
/* 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;
/* 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. */
/* 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);
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);