d65575fa1fec68afd0ba78f25411b4055f765d83
[openafs.git] / src / viced / viced.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  *
9  * Portions Copyright (c) 2006 Sine Nomine Associates
10  */
11
12 /*  file.h      - include file for the File Server                      */
13 /*                                                                      */
14 /*  Date: 5/1/85                                                        */
15 /*                                                                      */
16 /************************************************************************/
17 /*
18  * Revision 2.2  90/08/29  15:12:11
19  * Cleanups.
20  *
21  * Revision 2.1  90/08/07  19:46:16
22  * Start with clean version to sync test and dev trees.
23  * */
24
25 #ifndef _AFS_VICED_VICED_H
26 #define _AFS_VICED_VICED_H
27
28 #include <afs/afssyscalls.h>
29 #include <afs/afsutil.h>
30 #include "fs_stats.h"           /*Defs for xstat-based statistics */
31
32 #define AFS_HARDDEADTIME        120
33
34 typedef struct DirHandle {
35     /* device+inode+vid are low level disk addressing + validity check */
36     /* vid+vnode+unique+cacheCheck are to guarantee validity of cached copy */
37     /* ***NOTE*** size of this stucture must not exceed size in buffer
38      * package (dir/buffer.c. Also, dir/buffer uses the first int as a
39      * hash into the page hash table.
40      * ***NOTE*** The volume, device and inode numbers used to compare
41      * fids are copied out of the handle to allow the handle to be reused
42      * while pages for the old fid are still in the buffer cache.
43      */
44     int dirh_vid;
45     int dirh_dev;
46     Inode dirh_ino;
47     VnodeId dirh_vnode;
48     afs_int32 dirh_cacheCheck;
49     Unique dirh_unique;
50     IHandle_t *dirh_handle;
51 } DirHandle;
52
53
54
55 #define MAXCNTRS (AFS_HIGHEST_OPCODE+1)
56
57 #define MAXCONSOLE 5
58 #define CONSOLENAME "opcons"
59 #define NEWCONNECT "NEWCONNECT"
60 #define TOTAL 0
61 #define FETCHDATAOP 30
62 #define FETCHDATA 31
63 #define FETCHD1 32
64 #define FETCHD2 33
65 #define FETCHD3 34
66 #define FETCHD4 35
67 #define FETCHD5 36
68 #define FETCHTIME 37
69 #define STOREDATAOP 40
70 #define STOREDATA 41
71 #define STORED1 42
72 #define STORED2 43
73 #define STORED3 44
74 #define STORED4 45
75 #define STORED5 46
76 #define STORETIME 47
77 /* N.B.: the biggest "opcode" here must not be as big as VICELOWEST_OPCODE */
78
79
80 #define SIZE1 1024
81 #define SIZE2 SIZE1*8
82 #define SIZE3 SIZE2*8
83 #define SIZE4 SIZE3*8
84
85 #define BIGTIME (0x7FFFFFFF)    /* Should be max u_int, rather than max int */
86
87 struct AFSCallStatistics {
88     /* References to AFS interface calls */
89     afs_uint32 FetchData;
90     afs_uint32 FetchACL;
91     afs_uint32 FetchStatus;
92     afs_uint32 StoreData;
93     afs_uint32 StoreACL;
94     afs_uint32 StoreStatus;
95     afs_uint32 RemoveFile;
96     afs_uint32 CreateFile;
97     afs_uint32 Rename;
98     afs_uint32 Symlink;
99     afs_uint32 Link;
100     afs_uint32 MakeDir;
101     afs_uint32 RemoveDir;
102     afs_uint32 SetLock;
103     afs_uint32 ExtendLock;
104     afs_uint32 ReleaseLock;
105     afs_uint32 GetStatistics;
106     afs_uint32 GiveUpCallBacks;
107     afs_uint32 GetVolumeInfo;
108     afs_uint32 GetVolumeStatus;
109     afs_uint32 SetVolumeStatus;
110     afs_uint32 GetRootVolume;
111     afs_uint32 CheckToken;
112     afs_uint32 GetTime;
113     afs_uint32 GetCapabilities;
114
115     /* General Fetch/Store Stats */
116     afs_uint32 TotalCalls;
117     afs_uint32 TotalFetchedBytes;
118     afs_uint32 AccumFetchTime;
119     afs_uint32 FetchSize1;
120     afs_uint32 FetchSize2;
121     afs_uint32 FetchSize3;
122     afs_uint32 FetchSize4;
123     afs_uint32 FetchSize5;
124     afs_uint32 TotalStoredBytes;
125     afs_uint32 AccumStoreTime;
126     afs_uint32 StoreSize1;
127     afs_uint32 StoreSize2;
128     afs_uint32 StoreSize3;
129     afs_uint32 StoreSize4;
130     afs_uint32 StoreSize5;
131 };
132
133 struct AFSDisk {
134     afs_int32 BlocksAvailable;
135     afs_int32 TotalBlocks;
136     DiskName Name;
137 };
138
139 #define AFS_MSTATSPARES 8
140 #define AFS_MSTATDISKS  10
141 struct AFSStatistics {
142     afs_uint32 CurrentMsgNumber;
143     afs_uint32 OldestMsgNumber;
144     afs_uint32 CurrentTime;
145     afs_uint32 BootTime;
146     afs_uint32 StartTime;
147     afs_int32 CurrentConnections;
148     afs_uint32 TotalAFSCalls;
149     afs_uint32 TotalFetchs;
150     afs_uint32 FetchDatas;
151     afs_uint32 FetchedBytes;
152     afs_int32 FetchDataRate;
153     afs_uint32 TotalStores;
154     afs_uint32 StoreDatas;
155     afs_uint32 StoredBytes;
156     afs_int32 StoreDataRate;
157     afs_uint32 TotalRPCBytesSent;
158     afs_uint32 TotalRPCBytesReceived;
159     afs_uint32 TotalRPCPacketsSent;
160     afs_uint32 TotalRPCPacketsReceived;
161     afs_uint32 TotalRPCPacketsLost;
162     afs_uint32 TotalRPCBogusPackets;
163     afs_int32 SystemCPU;
164     afs_int32 UserCPU;
165     afs_int32 NiceCPU;
166     afs_int32 IdleCPU;
167     afs_int32 TotalIO;
168     afs_int32 ActiveVM;
169     afs_int32 TotalVM;
170     afs_int32 EtherNetTotalErrors;
171     afs_int32 EtherNetTotalWrites;
172     afs_int32 EtherNetTotalInterupts;
173     afs_int32 EtherNetGoodReads;
174     afs_int32 EtherNetTotalBytesWritten;
175     afs_int32 EtherNetTotalBytesRead;
176     afs_int32 ProcessSize;
177     afs_int32 WorkStations;
178     afs_int32 ActiveWorkStations;
179     afs_int32 Spares[AFS_MSTATSPARES];
180     struct AFSDisk Disks[AFS_MSTATDISKS];
181 };
182
183 extern int busyonrst;
184 extern int saneacls;
185
186 #define RESTART_ORDINARY 1
187 #define RESTART_FAST 2
188 #define RESTART_SAFE 3
189
190 #define DONTPANIC 0
191 #define PANIC 1
192
193 #define MAX_FILESERVER_THREAD 16384 /* max number of threads in fileserver */
194 #define FILESERVER_HELPER_THREADS 8 /* Listner, IOMGR, FiveMinute, FsyncCk
195                                          * HostCheck, Signal, min 2 for RXSTATS */
196 #include <pthread.h>
197 extern pthread_mutex_t fileproc_glock_mutex;
198 #define FS_LOCK MUTEX_ENTER(&fileproc_glock_mutex);
199 #define FS_UNLOCK MUTEX_EXIT(&fileproc_glock_mutex);
200 extern pthread_mutex_t fsync_glock_mutex;
201 #define FSYNC_LOCK MUTEX_ENTER(&fsync_glock_mutex);
202 #define FSYNC_UNLOCK MUTEX_EXIT(&fsync_glock_mutex);
203
204
205 #ifdef AFS_DEMAND_ATTACH_FS
206 /*
207  * demand attach fs
208  * fileserver mode support
209  */
210 struct fs_state {
211     volatile int mode;
212     volatile byte FiveMinuteLWP_tranquil;      /* five minute check thread is shutdown or sleeping */
213     volatile byte HostCheckLWP_tranquil;       /* host check thread is shutdown or sleeping */
214     volatile byte FsyncCheckLWP_tranquil;      /* fsync check thread is shutdown or sleeping */
215     volatile byte salvsync_fatal_error;        /* fatal error with salvsync comm */
216
217     /* some command-line options we use in
218      * various places
219      *
220      * these fields are immutable once we
221      * go multithreaded */
222     struct {
223         byte fs_state_save;
224         byte fs_state_restore;
225         byte fs_state_verify_before_save;
226         byte fs_state_verify_after_restore;
227     } options;
228
229     pthread_cond_t worker_done_cv;
230     pthread_rwlock_t state_lock;
231 };
232
233 extern struct fs_state fs_state;
234
235 /* this lock is defined to be directly above FS_LOCK in the locking hierarchy */
236 #ifdef AFS_NT40_ENV
237 #define FS_STATE_INIT    fs_stateInit()
238 #else
239 #define FS_STATE_INIT    osi_Assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0)
240 #endif
241 #define FS_STATE_RDLOCK  osi_Assert(pthread_rwlock_rdlock(&fs_state.state_lock) == 0)
242 #define FS_STATE_WRLOCK  osi_Assert(pthread_rwlock_wrlock(&fs_state.state_lock) == 0)
243 #define FS_STATE_UNLOCK  osi_Assert(pthread_rwlock_unlock(&fs_state.state_lock) == 0)
244
245 #define FS_MODE_NORMAL    0
246 #define FS_MODE_SHUTDOWN  1
247 #endif /* AFS_DEMAND_ATTACH_FS */
248
249 extern int viced_SuperUser(struct rx_call *call);
250
251 #endif /* _AFS_VICED_VICED_H */