#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <sys/stat.h>
#include <fcntl.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
#ifdef AFS_NT40_ENV
#include <io.h>
#include <windows.h>
int eventlog = 0, rxlog = 0;
FILE *debugFile;
-FILE *console = NULL;
#ifdef AFS_PTHREAD_ENV
pthread_mutex_t fsync_glock_mutex;
#endif /* AFS_PTHREAD_ENV */
#ifdef AFS_NT40_ENV
-#define AFS_QUIETFS_ENV 1
#define NT_OPEN_MAX 1024 /* This is an arbitrary no. we came up with for
* now. We hope this will be replaced by a more
* intelligent estimate later. */
int udpBufSize = 0; /* UDP buffer size for receive */
int sendBufSize = 16384; /* send buffer size */
int saneacls = 0; /* Sane ACLs Flag */
+static int unsafe_attach = 0; /* avoid inUse check on vol attach? */
struct timeval tp;
#define PTHREAD_RWLOCK_INITIALIZER {0x2DA8B3B4, {0}}
#endif
+#ifndef AFS_NT40_ENV
struct fs_state fs_state =
{ FS_MODE_NORMAL,
0,
PTHREAD_COND_INITIALIZER,
PTHREAD_RWLOCK_INITIALIZER
};
+#else /* AFS_NT40_ENV */
+struct fs_state fs_state;
+
+static int fs_stateInit(void)
+{
+ fs_state.mode = FS_MODE_NORMAL;
+ fs_state.FiveMinuteLWP_tranquil = 0;
+ fs_state.HostCheckLWP_tranquil = 0;
+ fs_state.FsyncCheckLWP_tranquil = 0;
+ fs_state.salvsync_fatal_error = 0;
+
+ fs_state.options.fs_state_save = 1;
+ fs_state.options.fs_state_restore = 1;
+ fs_state.options.fs_state_verify_before_save = 1;
+ fs_state.options.fs_state_verify_after_restore = 1;
+
+ assert(pthread_cond_init(&fs_state.worker_done_cv, NULL) == 0);
+ assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0);
+}
+#endif /* AFS_NT40_ENV */
#endif /* AFS_DEMAND_ATTACH_FS */
/*
pthread_setspecific(rx_thread_id_key, (void *)(intptr_t)rxi_pthread_hinum);
MUTEX_EXIT(&rx_stats_mutex);
ViceLog(0,
- ("Set thread id %d for '%s'\n",
+ ("Set thread id %p for '%s'\n",
pthread_getspecific(rx_thread_id_key), s));
#endif
}
#endif
if (printBanner && (++msg & 1)) { /* Every 10 minutes */
time_t now = FT_ApproxTime();
- if (console != NULL) {
-#ifndef AFS_QUIETFS_ENV
- fprintf(console, "File server is running at %s\r",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
-#endif /* AFS_QUIETFS_ENV */
- ViceLog(2,
- ("File server is running at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
- }
+ ViceLog(2,
+ ("File server is running at %s\n",
+ afs_ctime(&now, tbuffer, sizeof(tbuffer))));
}
#ifdef AFS_DEMAND_ATTACH_FS
FS_STATE_WRLOCK;
#ifdef AFS_DEMAND_ATTACH_FS
FS_STATE_WRLOCK;
+ if (fs_state.mode == FS_MODE_SHUTDOWN) {
+ /* it is possible for at least fs_stateSave() (called below) to call
+ * ShutDownAndCore if there's host list corruption; prevent
+ * deinitializing some stuff twice */
+ ViceLog(0, ("ShutDownAndCore called during shutdown? Skipping volume "
+ "and host package shutdown\n"));
+ FS_STATE_UNLOCK;
+ goto done_vol_host;
+ }
fs_state.mode = FS_MODE_SHUTDOWN;
FS_STATE_UNLOCK;
#endif
afs_ctime(&now, tbuffer, sizeof(tbuffer))));
if (dopanic)
ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
-#ifndef AFS_QUIETFS_ENV
- if (console != NULL) {
- fprintf(console, "File server restart/shutdown received at %s\r",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
- }
-#endif
DFlush();
if (!dopanic)
PrintCounters();
FS_UNLOCK;
FS_STATE_RDLOCK;
}
+ FS_STATE_UNLOCK;
/* ok. it should now be fairly safe. let's do the state dump */
fs_stateSave();
}
}
+ done_vol_host:
+
#endif /* AFS_DEMAND_ATTACH_FS */
if (debugFile) {
rx_PrintStats(debugFile);
fflush(debugFile);
}
- if (console != NULL) {
- now = time(0);
- if (dopanic) {
-#ifndef AFS_QUIETFS_ENV
- fprintf(console, "File server has terminated abnormally at %s\r",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
-#endif
- ViceLog(0,
- ("File server has terminated abnormally at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
- } else {
-#ifndef AFS_QUIETFS_ENV
- fprintf(console, "File server has terminated normally at %s\r",
- afs_ctime(&now, tbuffer, sizeof(tbuffer)));
-#endif
- ViceLog(0,
- ("File server has terminated normally at %s\n",
- afs_ctime(&now, tbuffer, sizeof(tbuffer))));
- }
+ now = time(0);
+ if (dopanic) {
+ ViceLog(0,
+ ("File server has terminated abnormally at %s\n",
+ afs_ctime(&now, tbuffer, sizeof(tbuffer))));
+ } else {
+ ViceLog(0,
+ ("File server has terminated normally at %s\n",
+ afs_ctime(&now, tbuffer, sizeof(tbuffer))));
}
if (dopanic)
fputs("[-vlruthresh <minutes before unused volumes become eligible for soft detach> (default is 2 hours)] ", stdout);
fputs("[-vlruinterval <seconds between VLRU scans> (default is 2 minutes)] ", stdout);
fputs("[-vlrumax <max volumes to soft detach in one VLRU scan> (default is 8)] ", stdout);
+ fputs("[-unsafe-nosalvage (bypass volume inUse safety check on attach, bypassing salvage)] ", stdout);
#elif AFS_PTHREAD_ENV
fputs("[-vattachpar <number of volume attach threads> (default is 1)] ", stdout);
#endif
return -1;
}
VLRU_SetOptions(VLRU_SET_MAX, atoi(argv[++i]));
+ } else if (!strcmp(argv[i], "-unsafe-nosalvage")) {
+ unsafe_attach = 1;
#endif /* AFS_DEMAND_ATTACH_FS */
} else if (!strcmp(argv[i], "-s")) {
Sawsmall = 1;
ViceLog(0, ("Read on parms failed with errno = %d\n", errno));
} else {
ViceLog(0,
- ("Read on parms failed; expected %d bytes but read %d\n",
- sbuf.st_size, i));
+ ("Read on parms failed; expected %ld bytes but read %d\n",
+ (long) sbuf.st_size, i));
}
free(parms);
return;
afs_int32
vl_Initialize(const char *confDir)
{
- afs_int32 code, scIndex = 0, i;
+ afs_int32 code, i;
+ afs_int32 scIndex = RX_SECIDX_NULL;
struct afsconf_dir *tdir;
struct rx_securityClass *sc;
struct afsconf_cell info;
argv[0]);
exit(2);
}
-#ifndef AFS_QUIETFS_ENV
- console = afs_fopen("/dev/console", "w");
-#endif
/* set ihandle package defaults prior to parsing args */
ih_PkgDefaults();
ViceLog(0, ("Both -spare and -pctspare specified, exiting.\n"));
exit(-1);
}
-#ifdef AFS_SGI_XFS_IOPS_ENV
- ViceLog(0, ("XFS/EFS File server starting\n"));
-#else
- ViceLog(0, ("File server starting\n"));
-#endif
+ LogCommandLine(argc, argv, "starting", "", "File server", FSLog);
#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
/* initialize the pthread soft signal handler thread */
opts.nLargeVnodes = large;
opts.nSmallVnodes = nSmallVns;
opts.volcache = volcache;
+ opts.unsafe_attach = unsafe_attach;
if (VInitVolumePackage2(fileServer, &opts)) {
ViceLog(0,
FT_GetTimeOfDay(&tp, 0);
-#ifndef AFS_QUIETFS_ENV
- if (console != NULL) {
- time_t t = tp.tv_sec;
- fprintf(console, "File server has started at %s\r",
- afs_ctime(&t, tbuffer, sizeof(tbuffer)));
- }
-#endif
+ ViceLog(0, ("File server has started at %s",
+ afs_ctime((time_t *)&(tp.tv_sec), tbuffer, sizeof(tbuffer))));
/*
* Figure out the FileServer's name and primary address.