Remove -settime/RXAFS_GetTime client support
authorAndrew Deason <adeason@sinenomine.net>
Wed, 2 Nov 2011 15:43:54 +0000 (10:43 -0500)
committerDerrick Brashear <shadow@dementix.org>
Thu, 3 Nov 2011 20:13:35 +0000 (13:13 -0700)
Remove the -settime option from afsd, and any code for making
RXAFS_GetTime calls in libafs. Server probes have been replaced by
calls to RXAFS_GetCapabilities, and the actual functionality of
synchronizing the system clock has been superseded by other systems
like NTP. Issue a warning for all code paths that try to enable
-settime support.

Historical note: the code that this commit is removing contains bugs.
Do not simply revert this commit to turn on -settime support again.

Change-Id: Id291f5f88b1ad84594706f2a1a02a933dddd0cb9
Reviewed-on: http://gerrit.openafs.org/5787
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/afs/afs_call.c
src/afs/afs_init.c
src/afs/afs_prototypes.h
src/afs/afs_server.c
src/afsd/afsd.c

index cf00d87..cdb034e 100644 (file)
@@ -58,7 +58,6 @@ krwlock_t afsifinfo_lock;
 
 afs_int32 afs_initState = 0;
 afs_int32 afs_termState = 0;
-afs_int32 afs_setTime = 0;
 int afs_cold_shutdown = 0;
 char afs_SynchronousCloses = '\0';
 static int afs_CB_Running = 0;
@@ -981,7 +980,10 @@ afs_syscall_call(long parm, long parm2, long parm3,
        }
        afs_CacheInit_Done = 1;
         code = afs_icl_InitLogs();
-       afs_setTime = cparms.setTimeFlag;
+       if (cparms.setTimeFlag) {
+           afs_warn("afs: AFSOP_CACHEINIT setTimeFlag ignored; are you "
+                    "running an old afsd?\n");
+       }
 
        code =
            afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles,
@@ -1064,7 +1066,11 @@ afs_syscall_call(long parm, long parm2, long parm3,
        while (afs_initState < AFSOP_GO)
            afs_osi_Sleep(&afs_initState);
        afs_initState = 101;
-       afs_setTime = parm2;
+       if (parm2) {
+           /* parm2 used to set afs_setTime */
+           afs_warn("afs: AFSOP_GO setTime flag ignored; are you running an "
+                    "old afsd?\n");
+       }
        if (afs_tpct1 + afs_tpct2 != 100) {
            afs_tpct1 = 0;
            afs_tpct2 = 0;
@@ -1478,7 +1484,7 @@ void
 shutdown_afstest(void)
 {
     AFS_STATCNT(shutdown_afstest);
-    afs_initState = afs_termState = afs_setTime = 0;
+    afs_initState = afs_termState = 0;
     AFS_Running = afs_CB_Running = 0;
     afs_CacheInit_Done = afs_Go_Done = 0;
     if (afs_cold_shutdown) {
index 2352262..12f3852 100644 (file)
@@ -188,7 +188,7 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
     cm_initParams.cmi_firstChunkSize = AFS_FIRSTCSIZE;
     cm_initParams.cmi_otherChunkSize = AFS_OTHERCSIZE;
     cm_initParams.cmi_cacheSize = afs_cacheBlocks;
-    cm_initParams.cmi_setTime = afs_setTime;
+    cm_initParams.cmi_setTime = 0;
     cm_initParams.cmi_memCache = (aflags & AFSCALL_INIT_MEMCACHE) ? 1 : 0;
 
     return 0;
@@ -854,7 +854,6 @@ shutdown_AFS(void)
        afs_sysname = 0;
        afs_sysnamecount = 0;
        afs_marinerHost = 0;
-       afs_setTimeHost = NULL;
        afs_volCounter = 1;
        afs_waitForever = afs_waitForeverCount = 0;
        afs_FVIndex = -1;
index 4135ebb..708ba80 100644 (file)
@@ -30,7 +30,6 @@ extern void shutdown_bufferpackage(void);
 
 /* afs_call.c */
 extern int afs_cold_shutdown;
-extern afs_int32 afs_setTime;
 extern char afs_rootVolumeName[64];
 extern void afs_shutdown(void);
 extern void afs_FlushCBs(void);
@@ -856,7 +855,6 @@ extern afs_rwlock_t afs_icl_lock;
 extern struct srvAddr *afs_srvAddrs[NSERVERS];
 extern struct server *afs_servers[NSERVERS];
 extern int afs_totalServers;
-extern struct server *afs_setTimeHost;
 extern struct server *afs_FindServer(afs_int32 aserver, afs_uint16 aport,
                                     afsUUID * uuidp, afs_int32 locktype);
 extern struct server *afs_GetServer(afs_uint32 * aserver, afs_int32 nservers,
index 1406ff1..3515164 100644 (file)
@@ -70,7 +70,6 @@
 
 /* Exported variables */
 afs_rwlock_t afs_xserver;      /* allocation lock for servers */
-struct server *afs_setTimeHost = 0;    /* last host we used for time */
 struct server *afs_servers[NSERVERS];  /* Hashed by server`s uuid & 1st ip */
 afs_rwlock_t afs_xsrvAddr;     /* allocation lock for srvAddrs */
 struct srvAddr *afs_srvAddrs[NSERVERS];        /* Hashed by server's ip */
@@ -155,11 +154,6 @@ afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown)
         * All ips are down we treat the whole server down
         */
        a_serverP->flags |= SRVR_ISDOWN;
-       /*
-        * If this was our time server, search for another time server
-        */
-       if (a_serverP == afs_setTimeHost)
-           afs_setTimeHost = 0;
     } else {
        sa->sa_flags &= ~SRVADDR_ISDOWN;
        /* If any ips are up, the server is also marked up */
@@ -558,138 +552,6 @@ CkSrv_MarkUpDown(struct afs_conn **conns, int nconns, afs_int32 *results)
 }
 
 void
-CkSrv_SetTime(struct rx_connection **rxconns, int nconns, int nservers,
-             struct afs_conn **conns, struct srvAddr **addrs)
-{
-    struct afs_conn *tc;
-    afs_int32 start, end = 0, delta;
-    osi_timeval_t tv;
-    struct srvAddr *sa;
-    afs_int32 *conntimer, *results, *deltas;
-    afs_int32 i = 0;
-    char tbuffer[CVBS];
-
-    conntimer = afs_osi_Alloc(nservers * sizeof (afs_int32));
-    osi_Assert(conntimer != NULL);
-    results = afs_osi_Alloc(nservers * sizeof (afs_int32));
-    osi_Assert(results != NULL);
-    deltas = afs_osi_Alloc(nservers * sizeof (afs_int32));
-    osi_Assert(deltas != NULL);
-
-    /* make sure we're starting from zero */
-    memset(&deltas, 0, sizeof(deltas));
-
-    start = osi_Time();         /* time the gettimeofday call */
-    AFS_GUNLOCK();
-    if ( afs_setTimeHost == NULL ) {
-       multi_Rx(rxconns,nconns)
-       {
-           tv.tv_sec = tv.tv_usec = 0;
-           multi_RXAFS_GetTime(
-               (afs_uint32 *)&tv.tv_sec, (afs_uint32 *)&tv.tv_usec);
-           tc = conns[multi_i];
-           sa = tc->parent->srvr;
-           if (conntimer[multi_i] == 1)
-               rx_SetConnDeadTime(rxconns[multi_i], afs_rx_deadtime);
-           end = osi_Time();
-           results[multi_i]=multi_error;
-           if ((start == end) && !multi_error)
-               deltas[multi_i] = end - tv.tv_sec;
-       } multi_End;
-    } else {                   /* find and query setTimeHost only */
-       for ( i = 0 ; i < nservers ; i++ ) {
-           if ( conns[i] == NULL || conns[i]->parent->srvr == NULL )
-               continue;
-           if ( conns[i]->parent->srvr->server == afs_setTimeHost ) {
-               tv.tv_sec = tv.tv_usec = 0;
-               results[i] = RXAFS_GetTime(rxconns[i],
-                                          (afs_uint32 *)&tv.tv_sec,
-                                          (afs_uint32 *)&tv.tv_usec);
-               end = osi_Time();
-               if ((start == end) && !results[i])
-                   deltas[i] = end - tv.tv_sec;
-               break;
-           }
-       }
-    }
-    AFS_GLOCK();
-
-    if ( afs_setTimeHost == NULL )
-       CkSrv_MarkUpDown(conns, nconns, results);
-    else /* We lack info for other than this host */
-       CkSrv_MarkUpDown(&conns[i], 1, &results[i]);
-
-    /*
-     * If we're supposed to set the time, and the call worked
-     * quickly (same second response) and this is the host we
-     * use for the time and the time is really different, then
-     * really set the time
-     */
-    if (afs_setTime != 0) {
-       for (i=0; i<nconns; i++) {
-           delta = deltas[i];
-           tc = conns[i];
-           sa = tc->parent->srvr;
-
-           if ((tc->parent->srvr->server == afs_setTimeHost ||
-                /* Sync only to a server in the local cell */
-                (afs_setTimeHost == (struct server *)0 &&
-                 afs_IsPrimaryCell(sa->server->cell)))) {
-               /* set the time */
-               char msgbuf[90];  /* strlen("afs: setting clock...") + slop */
-               delta = end - tv.tv_sec;   /* how many secs fast we are */
-
-               afs_setTimeHost = tc->parent->srvr->server;
-               /* see if clock has changed enough to make it worthwhile */
-               if (delta >= AFS_MINCHANGE || delta <= -AFS_MINCHANGE) {
-                   end = osi_Time();
-                   if (delta > AFS_MAXCHANGEBACK) {
-                       /* setting clock too far back, just do it a little */
-                       tv.tv_sec = end - AFS_MAXCHANGEBACK;
-                   } else {
-                       tv.tv_sec = end - delta;
-                   }
-                   afs_osi_SetTime(&tv);
-                   if (delta > 0) {
-                       strcpy(msgbuf, "afs: setting clock back ");
-                       if (delta > AFS_MAXCHANGEBACK) {
-                           afs_strcat(msgbuf,
-                                      afs_cv2string(&tbuffer[CVBS],
-                                                    AFS_MAXCHANGEBACK));
-                           afs_strcat(msgbuf, " seconds (of ");
-                           afs_strcat(msgbuf,
-                                      afs_cv2string(&tbuffer[CVBS],
-                                                    delta -
-                                                    AFS_MAXCHANGEBACK));
-                           afs_strcat(msgbuf, ", via ");
-                           print_internet_address(msgbuf, sa,
-                                                  "); clock is still fast.",
-                                                  0);
-                       } else {
-                           afs_strcat(msgbuf,
-                                      afs_cv2string(&tbuffer[CVBS], delta));
-                           afs_strcat(msgbuf, " seconds (via ");
-                           print_internet_address(msgbuf, sa, ").", 0);
-                       }
-                   } else {
-                       strcpy(msgbuf, "afs: setting clock ahead ");
-                       afs_strcat(msgbuf,
-                                  afs_cv2string(&tbuffer[CVBS], -delta));
-                       afs_strcat(msgbuf, " seconds (via ");
-                       print_internet_address(msgbuf, sa, ").", 0);
-                   }
-                    /* We're only going to set it once; why bother looping? */
-                   break;
-               }
-           }
-       }
-    }
-    afs_osi_Free(conntimer, nservers * sizeof(afs_int32));
-    afs_osi_Free(deltas, nservers * sizeof(afs_int32));
-    afs_osi_Free(results, nservers * sizeof(afs_int32));
-}
-
-void
 CkSrv_GetCaps(struct rx_connection **rxconns, int nconns, int nservers,
              struct afs_conn **conns, struct srvAddr **addrs)
 {
@@ -743,8 +605,7 @@ CkSrv_GetCaps(struct rx_connection **rxconns, int nconns, int nservers,
 void
 afs_CheckServers(int adown, struct cell *acellp)
 {
-    afs_LoopServers(adown?AFS_LS_DOWN:AFS_LS_UP, acellp, 1, CkSrv_GetCaps,
-                   afs_setTime?CkSrv_SetTime:NULL);
+    afs_LoopServers(adown?AFS_LS_DOWN:AFS_LS_UP, acellp, 1, CkSrv_GetCaps, NULL);
 }
 
 /* adown: AFS_LS_UP   - check only up
@@ -857,8 +718,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
        if (!tc)
            continue;
 
-       if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(sa->server)
-           || (tc->parent->srvr->server == afs_setTimeHost)) {
+       if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(sa->server)) {
            conns[nconns]=tc;
            rxconns[nconns]=rxconn;
            if (sa->sa_flags & SRVADDR_ISDOWN) {
index 0b89142..91d6006 100644 (file)
@@ -266,7 +266,6 @@ static int sawBiod = 0;
 static int sawCacheStatEntries = 0;
 char afsd_cacheMountDir[1024]; /*Mount directory for AFS */
 static char rootVolume[64] = "root.afs";       /*AFS root volume name */
-static afs_int32 cacheSetTime = 0;     /*Keep checking time to avoid drift? */
 #ifdef AFS_XBSD_ENV
 static int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC;        /*Create & truncate on open */
 #else
@@ -1717,7 +1716,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
     if (as->parms[8].items) {
        /* -nosettime */
-       cacheSetTime = 0;
+       /* noop */
     }
     if (as->parms[9].items) {
        /* -verbose */
@@ -1849,7 +1848,10 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
     if (as->parms[32].items) {
        /* -settime */
-       cacheSetTime = 1;
+       printf("afsd: -settime ignored\n");
+       printf("afsd: the OpenAFS client no longer sets the system time; "
+              "please use NTP or\n");
+       printf("afsd: another such system to synchronize client time\n");
     }
 
     /* set rx_extraPackets */
@@ -2239,7 +2241,7 @@ afsd_run(void)
     cparams.cacheDcaches = dCacheSize;
     cparams.cacheVolumes = vCacheSize;
     cparams.chunkSize = chunkSize;
-    cparams.setTimeFlag = cacheSetTime;
+    cparams.setTimeFlag = 0;
     cparams.memCacheFlag = cacheFlags;
     cparams.dynamic_vcaches = afsd_dynamic_vcaches;
        afsd_call_syscall(AFSOP_CACHEINIT, &cparams);
@@ -2459,8 +2461,8 @@ afsd_run(void)
      */
     if (afsd_debug)
        printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", rn,
-              cacheSetTime);
-       afsd_call_syscall(AFSOP_GO, cacheSetTime);
+              0);
+       afsd_call_syscall(AFSOP_GO, 0);
 
     /*
      * At this point, we have finished passing the kernel all the info