2 * Mostly platform independent upcall operations to Venus:
7 * Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk>,
8 * Michael Callahan <callahan@maths.ox.ac.uk>
10 * Redone for Linux 2.1
11 * Copyright (C) 1997 Carnegie Mellon University
13 * Carnegie Mellon University encourages users of this code to contribute
14 * improvements to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
17 #include <asm/system.h>
18 #include <linux/signal.h>
19 #include <linux/sched.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
23 #include <linux/time.h>
25 #include <linux/file.h>
26 #include <linux/stat.h>
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <linux/slab.h>
30 #include <linux/mutex.h>
31 #include <asm/uaccess.h>
32 #include <linux/vmalloc.h>
33 #include <linux/vfs.h>
35 #include <linux/coda.h>
36 #include <linux/coda_psdev.h>
37 #include "coda_linux.h"
38 #include "coda_cache.h"
42 static int coda_upcall(struct venus_comm
*vc
, int inSize
, int *outSize
,
43 union inputArgs
*buffer
);
45 static void *alloc_upcall(int opcode
, int size
)
49 CODA_ALLOC(inp
, union inputArgs
*, size
);
51 return ERR_PTR(-ENOMEM
);
53 inp
->ih
.opcode
= opcode
;
54 inp
->ih
.pid
= current
->pid
;
55 inp
->ih
.pgid
= task_pgrp_nr(current
);
56 inp
->ih
.uid
= current_fsuid();
63 inp = (union inputArgs *)alloc_upcall(op, insize); \
64 if (IS_ERR(inp)) { return PTR_ERR(inp); }\
65 outp = (union outputArgs *)(inp); \
69 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
70 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
71 #define SIZE(tag) max_t(unsigned int, INSIZE(tag), OUTSIZE(tag))
75 int venus_rootfid(struct super_block
*sb
, struct CodaFid
*fidp
)
78 union outputArgs
*outp
;
79 int insize
, outsize
, error
;
84 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
86 *fidp
= outp
->coda_root
.VFid
;
88 CODA_FREE(inp
, insize
);
92 int venus_getattr(struct super_block
*sb
, struct CodaFid
*fid
,
93 struct coda_vattr
*attr
)
96 union outputArgs
*outp
;
97 int insize
, outsize
, error
;
99 insize
= SIZE(getattr
);
101 inp
->coda_getattr
.VFid
= *fid
;
103 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
105 *attr
= outp
->coda_getattr
.attr
;
107 CODA_FREE(inp
, insize
);
111 int venus_setattr(struct super_block
*sb
, struct CodaFid
*fid
,
112 struct coda_vattr
*vattr
)
114 union inputArgs
*inp
;
115 union outputArgs
*outp
;
116 int insize
, outsize
, error
;
118 insize
= SIZE(setattr
);
121 inp
->coda_setattr
.VFid
= *fid
;
122 inp
->coda_setattr
.attr
= *vattr
;
124 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
126 CODA_FREE(inp
, insize
);
130 int venus_lookup(struct super_block
*sb
, struct CodaFid
*fid
,
131 const char *name
, int length
, int * type
,
132 struct CodaFid
*resfid
)
134 union inputArgs
*inp
;
135 union outputArgs
*outp
;
136 int insize
, outsize
, error
;
139 offset
= INSIZE(lookup
);
140 insize
= max_t(unsigned int, offset
+ length
+1, OUTSIZE(lookup
));
143 inp
->coda_lookup
.VFid
= *fid
;
144 inp
->coda_lookup
.name
= offset
;
145 inp
->coda_lookup
.flags
= CLU_CASE_SENSITIVE
;
146 /* send Venus a null terminated string */
147 memcpy((char *)(inp
) + offset
, name
, length
);
148 *((char *)inp
+ offset
+ length
) = '\0';
150 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
152 *resfid
= outp
->coda_lookup
.VFid
;
153 *type
= outp
->coda_lookup
.vtype
;
156 CODA_FREE(inp
, insize
);
160 int venus_close(struct super_block
*sb
, struct CodaFid
*fid
, int flags
,
163 union inputArgs
*inp
;
164 union outputArgs
*outp
;
165 int insize
, outsize
, error
;
167 insize
= SIZE(release
);
171 inp
->coda_close
.VFid
= *fid
;
172 inp
->coda_close
.flags
= flags
;
174 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
176 CODA_FREE(inp
, insize
);
180 int venus_open(struct super_block
*sb
, struct CodaFid
*fid
,
181 int flags
, struct file
**fh
)
183 union inputArgs
*inp
;
184 union outputArgs
*outp
;
185 int insize
, outsize
, error
;
187 insize
= SIZE(open_by_fd
);
188 UPARG(CODA_OPEN_BY_FD
);
190 inp
->coda_open_by_fd
.VFid
= *fid
;
191 inp
->coda_open_by_fd
.flags
= flags
;
193 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
195 *fh
= outp
->coda_open_by_fd
.fh
;
197 CODA_FREE(inp
, insize
);
201 int venus_mkdir(struct super_block
*sb
, struct CodaFid
*dirfid
,
202 const char *name
, int length
,
203 struct CodaFid
*newfid
, struct coda_vattr
*attrs
)
205 union inputArgs
*inp
;
206 union outputArgs
*outp
;
207 int insize
, outsize
, error
;
210 offset
= INSIZE(mkdir
);
211 insize
= max_t(unsigned int, offset
+ length
+ 1, OUTSIZE(mkdir
));
214 inp
->coda_mkdir
.VFid
= *dirfid
;
215 inp
->coda_mkdir
.attr
= *attrs
;
216 inp
->coda_mkdir
.name
= offset
;
217 /* Venus must get null terminated string */
218 memcpy((char *)(inp
) + offset
, name
, length
);
219 *((char *)inp
+ offset
+ length
) = '\0';
221 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
223 *attrs
= outp
->coda_mkdir
.attr
;
224 *newfid
= outp
->coda_mkdir
.VFid
;
227 CODA_FREE(inp
, insize
);
232 int venus_rename(struct super_block
*sb
, struct CodaFid
*old_fid
,
233 struct CodaFid
*new_fid
, size_t old_length
,
234 size_t new_length
, const char *old_name
,
235 const char *new_name
)
237 union inputArgs
*inp
;
238 union outputArgs
*outp
;
239 int insize
, outsize
, error
;
242 offset
= INSIZE(rename
);
243 insize
= max_t(unsigned int, offset
+ new_length
+ old_length
+ 8,
247 inp
->coda_rename
.sourceFid
= *old_fid
;
248 inp
->coda_rename
.destFid
= *new_fid
;
249 inp
->coda_rename
.srcname
= offset
;
251 /* Venus must receive an null terminated string */
252 s
= ( old_length
& ~0x3) +4; /* round up to word boundary */
253 memcpy((char *)(inp
) + offset
, old_name
, old_length
);
254 *((char *)inp
+ offset
+ old_length
) = '\0';
256 /* another null terminated string for Venus */
258 inp
->coda_rename
.destname
= offset
;
259 s
= ( new_length
& ~0x3) +4; /* round up to word boundary */
260 memcpy((char *)(inp
) + offset
, new_name
, new_length
);
261 *((char *)inp
+ offset
+ new_length
) = '\0';
263 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
265 CODA_FREE(inp
, insize
);
269 int venus_create(struct super_block
*sb
, struct CodaFid
*dirfid
,
270 const char *name
, int length
, int excl
, int mode
,
271 struct CodaFid
*newfid
, struct coda_vattr
*attrs
)
273 union inputArgs
*inp
;
274 union outputArgs
*outp
;
275 int insize
, outsize
, error
;
278 offset
= INSIZE(create
);
279 insize
= max_t(unsigned int, offset
+ length
+ 1, OUTSIZE(create
));
282 inp
->coda_create
.VFid
= *dirfid
;
283 inp
->coda_create
.attr
.va_mode
= mode
;
284 inp
->coda_create
.excl
= excl
;
285 inp
->coda_create
.mode
= mode
;
286 inp
->coda_create
.name
= offset
;
288 /* Venus must get null terminated string */
289 memcpy((char *)(inp
) + offset
, name
, length
);
290 *((char *)inp
+ offset
+ length
) = '\0';
292 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
294 *attrs
= outp
->coda_create
.attr
;
295 *newfid
= outp
->coda_create
.VFid
;
298 CODA_FREE(inp
, insize
);
302 int venus_rmdir(struct super_block
*sb
, struct CodaFid
*dirfid
,
303 const char *name
, int length
)
305 union inputArgs
*inp
;
306 union outputArgs
*outp
;
307 int insize
, outsize
, error
;
310 offset
= INSIZE(rmdir
);
311 insize
= max_t(unsigned int, offset
+ length
+ 1, OUTSIZE(rmdir
));
314 inp
->coda_rmdir
.VFid
= *dirfid
;
315 inp
->coda_rmdir
.name
= offset
;
316 memcpy((char *)(inp
) + offset
, name
, length
);
317 *((char *)inp
+ offset
+ length
) = '\0';
319 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
321 CODA_FREE(inp
, insize
);
325 int venus_remove(struct super_block
*sb
, struct CodaFid
*dirfid
,
326 const char *name
, int length
)
328 union inputArgs
*inp
;
329 union outputArgs
*outp
;
330 int error
=0, insize
, outsize
, offset
;
332 offset
= INSIZE(remove
);
333 insize
= max_t(unsigned int, offset
+ length
+ 1, OUTSIZE(remove
));
336 inp
->coda_remove
.VFid
= *dirfid
;
337 inp
->coda_remove
.name
= offset
;
338 memcpy((char *)(inp
) + offset
, name
, length
);
339 *((char *)inp
+ offset
+ length
) = '\0';
341 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
343 CODA_FREE(inp
, insize
);
347 int venus_readlink(struct super_block
*sb
, struct CodaFid
*fid
,
348 char *buffer
, int *length
)
350 union inputArgs
*inp
;
351 union outputArgs
*outp
;
352 int insize
, outsize
, error
;
356 insize
= max_t(unsigned int,
357 INSIZE(readlink
), OUTSIZE(readlink
)+ *length
+ 1);
358 UPARG(CODA_READLINK
);
360 inp
->coda_readlink
.VFid
= *fid
;
362 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
364 retlen
= outp
->coda_readlink
.count
;
365 if ( retlen
> *length
)
368 result
= (char *)outp
+ (long)outp
->coda_readlink
.data
;
369 memcpy(buffer
, result
, retlen
);
370 *(buffer
+ retlen
) = '\0';
373 CODA_FREE(inp
, insize
);
379 int venus_link(struct super_block
*sb
, struct CodaFid
*fid
,
380 struct CodaFid
*dirfid
, const char *name
, int len
)
382 union inputArgs
*inp
;
383 union outputArgs
*outp
;
384 int insize
, outsize
, error
;
387 offset
= INSIZE(link
);
388 insize
= max_t(unsigned int, offset
+ len
+ 1, OUTSIZE(link
));
391 inp
->coda_link
.sourceFid
= *fid
;
392 inp
->coda_link
.destFid
= *dirfid
;
393 inp
->coda_link
.tname
= offset
;
395 /* make sure strings are null terminated */
396 memcpy((char *)(inp
) + offset
, name
, len
);
397 *((char *)inp
+ offset
+ len
) = '\0';
399 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
401 CODA_FREE(inp
, insize
);
405 int venus_symlink(struct super_block
*sb
, struct CodaFid
*fid
,
406 const char *name
, int len
,
407 const char *symname
, int symlen
)
409 union inputArgs
*inp
;
410 union outputArgs
*outp
;
411 int insize
, outsize
, error
;
414 offset
= INSIZE(symlink
);
415 insize
= max_t(unsigned int, offset
+ len
+ symlen
+ 8, OUTSIZE(symlink
));
418 /* inp->coda_symlink.attr = *tva; XXXXXX */
419 inp
->coda_symlink
.VFid
= *fid
;
421 /* Round up to word boundary and null terminate */
422 inp
->coda_symlink
.srcname
= offset
;
423 s
= ( symlen
& ~0x3 ) + 4;
424 memcpy((char *)(inp
) + offset
, symname
, symlen
);
425 *((char *)inp
+ offset
+ symlen
) = '\0';
427 /* Round up to word boundary and null terminate */
429 inp
->coda_symlink
.tname
= offset
;
430 s
= (len
& ~0x3) + 4;
431 memcpy((char *)(inp
) + offset
, name
, len
);
432 *((char *)inp
+ offset
+ len
) = '\0';
434 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
436 CODA_FREE(inp
, insize
);
440 int venus_fsync(struct super_block
*sb
, struct CodaFid
*fid
)
442 union inputArgs
*inp
;
443 union outputArgs
*outp
;
444 int insize
, outsize
, error
;
449 inp
->coda_fsync
.VFid
= *fid
;
450 error
= coda_upcall(coda_vcp(sb
), sizeof(union inputArgs
),
453 CODA_FREE(inp
, insize
);
457 int venus_access(struct super_block
*sb
, struct CodaFid
*fid
, int mask
)
459 union inputArgs
*inp
;
460 union outputArgs
*outp
;
461 int insize
, outsize
, error
;
463 insize
= SIZE(access
);
466 inp
->coda_access
.VFid
= *fid
;
467 inp
->coda_access
.flags
= mask
;
469 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
471 CODA_FREE(inp
, insize
);
476 int venus_pioctl(struct super_block
*sb
, struct CodaFid
*fid
,
477 unsigned int cmd
, struct PioctlData
*data
)
479 union inputArgs
*inp
;
480 union outputArgs
*outp
;
481 int insize
, outsize
, error
;
484 insize
= VC_MAXMSGSIZE
;
487 /* build packet for Venus */
488 if (data
->vi
.in_size
> VC_MAXDATASIZE
) {
493 if (data
->vi
.out_size
> VC_MAXDATASIZE
) {
498 inp
->coda_ioctl
.VFid
= *fid
;
500 /* the cmd field was mutated by increasing its size field to
501 * reflect the path and follow args. We need to subtract that
502 * out before sending the command to Venus. */
503 inp
->coda_ioctl
.cmd
= (cmd
& ~(PIOCPARM_MASK
<< 16));
504 iocsize
= ((cmd
>> 16) & PIOCPARM_MASK
) - sizeof(char *) - sizeof(int);
505 inp
->coda_ioctl
.cmd
|= (iocsize
& PIOCPARM_MASK
) << 16;
507 /* in->coda_ioctl.rwflag = flag; */
508 inp
->coda_ioctl
.len
= data
->vi
.in_size
;
509 inp
->coda_ioctl
.data
= (char *)(INSIZE(ioctl
));
511 /* get the data out of user space */
512 if ( copy_from_user((char*)inp
+ (long)inp
->coda_ioctl
.data
,
513 data
->vi
.in
, data
->vi
.in_size
) ) {
518 error
= coda_upcall(coda_vcp(sb
), SIZE(ioctl
) + data
->vi
.in_size
,
522 printk("coda_pioctl: Venus returns: %d for %s\n",
523 error
, coda_f2s(fid
));
527 if (outsize
< (long)outp
->coda_ioctl
.data
+ outp
->coda_ioctl
.len
) {
532 /* Copy out the OUT buffer. */
533 if (outp
->coda_ioctl
.len
> data
->vi
.out_size
) {
538 /* Copy out the OUT buffer. */
539 if (copy_to_user(data
->vi
.out
,
540 (char *)outp
+ (long)outp
->coda_ioctl
.data
,
541 outp
->coda_ioctl
.len
)) {
547 CODA_FREE(inp
, insize
);
551 int venus_statfs(struct dentry
*dentry
, struct kstatfs
*sfs
)
553 union inputArgs
*inp
;
554 union outputArgs
*outp
;
555 int insize
, outsize
, error
;
557 insize
= max_t(unsigned int, INSIZE(statfs
), OUTSIZE(statfs
));
560 error
= coda_upcall(coda_vcp(dentry
->d_sb
), insize
, &outsize
, inp
);
562 sfs
->f_blocks
= outp
->coda_statfs
.stat
.f_blocks
;
563 sfs
->f_bfree
= outp
->coda_statfs
.stat
.f_bfree
;
564 sfs
->f_bavail
= outp
->coda_statfs
.stat
.f_bavail
;
565 sfs
->f_files
= outp
->coda_statfs
.stat
.f_files
;
566 sfs
->f_ffree
= outp
->coda_statfs
.stat
.f_ffree
;
569 CODA_FREE(inp
, insize
);
574 * coda_upcall and coda_downcall routines.
576 static void coda_block_signals(sigset_t
*old
)
580 *old
= current
->blocked
;
582 sigfillset(&blocked
);
583 sigdelset(&blocked
, SIGKILL
);
584 sigdelset(&blocked
, SIGSTOP
);
585 sigdelset(&blocked
, SIGINT
);
587 set_current_blocked(&blocked
);
590 static void coda_unblock_signals(sigset_t
*old
)
592 set_current_blocked(old
);
595 /* Don't allow signals to interrupt the following upcalls before venus
597 * - CODA_CLOSE or CODA_RELEASE upcall (to avoid reference count problems)
598 * - CODA_STORE (to avoid data loss)
600 #define CODA_INTERRUPTIBLE(r) (!coda_hard && \
601 (((r)->uc_opcode != CODA_CLOSE && \
602 (r)->uc_opcode != CODA_STORE && \
603 (r)->uc_opcode != CODA_RELEASE) || \
604 (r)->uc_flags & CODA_REQ_READ))
606 static inline void coda_waitfor_upcall(struct venus_comm
*vcp
,
609 DECLARE_WAITQUEUE(wait
, current
);
610 unsigned long timeout
= jiffies
+ coda_timeout
* HZ
;
614 coda_block_signals(&old
);
617 add_wait_queue(&req
->uc_sleep
, &wait
);
619 if (CODA_INTERRUPTIBLE(req
))
620 set_current_state(TASK_INTERRUPTIBLE
);
622 set_current_state(TASK_UNINTERRUPTIBLE
);
625 if (req
->uc_flags
& (CODA_REQ_WRITE
| CODA_REQ_ABORT
))
628 if (blocked
&& time_after(jiffies
, timeout
) &&
629 CODA_INTERRUPTIBLE(req
))
631 coda_unblock_signals(&old
);
635 if (signal_pending(current
)) {
636 list_del(&req
->uc_chain
);
640 mutex_unlock(&vcp
->vc_mutex
);
642 schedule_timeout(HZ
);
645 mutex_lock(&vcp
->vc_mutex
);
648 coda_unblock_signals(&old
);
650 remove_wait_queue(&req
->uc_sleep
, &wait
);
651 set_current_state(TASK_RUNNING
);
656 * coda_upcall will return an error in the case of
657 * failed communication with Venus _or_ will peek at Venus
658 * reply and return Venus' error.
660 * As venus has 2 types of errors, normal errors (positive) and internal
661 * errors (negative), normal errors are negated, while internal errors
662 * are all mapped to -EINTR, while showing a nice warning message. (jh)
664 static int coda_upcall(struct venus_comm
*vcp
,
665 int inSize
, int *outSize
,
666 union inputArgs
*buffer
)
668 union outputArgs
*out
;
669 union inputArgs
*sig_inputArgs
;
670 struct upc_req
*req
= NULL
, *sig_req
;
673 mutex_lock(&vcp
->vc_mutex
);
675 if (!vcp
->vc_inuse
) {
676 printk(KERN_NOTICE
"coda: Venus dead, not sending upcall\n");
681 /* Format the request message. */
682 req
= kmalloc(sizeof(struct upc_req
), GFP_KERNEL
);
688 req
->uc_data
= (void *)buffer
;
690 req
->uc_inSize
= inSize
;
691 req
->uc_outSize
= *outSize
? *outSize
: inSize
;
692 req
->uc_opcode
= ((union inputArgs
*)buffer
)->ih
.opcode
;
693 req
->uc_unique
= ++vcp
->vc_seq
;
694 init_waitqueue_head(&req
->uc_sleep
);
696 /* Fill in the common input args. */
697 ((union inputArgs
*)buffer
)->ih
.unique
= req
->uc_unique
;
699 /* Append msg to pending queue and poke Venus. */
700 list_add_tail(&req
->uc_chain
, &vcp
->vc_pending
);
702 wake_up_interruptible(&vcp
->vc_waitq
);
703 /* We can be interrupted while we wait for Venus to process
704 * our request. If the interrupt occurs before Venus has read
705 * the request, we dequeue and return. If it occurs after the
706 * read but before the reply, we dequeue, send a signal
707 * message, and return. If it occurs after the reply we ignore
708 * it. In no case do we want to restart the syscall. If it
709 * was interrupted by a venus shutdown (psdev_close), return
712 /* Go to sleep. Wake up on signals only after the timeout. */
713 coda_waitfor_upcall(vcp
, req
);
715 /* Op went through, interrupt or not... */
716 if (req
->uc_flags
& CODA_REQ_WRITE
) {
717 out
= (union outputArgs
*)req
->uc_data
;
718 /* here we map positive Venus errors to kernel errors */
719 error
= -out
->oh
.result
;
720 *outSize
= req
->uc_outSize
;
725 if ((req
->uc_flags
& CODA_REQ_ABORT
) || !signal_pending(current
)) {
726 printk(KERN_WARNING
"coda: Unexpected interruption.\n");
730 /* Interrupted before venus read it. */
731 if (!(req
->uc_flags
& CODA_REQ_READ
))
734 /* Venus saw the upcall, make sure we can send interrupt signal */
735 if (!vcp
->vc_inuse
) {
736 printk(KERN_INFO
"coda: Venus dead, not sending signal.\n");
741 sig_req
= kmalloc(sizeof(struct upc_req
), GFP_KERNEL
);
742 if (!sig_req
) goto exit
;
744 CODA_ALLOC((sig_req
->uc_data
), char *, sizeof(struct coda_in_hdr
));
745 if (!sig_req
->uc_data
) {
751 sig_inputArgs
= (union inputArgs
*)sig_req
->uc_data
;
752 sig_inputArgs
->ih
.opcode
= CODA_SIGNAL
;
753 sig_inputArgs
->ih
.unique
= req
->uc_unique
;
755 sig_req
->uc_flags
= CODA_REQ_ASYNC
;
756 sig_req
->uc_opcode
= sig_inputArgs
->ih
.opcode
;
757 sig_req
->uc_unique
= sig_inputArgs
->ih
.unique
;
758 sig_req
->uc_inSize
= sizeof(struct coda_in_hdr
);
759 sig_req
->uc_outSize
= sizeof(struct coda_in_hdr
);
761 /* insert at head of queue! */
762 list_add(&(sig_req
->uc_chain
), &vcp
->vc_pending
);
763 wake_up_interruptible(&vcp
->vc_waitq
);
767 mutex_unlock(&vcp
->vc_mutex
);
772 The statements below are part of the Coda opportunistic
773 programming -- taken from the Mach/BSD kernel code for Coda.
774 You don't get correct semantics by stating what needs to be
775 done without guaranteeing the invariants needed for it to happen.
776 When will be have time to find out what exactly is going on? (pjb)
781 * There are 7 cases where cache invalidations occur. The semantics
782 * of each is listed here:
784 * CODA_FLUSH -- flush all entries from the name cache and the cnode cache.
785 * CODA_PURGEUSER -- flush all entries from the name cache for a specific user
786 * This call is a result of token expiration.
788 * The next arise as the result of callbacks on a file or directory.
789 * CODA_ZAPFILE -- flush the cached attributes for a file.
791 * CODA_ZAPDIR -- flush the attributes for the dir and
792 * force a new lookup for all the children
796 * The next is a result of Venus detecting an inconsistent file.
797 * CODA_PURGEFID -- flush the attribute for the file
798 * purge it and its children from the dcache
800 * The last allows Venus to replace local fids with global ones
801 * during reintegration.
803 * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */
805 int coda_downcall(struct venus_comm
*vcp
, int opcode
, union outputArgs
*out
)
807 struct inode
*inode
= NULL
;
808 struct CodaFid
*fid
= NULL
, *newfid
;
809 struct super_block
*sb
;
811 /* Handle invalidation requests. */
812 mutex_lock(&vcp
->vc_mutex
);
814 if (!sb
|| !sb
->s_root
)
819 coda_cache_clear_all(sb
);
820 shrink_dcache_sb(sb
);
821 if (sb
->s_root
->d_inode
)
822 coda_flag_inode(sb
->s_root
->d_inode
, C_FLUSH
);
826 coda_cache_clear_all(sb
);
830 fid
= &out
->coda_zapdir
.CodaFid
;
834 fid
= &out
->coda_zapfile
.CodaFid
;
838 fid
= &out
->coda_purgefid
.CodaFid
;
842 fid
= &out
->coda_replace
.OldFid
;
846 inode
= coda_fid_to_inode(fid
, sb
);
849 mutex_unlock(&vcp
->vc_mutex
);
856 coda_flag_inode_children(inode
, C_PURGE
);
857 coda_flag_inode(inode
, C_VATTR
);
861 coda_flag_inode(inode
, C_VATTR
);
865 coda_flag_inode_children(inode
, C_PURGE
);
867 /* catch the dentries later if some are still busy */
868 coda_flag_inode(inode
, C_PURGE
);
869 d_prune_aliases(inode
);
873 newfid
= &out
->coda_replace
.NewFid
;
874 coda_replace_fid(inode
, fid
, newfid
);