coda_subr.c revision 1.6.6.1 1 /* $NetBSD: coda_subr.c,v 1.6.6.1 1999/10/10 20:49:49 cgd Exp $ */
2
3 /*
4 *
5 * Coda: an Experimental Distributed File System
6 * Release 3.1
7 *
8 * Copyright (c) 1987-1998 Carnegie Mellon University
9 * All Rights Reserved
10 *
11 * Permission to use, copy, modify and distribute this software and its
12 * documentation is hereby granted, provided that both the copyright
13 * notice and this permission notice appear in all copies of the
14 * software, derivative works or modified versions, and any portions
15 * thereof, and that both notices appear in supporting documentation, and
16 * that credit is given to Carnegie Mellon University in all documents
17 * and publicity pertaining to direct or indirect use of this code or its
18 * derivatives.
19 *
20 * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
21 * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
22 * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
23 * DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
24 * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
25 * ANY DERIVATIVE WORK.
26 *
27 * Carnegie Mellon encourages users of this software to return any
28 * improvements or extensions that they make, and to grant Carnegie
29 * Mellon the rights to redistribute these changes without encumbrance.
30 *
31 * @(#) coda/coda_subr.c,v 1.1.1.1 1998/08/29 21:26:45 rvb Exp $
32 */
33
34 /*
35 * Mach Operating System
36 * Copyright (c) 1989 Carnegie-Mellon University
37 * All rights reserved. The CMU software License Agreement specifies
38 * the terms and conditions for use and redistribution.
39 */
40
41 /*
42 * This code was written for the Coda file system at Carnegie Mellon
43 * University. Contributers include David Steere, James Kistler, and
44 * M. Satyanarayanan. */
45
46 /*
47 * HISTORY
48 * $Log: coda_subr.c,v $
49 * Revision 1.6.6.1 1999/10/10 20:49:49 cgd
50 * pull up rev 1.7 from trunk (requested by mycroft):
51 * Fix potential overflow of v_usecount and v_writecount (and panics
52 * resulting from this) by widening them to `long'. Mostly affects
53 * systems where maxvnodes>=32768.
54 *
55 * Revision 1.6 1998/10/28 19:54:50 rvb
56 * Venus must be passed O_CREAT flag on VOP_OPEN iff this is
57 * a creat so that we can will allow a mode 444 file to be
58 * written into. Sync with the latest coda.h and deal with
59 * collateral damage.
60 *
61 * Revision 1.5 1998/09/25 15:01:13 rvb
62 * Conditionalize "stray" printouts under DIAGNOSTIC and DEBUG.
63 * Make files compile if DEBUG is on (from Alan Barrett). Finally,
64 * make coda an lkm.
65 *
66 * Revision 1.4 1998/09/15 02:02:59 rvb
67 * Final piece of rename cfs->coda
68 *
69 * Revision 1.3 1998/09/12 15:05:49 rvb
70 * Change cfs/CFS in symbols, strings and constants to coda/CODA
71 * to avoid fs conflicts.
72 *
73 * Revision 1.2 1998/09/08 17:12:47 rvb
74 * Pass2 complete
75 *
76 * Revision 1.1.1.1 1998/08/29 21:26:45 rvb
77 * Very Preliminary Coda
78 *
79 * Revision 1.11 1998/08/28 18:12:18 rvb
80 * Now it also works on FreeBSD -current. This code will be
81 * committed to the FreeBSD -current and NetBSD -current
82 * trees. It will then be tailored to the particular platform
83 * by flushing conditional code.
84 *
85 * Revision 1.10 1998/08/18 17:05:16 rvb
86 * Don't use __RCSID now
87 *
88 * Revision 1.9 1998/08/18 16:31:41 rvb
89 * Sync the code for NetBSD -current; test on 1.3 later
90 *
91 * Revision 1.8 98/01/31 20:53:12 rvb
92 * First version that works on FreeBSD 2.2.5
93 *
94 * Revision 1.7 98/01/23 11:53:42 rvb
95 * Bring RVB_CODA1_1 to HEAD
96 *
97 * Revision 1.6.2.3 98/01/23 11:21:05 rvb
98 * Sync with 2.2.5
99 *
100 * Revision 1.6.2.2 97/12/16 12:40:06 rvb
101 * Sync with 1.3
102 *
103 * Revision 1.6.2.1 97/12/06 17:41:21 rvb
104 * Sync with peters coda.h
105 *
106 * Revision 1.6 97/12/05 10:39:17 rvb
107 * Read CHANGES
108 *
109 * Revision 1.5.4.8 97/11/26 15:28:58 rvb
110 * Cant make downcall pbuf == union cfs_downcalls yet
111 *
112 * Revision 1.5.4.7 97/11/20 11:46:42 rvb
113 * Capture current cfs_venus
114 *
115 * Revision 1.5.4.6 97/11/18 10:27:16 rvb
116 * cfs_nbsd.c is DEAD!!!; integrated into cfs_vf/vnops.c
117 * cfs_nb_foo and cfs_foo are joined
118 *
119 * Revision 1.5.4.5 97/11/13 22:03:00 rvb
120 * pass2 cfs_NetBSD.h mt
121 *
122 * Revision 1.5.4.4 97/11/12 12:09:39 rvb
123 * reorg pass1
124 *
125 * Revision 1.5.4.3 97/11/06 21:02:38 rvb
126 * first pass at ^c ^z
127 *
128 * Revision 1.5.4.2 97/10/29 16:06:27 rvb
129 * Kill DYING
130 *
131 * Revision 1.5.4.1 97/10/28 23:10:16 rvb
132 * >64Meg; venus can be killed!
133 *
134 * Revision 1.5 97/08/05 11:08:17 lily
135 * Removed cfsnc_replace, replaced it with a coda_find, unhash, and
136 * rehash. This fixes a cnode leak and a bug in which the fid is
137 * not actually replaced. (cfs_namecache.c, cfsnc.h, cfs_subr.c)
138 *
139 * Revision 1.4 96/12/12 22:10:59 bnoble
140 * Fixed the "downcall invokes venus operation" deadlock in all known cases.
141 * There may be more
142 *
143 * Revision 1.3 1996/12/05 16:20:15 bnoble
144 * Minor debugging aids
145 *
146 * Revision 1.2 1996/01/02 16:57:01 bnoble
147 * Added support for Coda MiniCache and raw inode calls (final commit)
148 *
149 * Revision 1.1.2.1 1995/12/20 01:57:27 bnoble
150 * Added CODA-specific files
151 *
152 * Revision 3.1.1.1 1995/03/04 19:07:59 bnoble
153 * Branch for NetBSD port revisions
154 *
155 * Revision 3.1 1995/03/04 19:07:58 bnoble
156 * Bump to major revision 3 to prepare for NetBSD port
157 *
158 * Revision 2.8 1995/03/03 17:00:04 dcs
159 * Fixed kernel bug involving sleep and upcalls. Basically if you killed
160 * a job waiting on venus, the venus upcall queues got trashed. Depending
161 * on luck, you could kill the kernel or not.
162 * (mods to cfs_subr.c and cfs_mach.d)
163 *
164 * Revision 2.7 95/03/02 22:45:21 dcs
165 * Sun4 compatibility
166 *
167 * Revision 2.6 95/02/17 16:25:17 dcs
168 * These versions represent several changes:
169 * 1. Allow venus to restart even if outstanding references exist.
170 * 2. Have only one ctlvp per client, as opposed to one per mounted cfs device.d
171 * 3. Allow ody_expand to return many members, not just one.
172 *
173 * Revision 2.5 94/11/09 15:56:26 dcs
174 * Had the thread sleeping on the wrong thing!
175 *
176 * Revision 2.4 94/10/14 09:57:57 dcs
177 * Made changes 'cause sun4s have braindead compilers
178 *
179 * Revision 2.3 94/10/12 16:46:26 dcs
180 * Cleaned kernel/venus interface by removing XDR junk, plus
181 * so cleanup to allow this code to be more easily ported.
182 *
183 * Revision 1.2 92/10/27 17:58:22 lily
184 * merge kernel/latest and alpha/src/cfs
185 *
186 * Revision 2.4 92/09/30 14:16:26 mja
187 * Incorporated Dave Steere's fix for the GNU-Emacs bug.
188 * Also, included his coda_flush routine in place of the former coda_nc_flush.
189 * [91/02/07 jjk]
190 *
191 * Added contributors blurb.
192 * [90/12/13 jjk]
193 *
194 * Hack to allow users to keep coda venus calls uninterruptible. THis
195 * basically prevents the Gnu-emacs bug from appearing, in which a call
196 * was being interrupted, and return EINTR, but gnu didn't check for the
197 * error and figured the file was buggered.
198 * [90/12/09 dcs]
199 *
200 * Revision 2.3 90/08/10 10:23:20 mrt
201 * Removed include of vm/vm_page.h as it no longer exists.
202 * [90/08/10 mrt]
203 *
204 * Revision 2.2 90/07/05 11:26:35 mrt
205 * Initialize name cache on first call to vcopen.
206 * [90/05/23 dcs]
207 *
208 * Created for the Coda File System.
209 * [90/05/23 dcs]
210 *
211 * Revision 1.5 90/05/31 17:01:35 dcs
212 * Prepare for merge with facilities kernel.
213 *
214 * Revision 1.2 90/03/19 15:56:25 dcs
215 * Initialize name cache on first call to vcopen.
216 *
217 * Revision 1.1 90/03/15 10:43:26 jjk
218 * Initial revision
219 *
220 */
221
222 /* NOTES: rvb
223 * 1. Added coda_unmounting to mark all cnodes as being UNMOUNTING. This has to
224 * be done before dounmount is called. Because some of the routines that
225 * dounmount calls before coda_unmounted might try to force flushes to venus.
226 * The vnode pager does this.
227 * 2. coda_unmounting marks all cnodes scanning coda_cache.
228 * 3. cfs_checkunmounting (under DEBUG) checks all cnodes by chasing the vnodes
229 * under the /coda mount point.
230 * 4. coda_cacheprint (under DEBUG) prints names with vnode/cnode address
231 */
232
233 #ifdef _LKM
234 #define NVCODA 4
235 #else
236 #include <vcoda.h>
237 #endif
238
239 #include <sys/param.h>
240 #include <sys/systm.h>
241 #include <sys/malloc.h>
242 #include <sys/proc.h>
243 #include <sys/select.h>
244 #include <sys/mount.h>
245
246 #include <coda/coda.h>
247 #include <coda/cnode.h>
248 #include <coda/coda_subr.h>
249 #include <coda/coda_namecache.h>
250
251 int coda_active = 0;
252 int coda_reuse = 0;
253 int coda_new = 0;
254
255 struct cnode *coda_freelist = NULL;
256 struct cnode *coda_cache[CODA_CACHESIZE];
257
258 #define coda_hash(fid) \
259 (((fid)->Volume + (fid)->Vnode) & (CODA_CACHESIZE-1))
260
261 #define CNODE_NEXT(cp) ((cp)->c_next)
262
263 #define ODD(vnode) ((vnode) & 0x1)
264
265 /*
266 * Allocate a cnode.
267 */
268 struct cnode *
269 coda_alloc(void)
270 {
271 struct cnode *cp;
272
273 if (coda_freelist) {
274 cp = coda_freelist;
275 coda_freelist = CNODE_NEXT(cp);
276 coda_reuse++;
277 }
278 else {
279 CODA_ALLOC(cp, struct cnode *, sizeof(struct cnode));
280 /* NetBSD vnodes don't have any Pager info in them ('cause there are
281 no external pagers, duh!) */
282 #define VNODE_VM_INFO_INIT(vp) /* MT */
283 VNODE_VM_INFO_INIT(CTOV(cp));
284 coda_new++;
285 }
286 bzero(cp, sizeof (struct cnode));
287
288 return(cp);
289 }
290
291 /*
292 * Deallocate a cnode.
293 */
294 void
295 coda_free(cp)
296 register struct cnode *cp;
297 {
298
299 CNODE_NEXT(cp) = coda_freelist;
300 coda_freelist = cp;
301 }
302
303 /*
304 * Put a cnode in the hash table
305 */
306 void
307 coda_save(cp)
308 struct cnode *cp;
309 {
310 CNODE_NEXT(cp) = coda_cache[coda_hash(&cp->c_fid)];
311 coda_cache[coda_hash(&cp->c_fid)] = cp;
312 }
313
314 /*
315 * Remove a cnode from the hash table
316 */
317 void
318 coda_unsave(cp)
319 struct cnode *cp;
320 {
321 struct cnode *ptr;
322 struct cnode *ptrprev = NULL;
323
324 ptr = coda_cache[coda_hash(&cp->c_fid)];
325 while (ptr != NULL) {
326 if (ptr == cp) {
327 if (ptrprev == NULL) {
328 coda_cache[coda_hash(&cp->c_fid)]
329 = CNODE_NEXT(ptr);
330 } else {
331 CNODE_NEXT(ptrprev) = CNODE_NEXT(ptr);
332 }
333 CNODE_NEXT(cp) = (struct cnode *)NULL;
334
335 return;
336 }
337 ptrprev = ptr;
338 ptr = CNODE_NEXT(ptr);
339 }
340 }
341
342 /*
343 * Lookup a cnode by fid. If the cnode is dying, it is bogus so skip it.
344 * NOTE: this allows multiple cnodes with same fid -- dcs 1/25/95
345 */
346 struct cnode *
347 coda_find(fid)
348 ViceFid *fid;
349 {
350 struct cnode *cp;
351
352 cp = coda_cache[coda_hash(fid)];
353 while (cp) {
354 if ((cp->c_fid.Vnode == fid->Vnode) &&
355 (cp->c_fid.Volume == fid->Volume) &&
356 (cp->c_fid.Unique == fid->Unique) &&
357 (!IS_UNMOUNTING(cp)))
358 {
359 coda_active++;
360 return(cp);
361 }
362 cp = CNODE_NEXT(cp);
363 }
364 return(NULL);
365 }
366
367 /*
368 * coda_kill is called as a side effect to vcopen. To prevent any
369 * cnodes left around from an earlier run of a venus or warden from
370 * causing problems with the new instance, mark any outstanding cnodes
371 * as dying. Future operations on these cnodes should fail (excepting
372 * coda_inactive of course!). Since multiple venii/wardens can be
373 * running, only kill the cnodes for a particular entry in the
374 * coda_mnttbl. -- DCS 12/1/94 */
375
376 int
377 coda_kill(whoIam, dcstat)
378 struct mount *whoIam;
379 enum dc_status dcstat;
380 {
381 int hash, count = 0;
382 struct cnode *cp;
383
384 /*
385 * Algorithm is as follows:
386 * Second, flush whatever vnodes we can from the name cache.
387 *
388 * Finally, step through whatever is left and mark them dying.
389 * This prevents any operation at all.
390
391 */
392
393 /* This is slightly overkill, but should work. Eventually it'd be
394 * nice to only flush those entries from the namecache that
395 * reference a vnode in this vfs. */
396 coda_nc_flush(dcstat);
397
398 for (hash = 0; hash < CODA_CACHESIZE; hash++) {
399 for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
400 if (CTOV(cp)->v_mount == whoIam) {
401 #ifdef DEBUG
402 printf("coda_kill: vp %p, cp %p\n", CTOV(cp), cp);
403 #endif
404 count++;
405 CODADEBUG(CODA_FLUSH,
406 myprintf(("Live cnode fid %lx.%lx.%lx flags %d count %ld\n",
407 (cp->c_fid).Volume,
408 (cp->c_fid).Vnode,
409 (cp->c_fid).Unique,
410 cp->c_flags,
411 CTOV(cp)->v_usecount)); );
412 }
413 }
414 }
415 return count;
416 }
417
418 /*
419 * There are two reasons why a cnode may be in use, it may be in the
420 * name cache or it may be executing.
421 */
422 void
423 coda_flush(dcstat)
424 enum dc_status dcstat;
425 {
426 int hash;
427 struct cnode *cp;
428
429 coda_clstat.ncalls++;
430 coda_clstat.reqs[CODA_FLUSH]++;
431
432 coda_nc_flush(dcstat); /* flush files from the name cache */
433
434 for (hash = 0; hash < CODA_CACHESIZE; hash++) {
435 for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
436 if (!ODD(cp->c_fid.Vnode)) /* only files can be executed */
437 coda_vmflush(cp);
438 }
439 }
440 }
441
442 /*
443 * As a debugging measure, print out any cnodes that lived through a
444 * name cache flush.
445 */
446 void
447 coda_testflush(void)
448 {
449 int hash;
450 struct cnode *cp;
451
452 for (hash = 0; hash < CODA_CACHESIZE; hash++) {
453 for (cp = coda_cache[hash];
454 cp != NULL;
455 cp = CNODE_NEXT(cp)) {
456 myprintf(("Live cnode fid %lx.%lx.%lx count %ld\n",
457 (cp->c_fid).Volume,(cp->c_fid).Vnode,
458 (cp->c_fid).Unique, CTOV(cp)->v_usecount));
459 }
460 }
461 }
462
463 /*
464 * First, step through all cnodes and mark them unmounting.
465 * NetBSD kernels may try to fsync them now that venus
466 * is dead, which would be a bad thing.
467 *
468 */
469 void
470 coda_unmounting(whoIam)
471 struct mount *whoIam;
472 {
473 int hash;
474 struct cnode *cp;
475
476 for (hash = 0; hash < CODA_CACHESIZE; hash++) {
477 for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
478 if (CTOV(cp)->v_mount == whoIam) {
479 if (cp->c_flags & (C_LOCKED|C_WANTED)) {
480 printf("coda_unmounting: Unlocking %p\n", cp);
481 cp->c_flags &= ~(C_LOCKED|C_WANTED);
482 wakeup((caddr_t) cp);
483 }
484 cp->c_flags |= C_UNMOUNTING;
485 }
486 }
487 }
488 }
489
490 #ifdef DEBUG
491 void
492 coda_checkunmounting(mp)
493 struct mount *mp;
494 {
495 register struct vnode *vp, *nvp;
496 struct cnode *cp;
497 int count = 0, bad = 0;
498 loop:
499 for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
500 if (vp->v_mount != mp)
501 goto loop;
502 nvp = vp->v_mntvnodes.le_next;
503 cp = VTOC(vp);
504 count++;
505 if (!(cp->c_flags & C_UNMOUNTING)) {
506 bad++;
507 printf("vp %p, cp %p missed\n", vp, cp);
508 cp->c_flags |= C_UNMOUNTING;
509 }
510 }
511 }
512
513 void
514 coda_cacheprint(whoIam)
515 struct mount *whoIam;
516 {
517 int hash;
518 struct cnode *cp;
519 int count = 0;
520
521 printf("coda_cacheprint: coda_ctlvp %p, cp %p", coda_ctlvp, VTOC(coda_ctlvp));
522 coda_nc_name(VTOC(coda_ctlvp));
523 printf("\n");
524
525 for (hash = 0; hash < CODA_CACHESIZE; hash++) {
526 for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
527 if (CTOV(cp)->v_mount == whoIam) {
528 printf("coda_cacheprint: vp %p, cp %p", CTOV(cp), cp);
529 coda_nc_name(cp);
530 printf("\n");
531 count++;
532 }
533 }
534 }
535 printf("coda_cacheprint: count %d\n", count);
536 }
537 #endif
538
539 /*
540 * There are 6 cases where invalidations occur. The semantics of each
541 * is listed here.
542 *
543 * CODA_FLUSH -- flush all entries from the name cache and the cnode cache.
544 * CODA_PURGEUSER -- flush all entries from the name cache for a specific user
545 * This call is a result of token expiration.
546 *
547 * The next two are the result of callbacks on a file or directory.
548 * CODA_ZAPDIR -- flush the attributes for the dir from its cnode.
549 * Zap all children of this directory from the namecache.
550 * CODA_ZAPFILE -- flush the attributes for a file.
551 *
552 * The fifth is a result of Venus detecting an inconsistent file.
553 * CODA_PURGEFID -- flush the attribute for the file
554 * If it is a dir (odd vnode), purge its
555 * children from the namecache
556 * remove the file from the namecache.
557 *
558 * The sixth allows Venus to replace local fids with global ones
559 * during reintegration.
560 *
561 * CODA_REPLACE -- replace one ViceFid with another throughout the name cache
562 */
563
564 int handleDownCall(opcode, out)
565 int opcode; union outputArgs *out;
566 {
567 int error;
568
569 /* Handle invalidate requests. */
570 switch (opcode) {
571 case CODA_FLUSH : {
572
573 coda_flush(IS_DOWNCALL);
574
575 CODADEBUG(CODA_FLUSH,coda_testflush();) /* print remaining cnodes */
576 return(0);
577 }
578
579 case CODA_PURGEUSER : {
580 coda_clstat.ncalls++;
581 coda_clstat.reqs[CODA_PURGEUSER]++;
582
583 /* XXX - need to prevent fsync's */
584 coda_nc_purge_user(out->coda_purgeuser.cred.cr_uid, IS_DOWNCALL);
585 return(0);
586 }
587
588 case CODA_ZAPFILE : {
589 struct cnode *cp;
590
591 error = 0;
592 coda_clstat.ncalls++;
593 coda_clstat.reqs[CODA_ZAPFILE]++;
594
595 cp = coda_find(&out->coda_zapfile.CodaFid);
596 if (cp != NULL) {
597 vref(CTOV(cp));
598
599 cp->c_flags &= ~C_VATTR;
600 if (CTOV(cp)->v_flag & VTEXT)
601 error = coda_vmflush(cp);
602 CODADEBUG(CODA_ZAPFILE, myprintf(("zapfile: fid = (%lx.%lx.%lx),
603 refcnt = %ld, error = %d\n",
604 cp->c_fid.Volume,
605 cp->c_fid.Vnode,
606 cp->c_fid.Unique,
607 CTOV(cp)->v_usecount - 1, error)););
608 if (CTOV(cp)->v_usecount == 1) {
609 cp->c_flags |= C_PURGING;
610 }
611 vrele(CTOV(cp));
612 }
613
614 return(error);
615 }
616
617 case CODA_ZAPDIR : {
618 struct cnode *cp;
619
620 coda_clstat.ncalls++;
621 coda_clstat.reqs[CODA_ZAPDIR]++;
622
623 cp = coda_find(&out->coda_zapdir.CodaFid);
624 if (cp != NULL) {
625 vref(CTOV(cp));
626
627 cp->c_flags &= ~C_VATTR;
628 coda_nc_zapParentfid(&out->coda_zapdir.CodaFid, IS_DOWNCALL);
629
630 CODADEBUG(CODA_ZAPDIR, myprintf(("zapdir: fid = (%lx.%lx.%lx),
631 refcnt = %ld\n",cp->c_fid.Volume,
632 cp->c_fid.Vnode,
633 cp->c_fid.Unique,
634 CTOV(cp)->v_usecount - 1)););
635 if (CTOV(cp)->v_usecount == 1) {
636 cp->c_flags |= C_PURGING;
637 }
638 vrele(CTOV(cp));
639 }
640
641 return(0);
642 }
643
644 case CODA_PURGEFID : {
645 struct cnode *cp;
646
647 error = 0;
648 coda_clstat.ncalls++;
649 coda_clstat.reqs[CODA_PURGEFID]++;
650
651 cp = coda_find(&out->coda_purgefid.CodaFid);
652 if (cp != NULL) {
653 vref(CTOV(cp));
654 if (ODD(out->coda_purgefid.CodaFid.Vnode)) { /* Vnode is a directory */
655 coda_nc_zapParentfid(&out->coda_purgefid.CodaFid,
656 IS_DOWNCALL);
657 }
658 cp->c_flags &= ~C_VATTR;
659 coda_nc_zapfid(&out->coda_purgefid.CodaFid, IS_DOWNCALL);
660 if (!(ODD(out->coda_purgefid.CodaFid.Vnode))
661 && (CTOV(cp)->v_flag & VTEXT)) {
662
663 error = coda_vmflush(cp);
664 }
665 CODADEBUG(CODA_PURGEFID, myprintf(("purgefid: fid = (%lx.%lx.%lx), refcnt = %ld, error = %d\n",
666 cp->c_fid.Volume, cp->c_fid.Vnode,
667 cp->c_fid.Unique,
668 CTOV(cp)->v_usecount - 1, error)););
669 if (CTOV(cp)->v_usecount == 1) {
670 cp->c_flags |= C_PURGING;
671 }
672 vrele(CTOV(cp));
673 }
674 return(error);
675 }
676
677 case CODA_REPLACE : {
678 struct cnode *cp = NULL;
679
680 coda_clstat.ncalls++;
681 coda_clstat.reqs[CODA_REPLACE]++;
682
683 cp = coda_find(&out->coda_replace.OldFid);
684 if (cp != NULL) {
685 /* remove the cnode from the hash table, replace the fid, and reinsert */
686 vref(CTOV(cp));
687 coda_unsave(cp);
688 cp->c_fid = out->coda_replace.NewFid;
689 coda_save(cp);
690
691 CODADEBUG(CODA_REPLACE, myprintf(("replace: oldfid = (%lx.%lx.%lx), newfid = (%lx.%lx.%lx), cp = %p\n",
692 out->coda_replace.OldFid.Volume,
693 out->coda_replace.OldFid.Vnode,
694 out->coda_replace.OldFid.Unique,
695 cp->c_fid.Volume, cp->c_fid.Vnode,
696 cp->c_fid.Unique, cp));)
697 vrele(CTOV(cp));
698 }
699 return (0);
700 }
701 default:
702 myprintf(("handleDownCall: unknown opcode %d\n", opcode));
703 return (EINVAL);
704 }
705 }
706
707 /* coda_grab_vnode: lives in either cfs_mach.c or cfs_nbsd.c */
708
709 int
710 coda_vmflush(cp)
711 struct cnode *cp;
712 {
713 return 0;
714 }
715
716
717 /*
718 * kernel-internal debugging switches
719 */
720
721 void coda_debugon(void)
722 {
723 codadebug = -1;
724 coda_nc_debug = -1;
725 coda_vnop_print_entry = 1;
726 coda_psdev_print_entry = 1;
727 coda_vfsop_print_entry = 1;
728 }
729
730 void coda_debugoff(void)
731 {
732 codadebug = 0;
733 coda_nc_debug = 0;
734 coda_vnop_print_entry = 0;
735 coda_psdev_print_entry = 0;
736 coda_vfsop_print_entry = 0;
737 }
738
739 /*
740 * Utilities used by both client and server
741 * Standard levels:
742 * 0) no debugging
743 * 1) hard failures
744 * 2) soft failures
745 * 3) current test software
746 * 4) main procedure entry points
747 * 5) main procedure exit points
748 * 6) utility procedure entry points
749 * 7) utility procedure exit points
750 * 8) obscure procedure entry points
751 * 9) obscure procedure exit points
752 * 10) random stuff
753 * 11) all <= 1
754 * 12) all <= 2
755 * 13) all <= 3
756 * ...
757 */
758