DAFS: Avoid SALVSYNC communication during shutdown
[openafs.git] / src / viced / viced.c
index 720d9d1..e166657 100644 (file)
@@ -68,6 +68,7 @@
 #include <afs/acl.h>
 #include <afs/prs_fs.h>
 #include <rx/rx.h>
+#include <rx/rxstat.h>
 #include <afs/keys.h>
 #include <afs/afs_args.h>
 #include <afs/vlserver.h>
@@ -91,7 +92,6 @@
 #include "sys/lock.h"
 #endif
 #include <rx/rx_globals.h>
-#include <rx/rxstat_prototypes.h>
 
 #ifdef O_LARGEFILE
 #define afs_stat       stat64
@@ -115,9 +115,6 @@ static void ResetCheckDescriptors(void);
 static void ResetCheckSignal(void);
 static void *CheckSignal(void *);
 
-extern int RXAFS_ExecuteRequest(struct rx_call *);
-extern int RXSTATS_ExecuteRequest(struct rx_call *);
-
 static afs_int32 Do_VLRegisterRPC(void);
 
 int eventlog = 0, rxlog = 0;
@@ -260,7 +257,8 @@ CheckDescriptors(void *unused)
     for (i = 0; i < tsize; i++) {
        if (afs_fstat(i, &status) != -1) {
            printf("%d: dev %x, inode %u, length %u, type/mode %x\n", i,
-                  status.st_dev, status.st_ino, 
+                  (unsigned int) status.st_dev,
+                  (unsigned int) status.st_ino,
                   (unsigned int) status.st_size,
                   status.st_mode);
        }
@@ -355,7 +353,7 @@ ResetCheckDescriptors(void)
 int
 threadNum(void)
 {
-    return (int)pthread_getspecific(rx_thread_id_key);
+    return (intptr_t)pthread_getspecific(rx_thread_id_key);
 }
 #endif
 
@@ -385,9 +383,9 @@ int
 viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
 {
     afs_uint32 rcode;
+#ifndef AFS_LINUX20_ENV
     void (*old) (int);
 
-#ifndef AFS_LINUX20_ENV
     old = (void (*)(int))signal(SIGSYS, SIG_IGN);
 #endif
     rcode = syscall(AFS_SYSCALL, 28 /* AFSCALL_CALL */ , a3, a4, a5);
@@ -433,7 +431,7 @@ setThreadId(char *s)
     /* set our 'thread-id' so that the host hold table works */
     MUTEX_ENTER(&rx_stats_mutex);      /* protects rxi_pthread_hinum */
     ++rxi_pthread_hinum;
-    pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum);
+    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",
@@ -664,9 +662,9 @@ ClearXStatValues(void)
     /*
      * Zero all xstat-related structures.
      */
-    memset((char *)(&afs_perfstats), 0, sizeof(struct afs_PerfStats));
+    memset((&afs_perfstats), 0, sizeof(struct afs_PerfStats));
 #if FS_STATS_DETAILED
-    memset((char *)(&afs_FullPerfStats), 0,
+    memset((&afs_FullPerfStats), 0,
           sizeof(struct fs_stats_FullPerfStats));
 
     /*
@@ -784,6 +782,8 @@ ShutDownAndCore(int dopanic)
      * are returned with an error code of RX_RESTARTING ( transient failure ) */
     rx_SetRxTranquil();                /* dhruba */
 
+    VSetTranquil();
+
 #ifdef AFS_DEMAND_ATTACH_FS
     FS_STATE_WRLOCK;
     fs_state.mode = FS_MODE_SHUTDOWN;
@@ -1296,7 +1296,7 @@ ParseArgs(int argc, char *argv[])
            rxMaxMTU = atoi(argv[++i]);
            if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || 
                (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
-               printf("rxMaxMTU %d%% invalid; must be between %d-%lu\n",
+               printf("rxMaxMTU %d%% invalid; must be between %d-%" AFS_SIZET_FMT "\n",
                       rxMaxMTU, RX_MIN_PACKET_SIZE, 
                       RX_MAX_PACKET_DATA_SIZE);
                return -1;
@@ -1785,6 +1785,7 @@ Do_VLRegisterRPC(void)
            ViceLog(0,
                    ("VL_RegisterAddrs rpc failed; will retry periodically (code=%d, err=%d)\n",
                     code, errno));
+           FS_registered = 1;  /* Retry in the gc daemon */
        }
     } else {
        FS_registered = 2;      /* So we don't have to retry in the gc daemon */
@@ -2124,13 +2125,13 @@ main(int argc, char *argv[])
     ClearXStatValues();
 
     code = InitVL();
-    if (code) {
+    if (code && code != VL_MULTIPADDR) {
        ViceLog(0, ("Fatal error in library initialization, exiting!!\n"));
        exit(1);
     }
 
     code = InitPR();
-    if (code) {
+    if (code && code != -1) {
        ViceLog(0, ("Fatal error in protection initialization, exiting!!\n"));
        exit(1);
     }