2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
16 #if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
18 * SOLARIS/osi_vnodeops.c
22 * Functions: AFS_TRYUP, _init, _info, _fini, afs_addmap, afs_delmap,
23 * afs_vmread, afs_vmwrite, afs_getpage, afs_GetOnePage, afs_putpage,
24 * afs_putapage, afs_nfsrdwr, afs_map, afs_PageLeft, afs_pathconf/afs_cntl,
25 * afs_ioctl, afs_rwlock, afs_rwunlock, afs_seek, afs_space, afs_dump,
26 * afs_cmp, afs_realvp, afs_pageio, afs_dumpctl, afs_dispose, afs_setsecattr,
27 * afs_getsecattr, gafs_open, gafs_close, gafs_getattr, gafs_setattr,
28 * gafs_access, gafs_lookup, gafs_create, gafs_remove, gafs_link,
29 * gafs_rename, gafs_mkdir, gafs_rmdir, gafs_readdir, gafs_symlink,
30 * gafs_readlink, gafs_fsync, afs_inactive, gafs_inactive, gafs_fid
33 * Variables: Afs_vnodeops
36 #include "afs/sysincludes.h" /* Standard vendor system headers */
37 #include "afsincludes.h" /* Afs-based standard headers */
38 #include "afs/afs_stats.h" /* statistics */
39 #include "afs/nfsclient.h"
48 #include <vm/seg_map.h>
49 #include <vm/seg_vn.h>
51 #if defined(AFS_SUN5_ENV)
52 #include <sys/modctl.h>
53 #include <sys/syscall.h>
57 #include <sys/debug.h>
58 #if defined(AFS_SUN5_ENV)
59 #include <sys/fs_subr.h>
62 #if defined(AFS_SUN5_ENV)
64 * XXX Temporary fix for problems with Solaris rw_tryupgrade() lock.
65 * It isn't very persistent in getting the upgrade when others are
66 * waiting for it and returns 0. So the UpgradeSToW() macro that the
67 * rw_tryupgrade used to map to wasn't good enough and we need to use
68 * the following code instead. Obviously this isn't the proper place
69 * for it but it's only called from here for now
76 if (!rw_tryupgrade(lock)) {
78 rw_enter(lock, RW_WRITER);
85 /* Translate a faultcode_t as returned by some of the vm routines
86 * into a suitable errno value.
89 afs_fc2errno(faultcode_t fc)
91 switch (FC_CODE(fc)) {
104 extern struct as kas; /* kernel addr space */
105 extern unsigned char *afs_indexFlags;
106 extern afs_lock_t afs_xdcache;
108 /* Additional vnodeops for SunOS 4.0.x */
109 int afs_nfsrdwr(), afs_getpage(), afs_putpage(), afs_map();
110 int afs_dump(), afs_cmp(), afs_realvp(), afs_GetOnePage();
117 afs_addmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp)
118 register struct vnode *avp;
122 int length, prot, maxprot, flags;
123 struct AFS_UCRED *credp;
125 /* XXX What should we do here?? XXX */
130 afs_delmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp)
131 register struct vnode *avp;
135 int length, prot, maxprot, flags;
136 struct AFS_UCRED *credp;
138 /* XXX What should we do here?? XXX */
143 afs_vmread(avp, auio, ioflag, acred)
144 register struct vnode *avp;
147 struct AFS_UCRED *acred;
151 if (!RW_READ_HELD(&(VTOAFS(avp))->rwlock))
152 osi_Panic("afs_vmread: !rwlock");
154 code = afs_nfsrdwr(VTOAFS(avp), auio, UIO_READ, ioflag, acred);
161 afs_vmwrite(avp, auio, ioflag, acred)
162 register struct vnode *avp;
165 struct AFS_UCRED *acred;
169 if (!RW_WRITE_HELD(&(VTOAFS(avp))->rwlock))
170 osi_Panic("afs_vmwrite: !rwlock");
172 code = afs_nfsrdwr(VTOAFS(avp), auio, UIO_WRITE, ioflag, acred);
177 #endif /* AFS_SUN5_ENV */
180 afs_getpage(vp, off, len, protp, pl, plsz, seg, addr, rw, acred)
195 struct AFS_UCRED *acred;
197 register afs_int32 code = 0;
198 AFS_STATCNT(afs_getpage);
201 if (vp->v_flag & VNOMAP) /* File doesn't allow mapping */
207 #if defined(AFS_SUN56_ENV)
210 afs_GetOnePage(vp, off, len, protp, pl, plsz, seg, addr, rw,
216 afs_GetOnePage(vp, (u_int) off, len, protp, pl, plsz, seg, addr,
220 code = afs_GetOnePage(vp, off, protp, pl, plsz, seg, addr, rw, acred);
224 struct vcache *vcp = VTOAFS(vp);
226 ObtainWriteLock(&vcp->vlock, 548);
228 ReleaseWriteLock(&vcp->vlock);
230 afs_BozonLock(&vcp->pvnLock, vcp);
231 #if defined(AFS_SUN56_ENV)
233 pvn_getpages(afs_GetOnePage, vp, off, len, protp, pl, plsz, seg,
237 pvn_getpages(afs_GetOnePage, vp, (u_int) off, len, protp, pl,
238 plsz, seg, addr, rw, acred);
240 afs_BozonUnlock(&vcp->pvnLock, vcp);
242 ObtainWriteLock(&vcp->vlock, 549);
244 ReleaseWriteLock(&vcp->vlock);
251 /* Return all the pages from [off..off+len) in file */
254 afs_GetOnePage(vp, off, alen, protp, pl, plsz, seg, addr, rw, acred)
258 afs_GetOnePage(vp, off, protp, pl, plsz, seg, addr, rw, acred)
261 #if defined(AFS_SUN56_ENV)
276 struct AFS_UCRED *acred;
278 register struct page *page;
279 register afs_int32 code = 0;
283 register struct vcache *avc;
284 register struct dcache *tdc;
287 afs_size_t offset, nlen;
288 struct vrequest treq;
289 afs_int32 mapForRead = 0, Code = 0;
290 #if defined(AFS_SUN56_ENV)
298 osi_Panic("GetOnePage: !acred");
300 acred = u.u_cred; /* better than nothing */
303 avc = VTOAFS(vp); /* cast to afs vnode */
306 if (avc->credp /*&& AFS_NFSXLATORREQ(acred) */
307 && AFS_NFSXLATORREQ(avc->credp)) {
311 if (code = afs_InitReq(&treq, acred))
315 /* This is a read-ahead request, e.g. due to madvise. */
321 ObtainReadLock(&avc->lock);
323 while (plen > 0 && !afs_BBusy()) {
324 /* Obtain a dcache entry at off. 2 means don't fetch data. */
326 afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen,
331 /* Write-lock the dcache entry, if we don't succeed, just go on */
332 if (0 != NBObtainWriteLock(&tdc->lock, 642)) {
337 /* If we aren't already fetching this dcache entry, queue it */
338 if (!(tdc->mflags & DFFetchReq)) {
341 tdc->mflags |= DFFetchReq;
342 bp = afs_BQueue(BOP_FETCH, avc, B_DONTWAIT, 0, acred,
343 (afs_size_t) off, (afs_size_t) 1, tdc);
345 /* Unable to start background fetch; might as well stop */
346 tdc->mflags &= ~DFFetchReq;
347 ReleaseWriteLock(&tdc->lock);
351 ReleaseWriteLock(&tdc->lock);
353 ReleaseWriteLock(&tdc->lock);
358 /* Adjust our offset and remaining length values */
362 /* If we aren't making progress for some reason, bail out */
367 ReleaseReadLock(&avc->lock);
372 pl[0] = NULL; /* Make sure it's empty */
374 /* first, obtain the proper lock for the VM system */
376 /* if this is a read request, map the page in read-only. This will
377 * allow us to swap out the dcache entry if there are only read-only
378 * pages created for the chunk, which helps a *lot* when dealing
379 * with small caches. Otherwise, we have to invalidate the vm
380 * pages for the range covered by a chunk when we swap out the
383 if (rw == S_READ || rw == S_EXEC)
389 if (AFS_NFSXLATORREQ(acred)) {
392 (avc, PRSFS_READ, &treq,
393 CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) {
402 if (rw == S_WRITE || rw == S_CREATE)
403 tdc = afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, 5);
405 tdc = afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, 1);
409 code = afs_VerifyVCache(avc, &treq);
414 return afs_CheckCode(code, &treq, 44); /* failed to get it */
417 afs_BozonLock(&avc->pvnLock, avc);
418 ObtainReadLock(&avc->lock);
420 afs_Trace4(afs_iclSetp, CM_TRACE_PAGEIN, ICL_TYPE_POINTER, (afs_int32) vp,
421 ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off), ICL_TYPE_LONG, len,
422 ICL_TYPE_LONG, (int)rw);
428 /* Check to see if we're in the middle of a VM purge, and if we are, release
429 * the locks and try again when the VM purge is done. */
430 ObtainWriteLock(&avc->vlock, 550);
432 ReleaseReadLock(&avc->lock);
433 ReleaseWriteLock(&avc->vlock);
434 afs_BozonUnlock(&avc->pvnLock, avc);
436 /* Check activeV again, it may have been turned off
437 * while we were waiting for a lock in afs_PutDCache */
438 ObtainWriteLock(&avc->vlock, 574);
440 avc->vstates |= VRevokeWait;
441 ReleaseWriteLock(&avc->vlock);
442 afs_osi_Sleep(&avc->vstates);
444 ReleaseWriteLock(&avc->vlock);
448 ReleaseWriteLock(&avc->vlock);
451 /* We're about to do stuff with our dcache entry.. Lock it. */
452 ObtainReadLock(&tdc->lock);
454 /* Check to see whether the cache entry is still valid */
455 if (!(avc->states & CStatd)
456 || !hsame(avc->m.DataVersion, tdc->f.versionNo)) {
457 ReleaseReadLock(&tdc->lock);
458 ReleaseReadLock(&avc->lock);
459 afs_BozonUnlock(&avc->pvnLock, avc);
465 while (1) { /* loop over all pages */
466 /* now, try to find the page in memory (it may already be intransit or laying
467 * around the free list */
469 page_lookup(vp, toffset, (rw == S_CREATE ? SE_EXCL : SE_SHARED));
473 /* if we make it here, we can't find the page in memory. Do a real disk read
474 * from the cache to get the data */
475 Code |= 0x200; /* XXX */
477 #if defined(AFS_SUN54_ENV)
478 /* use PG_EXCL because we know the page does not exist already. If it
479 * actually does exist, we have somehow raced between lookup and create.
480 * As of 4/98, that shouldn't be possible, but we'll be defensive here
481 * in case someone tries to relax all the serialization of read and write
482 * operations with harmless things like stat. */
483 #if defined(AFS_SUN58_ENV)
485 page_create_va(vp, toffset, PAGESIZE, PG_WAIT | PG_EXCL, seg,
489 page_create_va(vp, toffset, PAGESIZE, PG_WAIT | PG_EXCL,
493 page = page_create(vp, toffset, PAGESIZE, PG_WAIT);
499 pagezero(page, alen, PAGESIZE - alen);
501 page = rm_allocpage(seg, addr, PAGESIZE, 1); /* can't fail */
503 osi_Panic("afs_getpage alloc page");
504 /* we get a circularly-linked list of pages back, but we expect only
505 * one, since that's what we asked for */
506 if (page->p_next != page)
507 osi_Panic("afs_getpage list");
508 /* page enter returns a locked page; we'll drop the lock as a side-effect
509 * of the pvn_done done by afs_ustrategy. If we decide not to call
510 * strategy, we must be sure to call pvn_fail, at least, to release the
511 * page locks and otherwise reset the pages. The page, while locked, is
512 * not held, for what it is worth */
513 page->p_intrans = 1; /* set appropriate flags */
515 /* next call shouldn't fail, since we have pvnLock set */
516 if (page_enter(page, vp, toffset))
517 osi_Panic("afs_getpage enter race");
518 #endif /* AFS_SUN5_ENV */
521 if (rw == S_CREATE) {
522 /* XXX Don't read from AFS in write only cases XXX */
523 page_io_unlock(page);
527 /* XXX Don't read from AFS in write only cases XXX */
528 page->p_intrans = page->p_pagein = 0;
529 page_unlock(page); /* XXX */
536 /* now it is time to start I/O operation */
537 buf = pageio_setup(page, PAGESIZE, vp, B_READ); /* allocate a buf structure */
538 #if defined(AFS_SUN5_ENV)
542 buf->b_blkno = btodb(toffset);
543 bp_mapin(buf); /* map it in to our address space */
545 #if defined(AFS_SUN5_ENV)
547 /* afs_ustrategy will want to lock the dcache entry */
548 ReleaseReadLock(&tdc->lock);
549 code = afs_ustrategy(buf, acred); /* do the I/O */
550 ObtainReadLock(&tdc->lock);
553 ReleaseReadLock(&tdc->lock);
554 ReleaseReadLock(&avc->lock);
555 code = afs_ustrategy(buf); /* do the I/O */
556 ObtainReadLock(&avc->lock);
557 ObtainReadLock(&tdc->lock);
561 /* Before freeing unmap the buffer */
572 page_io_unlock(page);
576 /* come here when we have another page (already held) to enter */
578 /* put page in array and continue */
580 /* The p_selock must be downgraded to a shared lock after the page is read */
581 #if defined(AFS_SUN56_ENV)
582 if ((rw != S_CREATE) && !(PAGE_SHARED(page)))
584 if ((rw != S_CREATE) && !(se_shared_assert(&page->p_selock)))
587 page_downgrade(page);
592 code = page_iolock_assert(page);
599 break; /* done all the pages */
600 } /* while (1) ... */
604 ReleaseReadLock(&tdc->lock);
606 /* Prefetch next chunk if we're at a chunk boundary */
607 if (AFS_CHUNKOFFSET(off) == 0) {
608 if (!(tdc->mflags & DFNextStarted))
609 afs_PrefetchChunk(avc, tdc, acred, &treq);
612 ReleaseReadLock(&avc->lock);
614 ObtainWriteLock(&afs_xdcache, 246);
616 /* track that we have dirty (or dirty-able) pages for this chunk. */
617 afs_indexFlags[tdc->index] |= IFDirtyPages;
619 afs_indexFlags[tdc->index] |= IFAnyPages;
620 ReleaseWriteLock(&afs_xdcache);
622 afs_BozonUnlock(&avc->pvnLock, avc);
626 afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code,
627 ICL_TYPE_LONG, (int)page, ICL_TYPE_LONG, Code);
632 afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code,
633 ICL_TYPE_LONG, (int)page, ICL_TYPE_LONG, Code);
634 /* release all pages, drop locks, return code */
637 pvn_read_done(page, B_ERROR);
639 for (i = 0; i < slot; i++)
642 ReleaseReadLock(&avc->lock);
643 afs_BozonUnlock(&avc->pvnLock, avc);
645 ReleaseReadLock(&tdc->lock);
653 afs_putpage(vp, off, len, flags, cred)
658 struct AFS_UCRED *cred;
663 #if defined(AFS_SUN58_ENV)
669 afs_int32 NPages = 0;
670 #if defined(AFS_SUN56_ENV)
671 u_offset_t toff = off;
677 AFS_STATCNT(afs_putpage);
678 if (vp->v_flag & VNOMAP) /* file doesn't allow mapping */
682 * Putpage (ASYNC) is called every sec to flush out dirty vm pages
685 afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUT, ICL_TYPE_POINTER,
686 (afs_int32) vp, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off),
687 ICL_TYPE_INT32, (afs_int32) len, ICL_TYPE_LONG, (int)flags);
689 afs_BozonLock(&avc->pvnLock, avc);
690 ObtainSharedLock(&avc->lock, 247);
693 /* Get a list of modified (or whatever) pages */
695 endPos = (afs_offs_t) off + len; /* position we're supposed to write up to */
696 while ((afs_offs_t) toff < endPos
697 && (afs_offs_t) toff < avc->m.Length) {
698 /* If not invalidating pages use page_lookup_nowait to avoid reclaiming
699 * them from the free list
702 if (flags & (B_FREE | B_INVAL))
703 pages = page_lookup(vp, toff, SE_EXCL);
705 pages = page_lookup_nowait(vp, toff, SE_SHARED);
706 if (!pages || !pvn_getdirty(pages, flags))
712 UpgradeSToWLock(&avc->lock, 671);
716 code = afs_putapage(vp, pages, &toff, &tlen, flags, cred);
727 UpgradeSToWLock(&avc->lock, 670);
732 #if defined(AFS_SUN56_ENV)
733 code = pvn_vplist_dirty(vp, toff, afs_putapage, flags, cred);
735 code = pvn_vplist_dirty(vp, (u_int) off, afs_putapage, flags, cred);
740 if (code && !avc->vc_error) {
742 UpgradeSToWLock(&avc->lock, 669);
745 avc->vc_error = code;
749 ReleaseWriteLock(&avc->lock);
751 ReleaseSharedLock(&avc->lock);
752 afs_BozonUnlock(&avc->pvnLock, avc);
753 afs_Trace2(afs_iclSetp, CM_TRACE_PAGEOUTDONE, ICL_TYPE_LONG, code,
754 ICL_TYPE_LONG, NPages);
761 afs_putapage(struct vnode *vp, struct page *pages,
762 #if defined(AFS_SUN56_ENV)
767 #if defined(AFS_SUN58_ENV)
772 int flags, struct AFS_UCRED *credp)
775 struct vcache *avc = VTOAFS(vp);
777 u_int tlen = PAGESIZE;
778 afs_offs_t off = (pages->p_offset / PAGESIZE) * PAGESIZE;
781 * Now we've got the modified pages. All pages are locked and held
782 * XXX Find a kluster that fits in one block (or page). We also
783 * adjust the i/o if the file space is less than a while page. XXX
785 if (off + tlen > avc->m.Length) {
786 tlen = avc->m.Length - off;
788 /* can't call mapout with 0 length buffers (rmfree panics) */
789 if (((tlen >> 24) & 0xff) == 0xff) {
794 * Can't call mapout with 0 length buffers since we'll get rmfree panics
796 tbuf = pageio_setup(pages, tlen, vp, B_WRITE | flags);
801 tbuf->b_blkno = btodb(pages->p_offset);
804 afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUTONE, ICL_TYPE_LONG, avc,
805 ICL_TYPE_LONG, pages, ICL_TYPE_LONG, tlen, ICL_TYPE_OFFSET,
806 ICL_HANDLE_OFFSET(off));
807 code = afs_ustrategy(tbuf, credp); /* unlocks page */
811 pvn_write_done(pages, ((code) ? B_ERROR : 0) | B_WRITE | flags);
821 #else /* AFS_SUN5_ENV */
824 afs_putpage(vp, off, len, flags, cred)
829 struct AFS_UCRED *cred;
831 int wholeEnchilada; /* true if we must get all of the pages */
837 afs_int32 code = 0, rcode;
839 afs_int32 clusterStart, clusterEnd, endPos;
841 /* In the wholeEnchilada case, we must ensure that we get all of the pages
842 * from the system, since we're doing this to shutdown the use of a vnode */
844 AFS_STATCNT(afs_putpage);
845 wholeEnchilada = (off == 0 && len == 0
846 && (flags & (B_INVAL | B_ASYNC)) == B_INVAL);
849 afs_BozonLock(&avc->pvnLock, avc);
850 ObtainWriteLock(&avc->lock, 248);
853 /* in whole enchilada case, loop until call to pvn_getdirty can't find
854 * any more modified pages */
856 /* first we try to get a list of modified (or whatever) pages */
858 pages = pvn_vplist_dirty(vp, off, flags);
860 endPos = off + len; /* position we're supposed to write up to */
861 if (endPos > avc->m.Length)
862 endPos = avc->m.Length; /* bound by this */
863 clusterStart = off & ~(PAGESIZE - 1); /* round down to nearest page */
864 clusterEnd = ((endPos - 1) | (PAGESIZE - 1)) + 1; /* round up to nearest page */
866 pvn_range_dirty(vp, off, endPos, clusterStart, clusterEnd,
870 /* Now we've got the modified pages. All pages are locked and held */
871 rcode = 0; /* return code */
872 while (pages) { /* look over all pages in the returned set */
873 tpage = pages; /* get first page in the list */
875 /* write out the page */
876 poffset = tpage->p_offset; /* where the page starts in the file */
877 /* tlen will represent the end of the range to write, for a while */
878 tlen = PAGESIZE + poffset; /* basic place to end tpage write */
879 /* but we also don't want to write past end of off..off+len range */
880 if (len != 0 && tlen > off + len)
882 /* and we don't want to write past the end of the file */
883 if (tlen > avc->m.Length)
884 tlen = avc->m.Length;
885 /* and we don't want to write at all if page starts after end */
886 if (poffset >= tlen) {
887 pvn_fail(pages, B_WRITE | flags);
890 /* finally change tlen from end position to length */
891 tlen -= poffset; /* compute bytes to write from this page */
892 page_sub(&pages, tpage); /* remove tpage from "pages" list */
893 tbuf = pageio_setup(tpage, tlen, vp, B_WRITE | flags);
895 pvn_fail(tpage, B_WRITE | flags);
896 pvn_fail(pages, B_WRITE | flags);
900 tbuf->b_blkno = btodb(tpage->p_offset);
902 ReleaseWriteLock(&avc->lock); /* can't hold during strategy call */
903 code = afs_ustrategy(tbuf); /* unlocks page */
904 ObtainWriteLock(&avc->lock, 249); /* re-obtain */
906 /* unlocking of tpage is done by afs_ustrategy */
908 if (pages) /* may have already removed last page */
909 pvn_fail(pages, B_WRITE | flags);
912 } /* for (tpage=pages....) */
914 /* see if we've gotten all of the pages in the whole enchilada case */
915 if (!wholeEnchilada || !vp->v_pages)
917 } /* while(1) obtaining all pages */
920 * If low on chunks, and if writing the last byte of a chunk, try to
921 * free some. Note that afs_DoPartialWrite calls osi_SyncVM which now
922 * calls afs_putpage, so this is recursion. It stops there because we
923 * insist on len being non-zero.
925 if (afs_stats_cmperf.cacheCurrDirtyChunks >
926 afs_stats_cmperf.cacheMaxDirtyChunks && len != 0
927 && AFS_CHUNKOFFSET((off + len)) == 0) {
928 struct vrequest treq;
929 if (!afs_InitReq(&treq, cred ? cred : u.u_cred)) {
930 rcode = afs_DoPartialWrite(avc, &treq); /* XXX */
936 if (rcode && !avc->vc_error)
937 avc->vc_error = rcode;
939 /* when we're here, we just return code. */
940 ReleaseWriteLock(&avc->lock);
941 afs_BozonUnlock(&avc->pvnLock, avc);
945 #endif /* AFS_SUN5_ENV */
948 afs_nfsrdwr(avc, auio, arw, ioflag, acred)
949 register struct vcache *avc;
953 struct AFS_UCRED *acred;
955 register afs_int32 code;
958 afs_int32 mode, sflags;
960 struct dcache *dcp, *dcp_newpage;
961 afs_size_t fileBase, size;
963 register afs_int32 tsize;
964 register afs_int32 pageOffset, extraResid = 0;
965 register afs_size_t origLength; /* length when reading/writing started */
966 register long appendLength; /* length when this call will finish */
967 int created; /* created pages instead of faulting them */
969 int didFakeOpen, eof;
970 struct vrequest treq;
974 AFS_STATCNT(afs_nfsrdwr);
976 /* can't read or write other things */
977 if (vType(avc) != VREG)
980 if (auio->uio_resid == 0)
983 afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, (afs_int32) avc,
984 ICL_TYPE_LONG, (arw == UIO_WRITE ? 1 : 0), ICL_TYPE_OFFSET,
985 ICL_HANDLE_OFFSET(auio->uio_offset), ICL_TYPE_OFFSET,
986 ICL_HANDLE_OFFSET(auio->uio_resid));
988 #ifndef AFS_64BIT_CLIENT
989 if (AfsLargeFileUio(auio)) /* file is larger than 2 GB */
995 osi_Panic("rdwr: !acred");
1000 if (code = afs_InitReq(&treq, acred))
1003 /* It's not really possible to know if a write cause a growth in the
1004 * cache size, we we wait for a cache drain for any write.
1006 afs_MaybeWakeupTruncateDaemon();
1007 while ((arw == UIO_WRITE)
1008 && (afs_blocksUsed > (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) {
1009 if (afs_blocksUsed - afs_blocksDiscarded >
1010 (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
1011 afs_WaitForCacheDrain = 1;
1012 afs_osi_Sleep(&afs_WaitForCacheDrain);
1014 afs_MaybeFreeDiscardedDCache();
1015 afs_MaybeWakeupTruncateDaemon();
1017 code = afs_VerifyVCache(avc, &treq);
1019 return afs_CheckCode(code, &treq, 45);
1021 afs_BozonLock(&avc->pvnLock, avc);
1022 osi_FlushPages(avc, acred); /* hold bozon lock, but not basic vnode lock */
1024 ObtainWriteLock(&avc->lock, 250);
1026 /* adjust parameters when appending files */
1027 if ((ioflag & IO_APPEND) && arw == UIO_WRITE) {
1028 #if defined(AFS_SUN56_ENV)
1029 auio->uio_loffset = 0;
1031 auio->uio_offset = avc->m.Length; /* write at EOF position */
1033 if (auio->uio_offset < 0 || (auio->uio_offset + auio->uio_resid) < 0) {
1034 ReleaseWriteLock(&avc->lock);
1035 afs_BozonUnlock(&avc->pvnLock, avc);
1038 #ifndef AFS_64BIT_CLIENT
1039 /* file is larger than 2GB */
1040 if (AfsLargeFileSize(auio->uio_offset, auio->uio_resid)) {
1041 ReleaseWriteLock(&avc->lock);
1042 afs_BozonUnlock(&avc->pvnLock, avc);
1047 didFakeOpen = 0; /* keep track of open so we can do close */
1048 if (arw == UIO_WRITE) {
1049 /* do ulimit processing; shrink resid or fail */
1050 #if defined(AFS_SUN56_ENV)
1051 if (auio->uio_loffset + auio->afsio_resid > auio->uio_llimit) {
1052 if (auio->uio_llimit >= auio->uio_llimit) {
1053 ReleaseWriteLock(&avc->lock);
1054 afs_BozonUnlock(&avc->pvnLock, avc);
1057 /* track # of bytes we should write, but won't because of
1058 * ulimit; we must add this into the final resid value
1059 * so caller knows we punted some data.
1061 extraResid = auio->uio_resid;
1062 auio->uio_resid = auio->uio_llimit - auio->uio_loffset;
1063 extraResid -= auio->uio_resid;
1067 #ifdef AFS_SUN52_ENV
1068 if (auio->afsio_offset + auio->afsio_resid > auio->uio_limit) {
1069 if (auio->afsio_offset >= auio->uio_limit) {
1070 ReleaseWriteLock(&avc->lock);
1071 afs_BozonUnlock(&avc->pvnLock, avc);
1074 /* track # of bytes we should write, but won't because of
1075 * ulimit; we must add this into the final resid value
1076 * so caller knows we punted some data.
1078 extraResid = auio->uio_resid;
1079 auio->uio_resid = auio->uio_limit - auio->afsio_offset;
1080 extraResid -= auio->uio_resid;
1085 mode = S_WRITE; /* segment map-in mode */
1086 afs_FakeOpen(avc); /* do this for writes, so data gets put back
1087 * when we want it to be put back */
1088 didFakeOpen = 1; /* we'll be doing a fake open */
1089 /* before starting any I/O, we must ensure that the file is big enough
1090 * to hold the results (since afs_putpage will be called to force the I/O */
1091 size = auio->afsio_resid + auio->afsio_offset; /* new file size */
1092 appendLength = size;
1093 origLength = avc->m.Length;
1094 if (size > avc->m.Length) {
1095 afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, ICL_TYPE_STRING,
1096 __FILE__, ICL_TYPE_LONG, __LINE__, ICL_TYPE_OFFSET,
1097 ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET,
1098 ICL_HANDLE_OFFSET(size));
1099 avc->m.Length = size; /* file grew */
1101 avc->states |= CDirty; /* Set the dirty bit */
1102 avc->m.Date = osi_Time(); /* Set file date (for ranlib) */
1104 mode = S_READ; /* map-in read-only */
1105 origLength = avc->m.Length;
1108 if (acred && AFS_NFSXLATORREQ(acred)) {
1109 if (arw == UIO_READ) {
1111 (avc, PRSFS_READ, &treq,
1112 CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) {
1113 ReleaseWriteLock(&avc->lock);
1114 afs_BozonUnlock(&avc->pvnLock, avc);
1126 counter = 0; /* don't call afs_DoPartialWrite first time through. */
1128 /* compute the amount of data to move into this block,
1129 * based on auio->afsio_resid. Note that we copy data in units of
1130 * MAXBSIZE, not PAGESIZE. This is because segmap_getmap panics if you
1131 * call it with an offset based on blocks smaller than MAXBSIZE
1132 * (implying that it should be named BSIZE, since it is clearly both a
1133 * max and a min). */
1134 size = auio->afsio_resid; /* transfer size */
1135 fileBase = auio->afsio_offset; /* start file position for xfr */
1136 pageBase = fileBase & ~(MAXBSIZE - 1); /* file position of the page */
1137 pageOffset = fileBase & (MAXBSIZE - 1); /* xfr start's offset within page */
1138 tsize = MAXBSIZE - pageOffset; /* how much more fits in this page */
1139 /* we'll read tsize bytes, but first must make sure tsize isn't too big */
1141 tsize = size; /* don't read past end of request */
1142 eof = 0; /* flag telling us if we hit the EOF on the read */
1143 if (arw == UIO_READ) { /* we're doing a read operation */
1144 /* don't read past EOF */
1145 if (fileBase + tsize > origLength) {
1146 tsize = origLength - fileBase;
1147 eof = 1; /* we did hit the EOF */
1149 tsize = 0; /* better safe than sorry */
1154 /* Purge dirty chunks of file if there are too many dirty
1155 * chunks. Inside the write loop, we only do this at a chunk
1156 * boundary. Clean up partial chunk if necessary at end of loop.
1158 if (counter > 0 && code == 0 && AFS_CHUNKOFFSET(fileBase) == 0) {
1159 code = afs_DoPartialWrite(avc, &treq);
1163 #endif /* AFS_SUN5_ENV */
1164 /* write case, we ask segmap_release to call putpage. Really, we
1165 * don't have to do this on every page mapin, but for now we're
1166 * lazy, and don't modify the rest of AFS to scan for modified
1167 * pages on a close or other "synchronize with file server"
1168 * operation. This makes things a little cleaner, but probably
1169 * hurts performance. */
1174 break; /* nothing to transfer, we're done */
1177 if (arw == UIO_WRITE)
1178 avc->states |= CDirty; /* may have been cleared by DoPartialWrite */
1180 /* Before dropping lock, hold the chunk (create it if necessary). This
1181 * serves two purposes: (1) Ensure Cache Truncate Daemon doesn't try
1182 * to purge the chunk's pages while we have them locked. This would
1183 * cause deadlock because we might be waiting for the CTD to free up
1184 * a chunk. (2) If we're writing past the original EOF, and we're
1185 * at the base of the chunk, then make sure it exists online
1186 * before we do the uiomove, since the segmap_release will
1187 * write out to the chunk, causing it to get fetched if it hasn't
1188 * been created yet. The code that would otherwise notice that
1189 * we're fetching a chunk past EOF won't work, since we've
1190 * already adjusted the file size above.
1192 ObtainWriteLock(&avc->vlock, 551);
1193 while (avc->vstates & VPageCleaning) {
1194 ReleaseWriteLock(&avc->vlock);
1195 ReleaseWriteLock(&avc->lock);
1196 afs_osi_Sleep(&avc->vstates);
1197 ObtainWriteLock(&avc->lock, 334);
1198 ObtainWriteLock(&avc->vlock, 552);
1200 ReleaseWriteLock(&avc->vlock);
1202 afs_size_t toff, tlen;
1203 dcp = afs_GetDCache(avc, fileBase, &treq, &toff, &tlen, 2);
1210 ReleaseWriteLock(&avc->lock); /* uiomove may page fault */
1212 #if defined(AFS_SUN56_ENV)
1213 data = segmap_getmap(segkmap, AFSTOV(avc), (u_offset_t) pageBase);
1215 data = segmap_getmap(segkmap, AFSTOV(avc), pageBase);
1217 #ifndef AFS_SUN5_ENV
1219 afs_fc2errno(as_fault
1220 (&kas, data + pageOffset, tsize, F_SOFTLOCK, mode));
1222 AFS_UIOMOVE(data + pageOffset, tsize, arw, auio, code);
1223 as_fault(&kas, data + pageOffset, tsize, F_SOFTUNLOCK, mode);
1224 code2 = segmap_release(segkmap, data, sflags);
1228 (void)segmap_release(segkmap, data, 0);
1231 #if defined(AFS_SUN56_ENV)
1232 raddr = (caddr_t) (((uintptr_t) data + pageOffset) & PAGEMASK);
1234 raddr = (caddr_t) (((u_int) data + pageOffset) & PAGEMASK);
1237 (((u_int) data + pageOffset + tsize + PAGEOFFSET) & PAGEMASK) -
1240 /* if we're doing a write, and we're starting at the rounded
1241 * down page base, and we're writing enough data to cover all
1242 * created pages, then we must be writing all of the pages
1243 * in this MAXBSIZE window that we're creating.
1246 if (arw == UIO_WRITE && ((long)raddr == (long)data + pageOffset)
1247 && tsize >= rsize) {
1248 /* probably the dcache backing this guy is around, but if
1249 * not, we can't do this optimization, since we're creating
1250 * writable pages, which must be backed by a chunk.
1253 dcp_newpage = afs_FindDCache(avc, pageBase);
1255 && hsame(avc->m.DataVersion, dcp_newpage->f.versionNo)) {
1256 ObtainWriteLock(&avc->lock, 251);
1257 ObtainWriteLock(&avc->vlock, 576);
1258 ObtainReadLock(&dcp_newpage->lock);
1259 if ((avc->activeV == 0)
1260 && hsame(avc->m.DataVersion, dcp_newpage->f.versionNo)
1261 && !(dcp_newpage->dflags & (DFFetching))) {
1263 segmap_pagecreate(segkmap, raddr, rsize, 1);
1265 ObtainWriteLock(&afs_xdcache, 252);
1266 /* Mark the pages as created and dirty */
1267 afs_indexFlags[dcp_newpage->index]
1268 |= (IFAnyPages | IFDirtyPages);
1269 ReleaseWriteLock(&afs_xdcache);
1272 ReleaseReadLock(&dcp_newpage->lock);
1273 afs_PutDCache(dcp_newpage);
1274 ReleaseWriteLock(&avc->vlock);
1275 ReleaseWriteLock(&avc->lock);
1276 } else if (dcp_newpage)
1277 afs_PutDCache(dcp_newpage);
1282 afs_fc2errno(segmap_fault
1283 (kas.a_hat, segkmap, raddr, rsize,
1287 AFS_UIOMOVE(data + pageOffset, tsize, arw, auio, code);
1288 segmap_fault(kas.a_hat, segkmap, raddr, rsize, F_SOFTUNLOCK,
1292 code = segmap_release(segkmap, data, sflags);
1294 (void)segmap_release(segkmap, data, 0);
1296 #endif /* AFS_SUN5_ENV */
1298 ObtainWriteLock(&avc->lock, 253);
1303 #endif /* AFS_SUN5_ENV */
1308 afs_FakeClose(avc, acred);
1311 if (arw == UIO_WRITE && (avc->states & CDirty)) {
1312 code2 = afs_DoPartialWrite(avc, &treq);
1316 #endif /* AFS_SUN5_ENV */
1318 if (!code && avc->vc_error) {
1319 code = avc->vc_error;
1321 ReleaseWriteLock(&avc->lock);
1322 afs_BozonUnlock(&avc->pvnLock, avc);
1324 #ifdef AFS_SUN53_ENV
1325 if ((ioflag & FSYNC) && (arw == UIO_WRITE)
1326 && !AFS_NFSXLATORREQ(acred))
1327 code = afs_fsync(avc, 0, acred);
1329 if ((ioflag & IO_SYNC) && (arw == UIO_WRITE)
1330 && !AFS_NFSXLATORREQ(acred))
1331 code = afs_fsync(avc, acred);
1334 #ifdef AFS_SUN52_ENV
1336 * If things worked, add in as remaining in request any bytes
1337 * we didn't write due to file size ulimit.
1339 if (code == 0 && extraResid > 0)
1340 auio->uio_resid += extraResid;
1342 return afs_CheckCode(code, &treq, 46);
1345 afs_map(vp, off, as, addr, len, prot, maxprot, flags, cred)
1357 u_char prot, maxprot;
1359 u_int prot, maxprot;
1362 struct AFS_UCRED *cred;
1364 struct segvn_crargs crargs;
1365 register afs_int32 code;
1366 struct vrequest treq;
1367 register struct vcache *avc = VTOAFS(vp);
1369 AFS_STATCNT(afs_map);
1372 /* check for reasonableness on segment bounds; apparently len can be < 0 */
1373 if (off < 0 || off + len < 0) {
1376 #ifndef AFS_64BIT_CLIENT
1377 if (AfsLargeFileSize(off, len)) { /* file is larger than 2 GB */
1383 #if defined(AFS_SUN5_ENV)
1384 if (vp->v_flag & VNOMAP) /* File isn't allowed to be mapped */
1387 if (vp->v_filocks) /* if locked, disallow mapping */
1391 if (code = afs_InitReq(&treq, cred))
1394 if (vp->v_type != VREG) {
1399 code = afs_VerifyVCache(avc, &treq);
1403 afs_BozonLock(&avc->pvnLock, avc);
1404 osi_FlushPages(avc, cred); /* ensure old pages are gone */
1405 avc->states |= CMAPPED; /* flag cleared at afs_inactive */
1406 afs_BozonUnlock(&avc->pvnLock, avc);
1412 if ((flags & MAP_FIXED) == 0) {
1413 #if defined(AFS_SUN57_ENV)
1414 map_addr(addr, len, off, 1, flags);
1415 #elif defined(AFS_SUN56_ENV)
1416 map_addr(addr, len, off, 1);
1418 map_addr(addr, len, (off_t) off, 1);
1420 if (*addr == NULL) {
1428 (void)as_unmap(as, *addr, len); /* unmap old address space use */
1429 /* setup the create parameter block for the call */
1430 crargs.vp = AFSTOV(avc);
1431 crargs.offset = (u_int) off;
1433 crargs.type = flags & MAP_TYPE;
1435 crargs.maxprot = maxprot;
1436 crargs.amp = (struct anon_map *)0;
1437 #if defined(AFS_SUN5_ENV)
1438 crargs.flags = flags & ~MAP_TYPE;
1441 code = as_map(as, *addr, len, segvn_create, (char *)&crargs);
1447 code = afs_CheckCode(code, &treq, 47);
1451 code = afs_CheckCode(code, &treq, 48);
1456 /* Sun 4.0.X-specific code. It computes the number of bytes that need
1457 to be zeroed at the end of a page by pvn_vptrunc, given that you're
1458 trying to get vptrunc to truncate a file to alen bytes. The result
1459 will be passed to pvn_vptrunc by the truncate code */
1460 #ifndef AFS_SUN5_ENV /* Not good for Solaris */
1462 register afs_int32 alen;
1464 register afs_int32 nbytes;
1466 AFS_STATCNT(afs_PageLeft);
1467 nbytes = PAGESIZE - (alen & PAGEOFFSET); /* amount to zap in last page */
1468 /* now check if we'd zero the entire last page. Don't need to do this
1469 * since pvn_vptrunc will handle this case properly (it will invalidate
1471 if (nbytes == PAGESIZE)
1474 nbytes = 0; /* just in case */
1481 * For Now We use standard local kernel params for AFS system values. Change this
1484 #if defined(AFS_SUN5_ENV)
1485 afs_pathconf(vp, cmd, outdatap, credp)
1486 register struct AFS_UCRED *credp;
1488 afs_cntl(vp, cmd, indatap, outdatap, inflag, outflag)
1489 int inflag, outflag;
1496 AFS_STATCNT(afs_cntl);
1499 *outdatap = MAXLINK;
1502 *outdatap = MAXNAMLEN;
1505 *outdatap = MAXPATHLEN;
1507 case _PC_CHOWN_RESTRICTED:
1513 #if !defined(AFS_SUN5_ENV)
1515 *outdatap = CANBSIZ;
1518 *outdatap = VDISABLE;
1530 #endif /* AFS_SUN_ENV */
1532 #if defined(AFS_SUN5_ENV)
1534 afs_ioctl(vnp, com, arg, flag, credp, rvalp)
1544 afs_rwlock(vnp, wlock)
1548 rw_enter(&(VTOAFS(vnp))->rwlock, (wlock ? RW_WRITER : RW_READER));
1553 afs_rwunlock(vnp, wlock)
1557 rw_exit(&(VTOAFS(vnp))->rwlock);
1562 afs_seek(vnp, ooff, noffp)
1567 register int code = 0;
1569 if ((*noffp < 0 || *noffp > MAXOFF_T))
1575 afs_frlock(vnp, cmd, ap, flag, off,
1576 #ifdef AFS_SUN59_ENV
1582 #if defined(AFS_SUN56_ENV)
1589 #ifdef AFS_SUN59_ENV
1590 struct flk_callback *flkcb;
1592 struct AFS_UCRED *credp;
1594 register afs_int32 code = 0;
1596 * Implement based on afs_lockctl
1599 #ifdef AFS_SUN59_ENV
1601 afs_warn("Don't know how to deal with flk_callback's!\n");
1603 if ((cmd == F_GETLK) || (cmd == F_O_GETLK) || (cmd == F_SETLK)
1604 || (cmd == F_SETLKW)) {
1605 #ifdef AFS_SUN53_ENV
1606 ap->l_pid = ttoproc(curthread)->p_pid;
1609 ap->l_pid = ttoproc(curthread)->p_epid;
1610 ap->l_sysid = ttoproc(curthread)->p_sysid;
1614 #ifdef AFS_SUN56_ENV
1615 code = convoff(vnp, ap, 0, off);
1617 code = convoff(vnp, ap, 0, (off_t) off);
1624 code = afs_lockctl(VTOAFS(vnp), ap, cmd, credp);
1631 afs_space(vnp, cmd, ap, flag, off, credp)
1634 #if defined(AFS_SUN56_ENV)
1641 struct AFS_UCRED *credp;
1643 register afs_int32 code = EINVAL;
1646 if ((cmd == F_FREESP)
1647 #ifdef AFS_SUN56_ENV
1648 && ((code = convoff(vnp, ap, 0, off)) == 0)) {
1650 && ((code = convoff(vnp, ap, 0, (off_t) off)) == 0)) {
1654 vattr.va_mask = AT_SIZE;
1655 vattr.va_size = ap->l_start;
1656 code = afs_setattr(VTOAFS(vnp), &vattr, 0, credp);
1667 afs_dump(vp, addr, i1, i2)
1672 AFS_STATCNT(afs_dump);
1673 afs_warn("AFS_DUMP. MUST IMPLEMENT THIS!!!\n");
1678 /* Nothing fancy here; just compare if vnodes are identical ones */
1680 struct vnode *vp1, *vp2;
1682 AFS_STATCNT(afs_cmp);
1683 return (vp1 == vp2);
1688 afs_realvp(struct vnode *vp, struct vnode **vpp)
1690 AFS_STATCNT(afs_realvp);
1696 afs_pageio(vp, pp, ui1, ui2, i1, credp)
1703 afs_warn("afs_pageio: Not implemented\n");
1709 #ifdef AFS_SUN59_ENV
1715 #ifdef AFS_SUN59_ENV
1719 afs_warn("afs_dumpctl: Not implemented\n");
1723 #ifdef AFS_SUN54_ENV
1725 afs_dispose(vp, p, fl, dn, cr)
1731 fs_dispose(vp, p, fl, dn, cr);
1735 afs_setsecattr(vp, vsecattr, flag, creds)
1737 vsecattr_t *vsecattr;
1745 afs_getsecattr(vp, vsecattr, flag, creds)
1747 vsecattr_t *vsecattr;
1751 return fs_fab_acl(vp, vsecattr, flag, creds);
1755 #ifdef AFS_GLOBAL_SUNLOCK
1756 extern int gafs_open(), gafs_close(), afs_ioctl(), gafs_access();
1757 extern int gafs_getattr(), gafs_setattr(), gafs_lookup(), gafs_create();
1758 extern int gafs_remove(), gafs_link(), gafs_rename(), gafs_mkdir();
1759 extern int gafs_rmdir(), gafs_readdir(), gafs_fsync(), gafs_symlink();
1760 extern int gafs_fid(), gafs_readlink(), fs_setfl(), afs_pathconf();
1761 extern int afs_lockctl();
1762 extern void gafs_inactive();
1764 struct vnodeops Afs_vnodeops = {
1804 #ifdef AFS_SUN54_ENV
1809 #if defined(AFS_SUN56_ENV)
1813 struct vnodeops *afs_ops = &Afs_vnodeops;
1817 gafs_open(avcp, aflags, acred)
1818 register struct vcache **avcp;
1820 struct AFS_UCRED *acred;
1825 code = afs_open(avcp, aflags, acred);
1831 gafs_close(avc, aflags, count, offset, acred)
1834 register struct vcache *avc;
1836 struct AFS_UCRED *acred;
1841 code = afs_close(avc, aflags, count, offset, acred);
1847 gafs_getattr(avc, attrs, flags, acred)
1849 register struct vcache *avc;
1850 register struct vattr *attrs;
1851 struct AFS_UCRED *acred;
1856 code = afs_getattr(avc, attrs, flags, acred);
1862 gafs_setattr(avc, attrs, flags, acred)
1864 register struct vcache *avc;
1865 register struct vattr *attrs;
1866 struct AFS_UCRED *acred;
1871 code = afs_setattr(avc, attrs, flags, acred);
1877 gafs_access(avc, amode, flags, acred)
1879 register struct vcache *avc;
1880 register afs_int32 amode;
1881 struct AFS_UCRED *acred;
1886 code = afs_access(avc, amode, flags, acred);
1892 gafs_lookup(adp, aname, avcp, pnp, flags, rdir, acred)
1893 struct pathname *pnp;
1896 register struct vcache *adp, **avcp;
1898 struct AFS_UCRED *acred;
1903 code = afs_lookup(adp, aname, avcp, pnp, flags, rdir, acred);
1909 gafs_create(adp, aname, attrs, aexcl, amode, avcp, acred)
1910 register struct vcache *adp;
1912 struct vattr *attrs;
1915 struct vcache **avcp;
1916 struct AFS_UCRED *acred;
1921 code = afs_create(adp, aname, attrs, aexcl, amode, avcp, acred);
1926 gafs_remove(adp, aname, acred)
1927 register struct vcache *adp;
1929 struct AFS_UCRED *acred;
1934 code = afs_remove(adp, aname, acred);
1939 gafs_link(adp, avc, aname, acred)
1940 register struct vcache *avc;
1941 register struct vcache *adp;
1943 struct AFS_UCRED *acred;
1948 code = afs_link(adp, avc, aname, acred);
1953 gafs_rename(aodp, aname1, andp, aname2, acred)
1954 register struct vcache *aodp, *andp;
1955 char *aname1, *aname2;
1956 struct AFS_UCRED *acred;
1961 code = afs_rename(aodp, aname1, andp, aname2, acred);
1966 gafs_mkdir(adp, aname, attrs, avcp, acred)
1967 register struct vcache *adp;
1968 register struct vcache **avcp;
1970 struct vattr *attrs;
1971 struct AFS_UCRED *acred;
1976 code = afs_mkdir(adp, aname, attrs, avcp, acred);
1982 gafs_rmdir(adp, aname, cdirp, acred)
1983 struct vnode *cdirp;
1984 register struct vcache *adp;
1986 struct AFS_UCRED *acred;
1991 code = afs_rmdir(adp, aname, cdirp, acred);
1997 gafs_readdir(avc, auio, acred, eofp)
1999 register struct vcache *avc;
2001 struct AFS_UCRED *acred;
2006 code = afs_readdir(avc, auio, acred, eofp);
2011 gafs_symlink(adp, aname, attrs, atargetName, acred)
2012 register struct vcache *adp;
2013 register char *atargetName;
2015 struct vattr *attrs;
2016 struct AFS_UCRED *acred;
2021 code = afs_symlink(adp, aname, attrs, atargetName, acred);
2027 gafs_readlink(avc, auio, acred)
2028 register struct vcache *avc;
2030 struct AFS_UCRED *acred;
2035 code = afs_readlink(avc, auio, acred);
2040 #ifdef AFS_SUN53_ENV
2041 gafs_fsync(avc, flag, acred)
2044 gafs_fsync(avc, acred)
2046 register struct vcache *avc;
2047 struct AFS_UCRED *acred;
2052 #ifdef AFS_SUN53_ENV
2053 code = afs_fsync(avc, flag, acred);
2055 code = afs_fsync(avc, acred);
2062 afs_inactive(struct vcache *avc, struct AFS_UCRED *acred)
2064 struct vnode *vp = AFSTOV(avc);
2065 if (afs_shuttingdown)
2069 * In Solaris and HPUX s800 and HP-UX10.0 they actually call us with
2070 * v_count 1 on last reference!
2072 mutex_enter(&vp->v_lock);
2073 if (avc->vrefCount <= 0)
2074 osi_Panic("afs_inactive : v_count <=0\n");
2077 * If more than 1 don't unmap the vnode but do decrement the ref count
2080 if (vp->v_count > 0) {
2081 mutex_exit(&vp->v_lock);
2084 mutex_exit(&vp->v_lock);
2087 * Solaris calls VOP_OPEN on exec, but doesn't call VOP_CLOSE when
2088 * the executable exits. So we clean up the open count here.
2090 * Only do this for mvstat 0 vnodes: when using fakestat, we can't
2091 * lose the open count for volume roots (mvstat 2), even though they
2092 * will get VOP_INACTIVE'd when released by afs_PutFakeStat().
2094 if (avc->opens > 0 && avc->mvstat == 0 && !(avc->states & CCore))
2095 avc->opens = avc->execsOrWriters = 0;
2097 afs_InactiveVCache(avc, acred);
2101 gafs_inactive(avc, acred)
2102 register struct vcache *avc;
2103 struct AFS_UCRED *acred;
2106 afs_inactive(avc, acred);
2111 gafs_fid(avc, fidpp)
2118 code = afs_fid(avc, fidpp);
2123 #endif /* AFS_GLOBAL_SUNLOCK */