From 376a5dd834ab6813fc955a2b535eb4ab4aea3c0d Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 18 Dec 2005 05:41:19 +0000 Subject: [PATCH] separate-capabilities-by-source-20051217 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 | 3 - src/WINNT/afsd/cm_callback.c | 2 +- src/WINNT/afsd/cm_server.c | 120 ++++++++++++++++++++--------------- src/WINNT/afsd/cm_server.h | 3 +- src/afs/afs.h | 5 -- src/afs/afs_callback.c | 2 +- src/fsint/common.xg | 7 ++ src/viced/afsfileprocs.c | 6 +- src/viced/host.c | 4 +- src/viced/viced_prototypes.h | 4 -- 10 files changed, 88 insertions(+), 68 deletions(-) diff --git a/src/WINNT/afsd/afsd.h b/src/WINNT/afsd/afsd.h index b30e88542..18b121307 100644 --- a/src/WINNT/afsd/afsd.h +++ b/src/WINNT/afsd/afsd.h @@ -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 diff --git a/src/WINNT/afsd/cm_callback.c b/src/WINNT/afsd/cm_callback.c index 90bc8848e..ca26be418 100644 --- a/src/WINNT/afsd/cm_callback.c +++ b/src/WINNT/afsd/cm_callback.c @@ -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; diff --git a/src/WINNT/afsd/cm_server.c b/src/WINNT/afsd/cm_server.c index 99bca3620..efed40930 100644 --- a/src/WINNT/afsd/cm_server.c +++ b/src/WINNT/afsd/cm_server.c @@ -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; } diff --git a/src/WINNT/afsd/cm_server.h b/src/WINNT/afsd/cm_server.h index 922f26013..2d2e20122 100644 --- a/src/WINNT/afsd/cm_server.h +++ b/src/WINNT/afsd/cm_server.h @@ -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; diff --git a/src/afs/afs.h b/src/afs/afs.h index b26144b9a..ac140f7b0 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -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_ */ diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 2deab402a..40c4e094e 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -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; diff --git a/src/fsint/common.xg b/src/fsint/common.xg index db693382b..d11340809 100644 --- a/src/fsint/common.xg +++ b/src/fsint/common.xg @@ -175,4 +175,11 @@ typedef afs_uint32 cacheConfig<>; const AFSCAPABILITIESMAX = 196; typedef afs_int32 Capabilities; +/* 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 */ diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index f33719f40..98369607c 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -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; diff --git a/src/viced/host.c b/src/viced/host.c index 6b7eb8092..c74517a38 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -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); diff --git a/src/viced/viced_prototypes.h b/src/viced/viced_prototypes.h index 17795b312..df11f8aa5 100644 --- a/src/viced/viced_prototypes.h +++ b/src/viced/viced_prototypes.h @@ -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 -- 2.39.5