extern int cacheDiskType;
+
+#ifndef AFS_NOSTATS
+void
+FillStoreStats(int code, int idx, osi_timeval_t *xferStartTime,
+ afs_size_t bytesToXfer, afs_size_t bytesXferred)
+{
+ struct afs_stats_xferData *xferP;
+ osi_timeval_t xferStopTime;
+ XSTATS_DECLS;
+
+ xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[idx]);
+ osi_GetuTime(&xferStopTime);
+ (xferP->numXfers)++;
+ if (!code) {
+ (xferP->numSuccesses)++;
+ afs_stats_XferSumBytes[idx] += bytesXferred;
+ (xferP->sumBytes) += (afs_stats_XferSumBytes[idx] >> 10);
+ afs_stats_XferSumBytes[idx] &= 0x3FF;
+ if (bytesXferred < xferP->minBytes)
+ xferP->minBytes = bytesXferred;
+ if (bytesXferred > xferP->maxBytes)
+ xferP->maxBytes = bytesXferred;
+
+ /*
+ * Tally the size of the object. Note: we tally the actual size,
+ * NOT the number of bytes that made it out over the wire.
+ */
+ if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0) (xferP->count[0])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1) (xferP->count[1])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2) (xferP->count[2])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3) (xferP->count[3])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4) (xferP->count[4])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5) (xferP->count[5])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6) (xferP->count[6])++;
+ else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7) (xferP->count[7])++;
+ else
+ (xferP->count[8])++;
+
+ afs_stats_GetDiff(elapsedTime, (*xferStartTime), xferStopTime);
+ afs_stats_AddTo((xferP->sumTime), elapsedTime);
+ afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime);
+ if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) {
+ afs_stats_TimeAssign((xferP->minTime), elapsedTime);
+ }
+ if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) {
+ afs_stats_TimeAssign((xferP->maxTime), elapsedTime);
+ }
+ }
+}
+#endif /* AFS_NOSTATS */
+
/* rock and operations for RX_FILESERVER */
struct rxfs_storeVariables {
}
afs_int32
+rxfs_storePadd(void *rock, afs_uint32 size)
+{
+ afs_int32 code = 0;
+ int bsent, tlen;
+ struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock;
+
+ if ( !v->tbuffer )
+ v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+ memset(v->tbuffer, 0, AFS_LRALLOCSIZ);
+
+ while (size > 0) {
+ tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
+ RX_AFS_GUNLOCK();
+ code = rx_Write(v->call, v->tbuffer, tlen);
+ RX_AFS_GLOCK();
+
+ if (code != tlen)
+ return -33; /* XXX */
+ size -= tlen;
+ }
+ return code;
+}
+
+afs_int32
rxfs_storeStatus(void *rock)
{
struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock;
struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)*r;
*r = NULL;
+ if (v->call) {
+ afs_int32 code2;
+ RX_AFS_GUNLOCK();
+ code2 = rx_EndCall(v->call, code);
+ RX_AFS_GLOCK();
+ if (code2)
+ code = code2;
+ }
if (v->tbuffer)
osi_FreeLargeSpace(v->tbuffer);
if (v->tiov)
rxfs_storeUfsRead,
rxfs_storeUfsWrite,
rxfs_storeStatus,
+ rxfs_storePadd,
rxfs_storeClose,
rxfs_storeDestroy
};
rxfs_storeMemRead,
rxfs_storeMemWrite,
rxfs_storeStatus,
+ rxfs_storePadd,
rxfs_storeClose,
rxfs_storeDestroy
};
afs_int32
-rxfs_storeInit(struct vcache *avc, struct storeOps **ops, void **rock)
+rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, afs_size_t tlen,
+ afs_size_t bytes, afs_size_t base,
+ int sync, struct storeOps **ops, void **rock)
{
+ afs_int32 code;
struct rxfs_storeVariables *v;
+ if ( !tc )
+ return -1;
+
v = (struct rxfs_storeVariables *) osi_AllocSmallSpace(sizeof(struct rxfs_storeVariables));
if (!v)
osi_Panic("rxfs_storeInit: osi_AllocSmallSpace returned NULL\n");
v->InStatus.ClientModTime = avc->f.m.Date;
v->InStatus.Mask = AFS_SETMODTIME;
-
+ if (sync & AFS_SYNC)
+ v->InStatus.Mask |= AFS_FSYNC;
+ RX_AFS_GUNLOCK();
+ v->call = rx_NewCall(tc->id);
+ if (v->call) {
+#ifdef AFS_64BIT_CLIENT
+ if (!afs_serverHasNo64Bit(tc))
+ code = StartRXAFS_StoreData64(v->call,(struct AFSFid*)&avc->f.fid.Fid,
+ &v->InStatus, base, bytes, tlen);
+ else
+ if (tlen > 0xFFFFFFFF)
+ code = EFBIG;
+ else {
+ afs_int32 t1 = base, t2 = bytes, t3 = tlen;
+ code = StartRXAFS_StoreData(v->call,
+ (struct AFSFid *) &avc->f.fid.Fid,
+ &v->InStatus, t1, t2, t3);
+ }
+#else /* AFS_64BIT_CLIENT */
+ code = StartRXAFS_StoreData(v->call, (struct AFSFid *)&avc->f.fid.Fid,
+ &v->InStatus, base, bytes, tlen);
+#endif /* AFS_64BIT_CLIENT */
+ } else
+ code = -1;
+ RX_AFS_GLOCK();
+ if (code) {
+ osi_FreeSmallSpace(v);
+ return code;
+ }
if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (!v->tbuffer)
osi_Panic
- ("rxfs_storeInit: osi_AllocLargeSpace for iovecs returned NULL\n");
+ ("rxfs_storeInit: osi_AllocLargeSpace for iovecs returned NULL\n");
*ops = (struct storeOps *) &rxfs_storeUfsOps;
} else {
v->tiov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS);
if (!v->tiov)
osi_Panic
- ("rxfs_storeInit: osi_AllocSmallSpace for iovecs returned NULL\n");
+ ("rxfs_storeInit: osi_AllocSmallSpace for iovecs returned NULL\n");
*ops = (struct storeOps *) &rxfs_storeMemOps;
#ifdef notdef
/* do this at a higher level now -- it's a parameter */
}
#endif /* notdef */
}
+
*rock = (void *)v;
return 0;
}
-extern unsigned int storeallmissing;
+unsigned int storeallmissing = 0;
/*!
- * Called upon store.
+ * Called for each chunk upon store.
*
- * \param acall Ptr to the Rx call structure involved.
+ * \param avc Ptr to the vcache entry of the file being stored.
* \param dclist pointer to the list of dcaches
- * \param avc Ptr to the vcache entry.
- * \param bytes per chunk
+ * \param bytes total number of bytes for the current operation
* \param anewDV Ptr to the dataversion after store
- * \param doProcessFS Ptr to the processFS flag
- * \param OutStatus Ptr to the OutStatus structure
- * \param nchunks number of chunks to store
- * \param nomoreP pointer to the "nomore" flag
- *
- * \note Environment: Nothing interesting.
+ * \param doProcessFS pointer to the "do process FetchStatus" flag
+ * \param OutStatus pointer to the FetchStatus as returned by the fileserver
+ * \param nchunks number of dcaches to consider
+ * \param nomore copy of the "no more data" flag
+ * \param ops pointer to the block of storeOps to be used for this operation
+ * \param rock pointer to the opaque protocol-specific data of this operation
*/
-int
-afs_CacheStoreProc(register struct rx_call *acall,
- struct dcache **dclist,
- struct vcache *avc,
+afs_int32
+afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
afs_size_t bytes,
afs_hyper_t *anewDV,
int *doProcessFS,
struct AFSFetchStatus *OutStatus,
afs_uint32 nchunks,
- int *nomoreP)
+ int nomore,
+ struct storeOps *ops, void *rock)
{
- afs_int32 code = 0;
- afs_uint32 tlen;
- struct storeOps *ops;
- void * rock = NULL;
- struct osi_file *fP;
- int *shouldwake;
- int nomore = *nomoreP;
- struct dcache *tdc;
- int stored = 0;
+ int *shouldwake = NULL;
unsigned int i;
- afs_int32 alen;
+ afs_int32 code = 0;
+
#ifndef AFS_NOSTATS
- struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */
- osi_timeval_t xferStartTime, /*FS xfer start time */
- xferStopTime; /*FS xfer stop time */
+ osi_timeval_t xferStartTime; /*FS xfer start time */
afs_size_t bytesToXfer = 10000; /* # bytes to xfer */
afs_size_t bytesXferred = 10000; /* # bytes actually xferred */
#endif /* AFS_NOSTATS */
XSTATS_DECLS;
- code = rxfs_storeInit(avc, &ops, &rock);
- if ( code ) {
- osi_Panic("afs_CacheStoreProc: rxfs_storeInit failed");
- }
- ((struct rxfs_storeVariables *)rock)->call = acall;
-
for (i = 0; i < nchunks && !code; i++) {
+ int stored = 0;
+ struct osi_file *fP;
int offset = 0;
- tdc = dclist[i];
- alen = tdc->f.chunkBytes;
+ struct dcache *tdc = dclist[i];
+ afs_int32 alen = tdc->f.chunkBytes;
if (!tdc) {
afs_warn("afs: missing dcache!\n");
storeallmissing++;
fP = afs_CFileOpen(&tdc->f.inode);
afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
- ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
+ ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
+ ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
AFS_STATCNT(CacheStoreProc);
bytesToXfer = alen;
bytesXferred = 0;
- xferP = &(afs_stats_cmfullperf.rpc.
- fsXferTimes[AFS_STATS_FS_XFERIDX_STOREDATA]);
- osi_GetuTime(&xferStartTime);
+ GetuTime(&xferStartTime);
#endif /* AFS_NOSTATS */
- while ( alen > 0 ) {
+ while ( alen > 0 ) {
+ afs_uint32 tlen;
afs_int32 bytesread, byteswritten;
code = (*ops->prepare)(rock, alen, &tlen);
if ( code )
}
}
afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
- ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
+ ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
+ ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
#ifndef AFS_NOSTATS
- osi_GetuTime(&xferStopTime);
- (xferP->numXfers)++;
- if (!code) {
- (xferP->numSuccesses)++;
- afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] +=
- bytesXferred;
- (xferP->sumBytes) +=
- (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] >> 10);
- afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] &= 0x3FF;
- if (bytesXferred < xferP->minBytes)
- xferP->minBytes = bytesXferred;
- if (bytesXferred > xferP->maxBytes)
- xferP->maxBytes = bytesXferred;
-
- /*
- * Tally the size of the object. Note: we tally the actual size,
- * NOT the number of bytes that made it out over the wire.
- */
- if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0)
- (xferP->count[0])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1)
- (xferP->count[1])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2)
- (xferP->count[2])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3)
- (xferP->count[3])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4)
- (xferP->count[4])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5)
- (xferP->count[5])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6)
- (xferP->count[6])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7)
- (xferP->count[7])++;
- else
- (xferP->count[8])++;
-
- afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime);
- afs_stats_AddTo((xferP->sumTime), elapsedTime);
- afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime);
- if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) {
- afs_stats_TimeAssign((xferP->minTime), elapsedTime);
- }
- if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) {
- afs_stats_TimeAssign((xferP->maxTime), elapsedTime);
- }
- }
+ FillStoreStats(code, AFS_STATS_FS_XFERIDX_STOREDATA,
+ &xferStartTime, bytesToXfer, bytesXferred);
#endif /* AFS_NOSTATS */
afs_CFileClose(fP);
if ((tdc->f.chunkBytes < afs_OtherCSize)
- && (i < (nchunks - 1)) && code == 0) {
- int bsent, tlen, sbytes =
- afs_OtherCSize - tdc->f.chunkBytes;
- char *tbuffer =
- osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+ && (i < (nchunks - 1)) && code == 0) {
+ int bsent, tlen, sbytes = afs_OtherCSize - tdc->f.chunkBytes;
+ char *tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
while (sbytes > 0) {
tlen = (sbytes > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : sbytes);
memset(tbuffer, 0, tlen);
RX_AFS_GUNLOCK();
- bsent = rx_Write(((struct rxfs_storeVariables*)rock)->call,
- tbuffer, tlen);
+ bsent = rx_Write(
+ ((struct rxfs_storeVariables*)rock)->call, tbuffer, tlen);
RX_AFS_GLOCK();
if (bsent != tlen) {
osi_FreeLargeSpace(tbuffer);
}
stored += tdc->f.chunkBytes;
-
/* ideally, I'd like to unlock the dcache and turn
* off the writing bit here, but that would
* require being able to retry StoreAllSegments in
* if user can't read from a 'locked' dcache or
* one which has the writing bit turned on. */
}
+
if (!code) {
code = (*ops->close)(rock, OutStatus, doProcessFS);
if (*doProcessFS) {
XSTATS_END_TIME;
}
code = (*ops->destroy)(&rock, code);
+ return code;
+}
+
+#define lmin(a,b) (((a) < (b)) ? (a) : (b))
+/*!
+ * Called upon store.
+ *
+ * \param dclist pointer to the list of dcaches
+ * \param avc Ptr to the vcache entry.
+ * \param areq Ptr to the request structure
+ * \param sync sync flag
+ * \param minj the chunk offset for this call
+ * \param high index of last dcache to store
+ * \param moredata the moredata flag
+ * \param anewDV Ptr to the dataversion after store
+ * \param amaxStoredLength Ptr to the amount of that is actually stored
+ *
+ * \note Environment: Nothing interesting.
+ */
+int
+afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc,
+ struct vrequest *areq, int sync,
+ unsigned int minj, unsigned int high,
+ unsigned int moredata,
+ afs_hyper_t *anewDV, afs_size_t *amaxStoredLength)
+{
+ afs_int32 code = 0;
+ struct storeOps *ops;
+ void * rock = NULL;
+ unsigned int i, j;
+
+ struct AFSStoreStatus InStatus;
+ struct AFSFetchStatus OutStatus;
+ int doProcessFS = 0;
+ afs_size_t base, bytes, length;
+ afs_uint32 nchunks;
+ int nomore;
+ unsigned int first = 0;
+ struct afs_conn *tc;
+
+ for (bytes = 0, j = 0; !code && j <= high; j++) {
+ if (dcList[j]) {
+ ObtainSharedLock(&(dcList[j]->lock), 629);
+ if (!bytes)
+ first = j;
+ bytes += dcList[j]->f.chunkBytes;
+ if ((dcList[j]->f.chunkBytes < afs_OtherCSize)
+ && (dcList[j]->f.chunk - minj < high)
+ && dcList[j + 1]) {
+ int sbytes = afs_OtherCSize - dcList[j]->f.chunkBytes;
+ bytes += sbytes;
+ }
+ }
+ if (bytes && (j == high || !dcList[j + 1])) {
+ struct dcache **dclist = &dcList[first];
+ /* base = AFS_CHUNKTOBASE(dcList[first]->f.chunk); */
+ base = AFS_CHUNKTOBASE(first + minj);
+ /*
+ *
+ * take a list of dcache structs and send them all off to the server
+ * the list must be in order, and the chunks contiguous.
+ * Note - there is no locking done by this code currently. For
+ * safety's sake, xdcache could be locked over the entire call.
+ * However, that pretty well ties up all the threads. Meantime, all
+ * the chunks _MUST_ have their refcounts bumped.
+ * The writes done before a store back will clear setuid-ness
+ * in cache file.
+ * We can permit CacheStoreProc to wake up the user process IFF we
+ * are doing the last RPC for this close, ie, storing back the last
+ * set of contiguous chunks of a file.
+ */
+
+ nchunks = 1 + j - first;
+ nomore = !(moredata || (j != high));
+ length = lmin(avc->f.m.Length, avc->f.truncPos);
+ afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64,
+ ICL_TYPE_FID, &avc->f.fid.Fid, ICL_TYPE_OFFSET,
+ ICL_HANDLE_OFFSET(base), ICL_TYPE_OFFSET,
+ ICL_HANDLE_OFFSET(bytes), ICL_TYPE_OFFSET,
+ ICL_HANDLE_OFFSET(length));
+
+ do {
+ tc = afs_Conn(&avc->f.fid, areq, 0);
+
+#ifdef AFS_64BIT_CLIENT
+ restart:
+#endif
+ code = rxfs_storeInit(avc, tc, length, bytes, base,
+ sync, &ops, &rock);
+ if ( code ) {
+ osi_Panic(
+ "afs_CacheStoreProc: rxfs_storeInit failed with %d", code);
+ }
+
+ code = afs_CacheStoreDCaches(avc, dclist, bytes, anewDV,
+ &doProcessFS, &OutStatus, nchunks, nomore, ops, rock);
+
+#ifdef AFS_64BIT_CLIENT
+ if (code == RXGEN_OPCODE && !afs_serverHasNo64Bit(tc)) {
+ afs_serverSetNo64Bit(tc);
+ goto restart;
+ }
+#endif /* AFS_64BIT_CLIENT */
+ } while (afs_Analyze
+ (tc, code, &avc->f.fid, areq,
+ AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK,
+ NULL));
+
+ /* put back all remaining locked dcache entries */
+ for (i = 0; i < nchunks; i++) {
+ struct dcache *tdc = dclist[i];
+ if (!code) {
+ if (afs_indexFlags[tdc->index] & IFDataMod) {
+ /*
+ * LOCKXXX -- should hold afs_xdcache(W) when
+ * modifying afs_indexFlags.
+ */
+ afs_indexFlags[tdc->index] &= ~IFDataMod;
+ afs_stats_cmperf.cacheCurrDirtyChunks--;
+ afs_indexFlags[tdc->index] &= ~IFDirtyPages;
+ if (sync & AFS_VMSYNC_INVAL) {
+ /* since we have invalidated all the pages of this
+ ** vnode by calling osi_VM_TryToSmush, we can
+ ** safely mark this dcache entry as not having
+ ** any pages. This vnode now becomes eligible for
+ ** reclamation by getDownD.
+ */
+ afs_indexFlags[tdc->index] &= ~IFAnyPages;
+ }
+ }
+ }
+ UpgradeSToWLock(&tdc->lock, 628);
+ tdc->f.states &= ~DWriting; /* correct? */
+ tdc->dflags |= DFEntryMod;
+ ReleaseWriteLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ /* Mark the entry as released */
+ dclist[i] = NULL;
+ }
+
+ if (doProcessFS) {
+ /* Now copy out return params */
+ UpgradeSToWLock(&avc->lock, 28); /* keep out others for a while */
+ afs_ProcessFS(avc, &OutStatus, areq);
+ /* Keep last (max) size of file on server to see if
+ * we need to call afs_StoreMini to extend the file.
+ */
+ if (!moredata)
+ *amaxStoredLength = OutStatus.Length;
+ ConvertWToSLock(&avc->lock);
+ doProcessFS = 0;
+ }
+
+ if (code) {
+ for (j++; j <= high; j++) {
+ if (dcList[j]) {
+ ReleaseSharedLock(&(dcList[j]->lock));
+ afs_PutDCache(dcList[j]);
+ /* Releasing entry */
+ dcList[j] = NULL;
+ }
+ }
+ }
+
+ afs_Trace2(afs_iclSetp, CM_TRACE_STOREALLDCDONE,
+ ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code);
+ bytes = 0;
+ }
+ }
- *nomoreP = nomore;
return code;
}
afs_int32
rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
- afs_uint32 size, afs_uint32 *out_length, struct dcache *adc,
+ afs_uint32 size, afs_uint32 *alength, struct dcache *adc,
struct osi_file *fP, struct fetchOps **ops, void **rock)
{
struct rxfs_fetchVariables *v;
if (!v->call)
v->call = rx_NewCall(tc->id);
code =
- StartRXAFS_FetchData(v->call, (struct AFSFid *)
- &avc->f.fid.Fid, pos,
- size);
+ StartRXAFS_FetchData(v->call, (struct AFSFid *)&avc->f.fid.Fid,
+ pos, size);
RX_AFS_GLOCK();
}
afs_serverSetNo64Bit(tc);
return code;
}
- if ( cacheDiskType == AFS_FCACHE_TYPE_UFS ) {
+ if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (!v->tbuffer)
osi_Panic("rxfs_fetchInit: osi_AllocLargeSpace for iovecs returned NULL\n");
* We need to alloc the iovecs on the heap so that they are "pinned"
* rather than declare them on the stack - defect 11272
*/
- v->iov = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec) *
- RX_MAXIOVECS);
+ v->iov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS);
if (!v->iov)
- osi_Panic("afs_CacheFetchProc: osi_AllocSmallSpace for iovecs returned NULL\n");
+ osi_Panic("rxfs_fetchInit: osi_AllocSmallSpace for iovecs returned NULL\n");
*ops = (struct fetchOps *) &rxfs_fetchMemOps;
}
*rock = (void *)v;
- *out_length = length;
+ *alength = length;
return 0;
}
XSTATS_DECLS;
#ifndef AFS_NOSTATS
- struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */
- osi_timeval_t xferStartTime, /*FS xfer start time */
- xferStopTime; /*FS xfer stop time */
+ osi_timeval_t xferStartTime; /*FS xfer start time */
afs_size_t bytesToXfer = 0, bytesXferred = 0;
#endif
code = rxfs_fetchInit(tc, avc, abase, size, &length, adc, fP, &ops, &rock);
#ifndef AFS_NOSTATS
- xferP =
- &(afs_stats_cmfullperf.rpc.fsXferTimes[AFS_STATS_FS_XFERIDX_FETCHDATA]);
osi_GetuTime(&xferStartTime);
#endif /* AFS_NOSTATS */
(*ops->destroy)(&rock, code);
#ifndef AFS_NOSTATS
- osi_GetuTime(&xferStopTime);
- (xferP->numXfers)++;
- if (!code) {
- (xferP->numSuccesses)++;
- afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] += bytesXferred;
- (xferP->sumBytes) +=
- (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] >> 10);
- afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] &= 0x3FF;
- if (bytesXferred < xferP->minBytes)
- xferP->minBytes = bytesXferred;
- if (bytesXferred > xferP->maxBytes)
- xferP->maxBytes = bytesXferred;
-
- /*
- * Tally the size of the object. Note: we tally the actual size,
- * NOT the number of bytes that made it out over the wire.
- */
- if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0)
- (xferP->count[0])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1)
- (xferP->count[1])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2)
- (xferP->count[2])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3)
- (xferP->count[3])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4)
- (xferP->count[4])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5)
- (xferP->count[5])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6)
- (xferP->count[6])++;
- else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7)
- (xferP->count[7])++;
- else
- (xferP->count[8])++;
-
- afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime);
- afs_stats_AddTo((xferP->sumTime), elapsedTime);
- afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime);
- if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) {
- afs_stats_TimeAssign((xferP->minTime), elapsedTime);
- }
- if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) {
- afs_stats_TimeAssign((xferP->maxTime), elapsedTime);
- }
- }
+ FillStoreStats(code, AFS_STATS_FS_XFERIDX_FETCHDATA,&xferStartTime,
+ bytesToXfer, bytesXferred);
#endif
XSTATS_END_TIME;
return code;
}
-