20
20
#include <afs/param.h>
23
("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.18 2006/09/15 23:19:28 jaltman Exp $");
23
("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.27 2008/03/11 17:40:55 shadow Exp $");
26
26
#include <stdlib.h>
28
29
#include <sys/types.h>
29
30
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
30
31
#include <sys/stat.h>
113
106
extern int LogLevel, etext;
114
107
extern afs_int32 BlocksSpare, PctSpare;
109
void *ShutDown(void *);
117
110
static void ClearXStatValues(), NewParms(), PrintCounters();
118
111
static void ResetCheckDescriptors(void), ResetCheckSignal(void);
119
static void CheckSignal(void);
112
static void *CheckSignal(void *);
120
113
extern int GetKeysFromToken();
121
114
extern int RXAFS_ExecuteRequest();
122
115
extern int RXSTATS_ExecuteRequest();
166
159
int printBanner = 0;
167
160
int rxJumbograms = 1; /* default is to send and receive jumbograms. */
168
161
int rxBind = 0; /* don't bind */
162
int rxkadDisableDotCheck = 0; /* disable check for dot in principal name */
169
163
int rxMaxMTU = -1;
170
164
afs_int32 implicitAdminRights = PRSFS_LOOKUP; /* The ADMINISTER right is
171
165
* already implied */
458
454
* other 5 minute activities because it may be delayed by timeouts when
459
455
* it probes the workstations
458
HostCheckLWP(void *unused)
464
460
ViceLog(1, ("Starting Host check process\n"));
465
461
setThreadId("HostCheckLWP");
472
468
ViceLog(2, ("Checking for dead venii & clients\n"));
475
472
} /*HostCheckLWP */
477
474
/* This LWP does fsync checks every 5 minutes: it should not be used for
478
475
* other 5 minute activities because it may be delayed by timeouts when
479
476
* it probes the workstations
479
FsyncCheckLWP(void *unused)
485
482
#ifdef AFS_PTHREAD_ENV
742
739
strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
743
740
strcat(buffer, "[-rxmaxmtu <bytes>] ");
744
741
strcat(buffer, "[-rxbind (bind the Rx socket to one address)] ");
742
strcat(buffer, "[-allow-dotted-principals (disable the rxkad principal name dot check)] ");
745
743
#if AFS_PTHREAD_ENV
746
744
strcat(buffer, "[-vattachpar <number of volume attach threads>] ");
1060
1058
rxJumbograms = 0;
1061
1059
} else if (!strcmp(argv[i], "-rxbind")) {
1061
} else if (!strcmp(argv[i], "-allow-dotted-principals")) {
1062
rxkadDisableDotCheck = 1;
1063
1063
} else if (!strcmp(argv[i], "-rxmaxmtu")) {
1064
1064
if ((i + 1) >= argc) {
1065
1065
fprintf(stderr, "missing argument for -rxmaxmtu\n");
1076
1076
} else if (!strcmp(argv[i], "-realm")) {
1077
extern char local_realm[AFS_REALM_SZ];
1077
extern char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
1078
extern int num_lrealms;
1078
1079
if ((i + 1) >= argc) {
1079
1080
fprintf(stderr, "missing argument for -realm\n");
1088
strncpy(local_realm, argv[i], AFS_REALM_SZ);
1089
if (num_lrealms == -1)
1091
if (num_lrealms >= AFS_NUM_LREALMS) {
1093
("a maximum of %d -realm arguments can be specified.\n",
1097
strncpy(local_realms[num_lrealms++], argv[i], AFS_REALM_SZ);
1089
1098
} else if (!strcmp(argv[i], "-udpsize")) {
1090
1099
if ((i + 1) >= argc) {
1091
1100
printf("You have to specify -udpsize <integer value>\n");
1444
1453
AFSDIR_SERVER_SYSID_FILEPATH, nentries));
1447
FS_HostAddr_cnt = nentries;
1448
for (i = 0; i < nentries; i++) {
1449
if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1450
sizeof(afs_int32)) {
1452
("%s: Read of addresses failed (%d)\n",
1453
AFSDIR_SERVER_SYSID_FILEPATH, errno));
1454
FS_HostAddr_cnt = 0; /* reset it */
1456
if (FS_HostAddr_cnt == 0) {
1457
FS_HostAddr_cnt = nentries;
1458
for (i = 0; i < nentries; i++) {
1459
if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1460
sizeof(afs_int32)) {
1462
("%s: Read of addresses failed (%d)\n",
1463
AFSDIR_SERVER_SYSID_FILEPATH, errno));
1464
FS_HostAddr_cnt = 0; /* reset it */
1470
("%s: address list ignored (NetInfo/NetRestrict override)\n",
1471
AFSDIR_SERVER_SYSID_FILEPATH));
1817
1832
rx_SetBusyThreshold(busy_threshold, VBUSY);
1818
1833
rx_SetCallAbortThreshold(abort_threshold);
1819
1834
rx_SetConnAbortThreshold(abort_threshold);
1836
stackSize = 128 * 1024;
1820
1838
stackSize = lwps * 4000;
1821
1839
if (stackSize < 32000)
1822
1840
stackSize = 32000;
1823
1841
else if (stackSize > 44000)
1824
1842
stackSize = 44000;
1825
#if defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV)
1844
#if defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV) || defined(AFS_XBSD_ENV)
1826
1845
rx_SetStackSize(1, stackSize);
1828
1847
if (udpBufSize)
1857
1876
("Failed to initialize RX, probably two servers running.\n"));
1879
if (rxkadDisableDotCheck) {
1880
rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1881
(void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK,
1860
1884
rx_SetMinProcs(tservice, 3);
1861
1885
rx_SetMaxProcs(tservice, lwps);
1862
1886
rx_SetCheckReach(tservice, 1);
1907
1931
/* allow super users to manage RX statistics */
1908
1932
rx_SetRxStatUserOk(fs_rxstat_userok);
1934
#ifdef AFS_PTHREAD_ENV
1935
assert(pthread_cond_init(&fsync_cond, NULL) == 0);
1936
assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
1910
1939
rx_StartServer(0); /* now start handling requests */
1912
1941
/* we ensure that there is enough space in the vnode buffer to satisfy
1952
1981
assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
1954
1983
assert(pthread_create
1955
(&serverPid, &tattr, (void *)FiveMinuteCheckLWP,
1984
(&serverPid, &tattr, FiveMinuteCheckLWP,
1956
1985
&fiveminutes) == 0);
1957
1986
assert(pthread_create
1958
(&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
1987
(&serverPid, &tattr, HostCheckLWP, &fiveminutes) == 0);
1959
1988
assert(pthread_create
1960
(&serverPid, &tattr, (void *)FsyncCheckLWP, &fiveminutes) == 0);
1989
(&serverPid, &tattr, FsyncCheckLWP, &fiveminutes) == 0);
1961
1990
#else /* AFS_PTHREAD_ENV */
1962
1991
ViceLog(5, ("Starting LWP\n"));
1963
1992
assert(LWP_CreateProcess
1964
1993
(FiveMinuteCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1965
(void *)&fiveminutes, "FiveMinuteChecks",
1994
&fiveminutes, "FiveMinuteChecks",
1966
1995
&serverPid) == LWP_SUCCESS);
1968
1997
assert(LWP_CreateProcess
1969
1998
(HostCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1970
(void *)&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1999
&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1971
2000
assert(LWP_CreateProcess
1972
2001
(FsyncCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1973
(void *)&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
2002
&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
1974
2003
#endif /* AFS_PTHREAD_ENV */
1976
2005
TM_GetTimeOfDay(&tp, 0);