]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/iostats/statfs.h
68fccdc00be2c4d1c3c7ea2daab6a5d9b35eccb3
[plan9front.git] / sys / src / cmd / iostats / statfs.h
1 /*
2  * statfs.h - definitions for statistic gathering file server
3  */
4
5 #define DEBUGFILE       "iostats.out"
6 #define DONESTR         "done"
7 #define DEBUG           if(!dbg){}else fprint
8 #define MAXPROC         64
9 #define FHASHSIZE       64
10 #define fidhash(s)      fhash[s%FHASHSIZE]
11
12 enum{
13         Maxfdata        = 8192, /* max size of data in 9P message */
14         Maxrpc          = 20000,/* number of RPCs we'll log */
15 };
16
17 typedef struct Fsrpc Fsrpc;
18 typedef struct Fid Fid;
19 typedef struct File File;
20 typedef struct Proc Proc;
21 typedef struct Stats Stats;
22 typedef struct Rpc Rpc;
23 typedef struct Frec Frec;
24
25 struct Frec
26 {
27         Frec    *next;
28         char    *op;
29         ulong   nread;
30         ulong   nwrite;
31         ulong   bread;
32         ulong   bwrite;
33         ulong   opens;
34 };
35
36 struct Rpc
37 {
38         char    *name;
39         ulong   count;
40         vlong   time;
41         vlong   lo;
42         vlong   hi;
43         ulong   bin;
44         ulong   bout;
45 };
46
47 struct Stats
48 {
49         ulong   totread;
50         ulong   totwrite;
51         ulong   nrpc;
52         ulong   nproto;
53         Rpc     rpc[Maxrpc];
54 };
55
56 struct Fsrpc
57 {
58         int     busy;                   /* Work buffer has pending rpc to service */
59         uintptr pid;                    /* Pid of slave process executing the rpc */
60         int     canint;                 /* Interrupt gate */
61         int     flushtag;               /* Tag on which to reply to flush */
62         Fcall   work;                   /* Plan 9 incoming Fcall */
63         uchar   buf[IOHDRSZ+Maxfdata];  /* Data buffer */
64 };
65
66 struct Fid
67 {
68         int     fid;                    /* system fd for i/o */
69         File    *f;                     /* File attached to this fid */
70         int     mode;
71         int     nr;                     /* fid number */
72         Fid     *next;                  /* hash link */
73         ulong   nread;
74         ulong   nwrite;
75         ulong   bread;
76         ulong   bwrite;
77         vlong   offset;                 /* for directories */
78 };
79
80 struct File
81 {
82         char    *name;
83         Qid     qid;
84         int     inval;
85         File    *parent;
86         File    *child;
87         File    *childlist;
88 };
89
90 struct Proc
91 {
92         uintptr pid;
93         int     busy;
94         Proc    *next;
95 };
96
97 enum
98 {
99         Nr_workbufs     = 40,
100         Dsegpad         = 8192,
101         Fidchunk        = 1000,
102 };
103
104 Extern Fsrpc    *Workq;
105 Extern int      dbg;
106 Extern File     *root;
107 Extern Fid      **fhash;
108 Extern Fid      *fidfree;
109 Extern int      qid;
110 Extern Proc     *Proclist;
111 Extern int      done;
112 Extern Stats    *stats;
113 Extern Frec     *frhead;
114 Extern Frec     *frtail;
115 Extern int      myiounit;
116
117 /* File system protocol service procedures */
118 void Xcreate(Fsrpc*), Xclunk(Fsrpc*); 
119 void Xversion(Fsrpc*), Xauth(Fsrpc*), Xflush(Fsrpc*); 
120 void Xattach(Fsrpc*), Xwalk(Fsrpc*), Xauth(Fsrpc*);
121 void Xremove(Fsrpc*), Xstat(Fsrpc*), Xwstat(Fsrpc*);
122 void slave(Fsrpc*);
123
124 void    reply(Fcall*, Fcall*, char*);
125 Fid     *getfid(int);
126 int     freefid(int);
127 Fid     *newfid(int);
128 Fsrpc   *getsbuf(void);
129 void    initroot(void);
130 void    fatal(char*);
131 void    makepath(char*, File*, char*);
132 File    *file(File*, char*);
133 void    slaveopen(Fsrpc*);
134 void    slaveread(Fsrpc*);
135 void    slavewrite(Fsrpc*);
136 void    blockingslave(void);
137 void    reopen(Fid *f);
138 void    noteproc(int, char*);
139 void    flushaction(void*, char*);
140 void    catcher(void*, char*);
141 ulong   msec(void);
142 void    fidreport(Fid*);