#endif
#endif
assert(DInit(buffs) == 0);
+#ifdef AFS_DEMAND_ATTACH_FS
+ FS_STATE_INIT;
+#endif
#ifdef AFS_NT40_ENV
if (afs_winsockInit() < 0) {
exit(1);
}
+ /* Install handler to catch the shutdown signal;
+ * bosserver assumes SIGQUIT shutdown
+ */
+#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
+ softsig_signal(SIGQUIT, ShutDown_Signal);
+#else
+ (void)signal(SIGQUIT, ShutDown_Signal);
+#endif
+
+ if (VInitAttachVolumes(fileServer)) {
+ ViceLog(0,
+ ("Shutting down: errors encountered initializing volume package\n"));
+ VShutdown();
+ exit(1);
+ }
+
#ifdef AFS_DEMAND_ATTACH_FS
if (fs_state.options.fs_state_restore) {
/*
#ifdef AFS_PTHREAD_ENV
ViceLog(5, ("Starting pthreads\n"));
-#ifdef AFS_DEMAND_ATTACH_FS
- FS_STATE_INIT;
-#endif
assert(pthread_attr_init(&tattr) == 0);
assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
}
- /* Install handler to catch the shutdown signal;
- * bosserver assumes SIGQUIT shutdown
- */
-#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
- softsig_signal(SIGQUIT, ShutDown_Signal);
-#else
- (void)signal(SIGQUIT, ShutDown_Signal);
-#endif
-
t = tp.tv_sec;
ViceLog(0,
("File Server started %s",
pthread_mutex_t vol_trans_mutex;
pthread_cond_t vol_put_volume_cond;
pthread_cond_t vol_sleep_cond;
+pthread_cond_t vol_init_attach_cond;
int vol_attach_threads = 1;
#endif /* AFS_PTHREAD_ENV */
* 3 - initialized, all volumes have been attached, and
* VConnectFS() has completed. */
+static int vinit_attach_abort = 0;
bit32 VolumeCacheCheck; /* Incremented everytime a volume goes on line--
* used to stamp volume headers and in-core
assert(pthread_mutex_init(&vol_trans_mutex, NULL) == 0);
assert(pthread_cond_init(&vol_put_volume_cond, NULL) == 0);
assert(pthread_cond_init(&vol_sleep_cond, NULL) == 0);
+ assert(pthread_cond_init(&vol_init_attach_cond, NULL) == 0);
#else /* AFS_PTHREAD_ENV */
IOMGR_Initialize();
#endif /* AFS_PTHREAD_ENV */
if (errors)
return -1;
- if (programType == fileServer) {
+ if (programType != fileServer) {
+ errors = VInitAttachVolumes(programType);
+ if (errors) {
+ return -1;
+ }
+ }
+
+#ifdef FSSYNC_BUILD_CLIENT
+ if (programType == volumeUtility && connect) {
+ if (!VConnectFS()) {
+ Log("Unable to connect to file server; will retry at need\n");
+ /*exit(1);*/
+ }
+ }
+#ifdef AFS_DEMAND_ATTACH_FS
+ else if (programType == salvageServer) {
+ if (!VConnectFS()) {
+ Log("Unable to connect to file server; aborted\n");
+ exit(1);
+ }
+ }
+#endif /* AFS_DEMAND_ATTACH_FS */
+#endif /* FSSYNC_BUILD_CLIENT */
+ return 0;
+}
+
+int
+VInitAttachVolumes(ProgramType pt)
+{
+ assert(VInit==1);
+ if (pt == fileServer) {
struct DiskPartition64 *diskP;
#ifdef AFS_PTHREAD_ENV
struct vinitvolumepackage_thread_t params;
VOL_LOCK;
for (i=0; i < threads; i++) {
+ AFS_SIGSET_DECL;
+ AFS_SIGSET_CLEAR();
assert(pthread_create
(&tid, &attrs, &VInitVolumePackageThread,
¶ms) == 0);
+ AFS_SIGSET_RESTORE();
}
while(params.n_threads_complete < threads) {
}
#endif /* AFS_PTHREAD_ENV */
}
-
+ VOL_LOCK;
VInit = 2; /* Initialized, and all volumes have been attached */
-#ifdef FSSYNC_BUILD_CLIENT
- if (programType == volumeUtility && connect) {
- if (!VConnectFS()) {
- Log("Unable to connect to file server; will retry at need\n");
- /*exit(1);*/
- }
- }
-#ifdef AFS_DEMAND_ATTACH_FS
- else if (programType == salvageServer) {
- if (!VConnectFS()) {
- Log("Unable to connect to file server; aborted\n");
- exit(1);
- }
- }
-#endif /* AFS_DEMAND_ATTACH_FS */
-#endif /* FSSYNC_BUILD_CLIENT */
+#ifdef AFS_PTHREAD_ENV
+ assert(pthread_cond_broadcast(&vol_init_attach_cond) == 0);
+#else
+ LWP_NoYieldSignal(VInitAttachVolumes);
+#endif /* AFS_PTHREAD_ENV */
+ VOL_UNLOCK;
return 0;
}
while (queue_IsNotEmpty(params)) {
int nAttached = 0, nUnattached = 0;
+ if (vinit_attach_abort) {
+ Log("Aborting initialization\n");
+ goto done;
+ }
+
dpq = queue_First(params,diskpartition_queue_t);
queue_Remove(dpq);
VOL_UNLOCK;
VOL_LOCK;
}
+done:
params->n_threads_complete++;
pthread_cond_signal(¶ms->thread_done_cv);
VOL_UNLOCK;
while ((dp = readdir(dirp))) {
char *p;
p = strrchr(dp->d_name, '.');
+
+ if (vinit_attach_abort) {
+ Log("Partition %s: abort attach volumes\n", diskP->name);
+ goto done;
+ }
+
if (p != NULL && strcmp(p, VHDREXT) == 0) {
Error error;
Volume *vp;
}
Log("Partition %s: attached %d volumes; %d volumes not attached\n", diskP->name, *nAttached, *nUnattached);
+done:
closedir(dirp);
return ret;
}
memset(¶ms, 0, sizeof(vshutdown_thread_t));
+ if (VInit < 2) {
+ Log("VShutdown: aborting attach volumes\n");
+ vinit_attach_abort = 1;
+ VOL_CV_WAIT(&vol_init_attach_cond);
+ }
+
for (params.n_parts=0, diskP = DiskPartitionList;
diskP; diskP = diskP->next, params.n_parts++);
int i;
register Volume *vp, *np;
register afs_int32 code;
+
+ if (VInit < 2) {
+ Log("VShutdown: aborting attach volumes\n");
+ vinit_attach_abort = 1;
+#ifdef AFS_PTHREAD_ENV
+ VOL_CV_WAIT(&vol_init_attach_cond);
+#else
+ LWP_WaitProcess(VInitAttachVolumes);
+#endif /* AFS_PTHREAD_ENV */
+ }
+
Log("VShutdown: shutting down on-line volumes...\n");
for (i = 0; i < VolumeHashTable.Size; i++) {
/* try to hold first volume in the hash table */
void
VShutdown(void)
{
+ assert(VInit>0);
VOL_LOCK;
VShutdown_r();
VOL_UNLOCK;