separate-capabilities-by-source-20051217
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 18 Dec 2005 05:41:19 +0000 (05:41 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 18 Dec 2005 05:41:19 +0000 (05:41 +0000)
This patch separates the client and viced capabilties;
adds a viced capabilities for 64bit files;
and modifies the Windows client to probe the viced capabilities
the first time the client discovers the server and uses the capabilities
RPC instead of the GetTime RPC to probe for Up/Down status

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

define the capabilities constants

src/WINNT/afsd/afsd.h
src/WINNT/afsd/cm_callback.c
src/WINNT/afsd/cm_server.c
src/WINNT/afsd/cm_server.h
src/afs/afs.h
src/afs/afs_callback.c
src/fsint/common.xg
src/viced/afsfileprocs.c
src/viced/host.c
src/viced/viced_prototypes.h

index b30e885..18b1213 100644 (file)
@@ -127,9 +127,6 @@ extern long rx_mtu;
 
 extern HANDLE WaitToTerminate;
 
-#define CAPABILITY_ERRORTRANS (1<<0)
-#define CAPABILITY_BITS 1
-
 #undef  DFS_SUPPORT
 #define LOG_PACKET 1
 #undef  NOTSERVICE
index 90bc884..ca26be4 100644 (file)
@@ -1142,7 +1142,7 @@ SRXAFSCB_TellMeAboutYourself( struct rx_call *callp,
 
     dataBytes = 1 * sizeof(afs_int32);
     dataBuffP = (afs_int32 *) osi_Alloc(dataBytes);
-    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
     capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
     capabilities->Capabilities_val = dataBuffP;
 
index 99bca36..efed409 100644 (file)
@@ -29,6 +29,67 @@ osi_rwlock_t cm_serverLock;
 
 cm_server_t *cm_allServersp;
 
+void 
+cm_PingServer(cm_server_t *tsp)
+{
+    long code;
+    int wasDown = 0;
+    cm_conn_t *connp;
+    struct rx_connection * callp;
+    long secs;
+    long usecs;
+    Capabilities caps = {0, 0};
+
+    code = cm_ConnByServer(tsp, cm_rootUserp, &connp);
+    if (code == 0) {
+       /* now call the appropriate ping call.  Drop the timeout if
+       * the server is known to be down, so that we don't waste a
+       * lot of time retiming out down servers.
+       */
+        wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
+       if (wasDown)
+           rx_SetConnDeadTime(connp->callp, 10);
+       if (tsp->type == CM_SERVER_VLDB) {
+           code = VL_ProbeServer(connp->callp);
+       }
+       else {
+           /* file server */
+           callp = cm_GetRxConn(connp);
+           code = RXAFS_GetCapabilities(callp, &caps);
+           if (code == RXGEN_OPCODE)
+               code = RXAFS_GetTime(callp, &secs, &usecs);
+           rx_PutConnection(callp);
+       }
+       if (wasDown)
+           rx_SetConnDeadTime(connp->callp, ConnDeadtimeout);
+       cm_PutConn(connp);
+    }  /* got an unauthenticated connection to this server */
+
+    lock_ObtainMutex(&tsp->mx);
+    if (code >= 0) {
+       /* mark server as up */
+       tsp->flags &= ~CM_SERVERFLAG_DOWN;
+
+       /* we currently handle 32-bits of capabilities */
+       if (caps.Capabilities_len > 0) {
+           tsp->capabilities = caps.Capabilities_val[0];
+           free(caps.Capabilities_val);
+           caps.Capabilities_len = 0;
+           caps.Capabilities_val = 0;
+       } else {
+           tsp->capabilities = 0;
+       }
+    }
+    else {
+       /* mark server as down */
+       tsp->flags |= CM_SERVERFLAG_DOWN;
+       if (code != VRESTARTING)
+           cm_ForceNewConnections(tsp);
+    }
+    lock_ReleaseMutex(&tsp->mx);
+}
+
+
 void cm_CheckServers(long flags, cm_cell_t *cellp)
 {
     /* ping all file servers, up or down, with unauthenticated connection,
@@ -36,14 +97,8 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
      * Also, ping down VLDBs.
      */
     cm_server_t *tsp;
-    long code;
-    long secs;
-    long usecs;
     int doPing;
-    int serverType;
-    int wasDown;
-    cm_conn_t *connp;
-    struct rx_connection * callp;
+    int isDown;
 
     lock_ObtainWrite(&cm_serverLock);
     for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
@@ -53,18 +108,16 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
         /* now process the server */
         lock_ObtainMutex(&tsp->mx);
 
-        serverType = tsp->type;
         doPing = 0;
-        wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
+        isDown = tsp->flags & CM_SERVERFLAG_DOWN;
 
         /* only do the ping if the cell matches the requested cell, or we're
          * matching all cells (cellp == NULL), and if we've requested to ping
          * this type of {up, down} servers.
          */
         if ((cellp == NULL || cellp == tsp->cellp) &&
-             ((wasDown && (flags & CM_FLAG_CHECKDOWNSERVERS)) ||
-               (!wasDown && (flags & CM_FLAG_CHECKUPSERVERS)))) {
-
+             ((isDown && (flags & CM_FLAG_CHECKDOWNSERVERS)) ||
+               (!isDown && (flags & CM_FLAG_CHECKUPSERVERS)))) {
             doPing = 1;
         }      /* we're supposed to check this up/down server */
         lock_ReleaseMutex(&tsp->mx);
@@ -72,42 +125,8 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
         /* at this point, we've adjusted the server state, so do the ping and
          * adjust things.
          */
-        if (doPing) {
-            code = cm_ConnByServer(tsp, cm_rootUserp, &connp);
-            if (code == 0) {
-                /* now call the appropriate ping call.  Drop the timeout if
-                 * the server is known to be down, so that we don't waste a
-                 * lot of time retiming out down servers.
-                 */
-                if (wasDown)
-                    rx_SetConnDeadTime(connp->callp, 10);
-                if (serverType == CM_SERVER_VLDB) {
-                    code = VL_ProbeServer(connp->callp);
-                }
-                else {
-                    /* file server */
-                    callp = cm_GetRxConn(connp);
-                    code = RXAFS_GetTime(callp, &secs, &usecs);
-                    rx_PutConnection(callp);
-                }
-                if (wasDown)
-                    rx_SetConnDeadTime(connp->callp, ConnDeadtimeout);
-                cm_PutConn(connp);
-            }  /* got an unauthenticated connection to this server */
-
-            lock_ObtainMutex(&tsp->mx);
-            if (code >= 0) {
-                /* mark server as up */
-                tsp->flags &= ~CM_SERVERFLAG_DOWN;
-            }
-            else {
-                /* mark server as down */
-                tsp->flags |= CM_SERVERFLAG_DOWN;
-               if (code != VRESTARTING)
-                   cm_ForceNewConnections(tsp);
-            }
-            lock_ReleaseMutex(&tsp->mx);
-        }
+        if (doPing) 
+           cm_PingServer(tsp);
 
         /* also, run the GC function for connections on all of the
          * server's connections.
@@ -228,11 +247,12 @@ cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cell
 
     cm_SetServerPrefs(tsp); 
 
-    lock_ObtainWrite(&cm_serverLock); /* get server lock */
+    lock_ObtainWrite(&cm_serverLock);  /* get server lock */
     tsp->allNextp = cm_allServersp;
     cm_allServersp = tsp;
-    lock_ReleaseWrite(&cm_serverLock); /* release server lock */
+    lock_ReleaseWrite(&cm_serverLock);         /* release server lock */
 
+    cm_PingServer(tsp);                        /* Obtain Capabilities and check up/down state */
     return tsp;
 }
 
index 922f260..2d2e201 100644 (file)
@@ -25,7 +25,8 @@ typedef struct cm_server {
     struct sockaddr_in addr;           /* by mx */
     int type;                          /* by mx */
     struct cm_conn *connsp;            /* locked by cm_connLock */
-    long flags;                                /* by mx */
+    afs_int32 flags;                   /* by mx */
+    afs_int32 capabilities;            /* by mx */
     struct cm_cell *cellp;             /* cell containing this server */
     unsigned long refCount;            /* locked by cm_serverLock */
     osi_mutex_t mx;
index b26144b..ac140f7 100644 (file)
@@ -1216,9 +1216,4 @@ struct afs_fakestat_state {
 
 extern int afs_fakestat_enable;
 
-/* First 32 bits of capabilities */
-#define CAPABILITY_ERRORTRANS (1<<0)
-
-#define CAPABILITY_BITS 1
-
 #endif /* _AFS_H_ */
index 2deab40..40c4e09 100644 (file)
@@ -1534,7 +1534,7 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
 
     dataBytes = 1 * sizeof(afs_int32);
     dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
-    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
     capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
     capabilities->Capabilities_val = dataBuffP;
 
index db69338..d113408 100644 (file)
@@ -175,4 +175,11 @@ typedef afs_uint32 cacheConfig<>;
 const AFSCAPABILITIESMAX = 196;
 typedef afs_int32 Capabilities<AFSCAPABILITIESMAX>;
 
+/* Viced Capability Flags */
+const VICED_CAPABILITY_ERRORTRANS      = 0x0001;
+const VICED_CAPABILITY_64BITFILES      = 0x0002;
+
+/* Cache Manager Capability Flags */
+const CLIENT_CAPABILITY_ERRORTRANS     = 0x0001;
+
 %#endif /* FSINT_COMMON_XG */
index f33719f..9836960 100644 (file)
@@ -6044,7 +6044,11 @@ SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
 
     dataBytes = 1 * sizeof(afs_int32);
     dataBuffP = (afs_int32 *) malloc(dataBytes);
-    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS;
+#if defined(AFS_64BIT_ENV) && defined(AFS_LARGEFILE_ENV)
+    dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
+#endif
+
     capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
     capabilities->Capabilities_val = dataBuffP;
 
index 6b7eb80..c74517a 100644 (file)
@@ -1133,7 +1133,7 @@ h_GetHost_r(struct rx_connection *tcon)
            host->hostFlags |= VENUSDOWN;
        }
        if (caps.Capabilities_val
-           && (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS))
+           && (caps.Capabilities_val[0] & CLIENT_CAPABILITY_ERRORTRANS))
            host->hostFlags |= HERRORTRANS;
        else
            host->hostFlags &= ~(HERRORTRANS);
@@ -1331,7 +1331,7 @@ h_GetHost_r(struct rx_connection *tcon)
 
        }
        if (caps.Capabilities_val
-           && (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS))
+           && (caps.Capabilities_val[0] & CLIENT_CAPABILITY_ERRORTRANS))
            host->hostFlags |= HERRORTRANS;
        else
            host->hostFlags &= ~(HERRORTRANS);
index 17795b3..df11f8a 100644 (file)
@@ -2,7 +2,3 @@ extern int sendBufSize;
 afs_int32 sys_error_to_et(afs_int32 in);
 void init_sys_error_to_et(void);
 
-/* First 32 bits of capabilities */
-#define CAPABILITY_ERRORTRANS (1<<0)
-
-#define CAPABILITY_BITS 1