1 // SPDX-License-Identifier: GPL-2.0
3 * Mostly platform independent upcall operations to Venus:
8 * Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk>,
9 * Michael Callahan <callahan@maths.ox.ac.uk>
11 * Redone for Linux 2.1
12 * Copyright (C) 1997 Carnegie Mellon University
14 * Carnegie Mellon University encourages users of this code to contribute
15 * improvements to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
18 #include <linux/signal.h>
19 #include <linux/sched/signal.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 <linux/uaccess.h>
32 #include <linux/vmalloc.h>
33 #include <linux/vfs.h>
35 #include <linux/coda.h>
36 #include "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 inp
= kvzalloc(size
, GFP_KERNEL
);
51 return ERR_PTR(-ENOMEM
);
53 inp
->ih
.opcode
= opcode
;
54 inp
->ih
.pid
= task_pid_nr_ns(current
, &init_pid_ns
);
55 inp
->ih
.pgid
= task_pgrp_nr_ns(current
, &init_pid_ns
);
56 inp
->ih
.uid
= from_kuid(&init_user_ns
, 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
;
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
;
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
);
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
;
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
);
170 inp
->ih
.uid
= from_kuid(&init_user_ns
, uid
);
171 inp
->coda_close
.VFid
= *fid
;
172 inp
->coda_close
.flags
= flags
;
174 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
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
;
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
;
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
);
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
;
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
);
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
);
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
);
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
)
366 retlen
= *length
- 1;
368 result
= (char *)outp
+ (long)outp
->coda_readlink
.data
;
369 memcpy(buffer
, result
, retlen
);
370 *(buffer
+ retlen
) = '\0';
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
);
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
);
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
), insize
, &outsize
, inp
);
456 int venus_access(struct super_block
*sb
, struct CodaFid
*fid
, int mask
)
458 union inputArgs
*inp
;
459 union outputArgs
*outp
;
460 int insize
, outsize
, error
;
462 insize
= SIZE(access
);
465 inp
->coda_access
.VFid
= *fid
;
466 inp
->coda_access
.flags
= mask
;
468 error
= coda_upcall(coda_vcp(sb
), insize
, &outsize
, inp
);
475 int venus_pioctl(struct super_block
*sb
, struct CodaFid
*fid
,
476 unsigned int cmd
, struct PioctlData
*data
)
478 union inputArgs
*inp
;
479 union outputArgs
*outp
;
480 int insize
, outsize
, error
;
483 insize
= VC_MAXMSGSIZE
;
486 /* build packet for Venus */
487 if (data
->vi
.in_size
> VC_MAXDATASIZE
) {
492 if (data
->vi
.out_size
> VC_MAXDATASIZE
) {
497 inp
->coda_ioctl
.VFid
= *fid
;
499 /* the cmd field was mutated by increasing its size field to
500 * reflect the path and follow args. We need to subtract that
501 * out before sending the command to Venus. */
502 inp
->coda_ioctl
.cmd
= (cmd
& ~(PIOCPARM_MASK
<< 16));
503 iocsize
= ((cmd
>> 16) & PIOCPARM_MASK
) - sizeof(char *) - sizeof(int);
504 inp
->coda_ioctl
.cmd
|= (iocsize
& PIOCPARM_MASK
) << 16;
506 /* in->coda_ioctl.rwflag = flag; */
507 inp
->coda_ioctl
.len
= data
->vi
.in_size
;
508 inp
->coda_ioctl
.data
= (char *)(INSIZE(ioctl
));
510 /* get the data out of user space */
511 if (copy_from_user((char *)inp
+ (long)inp
->coda_ioctl
.data
,
512 data
->vi
.in
, data
->vi
.in_size
)) {
517 error
= coda_upcall(coda_vcp(sb
), SIZE(ioctl
) + data
->vi
.in_size
,
521 pr_warn("%s: Venus returns: %d for %s\n",
522 __func__
, error
, coda_f2s(fid
));
526 if (outsize
< (long)outp
->coda_ioctl
.data
+ outp
->coda_ioctl
.len
) {
531 /* Copy out the OUT buffer. */
532 if (outp
->coda_ioctl
.len
> data
->vi
.out_size
) {
537 /* Copy out the OUT buffer. */
538 if (copy_to_user(data
->vi
.out
,
539 (char *)outp
+ (long)outp
->coda_ioctl
.data
,
540 outp
->coda_ioctl
.len
)) {
550 int venus_statfs(struct dentry
*dentry
, struct kstatfs
*sfs
)
552 union inputArgs
*inp
;
553 union outputArgs
*outp
;
554 int insize
, outsize
, error
;
556 insize
= SIZE(statfs
);
559 error
= coda_upcall(coda_vcp(dentry
->d_sb
), insize
, &outsize
, inp
);
561 sfs
->f_blocks
= outp
->coda_statfs
.stat
.f_blocks
;
562 sfs
->f_bfree
= outp
->coda_statfs
.stat
.f_bfree
;
563 sfs
->f_bavail
= outp
->coda_statfs
.stat
.f_bavail
;
564 sfs
->f_files
= outp
->coda_statfs
.stat
.f_files
;
565 sfs
->f_ffree
= outp
->coda_statfs
.stat
.f_ffree
;
572 int venus_access_intent(struct super_block
*sb
, struct CodaFid
*fid
,
573 bool *access_intent_supported
,
574 size_t count
, loff_t ppos
, int type
)
576 union inputArgs
*inp
;
577 union outputArgs
*outp
;
578 int insize
, outsize
, error
;
580 type
== CODA_ACCESS_TYPE_READ_FINISH
||
581 type
== CODA_ACCESS_TYPE_WRITE_FINISH
;
583 if (!*access_intent_supported
&& !finalizer
)
586 insize
= SIZE(access_intent
);
587 UPARG(CODA_ACCESS_INTENT
);
589 inp
->coda_access_intent
.VFid
= *fid
;
590 inp
->coda_access_intent
.count
= count
;
591 inp
->coda_access_intent
.pos
= ppos
;
592 inp
->coda_access_intent
.type
= type
;
594 error
= coda_upcall(coda_vcp(sb
), insize
,
595 finalizer
? NULL
: &outsize
, inp
);
598 * we have to free the request buffer for synchronous upcalls
599 * or when asynchronous upcalls fail, but not when asynchronous
602 if (!finalizer
|| error
)
605 /* Chunked access is not supported or an old Coda client */
606 if (error
== -EOPNOTSUPP
) {
607 *access_intent_supported
= false;
614 * coda_upcall and coda_downcall routines.
616 static void coda_block_signals(sigset_t
*old
)
618 spin_lock_irq(¤t
->sighand
->siglock
);
619 *old
= current
->blocked
;
621 sigfillset(¤t
->blocked
);
622 sigdelset(¤t
->blocked
, SIGKILL
);
623 sigdelset(¤t
->blocked
, SIGSTOP
);
624 sigdelset(¤t
->blocked
, SIGINT
);
627 spin_unlock_irq(¤t
->sighand
->siglock
);
630 static void coda_unblock_signals(sigset_t
*old
)
632 spin_lock_irq(¤t
->sighand
->siglock
);
633 current
->blocked
= *old
;
635 spin_unlock_irq(¤t
->sighand
->siglock
);
638 /* Don't allow signals to interrupt the following upcalls before venus
640 * - CODA_CLOSE or CODA_RELEASE upcall (to avoid reference count problems)
641 * - CODA_STORE (to avoid data loss)
642 * - CODA_ACCESS_INTENT (to avoid reference count problems)
644 #define CODA_INTERRUPTIBLE(r) (!coda_hard && \
645 (((r)->uc_opcode != CODA_CLOSE && \
646 (r)->uc_opcode != CODA_STORE && \
647 (r)->uc_opcode != CODA_ACCESS_INTENT && \
648 (r)->uc_opcode != CODA_RELEASE) || \
649 (r)->uc_flags & CODA_REQ_READ))
651 static inline void coda_waitfor_upcall(struct venus_comm
*vcp
,
654 DECLARE_WAITQUEUE(wait
, current
);
655 unsigned long timeout
= jiffies
+ coda_timeout
* HZ
;
659 coda_block_signals(&old
);
662 add_wait_queue(&req
->uc_sleep
, &wait
);
664 if (CODA_INTERRUPTIBLE(req
))
665 set_current_state(TASK_INTERRUPTIBLE
);
667 set_current_state(TASK_UNINTERRUPTIBLE
);
670 if (req
->uc_flags
& (CODA_REQ_WRITE
| CODA_REQ_ABORT
))
673 if (blocked
&& time_after(jiffies
, timeout
) &&
674 CODA_INTERRUPTIBLE(req
))
676 coda_unblock_signals(&old
);
680 if (signal_pending(current
)) {
681 list_del(&req
->uc_chain
);
685 mutex_unlock(&vcp
->vc_mutex
);
687 schedule_timeout(HZ
);
690 mutex_lock(&vcp
->vc_mutex
);
693 coda_unblock_signals(&old
);
695 remove_wait_queue(&req
->uc_sleep
, &wait
);
696 set_current_state(TASK_RUNNING
);
701 * coda_upcall will return an error in the case of
702 * failed communication with Venus _or_ will peek at Venus
703 * reply and return Venus' error.
705 * As venus has 2 types of errors, normal errors (positive) and internal
706 * errors (negative), normal errors are negated, while internal errors
707 * are all mapped to -EINTR, while showing a nice warning message. (jh)
709 static int coda_upcall(struct venus_comm
*vcp
,
710 int inSize
, int *outSize
,
711 union inputArgs
*buffer
)
713 union outputArgs
*out
;
714 union inputArgs
*sig_inputArgs
;
715 struct upc_req
*req
= NULL
, *sig_req
;
718 mutex_lock(&vcp
->vc_mutex
);
720 if (!vcp
->vc_inuse
) {
721 pr_notice("Venus dead, not sending upcall\n");
726 /* Format the request message. */
727 req
= kmalloc(sizeof(struct upc_req
), GFP_KERNEL
);
733 buffer
->ih
.unique
= ++vcp
->vc_seq
;
735 req
->uc_data
= (void *)buffer
;
736 req
->uc_flags
= outSize
? 0 : CODA_REQ_ASYNC
;
737 req
->uc_inSize
= inSize
;
738 req
->uc_outSize
= (outSize
&& *outSize
) ? *outSize
: inSize
;
739 req
->uc_opcode
= buffer
->ih
.opcode
;
740 req
->uc_unique
= buffer
->ih
.unique
;
741 init_waitqueue_head(&req
->uc_sleep
);
743 /* Append msg to pending queue and poke Venus. */
744 list_add_tail(&req
->uc_chain
, &vcp
->vc_pending
);
745 wake_up_interruptible(&vcp
->vc_waitq
);
747 if (req
->uc_flags
& CODA_REQ_ASYNC
) {
748 mutex_unlock(&vcp
->vc_mutex
);
752 /* We can be interrupted while we wait for Venus to process
753 * our request. If the interrupt occurs before Venus has read
754 * the request, we dequeue and return. If it occurs after the
755 * read but before the reply, we dequeue, send a signal
756 * message, and return. If it occurs after the reply we ignore
757 * it. In no case do we want to restart the syscall. If it
758 * was interrupted by a venus shutdown (psdev_close), return
761 /* Go to sleep. Wake up on signals only after the timeout. */
762 coda_waitfor_upcall(vcp
, req
);
764 /* Op went through, interrupt or not... */
765 if (req
->uc_flags
& CODA_REQ_WRITE
) {
766 out
= (union outputArgs
*)req
->uc_data
;
767 /* here we map positive Venus errors to kernel errors */
768 error
= -out
->oh
.result
;
769 *outSize
= req
->uc_outSize
;
774 if ((req
->uc_flags
& CODA_REQ_ABORT
) || !signal_pending(current
)) {
775 pr_warn("Unexpected interruption.\n");
779 /* Interrupted before venus read it. */
780 if (!(req
->uc_flags
& CODA_REQ_READ
))
783 /* Venus saw the upcall, make sure we can send interrupt signal */
784 if (!vcp
->vc_inuse
) {
785 pr_info("Venus dead, not sending signal.\n");
790 sig_req
= kmalloc(sizeof(struct upc_req
), GFP_KERNEL
);
791 if (!sig_req
) goto exit
;
793 sig_inputArgs
= kvzalloc(sizeof(struct coda_in_hdr
), GFP_KERNEL
);
794 if (!sig_inputArgs
) {
800 sig_inputArgs
->ih
.opcode
= CODA_SIGNAL
;
801 sig_inputArgs
->ih
.unique
= req
->uc_unique
;
803 sig_req
->uc_flags
= CODA_REQ_ASYNC
;
804 sig_req
->uc_opcode
= sig_inputArgs
->ih
.opcode
;
805 sig_req
->uc_unique
= sig_inputArgs
->ih
.unique
;
806 sig_req
->uc_data
= (void *)sig_inputArgs
;
807 sig_req
->uc_inSize
= sizeof(struct coda_in_hdr
);
808 sig_req
->uc_outSize
= sizeof(struct coda_in_hdr
);
810 /* insert at head of queue! */
811 list_add(&(sig_req
->uc_chain
), &vcp
->vc_pending
);
812 wake_up_interruptible(&vcp
->vc_waitq
);
816 mutex_unlock(&vcp
->vc_mutex
);
821 The statements below are part of the Coda opportunistic
822 programming -- taken from the Mach/BSD kernel code for Coda.
823 You don't get correct semantics by stating what needs to be
824 done without guaranteeing the invariants needed for it to happen.
825 When will be have time to find out what exactly is going on? (pjb)
830 * There are 7 cases where cache invalidations occur. The semantics
831 * of each is listed here:
833 * CODA_FLUSH -- flush all entries from the name cache and the cnode cache.
834 * CODA_PURGEUSER -- flush all entries from the name cache for a specific user
835 * This call is a result of token expiration.
837 * The next arise as the result of callbacks on a file or directory.
838 * CODA_ZAPFILE -- flush the cached attributes for a file.
840 * CODA_ZAPDIR -- flush the attributes for the dir and
841 * force a new lookup for all the children
845 * The next is a result of Venus detecting an inconsistent file.
846 * CODA_PURGEFID -- flush the attribute for the file
847 * purge it and its children from the dcache
849 * The last allows Venus to replace local fids with global ones
850 * during reintegration.
852 * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */
854 int coda_downcall(struct venus_comm
*vcp
, int opcode
, union outputArgs
*out
,
857 struct inode
*inode
= NULL
;
858 struct CodaFid
*fid
= NULL
, *newfid
;
859 struct super_block
*sb
;
862 * Make sure we have received enough data from the cache
863 * manager to populate the necessary fields in the buffer
867 if (nbytes
< sizeof(struct coda_purgeuser_out
))
872 if (nbytes
< sizeof(struct coda_zapdir_out
))
877 if (nbytes
< sizeof(struct coda_zapfile_out
))
882 if (nbytes
< sizeof(struct coda_purgefid_out
))
887 if (nbytes
< sizeof(struct coda_replace_out
))
892 /* Handle invalidation requests. */
893 mutex_lock(&vcp
->vc_mutex
);
895 if (!sb
|| !sb
->s_root
)
900 coda_cache_clear_all(sb
);
901 shrink_dcache_sb(sb
);
902 if (d_really_is_positive(sb
->s_root
))
903 coda_flag_inode(d_inode(sb
->s_root
), C_FLUSH
);
907 coda_cache_clear_all(sb
);
911 fid
= &out
->coda_zapdir
.CodaFid
;
915 fid
= &out
->coda_zapfile
.CodaFid
;
919 fid
= &out
->coda_purgefid
.CodaFid
;
923 fid
= &out
->coda_replace
.OldFid
;
927 inode
= coda_fid_to_inode(fid
, sb
);
930 mutex_unlock(&vcp
->vc_mutex
);
937 coda_flag_inode_children(inode
, C_PURGE
);
938 coda_flag_inode(inode
, C_VATTR
);
942 coda_flag_inode(inode
, C_VATTR
);
946 coda_flag_inode_children(inode
, C_PURGE
);
948 /* catch the dentries later if some are still busy */
949 coda_flag_inode(inode
, C_PURGE
);
950 d_prune_aliases(inode
);
954 newfid
= &out
->coda_replace
.NewFid
;
955 coda_replace_fid(inode
, fid
, newfid
);