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
17 #include <afsconfig.h>
18 #include "afs/param.h"
23 #include "afs/sysincludes.h" /* Standard vendor system headers */
24 #include "afsincludes.h" /* Afs-based standard headers */
25 #include "afs/afs_stats.h" /* statistics */
26 #include "afs/afs_cbqueue.h"
27 #include "afs/nfsclient.h"
28 #include "afs/exporter.h"
29 #include "afs/afs_osidnlc.h"
32 extern struct DirEntry *afs_dir_GetBlob();
34 #ifdef AFS_LINUX22_ENV
35 extern struct inode_operations afs_symlink_iops, afs_dir_iops;
39 afs_int32 afs_bkvolpref = 0;
40 afs_int32 afs_bulkStatsDone;
41 static int bulkStatCounter = 0; /* counter for bulk stat seq. numbers */
42 int afs_fakestat_enable = 0; /* 1: fakestat-all, 2: fakestat-crosscell */
45 /* this would be faster if it did comparison as int32word, but would be
46 * dependant on byte-order and alignment, and I haven't figured out
47 * what "@sys" is in binary... */
48 #define AFS_EQ_ATSYS(name) (((name)[0]=='@')&&((name)[1]=='s')&&((name)[2]=='y')&&((name)[3]=='s')&&(!(name)[4]))
50 /* call under write lock, evaluate mvid field from a mt pt.
51 * avc is the vnode of the mount point object; must be write-locked.
52 * advc is the vnode of the containing directory (optional; if NULL and
53 * EvalMountPoint succeeds, caller must initialize *avolpp->dotdot)
54 * avolpp is where we return a pointer to the volume named by the mount pt, if success
55 * areq is the identity of the caller.
57 * NOTE: this function returns a held volume structure in *volpp if it returns 0!
60 EvalMountPoint(register struct vcache *avc, struct vcache *advc,
61 struct volume **avolpp, register struct vrequest *areq)
64 struct volume *tvp = 0;
67 char *cpos, *volnamep;
69 afs_int32 prefetch; /* 1=>None 2=>RO 3=>BK */
70 afs_int32 mtptCell, assocCell, hac = 0;
71 afs_int32 samecell, roname, len;
73 AFS_STATCNT(EvalMountPoint);
75 if (avc->mvid && (avc->states & CMValid))
76 return 0; /* done while racing */
79 code = afs_HandleLink(avc, areq);
83 /* Determine which cell and volume the mointpoint goes to */
84 type = avc->linkData[0]; /* '#'=>Regular '%'=>RW */
85 cpos = afs_strchr(&avc->linkData[1], ':'); /* if cell name present */
89 tcell = afs_GetCellByName(&avc->linkData[1], READ_LOCK);
92 volnamep = &avc->linkData[1];
93 tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
98 mtptCell = tcell->cellNum; /* The cell for the mountpoint */
100 hac = 1; /* has associated cell */
101 assocCell = tcell->lcellp->cellNum; /* The associated cell */
103 afs_PutCell(tcell, READ_LOCK);
105 /* Is volume name a "<n>.backup" or "<n>.readonly" name */
106 len = strlen(volnamep);
107 roname = ((len > 9) && (strcmp(&volnamep[len - 9], ".readonly") == 0))
108 || ((len > 7) && (strcmp(&volnamep[len - 7], ".backup") == 0));
110 /* When we cross mountpoint, do we stay in the same cell */
111 samecell = (avc->fid.Cell == mtptCell) || (hac
115 /* Decide whether to prefetch the BK, or RO. Also means we want the BK or
117 * If this is a regular mountpoint with a RW volume name
118 * - If BK preference is enabled AND we remain within the same cell AND
119 * start from a BK volume, then we will want to prefetch the BK volume.
120 * - If we cross a cell boundary OR start from a RO volume, then we will
121 * want to prefetch the RO volume.
123 if ((type == '#') && !roname) {
124 if (afs_bkvolpref && samecell && (avc->states & CBackup))
125 prefetch = 3; /* Prefetch the BK */
126 else if (!samecell || (avc->states & CRO))
127 prefetch = 2; /* Prefetch the RO */
129 prefetch = 1; /* Do not prefetch */
131 prefetch = 1; /* Do not prefetch */
134 /* Get the volume struct. Unless this volume name has ".readonly" or
135 * ".backup" in it, this will get the volume struct for the RW volume.
136 * The RO volume will be prefetched if requested (but not returned).
138 tvp = afs_GetVolumeByName(volnamep, mtptCell, prefetch, areq, WRITE_LOCK);
140 /* If no volume was found in this cell, try the associated linked cell */
141 if (!tvp && hac && areq->volumeError) {
143 afs_GetVolumeByName(volnamep, assocCell, prefetch, areq,
147 /* Still not found. If we are looking for the RO, then perhaps the RW
148 * doesn't exist? Try adding ".readonly" to volname and look for that.
149 * Don't know why we do this. Would have still found it in above call - jpm.
151 if (!tvp && (prefetch == 2) && len < AFS_SMALLOCSIZ - 10) {
152 buf = (char *)osi_AllocSmallSpace(len + 10);
154 strcpy(buf, volnamep);
155 afs_strcat(buf, ".readonly");
157 tvp = afs_GetVolumeByName(buf, mtptCell, 1, areq, WRITE_LOCK);
159 /* Try the associated linked cell if failed */
160 if (!tvp && hac && areq->volumeError) {
161 tvp = afs_GetVolumeByName(buf, assocCell, 1, areq, WRITE_LOCK);
163 osi_FreeSmallSpace(buf);
167 return ENODEV; /* Couldn't find the volume */
169 /* Don't cross mountpoint from a BK to a BK volume */
170 if ((avc->states & CBackup) && (tvp->states & VBackup)) {
171 afs_PutVolume(tvp, WRITE_LOCK);
175 /* If we want (prefetched) the BK and it exists, then drop the RW volume
177 * Otherwise, if we want (prefetched0 the RO and it exists, then drop the
178 * RW volume and get the RO.
179 * Otherwise, go with the RW.
181 if ((prefetch == 3) && tvp->backVol) {
182 tfid.Fid.Volume = tvp->backVol; /* remember BK volume */
183 tfid.Cell = tvp->cell;
184 afs_PutVolume(tvp, WRITE_LOCK); /* release old volume */
185 tvp = afs_GetVolume(&tfid, areq, WRITE_LOCK); /* get the new one */
187 return ENODEV; /* oops, can't do it */
188 } else if ((prefetch >= 2) && tvp->roVol) {
189 tfid.Fid.Volume = tvp->roVol; /* remember RO volume */
190 tfid.Cell = tvp->cell;
191 afs_PutVolume(tvp, WRITE_LOCK); /* release old volume */
192 tvp = afs_GetVolume(&tfid, areq, WRITE_LOCK); /* get the new one */
194 return ENODEV; /* oops, can't do it */
199 (struct VenusFid *)osi_AllocSmallSpace(sizeof(struct VenusFid));
200 avc->mvid->Cell = tvp->cell;
201 avc->mvid->Fid.Volume = tvp->volume;
202 avc->mvid->Fid.Vnode = 1;
203 avc->mvid->Fid.Unique = 1;
204 avc->states |= CMValid;
206 /* Used to: if the mount point is stored within a backup volume,
207 * then we should only update the parent pointer information if
208 * there's none already set, so as to avoid updating a volume's ..
209 * info with something in an OldFiles directory.
211 * Next two lines used to be under this if:
213 * if (!(avc->states & CBackup) || tvp->dotdot.Fid.Volume == 0)
215 * Now: update mount point back pointer on every call, so that we handle
216 * multiple mount points better. This way, when du tries to go back
217 * via chddir(".."), it will end up exactly where it started, yet
218 * cd'ing via a new path to a volume will reset the ".." pointer
221 tvp->mtpoint = avc->fid; /* setup back pointer to mtpoint */
223 tvp->dotdot = advc->fid;
232 * Must be called on an afs_fakestat_state object before calling
233 * afs_EvalFakeStat or afs_PutFakeStat. Calling afs_PutFakeStat
234 * without calling afs_EvalFakeStat is legal, as long as this
235 * function is called.
238 afs_InitFakeStat(struct afs_fakestat_state *state)
240 if (!afs_fakestat_enable)
245 state->need_release = 0;
249 * afs_EvalFakeStat_int
251 * The actual implementation of afs_EvalFakeStat and afs_TryEvalFakeStat,
252 * which is called by those wrapper functions.
254 * Only issues RPCs if canblock is non-zero.
257 afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
258 struct vrequest *areq, int canblock)
260 struct vcache *tvc, *root_vp;
261 struct volume *tvolp = NULL;
264 if (!afs_fakestat_enable)
267 osi_Assert(state->valid == 1);
268 osi_Assert(state->did_eval == 0);
272 if (tvc->mvstat != 1)
275 /* Is the call to VerifyVCache really necessary? */
276 code = afs_VerifyVCache(tvc, areq);
280 ObtainWriteLock(&tvc->lock, 599);
281 code = EvalMountPoint(tvc, NULL, &tvolp, areq);
282 ReleaseWriteLock(&tvc->lock);
286 tvolp->dotdot = tvc->fid;
287 tvolp->dotdot.Fid.Vnode = tvc->parentVnode;
288 tvolp->dotdot.Fid.Unique = tvc->parentUnique;
291 if (tvc->mvid && (tvc->states & CMValid)) {
297 ObtainWriteLock(&afs_xvcache, 597);
298 root_vp = afs_FindVCache(tvc->mvid, &retry, 0);
299 if (root_vp && retry) {
300 ReleaseWriteLock(&afs_xvcache);
301 afs_PutVCache(root_vp);
303 } while (root_vp && retry);
304 ReleaseWriteLock(&afs_xvcache);
306 root_vp = afs_GetVCache(tvc->mvid, areq, NULL, NULL);
309 code = canblock ? ENOENT : 0;
313 /* Is this always kosher? Perhaps we should instead use
314 * NBObtainWriteLock to avoid potential deadlock.
316 ObtainWriteLock(&root_vp->lock, 598);
318 root_vp->mvid = osi_AllocSmallSpace(sizeof(struct VenusFid));
319 *root_vp->mvid = tvolp->dotdot;
320 ReleaseWriteLock(&root_vp->lock);
322 state->need_release = 1;
323 state->root_vp = root_vp;
327 code = canblock ? ENOENT : 0;
332 afs_PutVolume(tvolp, WRITE_LOCK);
339 * Automatically does the equivalent of EvalMountPoint for vcache entries
340 * which are mount points. Remembers enough state to properly release
341 * the volume root vcache when afs_PutFakeStat() is called.
343 * State variable must be initialized by afs_InitFakeState() beforehand.
345 * Returns 0 when everything succeeds and *avcp points to the vcache entry
346 * that should be used for the real vnode operation. Returns non-zero if
347 * something goes wrong and the error code should be returned to the user.
350 afs_EvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state,
351 struct vrequest *areq)
353 return afs_EvalFakeStat_int(avcp, state, areq, 1);
357 * afs_TryEvalFakeStat
359 * Same as afs_EvalFakeStat, but tries not to talk to remote servers
360 * and only evaluate the mount point if all the data is already in
363 * Returns 0 if everything succeeds and *avcp points to a valid
364 * vcache entry (possibly evaluated).
367 afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state,
368 struct vrequest *areq)
370 return afs_EvalFakeStat_int(avcp, state, areq, 0);
376 * Perform any necessary cleanup at the end of a vnode op, given that
377 * afs_InitFakeStat was previously called with this state.
380 afs_PutFakeStat(struct afs_fakestat_state *state)
382 if (!afs_fakestat_enable)
385 osi_Assert(state->valid == 1);
386 if (state->need_release)
387 afs_PutVCache(state->root_vp);
392 afs_ENameOK(register char *aname)
396 AFS_STATCNT(ENameOK);
397 tlen = strlen(aname);
398 if (tlen >= 4 && strcmp(aname + tlen - 4, "@sys") == 0)
404 afs_getsysname(register struct vrequest *areq, register struct vcache *adp,
405 register char *bufp, int *num, char **sysnamelist[])
407 register struct unixuser *au;
408 register afs_int32 error;
410 AFS_STATCNT(getsysname);
412 *sysnamelist = afs_sysnamelist;
414 if (!afs_nfsexporter)
415 strcpy(bufp, (*sysnamelist)[0]);
417 au = afs_GetUser(areq->uid, adp->fid.Cell, 0);
419 error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
421 strcpy(bufp, "@sys");
425 strcpy(bufp, (*sysnamelist)[0]);
428 strcpy(bufp, afs_sysname);
435 Check_AtSys(register struct vcache *avc, char *aname,
436 struct sysname_info *state, struct vrequest *areq)
439 char **sysnamelist[MAXSYSNAME];
441 if (AFS_EQ_ATSYS(aname)) {
443 state->name = (char *)osi_AllocLargeSpace(AFS_SMALLOCSIZ);
445 state->index = afs_getsysname(areq, avc, state->name, &num, sysnamelist);
455 Next_AtSys(register struct vcache *avc, struct vrequest *areq,
456 struct sysname_info *state)
458 int num = afs_sysnamecount;
459 char **sysnamelist[MAXSYSNAME];
461 if (state->index == -1)
462 return 0; /* No list */
464 /* Check for the initial state of aname != "@sys" in Check_AtSys*/
465 if (state->offset == -1 && state->allocked == 0) {
466 register char *tname;
468 /* Check for .*@sys */
469 for (tname=state->name; *tname; tname++)
470 /*Move to the end of the string*/;
472 if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname-4))) {
473 state->offset = (tname - 4) - state->name;
474 tname = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
475 strncpy(tname, state->name, state->offset);
479 state->index = afs_getsysname(areq, avc, state->name+state->offset,
483 return 0; /* .*@sys doesn't match either */
485 register struct unixuser *au;
486 register afs_int32 error;
488 *sysnamelist = afs_sysnamelist;
490 if (afs_nfsexporter) {
491 au = afs_GetUser(areq->uid, avc->fid.Cell, 0);
493 error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
500 if (++(state->index) >= num || !(*sysnamelist)[state->index])
501 return 0; /* end of list */
503 strcpy(state->name+state->offset, (*sysnamelist)[state->index]);
507 #if (defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV))
508 extern int BlobScan(ino64_t * afile, afs_int32 ablob);
510 #if defined(AFS_HPUX1123_ENV)
511 /* DEE should use the new afs_inode_t for all */
512 extern int BlobScan(ino_t *afile, afs_int32 ablob);
514 #if defined AFS_LINUX_64BIT_KERNEL
515 extern int BlobScan(long *afile, afs_int32 ablob);
517 extern int BlobScan(afs_int32 * afile, afs_int32 ablob);
523 /* called with an unlocked directory and directory cookie. Areqp
524 * describes who is making the call.
525 * Scans the next N (about 30, typically) directory entries, and does
526 * a bulk stat call to stat them all.
528 * Must be very careful when merging in RPC responses, since we dont
529 * want to overwrite newer info that was added by a file system mutating
530 * call that ran concurrently with our bulk stat call.
532 * We do that, as described below, by not merging in our info (always
533 * safe to skip the merge) if the status info is valid in the vcache entry.
535 * If adapt ever implements the bulk stat RPC, then this code will need to
536 * ensure that vcaches created for failed RPC's to older servers have the
539 static struct vcache *BStvc = NULL;
542 afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
544 int nentries; /* # of entries to prefetch */
545 int nskip; /* # of slots in the LRU queue to skip */
546 struct vcache *lruvcp; /* vcache ptr of our goal pos in LRU queue */
547 struct dcache *dcp; /* chunk containing the dir block */
548 char *statMemp; /* status memory block */
549 char *cbfMemp; /* callback and fid memory block */
550 afs_size_t temp; /* temp for holding chunk length, &c. */
551 struct AFSFid *fidsp; /* file IDs were collecting */
552 struct AFSCallBack *cbsp; /* call back pointers */
553 struct AFSCallBack *tcbp; /* temp callback ptr */
554 struct AFSFetchStatus *statsp; /* file status info */
555 struct AFSVolSync volSync; /* vol sync return info */
556 struct vcache *tvcp; /* temp vcp */
557 struct afs_q *tq; /* temp queue variable */
558 AFSCBFids fidParm; /* file ID parm for bulk stat */
559 AFSBulkStats statParm; /* stat info parm for bulk stat */
560 int fidIndex; /* which file were stating */
561 struct conn *tcp; /* conn for call */
562 AFSCBs cbParm; /* callback parm for bulk stat */
563 struct server *hostp = 0; /* host we got callback from */
564 long startTime; /* time we started the call,
565 * for callback expiration base
567 afs_size_t statSeqNo; /* Valued of file size to detect races */
568 int code; /* error code */
569 long newIndex; /* new index in the dir */
570 struct DirEntry *dirEntryp; /* dir entry we are examining */
572 struct VenusFid afid; /* file ID we are using now */
573 struct VenusFid tfid; /* another temp. file ID */
574 afs_int32 retry; /* handle low-level SGI MP race conditions */
575 long volStates; /* flags from vol structure */
576 struct volume *volp = 0; /* volume ptr */
577 struct VenusFid dotdot;
578 int flagIndex; /* First file with bulk fetch flag set */
579 int inlinebulk = 0; /* Did we use InlineBulk RPC or not? */
581 /* first compute some basic parameters. We dont want to prefetch more
582 * than a fraction of the cache in any given call, and we want to preserve
583 * a portion of the LRU queue in any event, so as to avoid thrashing
584 * the entire stat cache (we will at least leave some of it alone).
585 * presently dont stat more than 1/8 the cache in any one call. */
586 nentries = afs_cacheStats / 8;
588 /* dont bother prefetching more than one calls worth of info */
589 if (nentries > AFSCBMAX)
592 /* heuristic to make sure that things fit in 4K. This means that
593 * we shouldnt make it any bigger than 47 entries. I am typically
594 * going to keep it a little lower, since we don't want to load
595 * too much of the stat cache.
600 /* now, to reduce the stack size, well allocate two 4K blocks,
601 * one for fids and callbacks, and one for stat info. Well set
602 * up our pointers to the memory from there, too.
604 statMemp = osi_AllocLargeSpace(nentries * sizeof(AFSFetchStatus));
605 statsp = (struct AFSFetchStatus *)statMemp;
607 osi_AllocLargeSpace(nentries *
608 (sizeof(AFSCallBack) + sizeof(AFSFid)));
609 fidsp = (AFSFid *) cbfMemp;
610 cbsp = (AFSCallBack *) (cbfMemp + nentries * sizeof(AFSFid));
612 /* next, we must iterate over the directory, starting from the specified
613 * cookie offset (dirCookie), and counting out nentries file entries.
614 * We skip files that already have stat cache entries, since we
615 * dont want to bulk stat files that are already in the cache.
618 code = afs_VerifyVCache(adp, areqp);
622 dcp = afs_GetDCache(adp, (afs_size_t) 0, areqp, &temp, &temp, 1);
628 /* lock the directory cache entry */
629 ObtainReadLock(&adp->lock);
630 ObtainReadLock(&dcp->lock);
633 * Make sure that the data in the cache is current. There are two
634 * cases we need to worry about:
635 * 1. The cache data is being fetched by another process.
636 * 2. The cache data is no longer valid
638 while ((adp->states & CStatd)
639 && (dcp->dflags & DFFetching)
640 && hsame(adp->m.DataVersion, dcp->f.versionNo)) {
641 afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING,
642 __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, dcp,
643 ICL_TYPE_INT32, dcp->dflags);
644 ReleaseReadLock(&dcp->lock);
645 ReleaseReadLock(&adp->lock);
646 afs_osi_Sleep(&dcp->validPos);
647 ObtainReadLock(&adp->lock);
648 ObtainReadLock(&dcp->lock);
650 if (!(adp->states & CStatd)
651 || !hsame(adp->m.DataVersion, dcp->f.versionNo)) {
652 ReleaseReadLock(&dcp->lock);
653 ReleaseReadLock(&adp->lock);
658 /* Generate a sequence number so we can tell whether we should
659 * store the attributes when processing the response. This number is
660 * stored in the file size when we set the CBulkFetching bit. If the
661 * CBulkFetching is still set and this value hasn't changed, then
662 * we know we were the last to set CBulkFetching bit for this file,
663 * and it is safe to set the status information for this file.
665 statSeqNo = bulkStatCounter++;
667 /* now we have dir data in the cache, so scan the dir page */
670 while (1) { /* Should probably have some constant bound */
671 /* look for first safe entry to examine in the directory. BlobScan
672 * looks for a the 1st allocated dir after the dirCookie slot.
674 newIndex = BlobScan(&dcp->f.inode, (dirCookie >> 5));
678 /* remember the updated directory cookie */
679 dirCookie = newIndex << 5;
681 /* get a ptr to the dir entry */
683 (struct DirEntry *)afs_dir_GetBlob(&dcp->f.inode, newIndex);
687 /* dont copy more than we have room for */
688 if (fidIndex >= nentries) {
689 DRelease((struct buffer *)dirEntryp, 0);
693 /* now, if the dir entry looks good, copy it out to our list. Vnode
694 * 0 means deleted, although it should also be free were it deleted.
696 if (dirEntryp->fid.vnode != 0) {
697 /* dont copy entries we have in our cache. This check will
698 * also make us skip "." and probably "..", unless it has
699 * disappeared from the cache since we did our namei call.
701 tfid.Cell = adp->fid.Cell;
702 tfid.Fid.Volume = adp->fid.Fid.Volume;
703 tfid.Fid.Vnode = ntohl(dirEntryp->fid.vnode);
704 tfid.Fid.Unique = ntohl(dirEntryp->fid.vunique);
707 ObtainWriteLock(&afs_xvcache, 130);
708 tvcp = afs_FindVCache(&tfid, &retry, 0 /* no stats | LRU */ );
710 ReleaseWriteLock(&afs_xvcache);
713 } while (tvcp && retry);
714 if (!tvcp) { /* otherwise, create manually */
715 tvcp = afs_NewVCache(&tfid, hostp);
716 ObtainWriteLock(&tvcp->lock, 505);
717 ReleaseWriteLock(&afs_xvcache);
718 afs_RemoveVCB(&tfid);
719 ReleaseWriteLock(&tvcp->lock);
721 ReleaseWriteLock(&afs_xvcache);
724 goto done; /* can't happen at present, more's the pity */
726 /* WARNING: afs_DoBulkStat uses the Length field to store a
727 * sequence number for each bulk status request. Under no
728 * circumstances should afs_DoBulkStat store a sequence number
729 * if the new length will be ignored when afs_ProcessFS is
730 * called with new stats. */
732 if (!(tvcp->states & (CStatd | CBulkFetching))
733 && (tvcp->execsOrWriters <= 0)
734 && !afs_DirtyPages(tvcp)
735 && !AFS_VN_MAPPED((vnode_t *) tvcp))
737 if (!(tvcp->states & (CStatd | CBulkFetching))
738 && (tvcp->execsOrWriters <= 0)
739 && !afs_DirtyPages(tvcp))
743 /* this entry doesnt exist in the cache, and is not
744 * already being fetched by someone else, so add it to the
745 * list of file IDs to obtain.
747 * We detect a callback breaking race condition by checking the
748 * CBulkFetching state bit and the value in the file size.
749 * It is safe to set the status only if the CBulkFetching
750 * flag is still set and the value in the file size does
753 * Don't fetch status for dirty files. We need to
754 * preserve the value of the file size. We could
755 * flush the pages, but it wouldn't be worthwhile.
757 memcpy((char *)(fidsp + fidIndex), (char *)&tfid.Fid,
759 tvcp->states |= CBulkFetching;
760 tvcp->m.Length = statSeqNo;
766 /* if dir vnode has non-zero entry */
767 /* move to the next dir entry by adding in the # of entries
768 * used by this dir entry.
770 temp = afs_dir_NameBlobs(dirEntryp->name) << 5;
771 DRelease((struct buffer *)dirEntryp, 0);
775 } /* while loop over all dir entries */
777 /* now release the dir lock and prepare to make the bulk RPC */
778 ReleaseReadLock(&dcp->lock);
779 ReleaseReadLock(&adp->lock);
781 /* release the chunk */
784 /* dont make a null call */
789 /* setup the RPC parm structures */
790 fidParm.AFSCBFids_len = fidIndex;
791 fidParm.AFSCBFids_val = fidsp;
792 statParm.AFSBulkStats_len = fidIndex;
793 statParm.AFSBulkStats_val = statsp;
794 cbParm.AFSCBs_len = fidIndex;
795 cbParm.AFSCBs_val = cbsp;
797 /* start the timer; callback expirations are relative to this */
798 startTime = osi_Time();
800 tcp = afs_Conn(&adp->fid, areqp, SHARED_LOCK);
802 hostp = tcp->srvr->server;
803 XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_BULKSTATUS);
806 if (!(tcp->srvr->server->flags & SNO_INLINEBULK)) {
808 RXAFS_InlineBulkStatus(tcp->id, &fidParm, &statParm,
810 if (code == RXGEN_OPCODE) {
811 tcp->srvr->server->flags |= SNO_INLINEBULK;
814 RXAFS_BulkStatus(tcp->id, &fidParm, &statParm,
821 RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, &cbParm,
829 (tcp, code, &adp->fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS,
832 /* now, if we didnt get the info, bail out. */
836 /* we need vol flags to create the entries properly */
837 dotdot.Fid.Volume = 0;
838 volp = afs_GetVolume(&adp->fid, areqp, READ_LOCK);
840 volStates = volp->states;
841 if (volp->dotdot.Fid.Volume != 0)
842 dotdot = volp->dotdot;
846 /* find the place to merge the info into We do this by skipping
847 * nskip entries in the LRU queue. The more we skip, the more
848 * we preserve, since the head of the VLRU queue is the most recently
852 nskip = afs_cacheStats / 2; /* preserved fraction of the cache */
853 ObtainReadLock(&afs_xvcache);
855 /* actually a serious error, probably should panic. Probably will
856 * panic soon, oh well. */
857 ReleaseReadLock(&afs_xvcache);
858 afs_warnuser("afs_DoBulkStat: VLRU empty!");
861 if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
862 refpanic("Bulkstat VLRU inconsistent");
864 for (tq = VLRU.next; tq != &VLRU; tq = QNext(tq)) {
867 else if (QNext(QPrev(tq)) != tq) {
869 refpanic("BulkStat VLRU inconsistent");
875 lruvcp = QTOV(VLRU.next);
877 /* now we have to hold this entry, so that it does not get moved
878 * into the free list while we're running. It could still get
879 * moved within the lru queue, but hopefully that will be rare; it
880 * doesn't hurt nearly as much.
883 osi_vnhold(lruvcp, &retry);
884 ReleaseReadLock(&afs_xvcache); /* could be read lock */
888 /* otherwise, merge in the info. We have to be quite careful here,
889 * since we need to ensure that we don't merge old info over newer
890 * stuff in a stat cache entry. We're very conservative here: we don't
891 * do the merge at all unless we ourselves create the stat cache
892 * entry. That's pretty safe, and should work pretty well, since we
893 * typically expect to do the stat cache creation ourselves.
895 * We also have to take into account racing token revocations.
897 for (i = 0; i < fidIndex; i++) {
898 if ((&statsp[i])->errorCode)
900 afid.Cell = adp->fid.Cell;
901 afid.Fid.Volume = adp->fid.Fid.Volume;
902 afid.Fid.Vnode = fidsp[i].Vnode;
903 afid.Fid.Unique = fidsp[i].Unique;
906 ObtainReadLock(&afs_xvcache);
907 tvcp = afs_FindVCache(&afid, &retry, 0 /* !stats&!lru */ );
908 ReleaseReadLock(&afs_xvcache);
909 } while (tvcp && retry);
911 /* The entry may no longer exist */
916 /* now we have the entry held, but we need to fill it in */
917 ObtainWriteLock(&tvcp->lock, 131);
919 /* if CBulkFetching is not set, or if the file size no longer
920 * matches the value we placed there when we set the CBulkFetching
921 * flag, then someone else has done something with this node,
922 * and we may not have the latest status information for this
923 * file. Leave the entry alone.
925 if (!(tvcp->states & CBulkFetching) || (tvcp->m.Length != statSeqNo)) {
927 ReleaseWriteLock(&tvcp->lock);
932 /* now copy ".." entry back out of volume structure, if necessary */
933 if (tvcp->mvstat == 2 && (dotdot.Fid.Volume != 0)) {
935 tvcp->mvid = (struct VenusFid *)
936 osi_AllocSmallSpace(sizeof(struct VenusFid));
937 *tvcp->mvid = dotdot;
940 ObtainWriteLock(&afs_xvcache, 132);
941 if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
942 refpanic("Bulkstat VLRU inconsistent2");
944 if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq)
945 || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) {
946 refpanic("Bulkstat VLRU inconsistent4");
948 if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq)
949 || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) {
950 refpanic("Bulkstat VLRU inconsistent5");
953 if (tvcp != lruvcp) { /* if they are == don't move it, don't corrupt vlru */
954 QRemove(&tvcp->vlruq);
955 QAdd(&lruvcp->vlruq, &tvcp->vlruq);
958 if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
959 refpanic("Bulkstat VLRU inconsistent3");
961 if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq)
962 || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) {
963 refpanic("Bulkstat VLRU inconsistent5");
965 if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq)
966 || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) {
967 refpanic("Bulkstat VLRU inconsistent6");
969 ReleaseWriteLock(&afs_xvcache);
971 ObtainWriteLock(&afs_xcbhash, 494);
973 /* We need to check the flags again. We may have missed
974 * something while we were waiting for a lock.
976 if (!(tvcp->states & CBulkFetching) || (tvcp->m.Length != statSeqNo)) {
978 ReleaseWriteLock(&tvcp->lock);
979 ReleaseWriteLock(&afs_xcbhash);
984 /* now merge in the resulting status back into the vnode.
985 * We only do this if the entry looks clear.
987 afs_ProcessFS(tvcp, &statsp[i], areqp);
988 #ifdef AFS_LINUX22_ENV
989 /* overwrite the ops if it's a directory or symlink. */
990 if (vType(tvcp) == VDIR)
991 tvcp->v.v_op = &afs_dir_iops;
992 else if (vType(tvcp) == VLNK)
993 tvcp->v.v_op = &afs_symlink_iops;
996 /* do some accounting for bulk stats: mark this entry as
997 * loaded, so we can tell if we use it before it gets
1000 tvcp->states |= CBulkStat;
1001 tvcp->states &= ~CBulkFetching;
1003 afs_bulkStatsDone++;
1005 /* merge in vol info */
1006 if (volStates & VRO)
1007 tvcp->states |= CRO;
1008 if (volStates & VBackup)
1009 tvcp->states |= CBackup;
1010 if (volStates & VForeign)
1011 tvcp->states |= CForeign;
1013 /* merge in the callback info */
1014 tvcp->states |= CTruth;
1016 /* get ptr to the callback we are interested in */
1019 if (tcbp->ExpirationTime != 0) {
1020 tvcp->cbExpires = tcbp->ExpirationTime + startTime;
1021 tvcp->callback = hostp;
1022 tvcp->states |= CStatd;
1023 afs_QueueCallback(tvcp, CBHash(tcbp->ExpirationTime), volp);
1024 } else if (tvcp->states & CRO) {
1025 /* ordinary callback on a read-only volume -- AFS 3.2 style */
1026 tvcp->cbExpires = 3600 + startTime;
1027 tvcp->callback = hostp;
1028 tvcp->states |= CStatd;
1029 afs_QueueCallback(tvcp, CBHash(3600), volp);
1032 tvcp->states &= ~(CStatd | CUnique);
1033 afs_DequeueCallback(tvcp);
1034 if ((tvcp->states & CForeign) || (vType(tvcp) == VDIR))
1035 osi_dnlc_purgedp(tvcp); /* if it (could be) a directory */
1037 ReleaseWriteLock(&afs_xcbhash);
1039 ReleaseWriteLock(&tvcp->lock);
1040 /* finally, we're done with the entry */
1041 afs_PutVCache(tvcp);
1042 } /* for all files we got back */
1044 /* finally return the pointer into the LRU queue */
1045 afs_PutVCache(lruvcp);
1048 /* Be sure to turn off the CBulkFetching flags */
1049 for (i = flagIndex; i < fidIndex; i++) {
1050 afid.Cell = adp->fid.Cell;
1051 afid.Fid.Volume = adp->fid.Fid.Volume;
1052 afid.Fid.Vnode = fidsp[i].Vnode;
1053 afid.Fid.Unique = fidsp[i].Unique;
1056 ObtainReadLock(&afs_xvcache);
1057 tvcp = afs_FindVCache(&afid, &retry, 0 /* !stats&!lru */ );
1058 ReleaseReadLock(&afs_xvcache);
1059 } while (tvcp && retry);
1060 if (tvcp != NULL && (tvcp->states & CBulkFetching)
1061 && (tvcp->m.Length == statSeqNo)) {
1062 tvcp->states &= ~CBulkFetching;
1065 afs_PutVCache(tvcp);
1069 afs_PutVolume(volp, READ_LOCK);
1071 /* If we did the InlineBulk RPC pull out the return code */
1073 if ((&statsp[0])->errorCode) {
1074 afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->fid, areqp,
1075 AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL);
1076 code = (&statsp[0])->errorCode;
1081 osi_FreeLargeSpace(statMemp);
1082 osi_FreeLargeSpace(cbfMemp);
1086 /* was: (AFS_DEC_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_NCR_ENV) */
1087 static int AFSDOBULK = 1;
1091 afs_lookup(adp, ndp)
1093 struct nameidata *ndp;
1095 char aname[MAXNAMLEN + 1]; /* XXX */
1096 struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
1097 struct ucred *acred = ndp->ni_cred;
1098 int wantparent = ndp->ni_nameiop & WANTPARENT;
1099 int opflag = ndp->ni_nameiop & OPFLAG;
1100 #else /* AFS_OSF_ENV */
1101 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
1102 afs_lookup(OSI_VC_ARG(adp), aname, avcp, pnp, flags, rdir, acred)
1103 struct pathname *pnp;
1107 #if defined(UKERNEL)
1108 afs_lookup(adp, aname, avcp, acred, flags)
1111 afs_lookup(adp, aname, avcp, acred)
1112 #endif /* UKERNEL */
1113 #endif /* SUN5 || SGI */
1115 struct vcache **avcp;
1117 struct AFS_UCRED *acred;
1120 struct vrequest treq;
1122 register struct vcache *tvc = 0;
1123 register afs_int32 code;
1124 register afs_int32 bulkcode = 0;
1125 int pass = 0, hit = 0;
1127 extern afs_int32 afs_mariner; /*Writing activity to log? */
1129 afs_hyper_t versionNo;
1130 int no_read_access = 0;
1131 struct sysname_info sysState; /* used only for @sys checking */
1132 int dynrootRetry = 1;
1133 struct afs_fakestat_state fakestate;
1134 int tryEvalOnly = 0;
1136 AFS_STATCNT(afs_lookup);
1137 afs_InitFakeStat(&fakestate);
1139 if ((code = afs_InitReq(&treq, acred)))
1143 ndp->ni_dvp = AFSTOV(adp);
1144 memcpy(aname, ndp->ni_ptr, ndp->ni_namelen);
1145 aname[ndp->ni_namelen] = '\0';
1146 #endif /* AFS_OSF_ENV */
1148 #if defined(AFS_DARWIN_ENV)
1149 /* Workaround for MacOSX Finder, which tries to look for
1150 * .DS_Store and Contents under every directory.
1152 if (afs_fakestat_enable && adp->mvstat == 1) {
1153 if (strcmp(aname, ".DS_Store") == 0)
1155 if (strcmp(aname, "Contents") == 0)
1161 code = afs_TryEvalFakeStat(&adp, &fakestate, &treq);
1163 code = afs_EvalFakeStat(&adp, &fakestate, &treq);
1164 if (tryEvalOnly && adp->mvstat == 1)
1169 *avcp = NULL; /* Since some callers don't initialize it */
1171 /* come back to here if we encounter a non-existent object in a read-only
1172 * volume's directory */
1175 *avcp = NULL; /* Since some callers don't initialize it */
1178 if (!(adp->states & CStatd)) {
1179 if ((code = afs_VerifyVCache2(adp, &treq))) {
1185 /* watch for ".." in a volume root */
1186 if (adp->mvstat == 2 && aname[0] == '.' && aname[1] == '.' && !aname[2]) {
1187 /* looking up ".." in root via special hacks */
1188 if (adp->mvid == (struct VenusFid *)0 || adp->mvid->Fid.Volume == 0) {
1190 extern struct vcache *afs_globalVp;
1191 if (adp == afs_globalVp) {
1192 struct vnode *rvp = AFSTOV(adp);
1194 ndp->ni_vp = rvp->v_vfsp->vfs_vnodecovered;
1195 ndp->ni_dvp = ndp->ni_vp;
1205 /* otherwise we have the fid here, so we use it */
1206 tvc = afs_GetVCache(adp->mvid, &treq, NULL, NULL);
1207 afs_Trace3(afs_iclSetp, CM_TRACE_GETVCDOTDOT, ICL_TYPE_FID, adp->mvid,
1208 ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, code);
1210 code = (tvc ? 0 : ENOENT);
1212 if (tvc && !VREFCOUNT(tvc)) {
1216 /*printf("LOOKUP GETVCDOTDOT -> %d\n", code); */
1221 /* now check the access */
1222 if (treq.uid != adp->last_looker) {
1223 if (!afs_AccessOK(adp, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS)) {
1228 adp->last_looker = treq.uid;
1231 /* Check for read access as well. We need read access in order to
1232 * stat files, but not to stat subdirectories. */
1233 if (!afs_AccessOK(adp, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS))
1236 /* special case lookup of ".". Can we check for it sooner in this code,
1237 * for instance, way up before "redo:" ??
1238 * I'm not fiddling with the LRUQ here, either, perhaps I should, or else
1239 * invent a lightweight version of GetVCache.
1241 if (aname[0] == '.' && !aname[1]) { /* special case */
1242 ObtainReadLock(&afs_xvcache);
1244 ReleaseReadLock(&afs_xvcache);
1248 if (adp && !VREFCOUNT(adp)) {
1254 Check_AtSys(adp, aname, &sysState, &treq);
1255 tname = sysState.name;
1257 /* 1st Check_AtSys and lookup by tname is required here, for now,
1258 * because the dnlc is *not* told to remove entries for the parent
1259 * dir of file/dir op that afs_LocalHero likes, but dnlc is informed
1260 * if the cached entry for the parent dir is invalidated for a
1262 * Otherwise, we'd be able to do a dnlc lookup on an entry ending
1263 * w/@sys and know the dnlc was consistent with reality. */
1264 tvc = osi_dnlc_lookup(adp, tname, WRITE_LOCK);
1265 *avcp = tvc; /* maybe wasn't initialized, but it is now */
1267 if (no_read_access && vType(tvc) != VDIR && vType(tvc) != VLNK) {
1268 /* need read access on dir to stat non-directory / non-link */
1274 #ifdef AFS_LINUX22_ENV
1275 if (tvc->mvstat == 2) { /* we don't trust the dnlc for root vcaches */
1283 #else /* non - LINUX */
1287 #endif /* linux22 */
1290 { /* sub-block just to reduce stack usage */
1291 register struct dcache *tdc;
1292 afs_size_t dirOffset, dirLen;
1294 struct VenusFid tfid;
1296 /* now we have to lookup the next fid */
1298 afs_GetDCache(adp, (afs_size_t) 0, &treq, &dirOffset, &dirLen, 1);
1300 *avcp = NULL; /* redundant, but harmless */
1305 /* now we will just call dir package with appropriate inode.
1306 * Dirs are always fetched in their entirety for now */
1307 ObtainReadLock(&adp->lock);
1308 ObtainReadLock(&tdc->lock);
1311 * Make sure that the data in the cache is current. There are two
1312 * cases we need to worry about:
1313 * 1. The cache data is being fetched by another process.
1314 * 2. The cache data is no longer valid
1316 while ((adp->states & CStatd)
1317 && (tdc->dflags & DFFetching)
1318 && hsame(adp->m.DataVersion, tdc->f.versionNo)) {
1319 ReleaseReadLock(&tdc->lock);
1320 ReleaseReadLock(&adp->lock);
1321 afs_osi_Sleep(&tdc->validPos);
1322 ObtainReadLock(&adp->lock);
1323 ObtainReadLock(&tdc->lock);
1325 if (!(adp->states & CStatd)
1326 || !hsame(adp->m.DataVersion, tdc->f.versionNo)) {
1327 ReleaseReadLock(&tdc->lock);
1328 ReleaseReadLock(&adp->lock);
1330 if (tname && tname != aname)
1331 osi_FreeLargeSpace(tname);
1335 /* Save the version number for when we call osi_dnlc_enter */
1336 hset(versionNo, tdc->f.versionNo);
1339 * check for, and handle "@sys" if it's there. We should be able
1340 * to avoid the alloc and the strcpy with a little work, but it's
1341 * not pressing. If there aren't any remote users (ie, via the
1342 * NFS translator), we have a slightly easier job.
1343 * the faster way to do this is to check for *aname == '@' and if
1344 * it's there, check for @sys, otherwise, assume there's no @sys
1345 * then, if the lookup fails, check for .*@sys...
1347 /* above now implemented by Check_AtSys and Next_AtSys */
1349 /* lookup the name in the appropriate dir, and return a cache entry
1350 * on the resulting fid */
1351 theDir = tdc->f.inode;
1353 afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid,
1356 /* If the first lookup doesn't succeed, maybe it's got @sys in the name */
1357 while (code == ENOENT && Next_AtSys(adp, &treq, &sysState))
1359 afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid,
1361 tname = sysState.name;
1363 ReleaseReadLock(&tdc->lock);
1366 if (code == ENOENT && afs_IsDynroot(adp) && dynrootRetry) {
1367 ReleaseReadLock(&adp->lock);
1369 if (tname[0] == '.')
1370 afs_LookupAFSDB(tname + 1);
1372 afs_LookupAFSDB(tname);
1373 if (tname && tname != aname)
1374 osi_FreeLargeSpace(tname);
1377 ReleaseReadLock(&adp->lock);
1380 /* new fid has same cell and volume */
1381 tfid.Cell = adp->fid.Cell;
1382 tfid.Fid.Volume = adp->fid.Fid.Volume;
1383 afs_Trace4(afs_iclSetp, CM_TRACE_LOOKUP, ICL_TYPE_POINTER, adp,
1384 ICL_TYPE_STRING, tname, ICL_TYPE_FID, &tfid,
1385 ICL_TYPE_INT32, code);
1388 if (code != ENOENT) {
1389 printf("LOOKUP dirLookupOff -> %d\n", code);
1394 /* prefetch some entries, if the dir is currently open. The variable
1395 * dirCookie tells us where to start prefetching from.
1397 if (AFSDOBULK && adp->opens > 0 && !(adp->states & CForeign)
1398 && !afs_IsDynroot(adp)) {
1400 /* if the entry is not in the cache, or is in the cache,
1401 * but hasn't been statd, then do a bulk stat operation.
1405 ObtainReadLock(&afs_xvcache);
1406 tvc = afs_FindVCache(&tfid, &retry, 0 /* !stats,!lru */ );
1407 ReleaseReadLock(&afs_xvcache);
1408 } while (tvc && retry);
1410 if (!tvc || !(tvc->states & CStatd))
1411 bulkcode = afs_DoBulkStat(adp, dirCookie, &treq);
1415 /* if the vcache isn't usable, release it */
1416 if (tvc && !(tvc->states & CStatd)) {
1425 /* now get the status info, if we don't already have it */
1426 /* This is kind of weird, but we might wind up accidentally calling
1427 * RXAFS_Lookup because we happened upon a file which legitimately
1428 * has a 0 uniquifier. That is the result of allowing unique to wrap
1429 * to 0. This was fixed in AFS 3.4. For CForeign, Unique == 0 means that
1430 * the file has not yet been looked up.
1433 afs_int32 cached = 0;
1434 if (!tfid.Fid.Unique && (adp->states & CForeign)) {
1435 tvc = afs_LookupVCache(&tfid, &treq, &cached, adp, tname);
1437 if (!tvc && !bulkcode) { /* lookup failed or wasn't called */
1438 tvc = afs_GetVCache(&tfid, &treq, &cached, NULL);
1441 } /* sub-block just to reduce stack usage */
1444 int force_eval = afs_fakestat_enable ? 0 : 1;
1446 if (adp->states & CForeign)
1447 tvc->states |= CForeign;
1448 tvc->parentVnode = adp->fid.Fid.Vnode;
1449 tvc->parentUnique = adp->fid.Fid.Unique;
1450 tvc->states &= ~CBulkStat;
1452 if (afs_fakestat_enable == 2 && tvc->mvstat == 1) {
1453 ObtainSharedLock(&tvc->lock, 680);
1454 if (!tvc->linkData) {
1455 UpgradeSToWLock(&tvc->lock, 681);
1456 code = afs_HandleLink(tvc, &treq);
1457 ConvertWToRLock(&tvc->lock);
1459 ConvertSToRLock(&tvc->lock);
1462 if (!code && !afs_strchr(tvc->linkData, ':'))
1464 ReleaseReadLock(&tvc->lock);
1466 #if defined(UKERNEL) && defined(AFS_WEB_ENHANCEMENTS)
1467 if (!(flags & AFS_LOOKUP_NOEVAL))
1468 /* don't eval mount points */
1469 #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */
1470 if (tvc->mvstat == 1 && force_eval) {
1471 /* a mt point, possibly unevaluated */
1472 struct volume *tvolp;
1474 ObtainWriteLock(&tvc->lock, 133);
1475 code = EvalMountPoint(tvc, adp, &tvolp, &treq);
1476 ReleaseWriteLock(&tvc->lock);
1481 afs_PutVolume(tvolp, WRITE_LOCK);
1485 /* next, we want to continue using the target of the mt point */
1486 if (tvc->mvid && (tvc->states & CMValid)) {
1488 /* now lookup target, to set .. pointer */
1489 afs_Trace2(afs_iclSetp, CM_TRACE_LOOKUP1,
1490 ICL_TYPE_POINTER, tvc, ICL_TYPE_FID,
1492 uvc = tvc; /* remember for later */
1494 if (tvolp && (tvolp->states & VForeign)) {
1495 /* XXXX tvolp has ref cnt on but not locked! XXX */
1497 afs_GetRootVCache(tvc->mvid, &treq, NULL, tvolp);
1499 tvc = afs_GetVCache(tvc->mvid, &treq, NULL, NULL);
1501 afs_PutVCache(uvc); /* we're done with it */
1506 afs_PutVolume(tvolp, WRITE_LOCK);
1511 /* now, if we came via a new mt pt (say because of a new
1512 * release of a R/O volume), we must reevaluate the ..
1513 * ptr to point back to the appropriate place */
1515 ObtainWriteLock(&tvc->lock, 134);
1516 if (tvc->mvid == NULL) {
1517 tvc->mvid = (struct VenusFid *)
1518 osi_AllocSmallSpace(sizeof(struct VenusFid));
1520 /* setup backpointer */
1521 *tvc->mvid = tvolp->dotdot;
1522 ReleaseWriteLock(&tvc->lock);
1523 afs_PutVolume(tvolp, WRITE_LOCK);
1529 afs_PutVolume(tvolp, WRITE_LOCK);
1534 if (tvc && !VREFCOUNT(tvc)) {
1539 /* if we get here, we found something in a directory that couldn't
1540 * be located (a Multics "connection failure"). If the volume is
1541 * read-only, we try flushing this entry from the cache and trying
1545 tv = afs_GetVolume(&adp->fid, &treq, READ_LOCK);
1547 if (tv->states & VRO) {
1548 pass = 1; /* try this *once* */
1549 ObtainWriteLock(&afs_xcbhash, 495);
1550 afs_DequeueCallback(adp);
1551 /* re-stat to get later version */
1552 adp->states &= ~CStatd;
1553 ReleaseWriteLock(&afs_xcbhash);
1554 osi_dnlc_purgedp(adp);
1555 afs_PutVolume(tv, READ_LOCK);
1558 afs_PutVolume(tv, READ_LOCK);
1565 /* put the network buffer back, if need be */
1566 if (tname != aname && tname)
1567 osi_FreeLargeSpace(tname);
1570 /* Handle RENAME; only need to check rename "." */
1571 if (opflag == RENAME && wantparent && *ndp->ni_next == 0) {
1572 if (!FidCmp(&(tvc->fid), &(adp->fid))) {
1573 afs_PutVCache(*avcp);
1575 afs_PutFakeStat(&fakestate);
1576 return afs_CheckCode(EISDIR, &treq, 18);
1579 #endif /* AFS_OSF_ENV */
1582 afs_AddMarinerName(aname, tvc);
1584 #if defined(UKERNEL) && defined(AFS_WEB_ENHANCEMENTS)
1585 if (!(flags & AFS_LOOKUP_NOEVAL))
1586 /* Here we don't enter the name into the DNLC because we want the
1587 * evaluated mount dir to be there (the vcache for the mounted volume)
1588 * rather than the vc of the mount point itself. we can still find the
1589 * mount point's vc in the vcache by its fid. */
1590 #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */
1592 osi_dnlc_enter(adp, aname, tvc, &versionNo);
1594 #ifdef AFS_LINUX20_ENV
1595 /* So Linux inode cache is up to date. */
1596 code = afs_VerifyVCache(tvc, &treq);
1598 afs_PutFakeStat(&fakestate);
1599 return 0; /* can't have been any errors if hit and !code */
1606 code = afs_CheckCode(code, &treq, 19);
1608 /* If there is an error, make sure *avcp is null.
1609 * Alphas panic otherwise - defect 10719.
1614 afs_PutFakeStat(&fakestate);