#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;
#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;
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();
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.