statfs.h 2.6 KB

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