6 #include <afs/sysincludes.h> /* Standard vendor system headers */
7 #include <afsincludes.h> /* Afs-based standard headers */
8 #include <afs/afs_stats.h> /* statistics */
9 #include <sys/malloc.h>
10 #include <sys/namei.h>
11 #ifndef AFS_FBSD50_ENV
12 #include <vm/vm_zone.h>
14 #include <vm/vm_page.h>
15 #include <vm/vm_object.h>
16 #include <vm/vm_pager.h>
17 #include <vm/vnode_pager.h>
18 extern int afs_pbuf_freecnt;
20 int afs_vop_lookup(struct vop_lookup_args *);
21 int afs_vop_create(struct vop_create_args *);
22 int afs_vop_mknod(struct vop_mknod_args *);
23 int afs_vop_open(struct vop_open_args *);
24 int afs_vop_close(struct vop_close_args *);
25 int afs_vop_access(struct vop_access_args *);
26 int afs_vop_getattr(struct vop_getattr_args *);
27 int afs_vop_setattr(struct vop_setattr_args *);
28 int afs_vop_read(struct vop_read_args *);
29 int afs_vop_write(struct vop_write_args *);
30 int afs_vop_getpages(struct vop_getpages_args *);
31 int afs_vop_putpages(struct vop_putpages_args *);
32 int afs_vop_ioctl(struct vop_ioctl_args *);
33 int afs_vop_poll(struct vop_poll_args *);
34 int afs_vop_mmap(struct vop_mmap_args *);
35 int afs_vop_fsync(struct vop_fsync_args *);
36 int afs_vop_remove(struct vop_remove_args *);
37 int afs_vop_link(struct vop_link_args *);
38 int afs_vop_rename(struct vop_rename_args *);
39 int afs_vop_mkdir(struct vop_mkdir_args *);
40 int afs_vop_rmdir(struct vop_rmdir_args *);
41 int afs_vop_symlink(struct vop_symlink_args *);
42 int afs_vop_readdir(struct vop_readdir_args *);
43 int afs_vop_readlink(struct vop_readlink_args *);
44 int afs_vop_inactive(struct vop_inactive_args *);
45 int afs_vop_reclaim(struct vop_reclaim_args *);
46 int afs_vop_lock(struct vop_lock_args *);
47 int afs_vop_unlock(struct vop_unlock_args *);
48 int afs_vop_bmap(struct vop_bmap_args *);
49 int afs_vop_strategy(struct vop_strategy_args *);
50 int afs_vop_print(struct vop_print_args *);
51 int afs_vop_islocked(struct vop_islocked_args *);
52 int afs_vop_advlock(struct vop_advlock_args *);
56 /* Global vfs data structures for AFS. */
57 vop_t **afs_vnodeop_p;
58 struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
59 { &vop_default_desc, (vop_t *) vop_eopnotsupp },
60 { &vop_access_desc, (vop_t *) afs_vop_access }, /* access */
61 { &vop_advlock_desc, (vop_t *) afs_vop_advlock }, /* advlock */
62 { &vop_bmap_desc, (vop_t *) afs_vop_bmap }, /* bmap */
63 #ifndef AFS_FBSD50_ENV
64 { &vop_bwrite_desc, (vop_t *) vop_stdbwrite },
66 { &vop_close_desc, (vop_t *) afs_vop_close }, /* close */
67 { &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject },
68 { &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject },
69 { &vop_create_desc, (vop_t *) afs_vop_create }, /* create */
70 { &vop_fsync_desc, (vop_t *) afs_vop_fsync }, /* fsync */
71 { &vop_getattr_desc, (vop_t *) afs_vop_getattr }, /* getattr */
72 { &vop_getpages_desc, (vop_t *) afs_vop_getpages }, /* read */
73 { &vop_getvobject_desc, (vop_t *) vop_stdgetvobject },
74 { &vop_putpages_desc, (vop_t *) afs_vop_putpages }, /* write */
75 { &vop_inactive_desc, (vop_t *) afs_vop_inactive }, /* inactive */
76 { &vop_islocked_desc, (vop_t *) afs_vop_islocked }, /* islocked */
77 { &vop_lease_desc, (vop_t *) vop_null },
78 { &vop_link_desc, (vop_t *) afs_vop_link }, /* link */
79 { &vop_lock_desc, (vop_t *) afs_vop_lock }, /* lock */
80 { &vop_lookup_desc, (vop_t *) afs_vop_lookup }, /* lookup */
81 { &vop_mkdir_desc, (vop_t *) afs_vop_mkdir }, /* mkdir */
82 { &vop_mknod_desc, (vop_t *) afs_vop_mknod }, /* mknod */
83 { &vop_mmap_desc, (vop_t *) afs_vop_mmap }, /* mmap */
84 { &vop_open_desc, (vop_t *) afs_vop_open }, /* open */
85 { &vop_poll_desc, (vop_t *) afs_vop_poll }, /* select */
86 { &vop_print_desc, (vop_t *) afs_vop_print }, /* print */
87 { &vop_read_desc, (vop_t *) afs_vop_read }, /* read */
88 { &vop_readdir_desc, (vop_t *) afs_vop_readdir }, /* readdir */
89 { &vop_readlink_desc, (vop_t *) afs_vop_readlink }, /* readlink */
90 { &vop_reclaim_desc, (vop_t *) afs_vop_reclaim }, /* reclaim */
91 { &vop_remove_desc, (vop_t *) afs_vop_remove }, /* remove */
92 { &vop_rename_desc, (vop_t *) afs_vop_rename }, /* rename */
93 { &vop_rmdir_desc, (vop_t *) afs_vop_rmdir }, /* rmdir */
94 { &vop_setattr_desc, (vop_t *) afs_vop_setattr }, /* setattr */
95 { &vop_strategy_desc, (vop_t *) afs_vop_strategy }, /* strategy */
96 { &vop_symlink_desc, (vop_t *) afs_vop_symlink }, /* symlink */
97 { &vop_unlock_desc, (vop_t *) afs_vop_unlock }, /* unlock */
98 { &vop_write_desc, (vop_t *) afs_vop_write }, /* write */
99 { &vop_ioctl_desc, (vop_t *) afs_vop_ioctl }, /* XXX ioctl */
100 /*{ &vop_seek_desc, afs_vop_seek },*/ /* seek */
103 struct vnodeopv_desc afs_vnodeop_opv_desc =
104 { &afs_vnodeop_p, afs_vnodeop_entries };
107 struct componentname *cnp = ap->a_cnp; \
109 MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
110 memcpy(name, cnp->cn_nameptr, cnp->cn_namelen); \
111 name[cnp->cn_namelen] = '\0'
113 #define DROPNAME() FREE(name, M_TEMP)
119 struct vop_lookup_args /* {
120 struct vnodeop_desc * a_desc;
122 struct vnode **a_vpp;
123 struct componentname *a_cnp;
128 struct vnode *vp, *dvp;
129 register int flags = ap->a_cnp->cn_flags;
130 int lockparent; /* 1 => lockparent flag is set */
131 int wantparent; /* 1 => wantparent or lockparent flag */
132 #ifdef AFS_FBSD50_ENV
133 struct thread *p = ap->a_cnp->cn_thread;
135 struct proc *p = ap->a_cnp->cn_proc;
139 lockparent = flags & LOCKPARENT;
140 wantparent = flags & (LOCKPARENT|WANTPARENT);
142 if (ap->a_dvp->v_type != VDIR) {
148 if (flags & ISDOTDOT)
149 VOP_UNLOCK(dvp, 0, p);
151 error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
154 if (flags & ISDOTDOT)
155 VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
156 if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
157 (flags & ISLASTCN) && error == ENOENT)
159 if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
160 cnp->cn_flags |= SAVENAME;
165 vp = AFSTOV(vcp); /* always get a node if no error */
167 /* The parent directory comes in locked. We unlock it on return
168 unless the caller wants it left locked.
169 we also always return the vnode locked. */
171 if (flags & ISDOTDOT) {
172 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
173 /* always return the child locked */
174 if (lockparent && (flags & ISLASTCN) &&
175 (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
180 } else if (vp == dvp) {
181 /* they're the same; afs_lookup() already ref'ed the leaf.
182 It came in locked, so we don't need to ref OR lock it */
184 if (!lockparent || !(flags & ISLASTCN))
185 VOP_UNLOCK(dvp, 0, p); /* done with parent. */
186 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
187 /* always return the child locked */
191 if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) ||
192 (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)))
193 cnp->cn_flags |= SAVENAME;
201 struct vop_create_args /* {
203 struct vnode **a_vpp;
204 struct componentname *a_cnp;
210 register struct vnode *dvp = ap->a_dvp;
216 error = afs_create(VTOAFS(dvp), name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
217 ap->a_vap->va_mode, &vcp,
226 *ap->a_vpp = AFSTOV(vcp);
227 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE| LK_RETRY, p);
237 struct vop_mknod_args /* {
239 struct vnode **a_vpp;
240 struct componentname *a_cnp;
248 static int validate_vops(struct vnode *vp, int after)
251 struct vnodeopv_entry_desc *this;
252 for (this=afs_vnodeop_entries; this->opve_op; this++) {
253 if (vp->v_op[this->opve_op->vdesc_offset] != this->opve_impl) {
255 printf("v_op %d ", after);
259 printf("For oper %d (%s), func is %p, not %p",
260 this->opve_op->vdesc_offset, this->opve_op->vdesc_name,
261 vp->v_op[this->opve_op->vdesc_offset], this->opve_impl);
269 struct vop_open_args /* {
272 struct ucred *a_cred;
278 struct vcache *vc = VTOAFS(ap->a_vp);
281 error = afs_open(&vc, ap->a_mode, ap->a_cred);
283 if (AFSTOV(vc) != ap->a_vp)
284 panic("AFS open changed vnode!");
286 afs_BozonLock(&vc->pvnLock, vc);
287 osi_FlushPages(vc, ap->a_cred);
288 afs_BozonUnlock(&vc->pvnLock, vc);
295 struct vop_close_args /* {
298 struct ucred *a_cred;
303 struct vcache *avc=ap->a_vp;
306 code=afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p);
308 code=afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p);
309 afs_BozonLock(&avc->pvnLock, avc);
310 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
311 afs_BozonUnlock(&avc->pvnLock, avc);
318 struct vop_access_args /* {
321 struct ucred *a_cred;
327 code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
333 struct vop_getattr_args /* {
336 struct ucred *a_cred;
342 code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
348 struct vop_setattr_args /* {
351 struct ucred *a_cred;
357 code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
362 struct vop_read_args /* {
366 struct ucred *a_cred;
371 struct vcache *avc=VTOAFS(ap->a_vp);
373 afs_BozonLock(&avc->pvnLock, avc);
374 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
375 code=afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0);
376 afs_BozonUnlock(&avc->pvnLock, avc);
382 struct vop_getpages_args /* {
387 vm_oofset_t a_offset;
391 int i, nextoff, size, toff, npages;
396 struct vcache *avc=VTOAFS(ap->a_vp);
398 if (avc->v.v_object == NULL) {
399 printf("afs_getpages: called with non-merged cache vnode??\n");
400 return VM_PAGER_ERROR;
402 npages=btoc(ap->a_count);
404 * If the requested page is partially valid, just return it and
405 * allow the pager to zero-out the blanks. Partially valid pages
406 * can only occur at the file EOF.
410 vm_page_t m = ap->a_m[ap->a_reqpage];
413 /* handled by vm_fault now */
414 /* vm_page_zero_invalid(m, TRUE); */
415 for (i = 0; i < npages; ++i) {
416 if (i != ap->a_reqpage)
417 vnode_pager_freepage(ap->a_m[i]);
422 bp = getpbuf(&afs_pbuf_freecnt);
423 kva = (vm_offset_t) bp->b_data;
424 pmap_qenter(kva, ap->a_m, npages);
425 iov.iov_base=(caddr_t)kva;
426 iov.iov_len=ap->a_count;
429 uio.uio_offset=IDX_TO_OFF(ap->a_m[0]->pindex);
430 uio.uio_resid=ap->a_count;
431 uio.uio_segflg=UIO_SYSSPACE;
433 uio.uio_procp=curproc;
435 afs_BozonLock(&avc->pvnLock, avc);
436 osi_FlushPages(avc, curproc->p_cred->pc_ucred); /* hold bozon lock, but not basic vnode lock */
437 code=afs_read(avc, &uio, curproc->p_cred->pc_ucred, 0, 0, 0);
438 afs_BozonUnlock(&avc->pvnLock, avc);
440 pmap_qremove(kva, npages);
442 relpbuf(bp, &afs_pbuf_freecnt);
443 if (code && (uio.uio_resid == ap->a_count)) {
444 for (i = 0; i < npages; ++i) {
445 if (i != ap->a_reqpage)
446 vnode_pager_freepage(ap->a_m[i]);
448 return VM_PAGER_ERROR;
450 size = ap->a_count - uio.uio_resid;
451 for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
453 nextoff = toff + PAGE_SIZE;
456 m->flags &= ~PG_ZERO;
458 if (nextoff <= size) {
460 * Read operation filled an entire page
462 m->valid = VM_PAGE_BITS_ALL;
464 } else if (size > toff) {
466 * Read operation filled a partial page.
469 vm_page_set_validclean(m, 0, size - toff);
470 /* handled by vm_fault now */
471 /* vm_page_zero_invalid(m, TRUE); */
474 if (i != ap->a_reqpage) {
476 * Whether or not to leave the page activated is up in
477 * the air, but we should put the page on a page queue
478 * somewhere (it already is in the object). Result:
479 * It appears that emperical results show that
480 * deactivating pages is best.
484 * Just in case someone was asking for this page we
485 * now tell them that it is ok to use.
488 if (m->flags & PG_WANTED)
491 vm_page_deactivate(m);
494 vnode_pager_freepage(m);
503 struct vop_write_args /* {
507 struct ucred *a_cred;
511 struct vcache *avc=VTOAFS(ap->a_vp);
513 afs_BozonLock(&avc->pvnLock, avc);
514 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
515 code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
516 afs_BozonUnlock(&avc->pvnLock, avc);
523 struct vop_putpages_args /* {
529 vm_oofset_t a_offset;
533 int i, size, npages, sync;
538 struct vcache *avc=VTOAFS(ap->a_vp);
540 if (avc->v.v_object == NULL) {
541 printf("afs_putpages: called with non-merged cache vnode??\n");
542 return VM_PAGER_ERROR;
544 if (vType(avc) != VREG) {
545 printf("afs_putpages: not VREG");
546 return VM_PAGER_ERROR;
548 npages=btoc(ap->a_count);
549 for (i=0; i < npages; i++ ) ap->a_rtvals[i]=VM_PAGER_AGAIN;
550 bp = getpbuf(&afs_pbuf_freecnt);
551 kva = (vm_offset_t) bp->b_data;
552 pmap_qenter(kva, ap->a_m, npages);
553 iov.iov_base=(caddr_t)kva;
554 iov.iov_len=ap->a_count;
557 uio.uio_offset=IDX_TO_OFF(ap->a_m[0]->pindex);
558 uio.uio_resid=ap->a_count;
559 uio.uio_segflg=UIO_SYSSPACE;
560 uio.uio_rw=UIO_WRITE;
561 uio.uio_procp=curproc;
563 if (ap->a_sync & VM_PAGER_PUT_SYNC)
565 /*if (ap->a_sync & VM_PAGER_PUT_INVAL)
569 afs_BozonLock(&avc->pvnLock, avc);
570 code=afs_write(avc, &uio, sync, curproc->p_cred->pc_ucred, 0);
571 afs_BozonUnlock(&avc->pvnLock, avc);
573 pmap_qremove(kva, npages);
575 relpbuf(bp, &afs_pbuf_freecnt);
577 size = ap->a_count - uio.uio_resid;
578 for (i = 0; i < round_page(size) / PAGE_SIZE; i++) {
579 ap->a_rtvals[i]=VM_PAGER_OK;
582 return VM_PAGER_ERROR;
584 return ap->a_rtvals[0];
588 struct vop_ioctl_args /* {
593 struct ucred *a_cred;
597 struct vcache *tvc = VTOAFS(ap->a_vp);
598 struct afs_ioctl data;
601 /* in case we ever get in here... */
603 AFS_STATCNT(afs_ioctl);
604 if (((ap->a_command >> 8) & 0xff) == 'V') {
605 /* This is a VICEIOCTL call */
607 error = HandleIoctl(tvc, (struct file *)0/*Not used*/,
608 ap->a_command, ap->a_data);
612 /* No-op call; just return. */
620 struct vop_poll_args /* {
623 struct ucred *a_cred;
628 * We should really check to see if I/O is possible.
635 * NB Currently unsupported.
640 struct vop_mmap_args /* {
643 struct ucred *a_cred;
652 struct vop_fsync_args /* {
654 struct ucred *a_cred;
659 int wait = ap->a_waitfor == MNT_WAIT;
661 register struct vnode *vp = ap->a_vp;
664 /*vflushbuf(vp, wait);*/
666 error=afs_fsync(VTOAFS(vp), ap->a_cred);
668 error=afs_fsync(VTOAFS(vp), &afs_osi_cred);
675 struct vop_remove_args /* {
678 struct componentname *a_cnp;
682 register struct vnode *vp = ap->a_vp;
683 register struct vnode *dvp = ap->a_dvp;
687 error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
696 struct vop_link_args /* {
698 struct vnode *a_tdvp;
699 struct componentname *a_cnp;
703 register struct vnode *dvp = ap->a_tdvp;
704 register struct vnode *vp = ap->a_vp;
709 if (dvp->v_mount != vp->v_mount) {
713 if (vp->v_type == VDIR) {
717 if (error = vn_lock(vp, LK_EXCLUSIVE, p)) {
721 error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
732 struct vop_rename_args /* {
733 struct vnode *a_fdvp;
735 struct componentname *a_fcnp;
736 struct vnode *a_tdvp;
738 struct componentname *a_tcnp;
742 struct componentname *fcnp = ap->a_fcnp;
744 struct componentname *tcnp = ap->a_tcnp;
746 struct vnode *tvp = ap->a_tvp;
747 register struct vnode *tdvp = ap->a_tdvp;
748 struct vnode *fvp = ap->a_fvp;
749 register struct vnode *fdvp = ap->a_fdvp;
750 struct proc *p=fcnp->cn_proc;
753 * Check for cross-device rename.
755 if ((fvp->v_mount != tdvp->v_mount) ||
756 (tvp && (fvp->v_mount != tvp->v_mount))) {
770 * if fvp == tvp, we're just removing one name of a pair of
771 * directory entries for the same element. convert call into rename.
772 ( (pinched from FreeBSD 4.4's ufs_rename())
776 if (fvp->v_type == VDIR) {
781 /* Release destination completely. */
788 fcnp->cn_flags &= ~MODMASK;
789 fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
790 if ((fcnp->cn_flags & SAVESTART) == 0)
791 panic("afs_rename: lost from startdir");
792 fcnp->cn_nameiop = DELETE;
794 error=relookup(fdvp, &fvp, fcnp);
801 error=VOP_REMOVE(fdvp, fvp, fcnp);
809 if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
812 MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK);
813 memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen);
814 fname[fcnp->cn_namelen] = '\0';
815 MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK);
816 memcpy(tname, tcnp->cn_nameptr, tcnp->cn_namelen);
817 tname[tcnp->cn_namelen] = '\0';
821 /* XXX use "from" or "to" creds? NFS uses "to" creds */
822 error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
840 struct vop_mkdir_args /* {
842 struct vnode **a_vpp;
843 struct componentname *a_cnp;
847 register struct vnode *dvp = ap->a_dvp;
848 register struct vattr *vap = ap->a_vap;
856 if ((cnp->cn_flags & HASBUF) == 0)
857 panic("afs_vop_mkdir: no name");
860 error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
868 *ap->a_vpp = AFSTOV(vcp);
869 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE|LK_RETRY, p);
878 struct vop_rmdir_args /* {
881 struct componentname *a_cnp;
885 register struct vnode *vp = ap->a_vp;
886 register struct vnode *dvp = ap->a_dvp;
890 error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
898 struct vop_symlink_args /* {
900 struct vnode **a_vpp;
901 struct componentname *a_cnp;
906 register struct vnode *dvp = ap->a_dvp;
908 /* NFS ignores a_vpp; so do we. */
912 error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
921 struct vop_readdir_args /* {
924 struct ucred *a_cred;
932 /* printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies,
934 off=ap->a_uio->uio_offset;
936 error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
939 if (!error && ap->a_ncookies != NULL) {
940 struct uio *uio = ap->a_uio;
941 const struct dirent *dp, *dp_start, *dp_end;
943 u_long *cookies, *cookiep;
945 if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
946 panic("afs_readdir: burned cookies");
947 dp = (const struct dirent *)
948 ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off));
950 dp_end = (const struct dirent *) uio->uio_iov->iov_base;
951 for (dp_start = dp, ncookies = 0;
953 dp = (const struct dirent *)((const char *) dp + dp->d_reclen))
956 MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
958 for (dp = dp_start, cookiep = cookies;
960 dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) {
964 *ap->a_cookies = cookies;
965 *ap->a_ncookies = ncookies;
973 struct vop_readlink_args /* {
976 struct ucred *a_cred;
980 /* printf("readlink %x\n", ap->a_vp);*/
982 error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
987 extern int prtactive;
991 struct vop_inactive_args /* {
996 register struct vnode *vp = ap->a_vp;
998 if (prtactive && vp->v_usecount != 0)
999 vprint("afs_vop_inactive(): pushing active", vp);
1002 afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */
1004 VOP_UNLOCK(vp, 0, ap->a_p);
1010 struct vop_reclaim_args /* {
1016 register struct vnode *vp = ap->a_vp;
1018 cache_purge(vp); /* just in case... */
1022 error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */
1025 if (!error && vp->v_data)
1026 panic("afs_reclaim: vnode not cleaned");
1029 if (vp->v_usecount == 2) {
1030 vprint("reclaim count==2", vp);
1031 } else if (vp->v_usecount == 1) {
1032 vprint("reclaim count==1", vp);
1034 vprint("reclaim bad count", vp);
1042 struct vop_lock_args /* {
1046 register struct vnode *vp = ap->a_vp;
1047 register struct vcache *avc = VTOAFS(vp);
1049 if (vp->v_tag == VT_NON)
1051 return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock,
1057 struct vop_unlock_args /* {
1061 struct vnode *vp = ap->a_vp;
1062 struct vcache *avc = VTOAFS(vp);
1063 return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
1064 &vp->v_interlock, ap->a_p));
1070 struct vop_bmap_args /* {
1073 struct vnode **a_vpp;
1082 *ap->a_bnp = ap->a_bn * (PAGE_SIZE / DEV_BSIZE);
1085 *ap->a_vpp = ap->a_vp;
1087 if (ap->a_runp != NULL)
1089 if (ap->a_runb != NULL)
1095 afs_vop_strategy(ap)
1096 struct vop_strategy_args /* {
1102 error= afs_ustrategy(ap->a_bp);
1108 struct vop_print_args /* {
1112 register struct vnode *vp = ap->a_vp;
1113 register struct vcache *vc = VTOAFS(ap->a_vp);
1115 printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
1116 vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens,
1117 vc->execsOrWriters);
1118 printf("\n states%s%s%s%s%s", (s&CStatd) ? " statd" : "", (s&CRO) ? " readonly" : "",(s&CDirty) ? " dirty" : "",(s&CMAPPED) ? " mapped" : "", (s&CVFlushed) ? " flush in progress" : "");
1124 afs_vop_islocked(ap)
1125 struct vop_islocked_args /* {
1129 struct vcache *vc = VTOAFS(ap->a_vp);
1130 return lockstatus(&vc->rwlock, ap->a_p);
1134 * Advisory record locking support (fcntl() POSIX style)
1138 struct vop_advlock_args /* {
1147 struct proc *p=curproc;
1149 cr=*p->p_cred->pc_ucred;
1151 error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr,