* the callback RPC interface.
*/
-#include "../afs/param.h" /*Should be always first*/
-#include "../afs/sysincludes.h" /*Standard vendor system headers*/
-#include "../afs/afsincludes.h" /*AFS-based standard headers*/
-#include "../afs/afs_stats.h" /*Cache Manager stats*/
-#include "../afs/afs_args.h"
-
-extern struct volume *afs_volumes[NVOLS]; /* volume hash table */
-extern void afs_DequeueCallback();
-extern void afs_ComputePAGStats();
+#include <afsconfig.h>
+#include "afs/param.h"
+
+RCSID("$Header$");
+
+#include "afs/sysincludes.h" /*Standard vendor system headers*/
+#include "afsincludes.h" /*AFS-based standard headers*/
+#include "afs/afs_stats.h" /*Cache Manager stats*/
+#include "afs/afs_args.h"
+
afs_int32 afs_allCBs = 0; /*Break callbacks on all objects */
afs_int32 afs_oddCBs = 0; /*Break callbacks on dirs*/
afs_int32 afs_evenCBs = 0; /*Break callbacks received on files*/
afs_int32 afs_oddZaps = 0; /*Dir cache entries deleted*/
afs_int32 afs_evenZaps = 0; /*File cache entries deleted*/
afs_int32 afs_connectBacks = 0;
-extern struct rx_service *afs_server;
-
-extern afs_lock_t afs_xvcb, afs_xbrs, afs_xdcache;
-extern afs_rwlock_t afs_xvcache, afs_xserver, afs_xcell, afs_xuser;
-extern afs_rwlock_t afs_xvolume, afs_puttofileLock, afs_ftf, afs_xinterface;
-extern afs_rwlock_t afs_xconn;
-extern struct afs_lock afs_xaxs;
-extern afs_lock_t afs_xcbhash;
-extern struct srvAddr *afs_srvAddrs[NSERVERS];
-extern struct afs_q CellLRU;
-extern struct cm_initparams cm_initParams;
/*
* Some debugging aids.
char *name;
char *addr;
} ltable []= {
- "afs_xvcache", (char *)&afs_xvcache,
- "afs_xdcache", (char *)&afs_xdcache,
- "afs_xserver", (char *)&afs_xserver,
- "afs_xvcb", (char *)&afs_xvcb,
- "afs_xbrs", (char *)&afs_xbrs,
- "afs_xcell", (char *)&afs_xcell,
- "afs_xconn", (char *)&afs_xconn,
- "afs_xuser", (char *)&afs_xuser,
- "afs_xvolume", (char *)&afs_xvolume,
- "puttofile", (char *)&afs_puttofileLock,
- "afs_ftf", (char *)&afs_ftf,
- "afs_xcbhash", (char *)&afs_xcbhash,
- "afs_xaxs", (char *)&afs_xaxs,
- "afs_xinterface", (char *)&afs_xinterface,
+ {"afs_xvcache", (char *)&afs_xvcache},
+ {"afs_xdcache", (char *)&afs_xdcache},
+ {"afs_xserver", (char *)&afs_xserver},
+ {"afs_xvcb", (char *)&afs_xvcb},
+ {"afs_xbrs", (char *)&afs_xbrs},
+ {"afs_xcell", (char *)&afs_xcell},
+ {"afs_xconn", (char *)&afs_xconn},
+ {"afs_xuser", (char *)&afs_xuser},
+ {"afs_xvolume", (char *)&afs_xvolume},
+ {"puttofile", (char *)&afs_puttofileLock},
+ {"afs_ftf", (char *)&afs_ftf},
+ {"afs_xcbhash", (char *)&afs_xcbhash},
+ {"afs_xaxs", (char *)&afs_xaxs},
+ {"afs_xinterface", (char *)&afs_xinterface},
+ {"afs_xosi", (char *)&afs_xosi},
+ {"afs_xsrvAddr",(char *)&afs_xsrvAddr}
};
unsigned long lastCallBack_vnode;
unsigned int lastCallBack_dv;
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetCE(a_call, a_index, a_result)
- struct rx_call *a_call;
- afs_int32 a_index;
- struct AFSDBCacheEntry *a_result;
-
-{ /*SRXAFSCB_GetCE*/
+int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry *a_result)
+{
register int i; /*Loop variable*/
register struct vcache *tvc; /*Ptr to current cache entry*/
int code; /*Return code*/
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETCE);
} /*Zip through hash chains*/
searchDone:
- if (tvc == (struct vcache *) 0) {
+ if (tvc == NULL) {
/*Past EOF*/
code = 1;
goto fcnDone;
a_result->lock.pid_writer = 0;
a_result->lock.src_indicator = 0;
#endif /* AFS_OSF20_ENV */
+#ifdef AFS_64BIT_CLIENT
+ a_result->Length = (afs_int32) tvc->m.Length & 0xffffffff;
+#else /* AFS_64BIT_CLIENT */
a_result->Length = tvc->m.Length;
+#endif /* AFS_64BIT_CLIENT */
a_result->DataVersion = hgetlo(tvc->m.DataVersion);
a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */
a_result->cbExpires = tvc->cbExpires;
- a_result->refCount = tvc->vrefCount;
+ a_result->refCount = VREFCOUNT(tvc);
a_result->opens = tvc->opens;
a_result->writers = tvc->execsOrWriters;
a_result->mvstat = tvc->mvstat;
fcnDone:
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(code);
} /*SRXAFSCB_GetCE*/
+int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry64 *a_result)
+{
+ register int i; /*Loop variable*/
+ register struct vcache *tvc; /*Ptr to current cache entry*/
+ int code; /*Return code*/
+ XSTATS_DECLS;
+
+ RX_AFS_GLOCK();
+
+ XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETCE);
+
+ AFS_STATCNT(SRXAFSCB_GetCE64);
+ for (i = 0; i < VCSIZE; i++) {
+ for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+ if (a_index == 0)
+ goto searchDone;
+ a_index--;
+ } /*Zip through current hash chain*/
+ } /*Zip through hash chains*/
+
+ searchDone:
+ if (tvc == NULL) {
+ /*Past EOF*/
+ code = 1;
+ goto fcnDone;
+ }
+
+ /*
+ * Copy out the located entry.
+ */
+ a_result->addr = afs_data_pointer_to_int32(tvc);
+ a_result->cell = tvc->fid.Cell;
+ a_result->netFid.Volume = tvc->fid.Fid.Volume;
+ a_result->netFid.Vnode = tvc->fid.Fid.Vnode;
+ a_result->netFid.Unique = tvc->fid.Fid.Unique;
+ a_result->lock.waitStates = tvc->lock.wait_states;
+ a_result->lock.exclLocked = tvc->lock.excl_locked;
+ a_result->lock.readersReading = tvc->lock.readers_reading;
+ a_result->lock.numWaiting = tvc->lock.num_waiting;
+#if defined(INSTRUMENT_LOCKS)
+ a_result->lock.pid_last_reader = tvc->lock.pid_last_reader;
+ a_result->lock.pid_writer = tvc->lock.pid_writer;
+ a_result->lock.src_indicator = tvc->lock.src_indicator;
+#else
+ /* On osf20 , the vcache does not maintain these three fields */
+ a_result->lock.pid_last_reader = 0;
+ a_result->lock.pid_writer = 0;
+ a_result->lock.src_indicator = 0;
+#endif /* AFS_OSF20_ENV */
+#ifdef AFS_64BIT_ENV
+ a_result->Length = tvc->m.Length;
+#else /* AFS_64BIT_ENV */
+#ifdef AFS_64BIT_CLIENT
+ a_result->Length = tvc->m.Length;
+#else /* AFS_64BIT_CLIENT */
+ a_result->Length.high = 0;
+ a_result->Length.low = tvc->m.Length;
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFS_64BIT_ENV */
+ a_result->DataVersion = hgetlo(tvc->m.DataVersion);
+ a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */
+ a_result->cbExpires = tvc->cbExpires;
+ a_result->refCount = VREFCOUNT(tvc);
+ a_result->opens = tvc->opens;
+ a_result->writers = tvc->execsOrWriters;
+ a_result->mvstat = tvc->mvstat;
+ a_result->states = tvc->states;
+ code = 0;
+
+ /*
+ * Return our results.
+ */
+fcnDone:
+ XSTATS_END_TIME;
+
+ RX_AFS_GUNLOCK();
+
+ return(code);
+
+} /*SRXAFSCB_GetCE64*/
+
/*------------------------------------------------------------------------
* EXPORTED SRXAFSCB_GetLock
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetLock (a_call, a_index, a_result)
- struct rx_call *a_call;
- afs_int32 a_index;
- struct AFSDBLock *a_result;
-
-{ /*SRXAFSCB_GetLock*/
-
+int SRXAFSCB_GetLock (struct rx_call *a_call, afs_int32 a_index, struct AFSDBLock *a_result)
+{
struct ltable *tl; /*Ptr to lock table entry*/
int nentries; /*Num entries in table*/
int code; /*Return code*/
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETLOCK);
a_result->lock.exclLocked = ((struct afs_lock *)(tl->addr))->excl_locked;
a_result->lock.readersReading = ((struct afs_lock *)(tl->addr))->readers_reading;
a_result->lock.numWaiting = ((struct afs_lock *)(tl->addr))->num_waiting;
+#ifdef INSTRUMENT_LOCKS
a_result->lock.pid_last_reader = ((struct afs_lock *)(tl->addr))->pid_last_reader;
a_result->lock.pid_writer = ((struct afs_lock *)(tl->addr))->pid_writer;
a_result->lock.src_indicator = ((struct afs_lock *)(tl->addr))->src_indicator;
+#else
+ a_result->lock.pid_last_reader = 0;
+ a_result->lock.pid_writer = 0;
+ a_result->lock.src_indicator = 0;
+#endif
code = 0;
}
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(code);
*
* Side Effects:
* As advertised.
- *------------------------------------------------------------------------*/
-static ClearCallBack(a_conn, a_fid)
- register struct rx_connection *a_conn;
- register struct AFSFid *a_fid;
+Appears to need to be called with GLOCK held, as the icl_Event4 stuff asserts otherwise
-{ /*ClearCallBack*/
+ *------------------------------------------------------------------------*/
+static int ClearCallBack(register struct rx_connection *a_conn, register struct AFSFid *a_fid)
+{
register struct vcache *tvc;
register int i;
struct VenusFid localFid;
AFS_STATCNT(ClearCallBack);
+ AFS_ASSERT_GLOCK();
+
/*
* XXXX Don't hold any server locks here because of callback protocol XXX
*/
for (i = 0; i < VCSIZE; i++)
for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
if (tvc->fid.Fid.Volume == a_fid->Volume) {
- tvc->callback = (struct server *)0;
+ tvc->callback = NULL;
tvc->quick.stamp = 0;
if (!localFid.Cell)
localFid.Cell = tvc->fid.Cell;
if (tvc->fid.Fid.Vnode == a_fid->Vnode
&& tvc->fid.Fid.Volume == a_fid->Volume
&& tvc->fid.Fid.Unique == a_fid->Unique ) {
- tvc->callback = (struct server *)0;
+ tvc->callback = NULL;
tvc->quick.stamp = 0;
tvc->h1.dchint = NULL; /* invalidate hints */
ObtainWriteLock(&afs_xcbhash, 450);
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_CallBack(a_call, a_fids, a_callbacks)
- struct rx_call *a_call;
- register struct AFSCBFids *a_fids;
- struct AFSCBs *a_callbacks;
-
-{ /*SRXAFSCB_CallBack*/
-
+int SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, struct AFSCBs *a_callbacks)
+{
register int i; /*Loop variable*/
struct AFSFid *tfid; /*Ptr to current fid*/
register struct rx_connection *tconn; /*Call's connection*/
int code=0;
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_CALLBACK);
AFS_STATCNT(SRXAFSCB_CallBack);
- if (!(tconn = rx_ConnectionOf(a_call))) return;
+ if (!(tconn = rx_ConnectionOf(a_call))) return(0);
tfid = (struct AFSFid *) a_fids->AFSCBFids_val;
/*
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(0);
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_Probe(a_call)
- struct rx_call *a_call;
-
-{ /*SRXAFSCB_Probe*/
+int SRXAFSCB_Probe(struct rx_call *a_call)
+{
int code = 0;
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_Probe);
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_PROBE);
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(0);
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_InitCallBackState(a_call)
- struct rx_call *a_call;
-
-{ /*SRXAFSCB_InitCallBackState*/
-
+int SRXAFSCB_InitCallBackState(struct rx_call *a_call)
+{
register int i;
register struct vcache *tvc;
register struct rx_connection *tconn;
register struct rx_peer *peer;
struct server *ts;
int code = 0;
- extern int osi_dnlc_purge();
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_INITCALLBACKSTATE);
AFS_STATCNT(SRXAFSCB_InitCallBackState);
if (tvc->callback == ts) {
ObtainWriteLock(&afs_xcbhash, 451);
afs_DequeueCallback(tvc);
- tvc->callback = (struct server *)0;
+ tvc->callback = NULL;
tvc->states &= ~(CStatd | CUnique | CBulkFetching);
ReleaseWriteLock(&afs_xcbhash);
}
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(0);
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_XStatsVersion(a_call, a_versionP)
- struct rx_call *a_call;
- afs_int32 *a_versionP;
-
-{ /*SRXAFSCB_XStatsVersion*/
+int SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 *a_versionP)
+{
int code=0;
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_XSTATSVERSION);
*a_versionP = AFSCB_XSTAT_VERSION;
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(0);
} /*SRXAFSCB_XStatsVersion*/
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVersionNumP, a_timeP, a_dataP)
- struct rx_call *a_call;
- afs_int32 a_clientVersionNum;
- afs_int32 a_collectionNumber;
- afs_int32 *a_srvVersionNumP;
- afs_int32 *a_timeP;
- AFSCB_CollData *a_dataP;
-
-{ /*SRXAFSCB_GetXStats*/
-
+int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
+ afs_int32 a_collectionNumber, afs_int32 *a_srvVersionNumP,
+ afs_int32 *a_timeP, AFSCB_CollData *a_dataP)
+{
register int code; /*Return value*/
afs_int32 *dataBuffP; /*Ptr to data to be returned*/
afs_int32 dataBytes; /*Bytes in data buffer*/
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETXSTATS);
* no data.
*/
a_dataP->AFSCB_CollData_len = 0;
- a_dataP->AFSCB_CollData_val = (afs_int32 *)0;
+ a_dataP->AFSCB_CollData_val = NULL;
#else
switch(a_collectionNumber) {
case AFSCB_XSTATSCOLL_CALL_INFO:
*/
dataBytes = sizeof(struct afs_CMStats);
dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
- bcopy((char *)&afs_cmstats, (char *)dataBuffP, dataBytes);
+ memcpy((char *)dataBuffP, (char *)&afs_cmstats, dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes>>2;
a_dataP->AFSCB_CollData_val = dataBuffP;
break;
afs_CountServers();
dataBytes = sizeof(afs_stats_cmperf);
dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
- bcopy((char *)&afs_stats_cmperf, (char *)dataBuffP, dataBytes);
+ memcpy((char *)dataBuffP, (char *)&afs_stats_cmperf, dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes>>2;
a_dataP->AFSCB_CollData_val = dataBuffP;
break;
*/
afs_stats_cmperf.numPerfCalls++;
afs_CountServers();
- bcopy((char *)(&afs_stats_cmperf),
- (char *)(&(afs_stats_cmfullperf.perf)),
- sizeof(struct afs_stats_CMPerf));
+ memcpy((char *)(&(afs_stats_cmfullperf.perf)), (char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf));
afs_stats_cmfullperf.numFullPerfCalls++;
dataBytes = sizeof(afs_stats_cmfullperf);
dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
- bcopy((char *)(&afs_stats_cmfullperf), (char *)dataBuffP, dataBytes);
+ memcpy((char *)dataBuffP, (char *)(&afs_stats_cmfullperf), dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes>>2;
a_dataP->AFSCB_CollData_val = dataBuffP;
break;
* Illegal collection number.
*/
a_dataP->AFSCB_CollData_len = 0;
- a_dataP->AFSCB_CollData_val = (afs_int32 *)0;
+ a_dataP->AFSCB_CollData_val = NULL;
code = 1;
} /*Switch on collection number*/
#endif /* AFS_NOSTATS */
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return(code);
* As advertised.
*------------------------------------------------------------------------*/
-int afs_RXCallBackServer()
-
-{ /*afs_RXCallBackServer*/
+int afs_RXCallBackServer(void)
+{
AFS_STATCNT(afs_RXCallBackServer);
while (1) {
* As advertised.
*------------------------------------------------------------------------*/
-int shutdown_CB()
-
-{ /*shutdown_CB*/
-
- extern int afs_cold_shutdown;
-
+int shutdown_CB(void)
+{
AFS_STATCNT(shutdown_CB);
if (afs_cold_shutdown) {
* None
*------------------------------------------------------------------------*/
-int SRXAFSCB_InitCallBackState2(a_call, addr)
-struct rx_call *a_call;
-struct interfaceAddr * addr;
+int SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *addr)
{
return RXGEN_OPCODE;
}
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_WhoAreYou(a_call, addr)
-struct rx_call *a_call;
-struct interfaceAddr *addr;
+int SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr)
{
int i;
int code = 0;
- XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_WhoAreYou);
ReleaseReadLock(&afs_xinterface);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return code;
}
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_InitCallBackState3(a_call, a_uuid)
-struct rx_call *a_call;
-afsUUID *a_uuid;
+int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid)
{
int code;
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_ProbeUuid(a_call, a_uuid)
-struct rx_call *a_call;
-afsUUID *a_uuid;
+int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid)
{
int code = 0;
XSTATS_DECLS;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_Probe);
XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_PROBE);
code = 1; /* failure */
XSTATS_END_TIME;
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return code;
}
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetServerPrefs(
- struct rx_call *a_call,
- afs_int32 a_index,
- afs_int32 *a_srvr_addr,
- afs_int32 *a_srvr_rank)
+int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index,
+ afs_int32 *a_srvr_addr, afs_int32 *a_srvr_rank)
{
int i, j;
struct srvAddr *sa;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_GetServerPrefs);
ObtainReadLock(&afs_xserver);
ReleaseReadLock(&afs_xserver);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return 0;
}
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetCellServDB(
- struct rx_call *a_call,
- afs_int32 a_index,
- char **a_name,
- afs_int32 *a_hosts)
+int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
+ char **a_name, serverList *a_hosts)
{
- afs_int32 i, j;
+ afs_int32 i, j = 0;
struct cell *tcell;
- struct afs_q *cq, *tq;
- char *t_name;
+ char *t_name, *p_name = NULL;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_GetCellServDB);
- t_name = (char *)rxi_Alloc(AFSNAMEMAX);
+ tcell = afs_GetCellByIndex(a_index, READ_LOCK);
+
+ if (!tcell) {
+ i = 0;
+ a_hosts->serverList_val = 0;
+ a_hosts->serverList_len = 0;
+ } else {
+ p_name = tcell->cellName;
+ for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+ ;
+ i = strlen(p_name);
+ a_hosts->serverList_val = (afs_int32 *)afs_osi_Alloc(j*sizeof(afs_int32));
+ a_hosts->serverList_len = j;
+ for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+ a_hosts->serverList_val[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
+ afs_PutCell(tcell, READ_LOCK);
+ }
+
+ t_name = (char *)afs_osi_Alloc(i+1);
if (t_name == NULL) {
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ afs_osi_Free(a_hosts->serverList_val, (j*sizeof(afs_int32)));
+ RX_AFS_GUNLOCK();
return ENOMEM;
}
- t_name[0] = '\0';
- bzero(a_hosts, AFSMAXCELLHOSTS * sizeof(afs_int32));
-
- /* search the list for the cell with this index */
- ObtainReadLock(&afs_xcell);
- for (i=0, cq = CellLRU.next; cq != &CellLRU && i<= a_index; cq = tq, i++) {
- tq = QNext(cq);
- if (i == a_index) {
- tcell = QTOC(cq);
- strcpy(t_name, tcell->cellName);
- for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) {
- a_hosts[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
- }
- }
- }
- ReleaseReadLock(&afs_xcell);
+ t_name[i] = '\0';
+ if (p_name)
+ memcpy(t_name, p_name, i);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
*a_name = t_name;
return 0;
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetLocalCell(
- struct rx_call *a_call,
- char **a_name)
+int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
{
+ int plen;
struct cell *tcell;
- struct afs_q *cq, *tq;
- char *t_name;
+ char *t_name, *p_name = NULL;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_GetLocalCell);
- t_name = (char *)rxi_Alloc(AFSNAMEMAX);
- if (t_name == NULL) {
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
- return ENOMEM;
- }
-
- t_name[0] = '\0';
-
/* Search the list for the primary cell. Cell number 1 is only
* the primary cell is when no other cell is explicitly marked as
* the primary cell. */
- ObtainReadLock(&afs_xcell);
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tq = QNext(cq);
- tcell = QTOC(cq);
- if (tcell->states & CPrimary) {
- strcpy(t_name, tcell->cellName);
- break;
- }
- if (tcell->cell == 1) {
- strcpy(t_name, tcell->cellName);
- }
+ tcell = afs_GetPrimaryCell(READ_LOCK);
+ if (tcell)
+ p_name = tcell->cellName;
+ if (p_name)
+ plen = strlen(p_name);
+ else
+ plen = 0;
+ t_name = (char *)afs_osi_Alloc(plen+1);
+ if (t_name == NULL) {
+ if (tcell) afs_PutCell(tcell, READ_LOCK);
+ RX_AFS_GUNLOCK();
+ return ENOMEM;
}
- ReleaseReadLock(&afs_xcell);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ t_name[plen] = '\0';
+ if (p_name)
+ memcpy(t_name, p_name, plen);
+
+ RX_AFS_GUNLOCK();
*a_name = t_name;
+ if (tcell) afs_PutCell(tcell, READ_LOCK);
return 0;
}
*
* Returns void.
*/
-static void afs_MarshallCacheConfig(
- afs_uint32 callerVersion,
- cm_initparams_v1 *config,
- afs_uint32 *ptr)
+static void afs_MarshallCacheConfig(afs_uint32 callerVersion,
+ cm_initparams_v1 *config, afs_uint32 *ptr)
{
AFS_STATCNT(afs_MarshallCacheConfig);
/*
*(ptr++) = config->cacheSize;
*(ptr++) = config->setTime;
*(ptr++) = config->memCache;
-
}
* As advertised.
*------------------------------------------------------------------------*/
-int SRXAFSCB_GetCacheConfig(
- struct rx_call *a_call,
- afs_uint32 callerVersion,
- afs_uint32 *serverVersion,
- afs_uint32 *configCount,
- cacheConfig *config)
+int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
+ afs_uint32 *serverVersion, afs_uint32 *configCount, cacheConfig *config)
{
afs_uint32 *t_config;
size_t allocsize;
cm_initparams_v1 cm_config;
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
AFS_STATCNT(SRXAFSCB_GetCacheConfig);
/*
* Currently only support version 1
*/
allocsize = sizeof(cm_initparams_v1);
- t_config = (afs_uint32 *)rxi_Alloc(allocsize);
+ t_config = (afs_uint32 *)afs_osi_Alloc(allocsize);
if (t_config == NULL) {
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return ENOMEM;
}
config->cacheConfig_val = t_config;
config->cacheConfig_len = allocsize/sizeof(afs_uint32);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
return 0;
}
+
+/*------------------------------------------------------------------------
+ * EXPORTED SRXAFSCB_FetchData
+ *
+ * Description:
+ * Routine to do third party move from a remioserver to the original
+ * issuer of an ArchiveData request. Presently supported only by the
+ * "fs" command, not by the AFS client.
+ *
+ * Arguments:
+ * rxcall: Ptr to Rx call on which this request came in.
+ * Fid: pointer to AFSFid structure.
+ * Fd: File descriptor inside fs command.
+ * Position: Offset in the file.
+ * Length: Data length to transfer.
+ * TotalLength: Pointer to total file length field
+ *
+ * Returns:
+ * 0 on success
+ *
+ * Environment:
+ * Nothing interesting.
+ *
+ * Side Effects:
+ *------------------------------------------------------------------------*/
+int SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd,
+ afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength)
+{
+ return ENOSYS;
+}
+
+/*------------------------------------------------------------------------
+ * EXPORTED SRXAFSCB_StoreData
+ *
+ * Description:
+ * Routine to do third party move from a remioserver to the original
+ * issuer of a RetrieveData request. Presently supported only by the
+ * "fs" command, not by the AFS client.
+ *
+ * Arguments:
+ * rxcall: Ptr to Rx call on which this request came in.
+ * Fid: pointer to AFSFid structure.
+ * Fd: File descriptor inside fs command.
+ * Position: Offset in the file.
+ * Length: Data length to transfer.
+ * TotalLength: Pointer to total file length field
+ *
+ * Returns:
+ * 0 on success
+ *
+ * Environment:
+ * Nothing interesting.
+ *
+ * Side Effects:
+ * As advertised.
+ *------------------------------------------------------------------------*/
+int SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd,
+ afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength)
+{
+ return ENOSYS;
+}
+
+/*------------------------------------------------------------------------
+ * EXPORTED SRXAFSCB_GetCellByNum
+ *
+ * Description:
+ * Routine to get information about a cell specified by its
+ * cell number (returned by GetCE/GetCE64).
+ *
+ * Arguments:
+ * a_call : Ptr to Rx call on which this request came in.
+ * a_cellnum : Input cell number
+ * a_name : Output cell name (one zero byte when no such cell).
+ * a_hosts : Output cell database servers in host byte order.
+ *
+ * Returns:
+ * 0 on success
+ *
+ * Environment:
+ * Nothing interesting.
+ *
+ * Side Effects:
+ * As advertised.
+ *------------------------------------------------------------------------*/
+
+int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
+ char **a_name, serverList *a_hosts)
+{
+ afs_int32 i, sn;
+ struct cell *tcell;
+
+ RX_AFS_GLOCK();
+ AFS_STATCNT(SRXAFSCB_GetCellByNum);
+
+ a_hosts->serverList_val = 0;
+ a_hosts->serverList_len = 0;
+
+ tcell = afs_GetCellStale(a_cellnum, READ_LOCK);
+ if (!tcell) {
+ *a_name = afs_strdup("");
+ RX_AFS_GUNLOCK();
+ return 0;
+ }
+
+ ObtainReadLock(&tcell->lock);
+ *a_name = afs_strdup(tcell->cellName);
+
+ for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++)
+ ;
+ a_hosts->serverList_len = sn;
+ a_hosts->serverList_val = (afs_int32 *) afs_osi_Alloc(sn*sizeof(afs_int32));
+
+ for (i = 0; i < sn; i++)
+ a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip);
+ ReleaseReadLock(&tcell->lock);
+ afs_PutCell(tcell, READ_LOCK);
+
+ RX_AFS_GUNLOCK();
+ return 0;
+}
+