OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsd/cm_server.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 #ifndef OPENAFS_WINNT_AFSD_CM_SERVER_H
00011 #define OPENAFS_WINNT_AFSD_CM_SERVER_H 1
00012 
00013 #include <winsock2.h>
00014 #include <osi.h>
00015 
00016 /* this value is set to 1022 in order to  */
00017 #define NUM_SERVER_VOLS         (32 - sizeof(void *) / 4)
00018 typedef struct cm_server_vols {
00019     afs_uint32             ids[NUM_SERVER_VOLS];
00020     struct cm_server_vols *nextp;
00021 } cm_server_vols_t;
00022 
00023 /* pointed to by volumes and cells without holds; cm_serverLock is obtained
00024  * at the appropriate times to change the pointers to these servers.
00025  */
00026 typedef struct cm_server {
00027     struct cm_server *allNextp;         /* locked by cm_serverLock */
00028     struct sockaddr_in addr;            /* by mx */
00029     int type;                           /* by mx */
00030     struct cm_conn *connsp;             /* locked by cm_connLock */
00031     afs_int32 flags;                    /* by mx */
00032     afs_int32 waitCount;                /* by mx */
00033     afs_int32 capabilities;             /* by mx */
00034     struct cm_cell *cellp;              /* cell containing this server */
00035     afs_int32 refCount;                 /* Interlocked with cm_serverLock */
00036     osi_mutex_t mx;
00037     unsigned short ipRank;              /* network class rank */
00038     unsigned short adminRank;           /* set if admin sets a rank
00039                                          * (fs setserverpref or registry or dns)
00040                                          */
00041     unsigned short activeRank;          /* Computed rank combining ipRank, adminRank,
00042                                          * and performance data.
00043                                          */
00044     cm_server_vols_t *  vols;           /* by mx */
00045     time_t downTime;                    /* by mx */
00046     afsUUID uuid;                       /* by mx */
00047 } cm_server_t;
00048 
00049 enum repstate {srv_not_busy, srv_busy, srv_offline, srv_deleted};
00050 
00051 typedef struct cm_serverRef {
00052     struct cm_serverRef *next;      /* locked by cm_serverLock */
00053     struct cm_server *server;       /* locked by cm_serverLock */
00054     enum repstate status;           /* locked by cm_serverLock */
00055     afs_int32 refCount;             /* locked by cm_serverLock */
00056     afs_uint32 volID;               /* locked by cm_serverLock */
00057 } cm_serverRef_t;
00058 
00059 /* types */
00060 #define CM_SERVER_VLDB          1       /* a VLDB server */
00061 #define CM_SERVER_FILE          2       /* a file server */
00062 
00063 /* flags */
00064 #define CM_SERVERFLAG_DOWN      0x1     /* server is down */
00065 #define CM_SERVERFLAG_PREF_SET  0x2     /* server preference set by user */
00066 #define CM_SERVERFLAG_PINGING   0x4     /* a ping against this server in progress */
00067 #define CM_SERVERFLAG_NO64BIT   0x8     /* server has no support for
00068                                            64-bit operations. */
00069 #define CM_SERVERFLAG_NOINLINEBULK 0x10 /* server has no support for inline bulk */
00070 #define CM_SERVERFLAG_UUID      0x20    /* server uuid is known */
00071 
00072 /* flags for procedures */
00073 #define CM_FLAG_CHECKUPSERVERS          1       /* check working servers */
00074 #define CM_FLAG_CHECKDOWNSERVERS        2       /* check down servers */
00075 #define CM_FLAG_CHECKVLDBSERVERS        4       /* check only vldb servers */
00076 #define CM_FLAG_CHECKFILESERVERS        8       /* check only file servers */
00077 
00078 /* values for ipRank */
00079 #define CM_IPRANK_TOP   5000    /* on same machine */
00080 #define CM_IPRANK_HI    20000   /* on same subnet  */
00081 #define CM_IPRANK_MED   30000   /* on same network */
00082 #define CM_IPRANK_LOW   40000   /* on different networks */
00083 #define CM_IPRANK_DOWN  65535   /* unavailable */
00084 
00085 /* the maximum number of network interfaces that this client has */
00086 
00087 #define CM_MAXINTERFACE_ADDR          16
00088 
00089 extern cm_server_t *cm_NewServer(struct sockaddr_in *addrp, int type,
00090         struct cm_cell *cellp, afsUUID *uuidp, afs_uint32 flags);
00091 
00092 extern cm_serverRef_t *cm_NewServerRef(struct cm_server *serverp, afs_uint32 volID);
00093 
00094 extern void cm_GetServerRef(cm_serverRef_t *tsrp, int locked);
00095 
00096 extern afs_int32 cm_PutServerRef(cm_serverRef_t *tsrp, int locked);
00097 
00098 extern LONG_PTR cm_ChecksumServerList(cm_serverRef_t *serversp);
00099 
00100 extern void cm_GetServer(cm_server_t *);
00101 
00102 extern void cm_GetServerNoLock(cm_server_t *);
00103 
00104 extern void cm_PutServer(cm_server_t *);
00105 
00106 extern void cm_PutServerNoLock(cm_server_t *);
00107 
00108 extern cm_server_t *cm_FindServer(struct sockaddr_in *addrp, int type, int locked);
00109 
00110 extern osi_rwlock_t cm_serverLock;
00111 
00112 extern osi_rwlock_t cm_syscfgLock;
00113 
00114 extern void cm_InitServer(void);
00115 
00116 extern void cm_CheckServers(afs_uint32 flags, struct cm_cell *cellp);
00117 
00118 extern cm_server_t *cm_allServersp;
00119 
00120 extern afs_int32 cm_RankServer(cm_server_t * server);
00121 
00122 extern void cm_RankUpServers();
00123 
00124 extern void cm_SetServerIPRank(cm_server_t * serverp);
00125 
00126 extern void cm_InsertServerList(cm_serverRef_t** list,cm_serverRef_t* element);
00127 
00128 extern long cm_ChangeRankServer(cm_serverRef_t** list, cm_server_t* server);
00129 
00130 extern void cm_RandomizeServer(cm_serverRef_t** list);
00131 
00132 extern void cm_FreeServer(cm_server_t* server);
00133 
00134 extern afs_uint32 cm_ServerListSize(cm_serverRef_t* list);
00135 
00136 #define CM_FREESERVERLIST_DELETE 1
00137 
00138 extern void cm_FreeServerList(cm_serverRef_t** list, afs_uint32 flags);
00139 
00140 extern void cm_ForceNewConnectionsAllServers(void);
00141 
00142 extern void cm_SetServerNo64Bit(cm_server_t * serverp, int no64bit);
00143 
00144 extern void cm_SetServerNoInlineBulk(cm_server_t * serverp, int no);
00145 
00146 extern cm_server_t * cm_FindServerByIP(afs_uint32 addr, unsigned short port, int type, int locked);
00147 
00148 extern cm_server_t * cm_FindServerByUuid(afsUUID* uuid, int type, int locked);
00149 
00150 extern void cm_SetLanAdapterChangeDetected(void);
00151 
00152 extern void cm_RemoveVolumeFromServer(cm_server_t * serverp, afs_uint32 volID);
00153 
00154 extern int cm_DumpServers(FILE *outputFile, char *cookie, int lock);
00155 
00156 extern int cm_ServerEqual(cm_server_t *srv1, cm_server_t *srv2);
00157 
00158 extern int cm_IsServerListEmpty(cm_serverRef_t *serversp);
00159 
00160 extern void cm_ServerClearRPCStats(void);
00161 
00162 /* Protected by cm_syscfgLock (rw) */
00163 extern int cm_noIPAddr;         /* number of client network interfaces */
00164 extern int cm_IPAddr[CM_MAXINTERFACE_ADDR];    /* client's IP address in host order */
00165 extern int cm_SubnetMask[CM_MAXINTERFACE_ADDR];/* client's subnet mask in host order*/
00166 extern int cm_NetMtu[CM_MAXINTERFACE_ADDR];    /* client's MTU sizes */
00167 extern int cm_NetFlags[CM_MAXINTERFACE_ADDR];  /* network flags */
00168 extern int cm_LanAdapterChangeDetected;
00169 
00170 /* Protected by cm_serverLock */
00171 extern cm_server_t *cm_allServersp;
00172 extern afs_uint32   cm_numFileServers;
00173 extern afs_uint32   cm_numVldbServers;
00174 #endif /*  OPENAFS_WINNT_AFSD_CM_SERVER_H */
 All Data Structures Files Functions Variables