Coda Distributed File System
vproc.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2025 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 *
21 * Specification of the Venus process abstraction
22 *
23 */
24
25#ifndef _VENUS_PROC_H_
26#define _VENUS_PROC_H_ 1
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36#include <stdio.h>
37#include "coda_string.h"
38#include <sys/types.h>
39#include <sys/stat.h>
40#include <sys/time.h>
41#include <stdint.h>
42
43#include <coda.h>
44
45#include <lwp/lwp.h>
46#include <lwp/lock.h>
47/* interfaces */
48#include <vice.h>
49
50/* from rvm */
51#include <rvmlib.h>
52
53#ifdef __cplusplus
54}
55#endif
56
57/* from util */
58#include <olist.h>
59#include <dlist.h>
60#include <rec_dlist.h>
61
62/* from vicedep */
63#include <venusioctl.h>
64
65/* from venus */
66#include "fso_cachefile.h"
67#include "venus.private.h"
68
69/* string with counts */
71 int cs_len;
73 char *cs_buf;
74};
75
76/* Forward declarations. */
77struct uarea;
78class vproc;
79class vproc_iterator;
80
81/* C++ Bogosity. */
82extern void PrintVprocs();
83extern void PrintVprocs(FILE *);
84extern void PrintVprocs(int);
85
86/* ***** Exported constants ***** */
87
88const int VPROC_DEFAULT_STACK_SIZE = 16384;
89const int RETRY_LIMIT = 10;
90
91/* ***** Exported types ***** */
92
93/* local-repair modification */
95{
114
115/* Holds user/call specific context. */
116class namectxt;
117class volent;
118struct uarea {
119 int u_error; /* implicit return code */
120 uid_t u_uid; /* implicit user identifier */
121 int u_priority; /* to be used in resource requests */
122 VenusFid u_cdir; /* for name lookup */
123 int u_flags; /* " " */
124 namectxt *u_nc; /* " " */
125 volent *u_vol; /* for volume-level concurrency control */
126 int u_volmode; /* " " */
127 int u_vfsop; /* vfs operation in progress */
128#ifdef TIMING
129 struct timeval u_tv1; /* for recording elapsed time */
130 struct timeval u_tv2; /* " " */
131#endif /* TIMING */
132 char *u_resblk; /* block to wait on for resolves */
133 int u_rescnt; /* safeguard against infinite retry loops */
134 int u_retrycnt; /* safeguard against infinite retry loops */
135 int u_wdblkcnt; /* safeguard against infinite retry loops */
136
137 int u_pid; /* the process id of the calling process */
138 int u_pgid; /* the process group id of the calling process */
139
140 /* Initialization. */
141 void Init()
142 {
143 memset((void *)this, 0, (int)sizeof(struct uarea));
144 u_volmode = /*VM_UNSET*/ -1;
145 u_vfsop = /*VFSOP_UNSET*/ -1;
146 }
147};
148
149typedef void (*PROCBODY)(void);
150
151class vproc : public olink {
152 friend void VprocInit();
153 friend void Rtry_Wait();
154 friend void Rtry_Signal();
155 friend vproc *FindVproc(int);
156 friend void VprocPreamble(void *);
157 friend vproc *VprocSelf();
158 friend int VprocIdle();
159 friend int VprocInterrupted();
160 friend void PrintVprocs(int);
161 friend class vproc_iterator;
162 friend void PrintWorkers(int);
163 friend void PrintMariners(int);
164
165private:
166 static olist tbl;
167 static int counter;
168 static char rtry_sync;
169
170 void do_ioctl(VenusFid *fid, unsigned char nr,
171 struct ViceIoctl *data) EXCLUDES_TRANSACTION;
172
173 void init(void);
174
175protected:
177 char *name;
178 PROCBODY func; /* function should be set if vproc::main isn't overloaded */
179 int vpid;
182
183 /* derived classes should call this function once they have finished their
184 * constructor. */
186
187 /* entry point, should be overloaded by derived classes */
188 virtual void main(void);
189
190public:
191 /* Public for the time being. -JJK */
194 int lwpri;
195 int seq;
196 struct uarea u;
197 unsigned idle : 1;
198 unsigned interrupted : 1;
199 struct vcbevent *ve;
200
201 vproc(const char *, PROCBODY, vproctype, int = VPROC_DEFAULT_STACK_SIZE,
202 int = LWP_NORMAL_PRIORITY);
203 vproc(vproc &); // not supported
204 int operator=(vproc &); // not supported
205 virtual ~vproc();
206
207 /* Volume-level concurrency control. */
208 void Begin_VFS(Volid *, int, int = -1) EXCLUDES_TRANSACTION;
209 void Begin_VFS(VenusFid *fid, int op, int arg = -1) EXCLUDES_TRANSACTION
210 {
211 Begin_VFS(MakeVolid(fid), op, arg);
212 }
213 void End_VFS(int * = 0) EXCLUDES_TRANSACTION;
214
215 /* The vproc interface: mostly matching kernel requests. */
216 void root(struct venus_cnode *);
217 void statfs(struct coda_statfs *);
218 void sync();
219 void vget(struct venus_cnode *, VenusFid *,
221 void open(struct venus_cnode *, int) EXCLUDES_TRANSACTION;
222 void close(struct venus_cnode *, int) EXCLUDES_TRANSACTION;
223 void ioctl(struct venus_cnode *, unsigned char nr, struct ViceIoctl *,
225 void select(struct venus_cnode *, int);
226 void getattr(struct venus_cnode *,
228 void setattr(struct venus_cnode *,
230 void access(struct venus_cnode *, int) EXCLUDES_TRANSACTION;
231 void lookup(struct venus_cnode *, const char *, struct venus_cnode *,
233 void create(struct venus_cnode *, char *, struct coda_vattr *, int, int,
235 void remove(struct venus_cnode *, char *) EXCLUDES_TRANSACTION;
236 void link(struct venus_cnode *, struct venus_cnode *,
237 char *) EXCLUDES_TRANSACTION;
238 void rename(struct venus_cnode *, char *, struct venus_cnode *,
239 char *) EXCLUDES_TRANSACTION;
240 void mkdir(struct venus_cnode *, char *, struct coda_vattr *,
242 void rmdir(struct venus_cnode *, char *) EXCLUDES_TRANSACTION;
243 void symlink(struct venus_cnode *, char *, struct coda_vattr *,
244 char *) EXCLUDES_TRANSACTION;
245 void readlink(struct venus_cnode *,
248
257 void read(struct venus_cnode *node, uint64_t pos,
258 int64_t count) EXCLUDES_TRANSACTION;
259
268 void write(struct venus_cnode *node, uint64_t pos,
269 int64_t count) EXCLUDES_TRANSACTION;
270
279 void read_finish(struct venus_cnode *node, uint64_t pos,
280 int64_t count) EXCLUDES_TRANSACTION;
281
290 void write_finish(struct venus_cnode *node, uint64_t pos,
291 int64_t count) EXCLUDES_TRANSACTION;
292
301 void mmap(struct venus_cnode *node, uint64_t pos,
302 int64_t count) EXCLUDES_TRANSACTION;
303
304 /* Pathname translation. */
305 int namev(char *, int, struct venus_cnode *) EXCLUDES_TRANSACTION;
306 void GetPath(VenusFid *, char *, int *, int = 1) EXCLUDES_TRANSACTION;
307 const char *expansion(const char *path);
308 void verifyname(char *name, int flags);
309#define NAME_NO_DOTS 1 /* don't allow '.', '..', '/' */
310#define NAME_NO_CONFLICT 2 /* don't allow @XXXXXXXX.YYYYYYYY.ZZZZZZZZ */
311#define NAME_NO_EXPANSION 4 /* don't allow @cpu / @sys */
312
313 void GetStamp(char *);
314 void print();
315 void print(FILE *);
316 void print(int);
317};
318
321
322public:
324 vproc *operator()();
325};
326
327/* ***** Exported routines ***** */
328void VPROC_printvattr(struct coda_vattr *vap);
329extern void VprocInit();
330extern void Rtry_Wait() EXCLUDES_TRANSACTION;
331extern void Rtry_Signal();
332extern vproc *FindVproc(int);
333extern vproc *VprocSelf();
334void VprocWait(const void *) EXCLUDES_TRANSACTION;
335void VprocMwait(int, const void **) EXCLUDES_TRANSACTION;
336void VprocSignal(const void *, int = 0);
337void VprocSleep(struct timeval *) EXCLUDES_TRANSACTION;
339int VprocSelect(int, fd_set *, fd_set *, fd_set *,
340 struct timeval *) EXCLUDES_TRANSACTION;
341extern void VprocSetRetry(int = -1, struct timeval * = 0);
342extern int VprocIdle();
343extern int VprocInterrupted();
344//extern void PrintVprocs();
345//extern void PrintVprocs(FILE *);
346//extern void PrintVprocs(int);
347
348/* Things which should be in vnode.h? -JJK */
349
350extern void va_init(struct coda_vattr *);
351extern long FidToNodeid(VenusFid *);
352
353#define FTTOVT(ft) \
354 ((ft) == (int)File ? C_VREG : \
355 (ft) == (int)Directory ? C_VDIR : \
356 (ft) == (int)SymbolicLink ? C_VLNK : \
357 C_VREG)
358
359/* Venus cnodes are a small placeholder structure to pass arguments
360 into the output buffer back to the kernel without clobbering the
361 inputbuffer, which is the same pointer as the output buffer.
362*/
363
365 u_short c_flags; /* flags (see below) */
366 VenusFid c_fid; /* file handle */
367 CacheFile *c_cf; /* container file object */
369};
370
371#define MAKE_CNODE(vp, fid, type) \
372 { \
373 KernelToVenusFid(&(vp).c_fid, &fid); \
374 (vp).c_type = type; \
375 (vp).c_flags = 0; \
376 }
377
378#define MAKE_CNODE2(vp, fid, type) \
379 { \
380 (vp).c_fid = fid; \
381 (vp).c_type = type; \
382 (vp).c_flags = 0; \
383 }
384
385/* Venus cnode's c_flags */
386#define C_FLAGS_INCON 0x2
387
388/* Definitions of the value -1 with correct cast for different
389 platforms, to be used in struct vattr to indicate a field to be
390 ignored. Used mostly in vproc::setattr() */
391
392#define VA_IGNORE_FSID ((long)-1)
393#define VA_IGNORE_ID ((unsigned long)-1)
394#define VA_IGNORE_NLINK ((short)-1)
395#define VA_IGNORE_BLOCKSIZE ((long)-1)
396#define VA_IGNORE_RDEV ((cdev_t) - 1)
397#define VA_IGNORE_STORAGE ((uint64_t)-1)
398#define VA_IGNORE_MODE ((u_short) - 1)
399#define VA_IGNORE_UID ((uid_t) - 1)
400#define VA_IGNORE_GID ((gid_t) - 1)
401#define VA_IGNORE_SIZE ((uint64_t)-1)
402#define VA_IGNORE_TIME1 ((time_t)-1)
403#define VA_IGNORE_FLAGS ((u_long) - 1)
404
405#endif /* _VENUS_PROC_H_ */
Definition: fso_cachefile.h:344
Definition: olist.h:75
Definition: olist.h:47
Definition: venusvol.h:620
Definition: vproc.h:319
vproc_iterator(vproctype=(vproctype) -1)
Definition: vproc.cc:847
vproc * operator()()
Definition: vproc.cc:853
Definition: vproc.h:151
void read_finish(struct venus_cnode *node, uint64_t pos, int64_t count) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1686
friend void VprocInit()
Definition: vproc.cc:79
friend void Rtry_Signal()
Definition: vproc.cc:102
void getattr(struct venus_cnode *, struct coda_vattr *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:307
char * name
Definition: vproc.h:177
unsigned idle
Definition: vproc.h:197
friend int VprocInterrupted()
Definition: vproc.cc:345
void vget(struct venus_cnode *, VenusFid *, int what=RC_STATUS) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:113
void setattr(struct venus_cnode *, struct coda_vattr *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:380
rvm_perthread_t rvm_data
Definition: vproc.h:180
virtual void main(void)
Definition: vproc.cc:442
virtual ~vproc()
Definition: vproc.cc:463
void GetStamp(char *)
Definition: vproc.cc:481
PROCESS lwpid
Definition: vproc.h:176
void statfs(struct coda_statfs *)
Definition: vproc_vfscalls.cc:96
void sync()
void write_finish(struct venus_cnode *node, uint64_t pos, int64_t count) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1710
unsigned interrupted
Definition: vproc.h:198
void Begin_VFS(Volid *, int, int=-1) EXCLUDES_TRANSACTION
Definition: vproc.cc:593
friend void VprocPreamble(void *)
Definition: vproc.cc:122
const char * expansion(const char *path)
Definition: vproc_pathname.cc:389
void fsync(struct venus_cnode *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1585
int seq
Definition: vproc.h:195
void start_thread(void) EXCLUDES_TRANSACTION
Definition: vproc.cc:408
int vpid
Definition: vproc.h:179
void verifyname(char *name, int flags)
Definition: vproc_pathname.cc:405
friend void Rtry_Wait()
Definition: vproc.cc:93
void lookup(struct venus_cnode *, const char *, struct venus_cnode *, int) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:597
struct Lock init_lock
Definition: vproc.h:181
void End_VFS(int *=0) EXCLUDES_TRANSACTION
Definition: vproc.cc:669
void GetPath(VenusFid *, char *, int *, int=1) EXCLUDES_TRANSACTION
Definition: vproc_pathname.cc:288
void link(struct venus_cnode *, struct venus_cnode *, char *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:874
void print()
Definition: vproc.cc:823
void write(struct venus_cnode *node, uint64_t pos, int64_t count) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1653
friend vproc * FindVproc(int)
Definition: vproc.cc:107
friend void PrintVprocs(int)
Definition: vproc.cc:362
void readlink(struct venus_cnode *, struct coda_string *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1513
friend int VprocIdle()
Definition: vproc.cc:340
vproctype type
Definition: vproc.h:192
PROCBODY func
Definition: vproc.h:178
struct uarea u
Definition: vproc.h:196
void symlink(struct venus_cnode *, char *, struct coda_vattr *, char *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1442
vproc(const char *, PROCBODY, vproctype, int=VPROC_DEFAULT_STACK_SIZE, int=LWP_NORMAL_PRIORITY)
Definition: vproc.cc:375
int lwpri
Definition: vproc.h:194
struct vcbevent * ve
Definition: vproc.h:199
void rename(struct venus_cnode *, char *, struct venus_cnode *, char *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1002
void create(struct venus_cnode *, char *, struct coda_vattr *, int, int, struct venus_cnode *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:683
void select(struct venus_cnode *, int)
int stacksize
Definition: vproc.h:193
void root(struct venus_cnode *)
Definition: vproc_vfscalls.cc:88
void mkdir(struct venus_cnode *, char *, struct coda_vattr *, struct venus_cnode *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1277
friend void PrintWorkers(int)
Definition: worker.cc:1013
friend void PrintMariners(int)
Definition: mariner.cc:305
void remove(struct venus_cnode *, char *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:810
void read(struct venus_cnode *node, uint64_t pos, int64_t count) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1628
void open(struct venus_cnode *, int) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:171
void access(struct venus_cnode *, int) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:532
int namev(char *, int, struct venus_cnode *) EXCLUDES_TRANSACTION
Definition: vproc_pathname.cc:80
int operator=(vproc &)
Definition: vproc.cc:457
friend vproc * VprocSelf()
Definition: vproc.cc:161
void ioctl(struct venus_cnode *, unsigned char nr, struct ViceIoctl *, int) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:293
void close(struct venus_cnode *, int) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:247
void mmap(struct venus_cnode *node, uint64_t pos, int64_t count) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1743
void rmdir(struct venus_cnode *, char *) EXCLUDES_TRANSACTION
Definition: vproc_vfscalls.cc:1350
#define EXCLUDES_TRANSACTION
Definition: coda_tsa.h:108
#define LWP_NORMAL_PRIORITY
Definition: lwp.h:86
void path(char *pathname, char *direc, char *file)
Definition: path.c:53
void(* type)()
Definition: rp2main.c:424
@ init
Definition: rvm_private.h:470
memset(PeerInfo, 0, sizeof(RPC2_PeerInfo))
Definition: lock.h:68
Definition: venusfid.h:24
Definition: coda.h:790
Definition: venusfid.h:31
Definition: rpc2.h:588
Definition: coda.h:256
Definition: vproc.h:70
char * cs_buf
Definition: vproc.h:73
int cs_len
Definition: vproc.h:71
int cs_maxlen
Definition: vproc.h:72
Definition: coda.h:234
Definition: lwp.private_pt.h:33
Definition: rvmlib.h:59
Definition: vproc.h:118
int u_pid
Definition: vproc.h:137
namectxt * u_nc
Definition: vproc.h:124
uid_t u_uid
Definition: vproc.h:120
int u_wdblkcnt
Definition: vproc.h:135
int u_rescnt
Definition: vproc.h:133
void Init()
Definition: vproc.h:141
int u_vfsop
Definition: vproc.h:127
VenusFid u_cdir
Definition: vproc.h:122
int u_volmode
Definition: vproc.h:126
int u_retrycnt
Definition: vproc.h:134
int u_pgid
Definition: vproc.h:138
char * u_resblk
Definition: vproc.h:132
volent * u_vol
Definition: vproc.h:125
int u_priority
Definition: vproc.h:121
int u_flags
Definition: vproc.h:123
int u_error
Definition: vproc.h:119
Definition: vproc.h:364
CacheFile * c_cf
Definition: vproc.h:367
int c_type
Definition: vproc.h:368
VenusFid c_fid
Definition: vproc.h:366
u_short c_flags
Definition: vproc.h:365
#define RC_STATUS
Definition: venus.private.h:67
Volid * MakeVolid(VenusFid *fid)
Definition: venusfid.h:51
void VprocInit()
Definition: vproc.cc:79
long FidToNodeid(VenusFid *)
Definition: vproc.cc:898
void Rtry_Signal()
Definition: vproc.cc:102
int VprocInterrupted()
Definition: vproc.cc:345
void VprocYield() EXCLUDES_TRANSACTION
Definition: vproc.cc:244
void VprocMwait(int, const void **) EXCLUDES_TRANSACTION
Definition: vproc.cc:191
void VprocSignal(const void *, int=0)
Definition: vproc.cc:208
vproc * FindVproc(int)
Definition: vproc.cc:107
void VPROC_printvattr(struct coda_vattr *vap)
Definition: vproc.cc:882
int VprocSelect(int, fd_set *, fd_set *, fd_set *, struct timeval *) EXCLUDES_TRANSACTION
Definition: vproc.cc:265
int VprocIdle()
Definition: vproc.cc:340
void VprocWait(const void *) EXCLUDES_TRANSACTION
Definition: vproc.cc:175
void VprocSleep(struct timeval *) EXCLUDES_TRANSACTION
Definition: vproc.cc:230
vproctype
Definition: vproc.h:95
@ VPT_Reintegrator
Definition: vproc.h:101
@ VPT_Main
Definition: vproc.h:96
@ VPT_UserDaemon
Definition: vproc.h:107
@ VPT_Daemon
Definition: vproc.h:112
@ VPT_ProbeDaemon
Definition: vproc.h:104
@ VPT_AdviceDaemon
Definition: vproc.h:110
@ VPT_VolDaemon
Definition: vproc.h:106
@ VPT_VmonDaemon
Definition: vproc.h:109
@ VPT_RecovDaemon
Definition: vproc.h:108
@ VPT_VSGDaemon
Definition: vproc.h:105
@ VPT_CallBack
Definition: vproc.h:99
@ VPT_LRDaemon
Definition: vproc.h:111
@ VPT_Resolver
Definition: vproc.h:102
@ VPT_HDBDaemon
Definition: vproc.h:100
@ VPT_Mariner
Definition: vproc.h:98
@ VPT_FSODaemon
Definition: vproc.h:103
@ VPT_Worker
Definition: vproc.h:97
void(* PROCBODY)(void)
Definition: vproc.h:149
const int VPROC_DEFAULT_STACK_SIZE
Definition: vproc.h:88
const int RETRY_LIMIT
Definition: vproc.h:89
void va_init(struct coda_vattr *)
Definition: vproc.cc:865
void PrintVprocs()
Definition: vproc.cc:350
vproc * VprocSelf()
Definition: vproc.cc:161
void VprocSetRetry(int=-1, struct timeval *=0)
Definition: vproc.cc:292
void Rtry_Wait() EXCLUDES_TRANSACTION
Definition: vproc.cc:93