2 * Copyright 2000, International Business Machines Corporation and others.
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
10 /* viced.c - File Server main loop */
14 /* Function - This routine has the initialization code for */
17 /* ********************************************************************** */
19 #include <afsconfig.h>
20 #include <afs/param.h>
28 #include <sys/types.h>
29 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
35 #include <WINNT/afsevent.h>
38 #include <netinet/in.h>
40 #include <unistd.h> /* sysconf() */
52 #endif /* ITIMER_REAL */
53 #include <sys/resource.h>
54 #endif /* AFS_NT40_ENV */
59 #ifdef AFS_PTHREAD_ENV
61 #else /* AFS_PTHREAD_ENV */
62 #include <afs/assert.h>
63 #endif /* AFS_PTHREAD_ENV */
66 #include <afs/ptclient.h>
67 #include <afs/afsint.h>
68 #include <afs/vldbint.h>
69 #include <afs/errors.h>
70 #include <afs/ihandle.h>
71 #include <afs/vnode.h>
72 #include <afs/volume.h>
74 #include <afs/cellconfig.h>
76 #include <afs/prs_fs.h>
80 #include <afs/afs_args.h>
81 #include <afs/vlserver.h>
82 #include <afs/afsutil.h>
83 #include <afs/fileutil.h>
85 #include <afs/netutils.h>
89 #ifdef AFS_PTHREAD_ENV
92 #if defined(AFS_SGI_ENV)
93 #include "sys/schedctl.h"
96 #include <rx/rx_globals.h>
99 #define afs_stat stat64
100 #define afs_fstat fstat64
101 #define afs_open open64
102 #define afs_fopen fopen64
103 #else /* !O_LARGEFILE */
104 #define afs_stat stat
105 #define afs_fstat fstat
106 #define afs_open open
107 #define afs_fopen fopen
108 #endif /* !O_LARGEFILE */
110 extern int BreakVolumeCallBacks(), InitCallBack();
111 extern int BreakVolumeCallBacks(), InitCallBack(), BreakLaterCallBacks();
112 extern int BreakVolumeCallBacksLater();
113 extern int LogLevel, etext;
114 extern afs_int32 BlocksSpare, PctSpare;
117 static void ClearXStatValues(), NewParms(), PrintCounters();
118 static void ResetCheckDescriptors(void), ResetCheckSignal(void);
119 static void CheckSignal(void);
120 extern int GetKeysFromToken();
121 extern int RXAFS_ExecuteRequest();
122 extern int RXSTATS_ExecuteRequest();
123 afs_int32 Do_VLRegisterRPC();
125 int eventlog = 0, rxlog = 0;
127 FILE *console = NULL;
129 #ifdef AFS_PTHREAD_ENV
130 pthread_mutex_t fsync_glock_mutex;
131 pthread_cond_t fsync_cond;
134 #endif /* AFS_PTHREAD_ENV */
137 #define AFS_QUIETFS_ENV 1
138 #define NT_OPEN_MAX 1024 /* This is an arbitrary no. we came up with for
139 * now. We hope this will be replaced by a more
140 * intelligent estimate later. */
143 int SystemId; /* ViceID of "Administrators" */
144 int SystemAnyUser; /* Viceid of "System:AnyUser" */
145 prlist SystemAnyUserCPS; /* CPS for "system:AnyUser */
146 int AnonymousID = 0; /* ViceId of "Anonymous" */
147 prlist AnonCPS; /* CPS for "Anonymous" */
149 struct afsconf_dir *confDir; /* Configuration dir object */
151 int restartMode = RESTART_ORDINARY;
153 int Testing = 0; /* for ListViceInodes */
156 * Home for the performance statistics.
158 struct afs_PerfStats afs_perfstats;
161 extern int Statistics;
169 int rxJumbograms = 1; /* default is to send and receive jumbograms. */
170 afs_int32 implicitAdminRights = PRSFS_LOOKUP; /* The ADMINISTER right is
172 afs_int32 readonlyServer = 0;
175 int stackSize = 24000;
176 int fiveminutes = 300; /* 5 minutes. Change this for debugging only */
177 int CurrentConnections = 0;
178 int hostaclRefresh = 7200; /* refresh host clients' acls every 2 hrs */
179 #if defined(AFS_SGI_ENV)
184 int rxpackets = 150; /* 100 */
185 int nSmallVns = 400; /* 200 */
186 int large = 400; /* 200 */
187 int volcache = 400; /* 400 */
188 int numberofcbs = 60000; /* 60000 */
189 int lwps = 9; /* 6 */
190 int buffs = 90; /* 70 */
191 int novbc = 0; /* Enable Volume Break calls */
192 int busy_threshold = 600;
193 int abort_threshold = 10;
194 int udpBufSize = 0; /* UDP buffer size for receive */
195 int sendBufSize = 16384; /* send buffer size */
200 * FileServer's name and IP address, both network byte order and
203 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
205 char FS_HostName[128] = "localhost";
206 afs_uint32 FS_HostAddr_NBO;
207 afs_uint32 FS_HostAddr_HBO;
208 afs_uint32 FS_HostAddrs[ADDRSPERSITE], FS_HostAddr_cnt = 0, FS_registered = 0;
209 /* All addresses in FS_HostAddrs are in NBO */
212 static void FlagMsg();
215 * Home for the performance statistics.
223 struct afs_stat status;
224 register int tsize = getdtablesize();
226 for (i = 0; i < tsize; i++) {
227 if (afs_fstat(i, &status) != -1) {
228 printf("%d: dev %x, inode %u, length %u, type/mode %x\n", i,
229 status.st_dev, status.st_ino, status.st_size,
234 ResetCheckDescriptors();
236 } /*CheckDescriptors */
239 #ifdef AFS_PTHREAD_ENV
241 CheckSignal_Signal(x)
253 CheckDescriptors_Signal(x)
257 #else /* AFS_PTHREAD_ENV */
259 CheckSignal_Signal(x)
261 IOMGR_SoftSig(CheckSignal, 0);
267 IOMGR_SoftSig(ShutDown, 0);
271 CheckDescriptors_Signal(x)
273 IOMGR_SoftSig(CheckDescriptors, 0);
275 #endif /* AFS_PTHREAD_ENV */
277 /* check whether caller is authorized to manage RX statistics */
279 fs_rxstat_userok(struct rx_call *call)
281 return afsconf_SuperUser(confDir, call, NULL);
285 ResetCheckSignal(void)
289 #if defined(AFS_HPUX_ENV)
292 #if defined(AFS_NT40_ENV)
299 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
300 softsig_signal(signo, CheckSignal_Signal);
302 signal(signo, CheckSignal_Signal);
307 ResetCheckDescriptors(void)
310 #if defined(AFS_PTHREAD_ENV)
311 softsig_signal(SIGTERM, CheckDescriptors_Signal);
313 (void)signal(SIGTERM, CheckDescriptors_Signal);
319 /* proc called by rxkad module to get a key */
321 get_key(char *arock, register afs_int32 akvno, char *akey)
324 static struct afsconf_key tkey;
325 register afs_int32 code;
328 ViceLog(0, ("conf dir not open\n"));
331 code = afsconf_GetKey(confDir, akvno, tkey.key);
334 memcpy(akey, tkey.key, sizeof(tkey.key));
341 viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
346 #ifndef AFS_LINUX20_ENV
347 old = (void (*)())signal(SIGSYS, SIG_IGN);
349 rcode = syscall(AFS_SYSCALL, 28 /* AFSCALL_CALL */ , a3, a4, a5);
350 #ifndef AFS_LINUX20_ENV
358 #if !defined(AFS_NT40_ENV)
359 #include "AFS_component_version_number.c"
360 #endif /* !AFS_NT40_ENV */
362 #define MAXADMINNAME 64
363 char adminName[MAXADMINNAME];
369 struct afs_stat status;
371 if ((afs_stat("/AdminName", &status)) || /* if file does not exist */
372 (status.st_size <= 0) || /* or it is too short */
373 (status.st_size >= (MAXADMINNAME)) || /* or it is too long */
374 !(fd = afs_open("/AdminName", O_RDONLY, 0))) { /* or the open fails */
375 strcpy(adminName, "System:Administrators"); /* use the default name */
377 (void)read(fd, adminName, status.st_size); /* use name from the file */
380 close(fd); /* close fd if it was opened */
382 } /*CheckAdminName */
388 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
389 /* set our 'thread-id' so that the host hold table works */
390 MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */
392 pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum);
393 MUTEX_EXIT(&rx_stats_mutex);
395 ("Set thread id %d for '%s'\n",
396 pthread_getspecific(rx_thread_id_key), s));
400 /* This LWP does things roughly every 5 minutes */
407 ViceLog(1, ("Starting five minute check process\n"));
408 setThreadId("FiveMinuteCheckLWP");
410 #ifdef AFS_PTHREAD_ENV
412 #else /* AFS_PTHREAD_ENV */
413 IOMGR_Sleep(fiveminutes);
414 #endif /* AFS_PTHREAD_ENV */
416 /* close the log so it can be removed */
417 ReOpenLog(AFSDIR_SERVER_FILELOG_FILEPATH); /* don't trunc, just append */
418 ViceLog(2, ("Cleaning up timed out callbacks\n"));
419 if (CleanupTimedOutCallBacks())
420 ViceLog(5, ("Timed out callbacks deleted\n"));
421 ViceLog(2, ("Set disk usage statistics\n"));
423 if (FS_registered == 1)
425 /* Force wakeup in case we missed something; pthreads does timedwait */
426 #ifndef AFS_PTHREAD_ENV
427 LWP_NoYieldSignal(fsync_wait);
429 if (printBanner && (++msg & 1)) { /* Every 10 minutes */
430 time_t now = FT_ApproxTime();
431 if (console != NULL) {
432 #ifndef AFS_QUIETFS_ENV
433 fprintf(console, "File server is running at %s\r",
434 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
435 #endif /* AFS_QUIETFS_ENV */
437 ("File server is running at %s\n",
438 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
442 } /*FiveMinuteCheckLWP */
445 /* This LWP does host checks every 5 minutes: it should not be used for
446 * other 5 minute activities because it may be delayed by timeouts when
447 * it probes the workstations
452 ViceLog(1, ("Starting Host check process\n"));
453 setThreadId("HostCheckLWP");
455 #ifdef AFS_PTHREAD_ENV
457 #else /* AFS_PTHREAD_ENV */
458 IOMGR_Sleep(fiveminutes);
459 #endif /* AFS_PTHREAD_ENV */
460 ViceLog(2, ("Checking for dead venii & clients\n"));
465 /* This LWP does fsync checks every 5 minutes: it should not be used for
466 * other 5 minute activities because it may be delayed by timeouts when
467 * it probes the workstations
473 #ifdef AFS_PTHREAD_ENV
474 struct timespec fsync_next;
476 ViceLog(1, ("Starting fsync check process\n"));
478 setThreadId("FsyncCheckLWP");
480 #ifdef AFS_PTHREAD_ENV
481 assert(pthread_cond_init(&fsync_cond, NULL) == 0);
482 assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
487 #ifdef AFS_PTHREAD_ENV
488 /* rounding is fine */
489 fsync_next.tv_nsec = 0;
490 fsync_next.tv_sec = time(0) + fiveminutes;
493 pthread_cond_timedwait(&fsync_cond, &fsync_glock_mutex,
495 if (code != 0 && code != ETIMEDOUT)
496 ViceLog(0, ("pthread_cond_timedwait returned %d\n", code));
497 #else /* AFS_PTHREAD_ENV */
498 if ((code = LWP_WaitProcess(fsync_wait)) != LWP_SUCCESS)
499 ViceLog(0, ("LWP_WaitProcess returned %d\n", code));
500 #endif /* AFS_PTHREAD_ENV */
502 ViceLog(2, ("Checking for fsync events\n"));
504 code = BreakLaterCallBacks();
509 /*------------------------------------------------------------------------
510 * PRIVATE ClearXStatValues
513 * Initialize all of the values collected via the xstat
523 * Must be called during File Server initialization.
527 *------------------------------------------------------------------------*/
531 { /*ClearXStatValues */
533 struct fs_stats_opTimingData *opTimeP; /*Ptr to timing struct */
534 struct fs_stats_xferData *opXferP; /*Ptr to xfer struct */
535 int i; /*Loop counter */
538 * Zero all xstat-related structures.
540 memset((char *)(&afs_perfstats), 0, sizeof(struct afs_PerfStats));
541 #if FS_STATS_DETAILED
542 memset((char *)(&afs_FullPerfStats), 0,
543 sizeof(struct fs_stats_FullPerfStats));
546 * That's not enough. We have to set reasonable minima for
547 * time and xfer values in the detailed stats.
549 opTimeP = &(afs_FullPerfStats.det.rpcOpTimes[0]);
550 for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++, opTimeP++)
551 opTimeP->minTime.tv_sec = 999999;
553 opXferP = &(afs_FullPerfStats.det.xferOpTimes[0]);
554 for (i = 0; i < FS_STATS_NUM_XFER_OPS; i++, opXferP++) {
555 opXferP->minTime.tv_sec = 999999;
556 opXferP->minBytes = 999999999;
560 * There's more. We have to set our unique system identifier, as
561 * declared in param.h. If such a thing is not defined, we bitch
562 * and declare ourselves to be an unknown system type.
565 afs_perfstats.sysname_ID = SYS_NAME_ID;
568 ViceLog(0, ("Sys name ID constant not defined in param.h!!\n"));
569 ViceLog(0, ("[Choosing ``undefined'' sys name ID.\n"));
571 afs_perfstats.sysname_ID = SYS_NAME_ID_UNDEFINED;
572 #endif /* SYS_NAME_ID */
575 } /*ClearXStatValues */
581 int dirbuff, dircall, dirio;
583 int workstations, activeworkstations, delworkstations;
587 TM_GetTimeOfDay(&tpl, 0);
590 ("Vice was last started at %s\n",
591 afs_ctime(&StartTime, tbuffer, sizeof(tbuffer))));
595 DStat(&dirbuff, &dircall, &dirio);
597 ("With %d directory buffers; %d reads resulted in %d read I/Os\n",
598 dirbuff, dircall, dirio));
599 rx_PrintStats(stderr);
601 PrintCallBackStats();
603 processSize = -1; /* TODO: */
605 processSize = (int)((long)sbrk(0) >> 10);
608 ("There are %d connections, process size %d\n",
609 CurrentConnections, processSize));
610 h_GetWorkStats(&workstations, &activeworkstations, &delworkstations,
611 tpl.tv_sec - 15 * 60);
613 ("There are %d workstations, %d are active (req in < 15 mins), %d marked \"down\"\n",
614 workstations, activeworkstations, delworkstations));
624 if (FS_registered > 0) {
626 * We have proper ip addresses; tell the vlserver what we got; the following
627 * routine will do the proper reporting for us
640 ShutDownAndCore(int dopanic)
642 time_t now = time(0);
646 ("Shutting down file server at %s",
647 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
649 ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
650 #ifndef AFS_QUIETFS_ENV
651 if (console != NULL) {
652 fprintf(console, "File server restart/shutdown received at %s\r",
653 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
660 /* do not allows new reqests to be served from now on, all new requests
661 * are returned with an error code of RX_RESTARTING ( transient failure ) */
662 rx_SetRxTranquil(); /* dhruba */
666 rx_PrintStats(debugFile);
669 if (console != NULL) {
672 #ifndef AFS_QUIETFS_ENV
673 fprintf(console, "File server has terminated abnormally at %s\r",
674 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
677 ("File server has terminated abnormally at %s\n",
678 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
680 #ifndef AFS_QUIETFS_ENV
681 fprintf(console, "File server has terminated normally at %s\r",
682 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
685 ("File server has terminated normally at %s\n",
686 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
696 { /* backward compatibility */
697 ShutDownAndCore(DONTPANIC);
706 /* default supports help flag */
708 strcpy(buffer, "Usage: fileserver ");
709 strcat(buffer, "[-d <debug level>] ");
710 strcat(buffer, "[-p <number of processes>] ");
711 strcat(buffer, "[-spare <number of spare blocks>] ");
712 strcat(buffer, "[-pctspare <percentage spare>] ");
713 strcat(buffer, "[-b <buffers>] ");
714 strcat(buffer, "[-l <large vnodes>] ");
715 strcat(buffer, "[-s <small vnodes>] ");
716 strcat(buffer, "[-vc <volume cachesize>] ");
717 strcat(buffer, "[-w <call back wait interval>] ");
718 strcat(buffer, "[-cb <number of call backs>] ");
719 strcat(buffer, "[-banner (print banner every 10 minutes)] ");
720 strcat(buffer, "[-novbc (whole volume cbs disabled)] ");
721 strcat(buffer, "[-implicit <admin mode bits: rlidwka>] ");
722 strcat(buffer, "[-readonly (read-only file server)] ");
724 "[-hr <number of hours between refreshing the host cps>] ");
725 strcat(buffer, "[-busyat <redirect clients when queue > n>] ");
726 strcat(buffer, "[-nobusy <no VBUSY before a volume is attached>] ");
727 strcat(buffer, "[-rxpck <number of rx extra packets>] ");
728 strcat(buffer, "[-rxdbg (enable rx debugging)] ");
729 strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
731 strcat(buffer, "[-m <min percentage spare in partition>] ");
733 #if defined(AFS_SGI_ENV)
734 strcat(buffer, "[-lock (keep fileserver from swapping)] ");
736 strcat(buffer, "[-L (large server conf)] ");
737 strcat(buffer, "[-S (small server conf)] ");
738 strcat(buffer, "[-k <stack size>] ");
739 strcat(buffer, "[-realm <Kerberos realm name>] ");
740 strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
741 strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
742 /* strcat(buffer, "[-enable_peer_stats] "); */
743 /* strcat(buffer, "[-enable_process_stats] "); */
744 strcat(buffer, "[-help]\n");
746 ViceLog(0, ("%s", buffer));
749 printf("%s", buffer);
756 ParseRights(char *arights)
762 if (!arights || !strcmp(arights, "")) {
763 printf("Missing list of mode bits on -implicit option\n");
766 if (!strcmp(arights, "none"))
768 else if (!strcmp(arights, "read"))
769 mode = PRSFS_READ | PRSFS_LOOKUP;
770 else if (!strcmp(arights, "write"))
772 PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
773 PRSFS_WRITE | PRSFS_LOCK;
774 else if (!strcmp(arights, "all"))
776 PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
777 PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
779 len = strlen(arights);
780 for (i = 0; i < len; i++) {
785 mode |= PRSFS_LOOKUP;
787 mode |= PRSFS_INSERT;
789 mode |= PRSFS_DELETE;
795 mode |= PRSFS_ADMINISTER;
813 printf("Illegal -implicit rights character '%c'.\n", tc);
822 * Limit MAX_FILESERVER_THREAD by the system limit on the number of
823 * pthreads (sysconf(_SC_THREAD_THREADS_MAX)), if applicable and
826 * AIX: sysconf() limit is real
827 * HP-UX: sysconf() limit is real
828 * IRIX: sysconf() limit is apparently NOT real -- too small
829 * DUX: sysconf() limit is apparently NOT real -- too big
830 * Linux: sysconf() limit is apparently NOT real -- too big
831 * Solaris: no sysconf() limit
834 max_fileserver_thread(void)
836 #if defined(AFS_PTHREAD_ENV)
837 #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV)
840 ans = sysconf(_SC_THREAD_THREADS_MAX);
841 if (0 < ans && ans < MAX_FILESERVER_THREAD)
844 #endif /* defined(AFS_PTHREAD_ENV) */
845 return MAX_FILESERVER_THREAD;
849 ParseArgs(int argc, char *argv[])
851 int SawL = 0, SawS = 0, SawVC = 0;
852 int Sawrxpck = 0, Sawsmall = 0, Sawlarge = 0, Sawcbs = 0, Sawlwps =
856 int bufSize = 0; /* temp variable to read in udp socket buf size */
858 for (i = 1; i < argc; i++) {
859 if (!strcmp(argv[i], "-d")) {
860 if ((i + 1) >= argc) {
861 fprintf(stderr, "missing argument for -d\n");
864 debuglevel = atoi(argv[++i]);
865 LogLevel = debuglevel;
866 } else if (!strcmp(argv[i], "-banner")) {
868 } else if (!strcmp(argv[i], "-implicit")) {
869 if ((i + 1) >= argc) {
870 fprintf(stderr, "missing argument for -implicit\n");
873 implicitAdminRights = ParseRights(argv[++i]);
874 if (implicitAdminRights < 0)
875 return implicitAdminRights;
876 } else if (!strcmp(argv[i], "-readonly")) {
878 } else if (!strcmp(argv[i], "-L")) {
880 } else if (!strcmp(argv[i], "-S")) {
882 } else if (!strcmp(argv[i], "-p")) {
884 max_fileserver_thread() - FILESERVER_HELPER_THREADS;
886 if ((i + 1) >= argc) {
887 fprintf(stderr, "missing argument for -p\n");
890 lwps = atoi(argv[++i]);
895 } else if (!strcmp(argv[i], "-b")) {
897 if ((i + 1) >= argc) {
898 fprintf(stderr, "missing argument for -b\n");
901 buffs = atoi(argv[++i]);
902 } else if (!strcmp(argv[i], "-l")) {
904 if ((i + 1) >= argc) {
905 fprintf(stderr, "missing argument for -l\n");
908 large = atoi(argv[++i]);
909 } else if (!strcmp(argv[i], "-vc")) {
911 if ((i + 1) >= argc) {
912 fprintf(stderr, "missing argument for -vc\n");
915 volcache = atoi(argv[++i]);
916 } else if (!strcmp(argv[i], "-novbc")) {
918 } else if (!strcmp(argv[i], "-rxpck")) {
920 if ((i + 1) >= argc) {
921 fprintf(stderr, "missing argument for -rxpck\n");
924 rxpackets = atoi(argv[++i]);
925 } else if (!strcmp(argv[i], "-s")) {
927 if ((i + 1) >= argc) {
928 fprintf(stderr, "missing argument for -s\n");
931 nSmallVns = atoi(argv[++i]);
932 } else if (!strcmp(argv[i], "-abortthreshold")) {
933 if ((i + 1) >= argc) {
934 fprintf(stderr, "missing argument for -abortthreshold\n");
937 abort_threshold = atoi(argv[++i]);
938 } else if (!strcmp(argv[i], "-k")) {
939 if ((i + 1) >= argc) {
940 fprintf(stderr, "missing argument for -k\n");
943 stack = atoi(argv[++i]);
945 #if defined(AFS_SGI_ENV)
946 else if (!strcmp(argv[i], "-lock")) {
950 else if (!strcmp(argv[i], "-spare")) {
951 if ((i + 1) >= argc) {
952 fprintf(stderr, "missing argument for -spare\n");
955 BlocksSpare = atoi(argv[++i]);
957 } else if (!strcmp(argv[i], "-pctspare")) {
958 if ((i + 1) >= argc) {
959 fprintf(stderr, "missing argument for -pctspare\n");
962 PctSpare = atoi(argv[++i]);
963 BlocksSpare = 0; /* has non-zero default */
965 } else if (!strcmp(argv[i], "-w")) {
966 if ((i + 1) >= argc) {
967 fprintf(stderr, "missing argument for -w\n");
970 fiveminutes = atoi(argv[++i]);
971 } else if (!strcmp(argv[i], "-hr")) {
973 if ((i + 1) >= argc) {
974 fprintf(stderr, "missing argument for -hr\n");
977 hr = atoi(argv[++i]);
978 if ((hr < 1) || (hr > 36)) {
980 ("host acl refresh interval of %d hours is invalid; hours must be between 1 and 36\n\n",
984 hostaclRefresh = hr * 60 * 60;
985 } else if (!strcmp(argv[i], "-rxdbg"))
987 else if (!strcmp(argv[i], "-rxdbge"))
989 else if (!strcmp(argv[i], "-cb")) {
991 if ((i + 1) >= argc) {
992 fprintf(stderr, "missing argument for -cb\n");
995 numberofcbs = atoi(argv[++i]);
996 if ((numberofcbs < 10000) || (numberofcbs > 2147483647)) {
998 ("number of cbs %d invalid; must be between 10000 and 2147483647\n",
1002 } else if (!strcmp(argv[i], "-busyat")) {
1004 if ((i + 1) >= argc) {
1005 fprintf(stderr, "missing argument for -busyat\n");
1008 busy_threshold = atoi(argv[++i]);
1009 if (busy_threshold < 10) {
1011 ("Busy threshold %d is too low, will compute default.\n",
1015 } else if (!strcmp(argv[i], "-nobusy"))
1017 #ifdef AFS_AIX32_ENV
1018 else if (!strcmp(argv[i], "-m")) {
1019 extern int aixlow_water;
1020 if ((i + 1) >= argc) {
1021 fprintf(stderr, "missing argument for -m\n");
1024 aixlow_water = atoi(argv[++i]);
1025 if ((aixlow_water < 0) || (aixlow_water > 30)) {
1026 printf("space reserved %d% invalid; must be between 0-30%\n",
1032 else if (!strcmp(argv[i], "-nojumbo")) {
1034 } else if (!strcmp(argv[i], "-realm")) {
1035 extern char local_realm[AFS_REALM_SZ];
1036 if ((i + 1) >= argc) {
1037 fprintf(stderr, "missing argument for -realm\n");
1040 if (strlen(argv[++i]) >= AFS_REALM_SZ) {
1042 ("-realm argument must contain fewer than %d characters.\n",
1046 strncpy(local_realm, argv[i], AFS_REALM_SZ);
1047 } else if (!strcmp(argv[i], "-udpsize")) {
1048 if ((i + 1) >= argc) {
1049 printf("You have to specify -udpsize <integer value>\n");
1052 bufSize = atoi(argv[++i]);
1053 if (bufSize < rx_GetMinUdpBufSize())
1055 ("Warning:udpsize %d is less than minimum %d; ignoring\n",
1056 bufSize, rx_GetMinUdpBufSize());
1058 udpBufSize = bufSize;
1059 } else if (!strcmp(argv[i], "-sendsize")) {
1060 if ((i + 1) >= argc) {
1061 printf("You have to specify -sendsize <integer value>\n");
1064 bufSize = atoi(argv[++i]);
1065 if (bufSize < 16384)
1067 ("Warning:sendsize %d is less than minimum %d; ignoring\n",
1070 sendBufSize = bufSize;
1071 } else if (!strcmp(argv[i], "-enable_peer_stats")) {
1072 rx_enablePeerRPCStats();
1073 } else if (!strcmp(argv[i], "-enable_process_stats")) {
1074 rx_enableProcessRPCStats();
1076 #ifndef AFS_NT40_ENV
1077 else if (strcmp(argv[i], "-syslog") == 0) {
1078 /* set syslog logging flag */
1079 serverLogSyslog = 1;
1080 } else if (strncmp(argv[i], "-syslog=", 8) == 0) {
1081 serverLogSyslog = 1;
1082 serverLogSyslogFacility = atoi(argv[i] + 8);
1090 printf("Only one of -L, or -S must be specified\n");
1101 numberofcbs = 20000;
1117 numberofcbs = 64000;
1126 busy_threshold = 3 * rxpackets / 2;
1136 NewParms(int initializing)
1138 static struct afs_stat sbuf;
1141 char *argv[MAXPARMS];
1144 if (!(afs_stat("/vice/file/parms", &sbuf))) {
1145 parms = (char *)malloc(sbuf.st_size);
1148 fd = afs_open("parms", O_RDONLY, 0666);
1150 ViceLog(0, ("Open for parms failed with errno = %d\n", errno));
1154 i = read(fd, parms, sbuf.st_size);
1156 if (i != sbuf.st_size) {
1158 ViceLog(0, ("Read on parms failed with errno = %d\n", errno));
1161 ("Read on parms failed; expected %d bytes but read %d\n",
1168 for (i = 0; i < MAXPARMS; argv[i++] = 0);
1170 for (argc = i = 0; i < sbuf.st_size; i++) {
1171 if ((*(parms + i) != ' ') && (*(parms + i) != '\n')) {
1172 if (argv[argc] == 0)
1173 argv[argc] = (parms + i);
1175 *(parms + i) = '\0';
1176 if (argv[argc] != 0) {
1177 if (++argc == MAXPARMS)
1180 while ((*(parms + i + 1) == ' ')
1181 || (*(parms + i + 1) == '\n'))
1185 if (ParseArgs(argc, argv) == 0) {
1186 ViceLog(0, ("Change parameters to:"));
1188 ViceLog(0, ("Invalid parameter in:"));
1190 for (i = 0; i < argc; i++) {
1191 ViceLog(0, (" %s", argv[i]));
1195 } else if (!initializing)
1197 ("Received request to change parms but no parms file exists\n"));
1202 /* Miscellaneous routines */
1206 ViceLog(0, ("%s\n", msg));
1218 * If this fails, it's because something major is wrong, and is not
1219 * likely to be time dependent.
1221 code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
1224 ("Couldn't initialize protection library; code=%d.\n", code));
1227 SystemId = SYSADMINID;
1228 SystemAnyUser = ANYUSERID;
1229 SystemAnyUserCPS.prlist_len = 0;
1230 SystemAnyUserCPS.prlist_val = NULL;
1231 AnonCPS.prlist_len = 0;
1232 AnonCPS.prlist_val = NULL;
1234 code = pr_GetCPS(SystemAnyUser, &SystemAnyUserCPS);
1237 ("Couldn't get CPS for AnyUser, will try again in 30 seconds; code=%d.\n",
1241 code = pr_GetCPS(ANONYMOUSID, &AnonCPS);
1244 ("Couldn't get Anonymous CPS, exiting; code=%d.\n",
1248 AnonymousID = ANONYMOUSID;
1251 #ifdef AFS_PTHREAD_ENV
1253 #else /* AFS_PTHREAD_ENV */
1255 #endif /* AFS_PTHREAD_ENV */
1259 struct rx_connection *serverconns[MAXSERVERS];
1260 struct ubik_client *cstruct;
1263 vl_Initialize(char *confDir)
1265 afs_int32 code, scIndex = 0, i;
1266 struct afsconf_dir *tdir;
1267 struct rx_securityClass *sc;
1268 struct afsconf_cell info;
1270 tdir = afsconf_Open(confDir);
1273 ("Could not open configuration directory (%s).\n", confDir));
1276 code = afsconf_ClientAuth(tdir, &sc, &scIndex);
1278 ViceLog(0, ("Could not get security object for localAuth\n"));
1281 code = afsconf_GetCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info);
1282 if (info.numServers > MAXSERVERS) {
1284 ("vl_Initialize: info.numServers=%d (> MAXSERVERS=%d)\n",
1285 info.numServers, MAXSERVERS));
1288 for (i = 0; i < info.numServers; i++)
1290 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
1291 info.hostAddr[i].sin_port, USER_SERVICE_ID, sc,
1293 code = ubik_ClientInit(serverconns, &cstruct);
1295 ViceLog(0, ("vl_Initialize: ubik client init failed.\n"));
1301 #define SYSIDMAGIC 0x88aabbcc
1302 #define SYSIDVERSION 1
1307 afs_int32 fd, nentries, i;
1308 struct versionStamp vsn;
1309 struct afs_stat status;
1312 if ((afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status))
1313 || (status.st_size <= 0)) {
1314 ViceLog(0, ("%s: doesn't exist\n", AFSDIR_SERVER_SYSID_FILEPATH));
1317 if (!(fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
1319 ("%s: can't open (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1323 if ((i = read(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1325 ("%s: Read failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1329 if (vsn.magic != SYSIDMAGIC) {
1331 ("%s: wrong magic %x (we support %x)\n",
1332 AFSDIR_SERVER_SYSID_FILEPATH, vsn.magic, SYSIDMAGIC));
1335 if (vsn.version != SYSIDVERSION) {
1337 ("%s: wrong version %d (we support %d)\n",
1338 AFSDIR_SERVER_SYSID_FILEPATH, vsn.version, SYSIDVERSION));
1342 read(fd, (char *)&uuid,
1343 sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1345 ("%s: read of uuid failed (%d)\n",
1346 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1349 afs_ntohuuid(&uuid);
1352 read(fd, (char *)&nentries,
1353 sizeof(afs_int32))) != sizeof(afs_int32)) {
1355 ("%s: Read of entries failed (%d)\n",
1356 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1359 if (nentries <= 0 || nentries > ADDRSPERSITE) {
1361 ("%s: invalid num of interfaces: %d\n",
1362 AFSDIR_SERVER_SYSID_FILEPATH, nentries));
1365 FS_HostAddr_cnt = nentries;
1366 for (i = 0; i < nentries; i++) {
1367 if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1368 sizeof(afs_int32)) {
1370 ("%s: Read of addresses failed (%d)\n",
1371 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1372 FS_HostAddr_cnt = 0; /* reset it */
1384 struct versionStamp vsn;
1385 struct afs_stat status;
1388 if (!afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
1390 * File exists; keep the old one around
1392 renamefile(AFSDIR_SERVER_SYSID_FILEPATH,
1393 AFSDIR_SERVER_OLDSYSID_FILEPATH);
1395 fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY | O_TRUNC | O_CREAT,
1399 ("%s: can't create (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1403 vsn.magic = SYSIDMAGIC;
1405 if ((i = write(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1407 ("%s: write failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1412 afs_htonuuid(&uuid);
1414 write(fd, (char *)&uuid,
1415 sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1417 ("%s: write of uuid failed (%d)\n",
1418 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1422 write(fd, (char *)&FS_HostAddr_cnt,
1423 sizeof(afs_int32))) != sizeof(afs_int32)) {
1425 ("%s: write of # of entries failed (%d)\n",
1426 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1429 for (i = 0; i < FS_HostAddr_cnt; i++) {
1430 if (write(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1431 sizeof(afs_int32)) {
1433 ("%s: write of addresses failed (%d)\n",
1434 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1444 * This routine sets up the buffers for the VL_RegisterAddrs RPC. All addresses
1445 * in FS_HostAddrs[] are in NBO, while the RPC treats them as a "blob" of data
1446 * and so we need to convert each of them into HBO which is what the extra
1447 * array called FS_HostAddrs_HBO is used here.
1454 extern int VL_RegisterAddrs();
1455 afs_uint32 FS_HostAddrs_HBO[ADDRSPERSITE];
1458 for (i = 0; i < FS_HostAddr_cnt; i++)
1459 FS_HostAddrs_HBO[i] = ntohl(FS_HostAddrs[i]);
1460 addrs.bulkaddrs_len = FS_HostAddr_cnt;
1461 addrs.bulkaddrs_val = (afs_uint32 *) FS_HostAddrs_HBO;
1462 code = ubik_Call(VL_RegisterAddrs, cstruct, 0, &FS_HostUUID, 0, &addrs);
1464 if (code == VL_MULTIPADDR) {
1466 ("VL_RegisterAddrs rpc failed; The ethernet address exist on a different server; repair it\n"));
1468 ("VL_RegisterAddrs rpc failed; See VLLog for details\n"));
1470 } else if (code == RXGEN_OPCODE) {
1472 ("vlserver doesn't support VL_RegisterAddrs rpc; ignored\n"));
1473 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1476 ("VL_RegisterAddrs rpc failed; will retry periodically (code=%d, err=%d)\n",
1480 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1491 extern int rxi_numNetAddrs;
1492 extern afs_uint32 rxi_NetAddrs[];
1495 * If this fails, it's because something major is wrong, and is not
1496 * likely to be time dependent.
1498 code = vl_Initialize(AFSDIR_SERVER_ETC_DIRPATH);
1501 ("Couldn't initialize protection library; code=%d.\n", code));
1505 /* Read or create the sysid file and register the fileserver's
1506 * IP addresses with the vlserver.
1508 code = ReadSysIdFile();
1510 /* Need to create the file */
1511 ViceLog(0, ("Creating new SysID file\n"));
1512 if ((code = afs_uuid_create(&FS_HostUUID))) {
1513 ViceLog(0, ("Failed to create new uuid: %d\n", code));
1517 /* A good sysid file exists; inform the vlserver. If any conflicts,
1518 * we always use the latest interface available as the real truth.
1520 #ifndef AFS_NT40_ENV
1521 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
1523 * Find addresses we are supposed to register as per the netrestrict
1524 * and netinfo files (/usr/afs/local/NetInfo and
1525 * /usr/afs/local/NetRestict)
1528 afs_int32 code = parseNetFiles(FS_HostAddrs, NULL, NULL,
1529 ADDRSPERSITE, reason,
1530 AFSDIR_SERVER_NETINFO_FILEPATH,
1531 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1533 ViceLog(0, ("Can't register any valid addresses: %s\n", reason));
1536 FS_HostAddr_cnt = (afs_uint32) code;
1540 FS_HostAddr_cnt = rx_getAllAddr(FS_HostAddrs, ADDRSPERSITE);
1544 code = Do_VLRegisterRPC();
1549 main(int argc, char *argv[])
1553 struct rx_securityClass *sc[4];
1554 struct rx_service *tservice;
1555 #ifdef AFS_PTHREAD_ENV
1556 pthread_t serverPid;
1557 pthread_attr_t tattr;
1558 #else /* AFS_PTHREAD_ENV */
1559 PROCESS parentPid, serverPid;
1560 #endif /* AFS_PTHREAD_ENV */
1562 int minVnodesRequired; /* min size of vnode cache */
1563 #ifndef AFS_NT40_ENV
1564 struct rlimit rlim; /* max number of open file descriptors */
1568 #ifdef AFS_AIX32_ENV
1569 struct sigaction nsa;
1571 sigemptyset(&nsa.sa_mask);
1572 nsa.sa_handler = SIG_DFL;
1573 nsa.sa_flags = SA_FULLDUMP;
1574 sigaction(SIGABRT, &nsa, NULL);
1575 sigaction(SIGSEGV, &nsa, NULL);
1578 /* Initialize dirpaths */
1579 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
1581 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
1583 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
1587 #ifndef AFS_QUIETFS_ENV
1588 console = afs_fopen("/dev/console", "w");
1591 if (ParseArgs(argc, argv)) {
1595 #ifdef AFS_PTHREAD_ENV
1596 assert(pthread_mutex_init(&fileproc_glock_mutex, NULL) == 0);
1597 #endif /* AFS_PTHREAD_ENV */
1599 #ifdef AFS_SGI_VNODE_GLUE
1600 if (afs_init_kernel_config(-1) < 0) {
1602 ("Can't determine NUMA configuration, not starting fileserver.\n");
1606 confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1608 fprintf(stderr, "Unable to open config directory %s\n",
1609 AFSDIR_SERVER_ETC_DIRPATH);
1615 /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
1616 #ifndef AFS_NT40_ENV
1617 serverLogSyslogTag = "fileserver";
1619 OpenLog(AFSDIR_SERVER_FILELOG_FILEPATH);
1622 if (SawSpare && SawPctSpare) {
1623 ViceLog(0, ("Both -spare and -pctspare specified, exiting.\n"));
1626 #ifdef AFS_SGI_XFS_IOPS_ENV
1627 ViceLog(0, ("XFS/EFS File server starting\n"));
1629 ViceLog(0, ("File server starting\n"));
1632 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1633 /* initialize the pthread soft signal handler thread */
1637 /* install signal handlers for controlling the fileserver process */
1638 ResetCheckSignal(); /* set CheckSignal_Signal() sig handler */
1639 ResetCheckDescriptors(); /* set CheckDescriptors_Signal() sig handler */
1641 #if defined(AFS_SGI_ENV)
1642 /* give this guy a non-degrading priority so help busy servers */
1643 schedctl(NDPRI, 0, NDPNORMMAX);
1647 #ifndef AFS_NT40_ENV
1648 nice(-5); /* TODO: */
1651 assert(DInit(buffs) == 0);
1654 if (afs_winsockInit() < 0) {
1655 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
1656 ViceLog(0, ("File server failed to intialize winsock.\n"));
1662 /* if we support more than 16 threads, then we better have the ability
1663 ** to keep open a large number of files simultaneously
1665 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV)
1666 curLimit = OPEN_MAX; /* for pre AIX 4.2 systems */
1667 #elif defined(AFS_NT40_ENV)
1668 curLimit = NT_OPEN_MAX; /* open file descriptor limit on NT */
1671 curLimit = 0; /* the number of open file descriptors */
1672 code = getrlimit(RLIMIT_NOFILE, &rlim);
1674 curLimit = rlim.rlim_cur;
1675 rlim.rlim_cur = rlim.rlim_max;
1676 code = setrlimit(RLIMIT_NOFILE, &rlim);
1678 curLimit = rlim.rlim_max;
1681 ViceLog(0, ("Failed to increase open file limit, using default\n"));
1683 #endif /* defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV) */
1685 curLimit -= 32; /* leave a slack of 32 file descriptors */
1686 if (lwps > curLimit) {
1690 lwps = 16; /* default to a maximum of 16 threads */
1692 ("The system supports a max of %d open files and we are starting %d threads\n",
1695 #ifndef AFS_PTHREAD_ENV
1696 assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) ==
1698 #endif /* !AFS_PTHREAD_ENV */
1700 /* Initialize volume support */
1702 V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
1705 /* initialize libacl routines */
1706 acl_Initialize(ACL_VERSION);
1708 /* initialize RX support */
1709 #ifndef AFS_NT40_ENV
1710 rxi_syscallp = viced_syscall;
1712 rx_extraPackets = rxpackets;
1713 rx_extraQuota = 4; /* for outgoing prserver calls from R threads */
1714 rx_SetBusyThreshold(busy_threshold, VBUSY);
1715 rx_SetCallAbortThreshold(abort_threshold);
1716 rx_SetConnAbortThreshold(abort_threshold);
1717 stackSize = lwps * 4000;
1718 if (stackSize < 32000)
1720 else if (stackSize > 44000)
1722 #if defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV)
1723 rx_SetStackSize(1, stackSize);
1726 rx_SetUdpBufSize(udpBufSize); /* set the UDP buffer size for receive */
1727 if (rx_Init((int)htons(7000)) < 0) {
1728 ViceLog(0, ("Cannot initialize RX\n"));
1731 if (!rxJumbograms) {
1732 /* Don't send and don't allow 3.4 clients to send jumbograms. */
1736 rx_SetRxDeadTime(30);
1737 sc[0] = rxnull_NewServerSecurityObject();
1738 sc[1] = 0; /* rxvab_NewServerSecurityObject(key1, 0) */
1739 sc[2] = rxkad_NewServerSecurityObject(rxkad_clear, NULL, get_key, NULL);
1740 sc[3] = rxkad_NewServerSecurityObject(rxkad_crypt, NULL, get_key, NULL);
1741 tservice = rx_NewService( /* port */ 0, /* service id */ 1, /*service name */
1743 /* security classes */ sc,
1744 /* numb sec classes */
1745 4, RXAFS_ExecuteRequest);
1748 ("Failed to initialize RX, probably two servers running.\n"));
1751 rx_SetDestroyConnProc(tservice, (void (*)())h_FreeConnection);
1752 rx_SetMinProcs(tservice, 3);
1753 rx_SetMaxProcs(tservice, lwps);
1754 rx_SetCheckReach(tservice, 1);
1757 rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 4,
1758 RXSTATS_ExecuteRequest);
1760 ViceLog(0, ("Failed to initialize rpc stat service.\n"));
1763 rx_SetMinProcs(tservice, 2);
1764 rx_SetMaxProcs(tservice, 4);
1767 * Enable RX hot threads, which allows the listener thread to trade
1768 * places with an idle thread and moves the context switch from listener
1769 * to worker out of the critical path.
1771 rx_EnableHotThread();
1773 /* Some rx debugging */
1774 if (rxlog || eventlog) {
1775 debugFile = afs_fopen("rx_dbg", "w");
1777 rx_debugFile = debugFile;
1779 rxevent_debugFile = debugFile;
1782 init_sys_error_to_et(); /* Set up error table translation */
1783 h_InitHostPackage(); /* set up local cellname and realmname */
1784 InitCallBack(numberofcbs);
1789 ViceLog(0, ("Fatal error in library initialization, exiting!!\n"));
1795 ViceLog(0, ("Fatal error in protection initialization, exiting!!\n"));
1799 /* allow super users to manage RX statistics */
1800 rx_SetRxStatUserOk(fs_rxstat_userok);
1802 rx_StartServer(0); /* now start handling requests */
1804 /* we ensure that there is enough space in the vnode buffer to satisfy
1805 ** requests from all concurrent threads.
1806 ** the maximum number of vnodes used by a single thread at any one time
1807 ** is three ( "link" uses three vnodes simultaneously, one vLarge and
1808 ** two vSmall for linking files and two vLarge and one vSmall for linking
1811 minVnodesRequired = 2 * lwps + 1;
1812 if (minVnodesRequired > nSmallVns) {
1813 nSmallVns = minVnodesRequired;
1815 ("Overriding -s command line parameter with %d\n",
1818 if (minVnodesRequired > large) {
1819 large = minVnodesRequired;
1820 ViceLog(0, ("Overriding -l command line parameter with %d\n", large));
1823 /* We now do this after getting the listener up and running, so that client
1824 * connections don't timeout (maybe) if a file server is restarted, since it
1825 * will be available "real soon now". Worry about whether we can satisfy the
1826 * calls in the volume package itself.
1828 if (VInitVolumePackage(fileServer, large, nSmallVns, 0, volcache)) {
1830 ("Shutting down: errors encountered initializing volume package\n"));
1836 * We are done calling fopen/fdopen. It is safe to use a large
1837 * of the file descriptor cache.
1841 #ifdef AFS_PTHREAD_ENV
1842 ViceLog(5, ("Starting pthreads\n"));
1843 assert(pthread_attr_init(&tattr) == 0);
1844 assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
1846 assert(pthread_create
1847 (&serverPid, &tattr, (void *)FiveMinuteCheckLWP,
1848 &fiveminutes) == 0);
1849 assert(pthread_create
1850 (&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
1851 assert(pthread_create
1852 (&serverPid, &tattr, (void *)FsyncCheckLWP, &fiveminutes) == 0);
1853 #else /* AFS_PTHREAD_ENV */
1854 ViceLog(5, ("Starting LWP\n"));
1855 assert(LWP_CreateProcess
1856 (FiveMinuteCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1857 (void *)&fiveminutes, "FiveMinuteChecks",
1858 &serverPid) == LWP_SUCCESS);
1860 assert(LWP_CreateProcess
1861 (HostCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1862 (void *)&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1863 assert(LWP_CreateProcess
1864 (FsyncCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1865 (void *)&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
1866 #endif /* AFS_PTHREAD_ENV */
1868 TM_GetTimeOfDay(&tp, 0);
1870 #ifndef AFS_QUIETFS_ENV
1871 if (console != NULL) {
1872 fprintf(console, "File server has started at %s\r",
1873 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer)));
1878 * Figure out the FileServer's name and primary address.
1880 ViceLog(0, ("Getting FileServer name...\n"));
1881 code = gethostname(FS_HostName, 64);
1883 ViceLog(0, ("gethostname() failed\n"));
1885 ViceLog(0, ("FileServer host name is '%s'\n", FS_HostName));
1887 ViceLog(0, ("Getting FileServer address...\n"));
1888 he = gethostbyname(FS_HostName);
1890 ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
1893 memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
1894 (void)afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
1895 FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
1897 ("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
1898 FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
1901 /* Install handler to catch the shutdown signal;
1902 * bosserver assumes SIGQUIT shutdown
1904 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1905 softsig_signal(SIGQUIT, ShutDown_Signal);
1907 (void)signal(SIGQUIT, ShutDown_Signal);
1911 ("File Server started %s",
1912 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer))));
1913 #if FS_STATS_DETAILED
1914 afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec;
1916 #ifdef AFS_PTHREAD_ENV
1918 sleep(1000); /* long time */
1920 #else /* AFS_PTHREAD_ENV */
1921 assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS);
1922 #endif /* AFS_PTHREAD_ENV */