2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
13 #include "afs/sysincludes.h" /* Standard vendor system headers */
14 #ifndef AFS_LINUX22_ENV
15 #include "rpc/types.h"
23 #endif /* AFS_ALPHA_ENV */
24 #include "afsincludes.h" /* Afs-based standard headers */
25 #include "afs/afs_stats.h" /* statistics */
26 #include "afs_prototypes.h"
28 extern int cacheDiskType;
30 /* rock and operations for RX_FILESERVER */
32 struct rxfs_storeVariables {
38 struct AFSStoreStatus InStatus;
42 rxfs_storeUfsPrepare(void *r, afs_uint32 size, afs_uint32 *tlen)
44 *tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
49 rxfs_storeMemPrepare(void *r, afs_uint32 size, afs_uint32 *tlen)
52 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *) r;
54 *tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
56 code = rx_WritevAlloc(v->call, v->tiov, &v->tnio, RX_MAXIOVECS, *tlen);
59 code = rx_Error(v->call);
71 rxfs_storeUfsRead(void *r, struct osi_file *tfile, afs_uint32 offset,
72 afs_uint32 tlen, afs_uint32 *bytesread)
75 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r;
78 code = afs_osi_Read(tfile, -1, v->tbuffer, tlen);
84 #if defined(KERNEL_HAVE_UERROR)
92 rxfs_storeMemRead(void *r, struct osi_file *tfile, afs_uint32 offset,
93 afs_uint32 tlen, afs_uint32 *bytesread)
96 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r;
97 struct memCacheEntry *mceP = (struct memCacheEntry *)tfile;
100 code = afs_MemReadvBlk(mceP, offset, v->tiov, v->tnio, tlen);
108 rxfs_storeMemWrite(void *r, afs_uint32 l, afs_uint32 *byteswritten)
111 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r;
114 code = rx_Writev(v->call, v->tiov, v->tnio, l);
117 code = rx_Error(v->call);
118 return (code ? code : -33);
120 *byteswritten = code;
125 rxfs_storeUfsWrite(void *r, afs_uint32 l, afs_uint32 *byteswritten)
128 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r;
131 code = rx_Write(v->call, v->tbuffer, l);
132 /* writing 0 bytes will
133 * push a short packet. Is that really what we want, just because the
134 * data didn't come back from the disk yet? Let's try it and see. */
137 code = rx_Error(v->call);
138 return (code ? code : -33);
140 *byteswritten = code;
145 rxfs_storeStatus(void *rock)
147 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock;
149 if (rx_GetRemoteStatus(v->call) & 1)
155 rxfs_storeClose(void *r, struct AFSFetchStatus *OutStatus, int *doProcessFS)
158 struct AFSVolSync tsync;
159 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r;
162 code = EndRXAFS_StoreData(v->call, OutStatus, &tsync);
165 *doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */
171 rxfs_storeDestroy(void **r, afs_int32 error)
173 afs_int32 code = error;
174 struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)*r;
180 code2 = rx_EndCall(v->call, code);
186 osi_FreeLargeSpace(v->tbuffer);
188 osi_FreeSmallSpace(v->tiov);
189 osi_FreeSmallSpace(v);
194 struct storeOps rxfs_storeUfsOps = {
195 rxfs_storeUfsPrepare,
204 struct storeOps rxfs_storeMemOps = {
205 rxfs_storeMemPrepare,
214 rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, afs_size_t tlen,
215 afs_size_t bytes, afs_size_t base,
216 struct storeOps **ops, void **rock)
219 struct rxfs_storeVariables *v;
220 struct rx_call *tcall;
225 v = (struct rxfs_storeVariables *) osi_AllocSmallSpace(sizeof(struct rxfs_storeVariables));
227 osi_Panic("rxfs_storeInit: osi_AllocSmallSpace returned NULL\n");
228 memset(v, 0, sizeof(struct rxfs_storeVariables));
230 v->InStatus.ClientModTime = avc->f.m.Date;
231 v->InStatus.Mask = AFS_SETMODTIME;
234 tcall = rx_NewCall(tc->id);
235 #ifdef AFS_64BIT_CLIENT
236 if (!afs_serverHasNo64Bit(tc))
237 code = StartRXAFS_StoreData64(tcall, (struct AFSFid *) &avc->f.fid.Fid,
238 &v->InStatus, base, bytes, tlen);
240 if (tlen > 0xFFFFFFFF) {
244 afs_int32 t1, t2, t3;
248 code = StartRXAFS_StoreData(tcall, (struct AFSFid *)&avc->f.fid.Fid,
249 &v->InStatus, t1, t2, t3);
252 #else /* AFS_64BIT_CLIENT */
253 code = StartRXAFS_StoreData(tcall, (struct AFSFid *)&avc->f.fid.Fid,
254 &v->InStatus, base, bytes, tlen);
255 #endif /* AFS_64BIT_CLIENT */
258 if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
259 v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
262 ("rxfs_storeInit: osi_AllocLargeSpace for iovecs returned NULL\n");
263 *ops = (struct storeOps *) &rxfs_storeUfsOps;
265 v->tiov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS);
268 ("rxfs_storeInit: osi_AllocSmallSpace for iovecs returned NULL\n");
269 *ops = (struct storeOps *) &rxfs_storeMemOps;
271 /* do this at a higher level now -- it's a parameter */
272 /* for now, only do 'continue from close' code if file fits in one
273 * chunk. Could clearly do better: if only one modified chunk
274 * then can still do this. can do this on *last* modified chunk */
275 tlen = avc->f.m.Length - 1; /* byte position of last byte we'll store */
277 if (AFS_CHUNK(tlen) != 0)
290 extern unsigned int storeallmissing;
294 * \param tc Ptr to the Rx connection structure involved.
295 * \param dclist pointer to the list of dcaches
296 * \param avc Ptr to the vcache entry.
297 * \param bytes per chunk
298 * \param base where to start the store
299 * \param length number of bytes to store
300 * \param anewDV Ptr to the dataversion after store
301 * \param doProcessFS Ptr to the processFS flag
302 * \param OutStatus Ptr to the OutStatus structure
303 * \param nchunks number of chunks to store
304 * \param nomoreP pointer to the "nomore" flag
306 * \note Environment: Nothing interesting.
309 afs_CacheStoreProc(register struct afs_conn *tc,
310 struct dcache **dclist,
317 struct AFSFetchStatus *OutStatus,
322 struct storeOps *ops;
324 int nomore = *nomoreP;
327 struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */
328 osi_timeval_t xferStartTime, /*FS xfer start time */
329 xferStopTime; /*FS xfer stop time */
330 afs_size_t bytesToXfer = 10000; /* # bytes to xfer */
331 afs_size_t bytesXferred = 10000; /* # bytes actually xferred */
332 #endif /* AFS_NOSTATS */
335 code = rxfs_storeInit(avc, tc, length, bytes, base, &ops, &rock);
337 osi_Panic("afs_CacheStoreProc: rxfs_storeInit failed with %d", code);
340 for (i = 0; i < nchunks && !code; i++) {
344 struct dcache *tdc = dclist[i];
345 afs_int32 alen = tdc->f.chunkBytes;
348 afs_warn("afs: missing dcache!\n");
350 continue; /* panic? */
352 afs_Trace4(afs_iclSetp, CM_TRACE_STOREALL2, ICL_TYPE_POINTER, avc,
353 ICL_TYPE_INT32, tdc->f.chunk, ICL_TYPE_INT32, tdc->index,
354 ICL_TYPE_INT32, afs_inode2trace(&tdc->f.inode));
357 if (avc->asynchrony == -1) {
358 if (afs_defaultAsynchrony > (bytes - stored))
359 shouldwake = &nomore;
361 else if ((afs_uint32) avc->asynchrony >= (bytes - stored))
362 shouldwake = &nomore;
364 fP = afs_CFileOpen(&tdc->f.inode);
366 afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
367 ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
368 ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
370 AFS_STATCNT(CacheStoreProc);
372 XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA);
373 avc->f.truncPos = AFS_NOTRUNC;
376 * In this case, alen is *always* the amount of data we'll be trying
382 xferP = &(afs_stats_cmfullperf.rpc.
383 fsXferTimes[AFS_STATS_FS_XFERIDX_STOREDATA]);
384 osi_GetuTime(&xferStartTime);
385 #endif /* AFS_NOSTATS */
389 afs_int32 bytesread, byteswritten;
390 code = (*ops->prepare)(rock, alen, &tlen);
394 code = (*ops->read)(rock, fP, offset, tlen, &bytesread);
399 code = (*ops->write)(rock, tlen, &byteswritten);
403 bytesXferred += byteswritten;
404 #endif /* AFS_NOSTATS */
409 * if file has been locked on server, can allow
412 if (shouldwake && *shouldwake && ((*ops->status)(rock) == 0)) {
413 *shouldwake = 0; /* only do this once */
417 afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
418 ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
419 ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
422 osi_GetuTime(&xferStopTime);
425 (xferP->numSuccesses)++;
426 afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] +=
429 (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] >> 10);
430 afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] &= 0x3FF;
431 if (bytesXferred < xferP->minBytes)
432 xferP->minBytes = bytesXferred;
433 if (bytesXferred > xferP->maxBytes)
434 xferP->maxBytes = bytesXferred;
437 * Tally the size of the object. Note: we tally the actual size,
438 * NOT the number of bytes that made it out over the wire.
440 if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0)
442 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1)
444 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2)
446 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3)
448 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4)
450 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5)
452 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6)
454 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7)
459 afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime);
460 afs_stats_AddTo((xferP->sumTime), elapsedTime);
461 afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime);
462 if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) {
463 afs_stats_TimeAssign((xferP->minTime), elapsedTime);
465 if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) {
466 afs_stats_TimeAssign((xferP->maxTime), elapsedTime);
469 #endif /* AFS_NOSTATS */
472 if ((tdc->f.chunkBytes < afs_OtherCSize)
473 && (i < (nchunks - 1)) && code == 0) {
474 int bsent, tlen, sbytes =
475 afs_OtherCSize - tdc->f.chunkBytes;
477 osi_AllocLargeSpace(AFS_LRALLOCSIZ);
480 tlen = (sbytes > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : sbytes);
481 memset(tbuffer, 0, tlen);
483 bsent = rx_Write(((struct rxfs_storeVariables*)rock)->call,
488 code = -33; /* XXX */
493 osi_FreeLargeSpace(tbuffer);
495 stored += tdc->f.chunkBytes;
497 /* ideally, I'd like to unlock the dcache and turn
498 * off the writing bit here, but that would
499 * require being able to retry StoreAllSegments in
500 * the event of a failure. It only really matters
501 * if user can't read from a 'locked' dcache or
502 * one which has the writing bit turned on. */
505 code = (*ops->close)(rock, OutStatus, doProcessFS);
511 code = (*ops->destroy)(&rock, code);
517 /* rock and operations for RX_FILESERVER */
519 struct rxfs_fetchVariables {
520 struct rx_call *call;
524 afs_int32 hasNo64bit;
530 rxfs_fetchUfsRead(void *r, afs_uint32 size, afs_uint32 *bytesread)
534 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
537 tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
539 code = rx_Read(v->call, v->tbuffer, tlen);
548 rxfs_fetchMemRead(void *r, afs_uint32 tlen, afs_uint32 *bytesread)
551 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
555 code = rx_Readv(v->call, v->iov, &v->nio, RX_MAXIOVECS, tlen);
565 rxfs_fetchMemWrite(void *r, struct osi_file *fP,
566 afs_uint32 offset, afs_uint32 tlen,
567 afs_uint32 *byteswritten)
570 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
571 struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
573 code = afs_MemWritevBlk(mceP, offset, v->iov, v->nio, tlen);
577 *byteswritten = code;
582 rxfs_fetchUfsWrite(void *r, struct osi_file *fP,
583 afs_uint32 offset, afs_uint32 tlen,
584 afs_uint32 *byteswritten)
587 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
589 code = afs_osi_Write(fP, -1, v->tbuffer, tlen);
593 *byteswritten = code;
599 rxfs_fetchClose(void *r, struct vcache *avc, struct dcache * adc,
600 struct afs_FetchOutput *tsmall)
602 afs_int32 code, code1 = 0;
603 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
609 code = EndRXAFS_FetchData(v->call, &tsmall->OutStatus,
616 code1 = rx_EndCall(v->call, code);
627 rxfs_fetchDestroy(void **r, afs_int32 error)
629 afs_int32 code = error;
630 struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)*r;
634 osi_FreeLargeSpace(v->tbuffer);
636 osi_FreeSmallSpace(v->iov);
637 osi_FreeSmallSpace(v);
642 rxfs_fetchMore(void *r, afs_uint32 *length, afs_uint32 *moredata)
645 register struct rxfs_fetchVariables *v
646 = (struct rxfs_fetchVariables *)r;
649 code = rx_Read(v->call, (void *)length, sizeof(afs_int32));
650 *length = ntohl(*length);
652 if (code != sizeof(afs_int32)) {
653 code = rx_Error(v->call);
654 return (code ? code : -1); /* try to return code, not -1 */
660 struct fetchOps rxfs_fetchUfsOps = {
669 struct fetchOps rxfs_fetchMemOps = {
678 rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
679 afs_uint32 size, afs_uint32 *out_length, struct dcache *adc,
680 struct osi_file *fP, struct fetchOps **ops, void **rock)
682 struct rxfs_fetchVariables *v;
684 afs_int32 length_hi, length, bytes;
685 #ifdef AFS_64BIT_CLIENT
687 afs_size_t lengthFound; /* as returned from server */
688 #endif /* AFS_64BIT_CLIENT */
690 v = (struct rxfs_fetchVariables *) osi_AllocSmallSpace(sizeof(struct rxfs_fetchVariables));
692 osi_Panic("rxfs_fetchInit: osi_AllocSmallSpace returned NULL\n");
693 memset(v, 0, sizeof(struct rxfs_fetchVariables));
696 v->call = rx_NewCall(tc->id);
699 #ifdef AFS_64BIT_CLIENT
700 length_hi = code = 0;
701 if (!afs_serverHasNo64Bit(tc)) {
704 code = StartRXAFS_FetchData64(v->call, (struct AFSFid *)&avc->f.fid.Fid,
708 afs_Trace2(afs_iclSetp, CM_TRACE_FETCH64CODE,
709 ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code);
711 bytes = rx_Read(v->call, (char *)&length_hi, sizeof(afs_int32));
713 if (bytes == sizeof(afs_int32)) {
714 length_hi = ntohl(length_hi);
717 code = rx_Error(v->call);
719 code1 = rx_EndCall(v->call, code);
725 if (code == RXGEN_OPCODE || afs_serverHasNo64Bit(tc)) {
726 if (base > 0x7FFFFFFF) {
733 v->call = rx_NewCall(tc->id);
735 StartRXAFS_FetchData(v->call, (struct AFSFid *)
736 &avc->f.fid.Fid, pos,
740 afs_serverSetNo64Bit(tc);
744 bytes = rx_Read(v->call, (char *)&length, sizeof(afs_int32));
746 if (bytes == sizeof(afs_int32))
747 length = ntohl(length);
749 code = rx_Error(v->call);
752 FillInt64(lengthFound, length_hi, length);
753 afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64LENG,
754 ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,
756 ICL_HANDLE_OFFSET(lengthFound));
757 #else /* AFS_64BIT_CLIENT */
759 code = StartRXAFS_FetchData(v->call, (struct AFSFid *)&avc->f.fid.Fid,
764 bytes = rx_Read(v->call, (char *)&length, sizeof(afs_int32));
766 if (bytes == sizeof(afs_int32))
767 length = ntohl(length);
769 code = rx_Error(v->call);
771 #endif /* AFS_64BIT_CLIENT */
773 osi_FreeSmallSpace(v);
777 if ( cacheDiskType == AFS_FCACHE_TYPE_UFS ) {
778 v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
780 osi_Panic("rxfs_fetchInit: osi_AllocLargeSpace for iovecs returned NULL\n");
781 osi_Assert(WriteLocked(&adc->lock));
783 *ops = (struct fetchOps *) &rxfs_fetchUfsOps;
786 afs_Trace4(afs_iclSetp, CM_TRACE_MEMFETCH, ICL_TYPE_POINTER, avc,
787 ICL_TYPE_POINTER, fP, ICL_TYPE_OFFSET,
788 ICL_HANDLE_OFFSET(base), ICL_TYPE_INT32, length);
790 * We need to alloc the iovecs on the heap so that they are "pinned"
791 * rather than declare them on the stack - defect 11272
793 v->iov = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec) *
796 osi_Panic("afs_CacheFetchProc: osi_AllocSmallSpace for iovecs returned NULL\n");
797 *ops = (struct fetchOps *) &rxfs_fetchMemOps;
800 *out_length = length;
806 * Routine called on fetch; also tells people waiting for data
807 * that more has arrived.
809 * \param tc Ptr to the Rx connection structure.
810 * \param fP File descriptor for the cache file.
811 * \param abase Base offset to fetch.
812 * \param adc Ptr to the dcache entry for the file, write-locked.
813 * \param avc Ptr to the vcache entry for the file.
814 * \param size Amount of data that should be fetched.
815 * \param tsmall Ptr to the afs_FetchOutput structure.
817 * \note Environment: Nothing interesting.
820 afs_CacheFetchProc(register struct afs_conn *tc,
821 register struct osi_file *fP, afs_size_t abase,
822 struct dcache *adc, struct vcache *avc,
824 struct afs_FetchOutput *tsmall)
826 register afs_int32 code;
828 afs_uint32 bytesread, byteswritten;
829 struct fetchOps *ops = NULL;
832 register int offset = 0;
836 struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */
837 osi_timeval_t xferStartTime, /*FS xfer start time */
838 xferStopTime; /*FS xfer stop time */
839 afs_size_t bytesToXfer = 0, bytesXferred = 0;
842 AFS_STATCNT(CacheFetchProc);
844 XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHDATA);
846 code = rxfs_fetchInit(tc, avc, abase, size, &length, adc, fP, &ops, &rock);
850 &(afs_stats_cmfullperf.rpc.fsXferTimes[AFS_STATS_FS_XFERIDX_FETCHDATA]);
851 osi_GetuTime(&xferStartTime);
852 #endif /* AFS_NOSTATS */
854 adc->validPos = abase;
858 code = (*ops->more)(rock, &length, &moredata);
863 * The fetch protocol is extended for the AFS/DFS translator
864 * to allow multiple blocks of data, each with its own length,
865 * to be returned. As long as the top bit is set, there are more
868 * We do not do this for AFS file servers because they sometimes
869 * return large negative numbers as the transfer size.
871 if (avc->f.states & CForeign) {
872 moredata = length & 0x80000000;
873 length &= ~0x80000000;
878 bytesToXfer += length;
879 #endif /* AFS_NOSTATS */
881 #ifdef RX_KERNEL_TRACE
882 afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
885 code = (*ops->read)(rock, length, &bytesread);
886 #ifdef RX_KERNEL_TRACE
887 afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
891 bytesXferred += bytesread;
892 #endif /* AFS_NOSTATS */
894 afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ,
895 ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,
896 ICL_TYPE_INT32, length);
900 code = (*ops->write)(rock, fP, offset, bytesread, &byteswritten);
906 adc->validPos = abase;
907 if (afs_osi_Wakeup(&adc->validPos) == 0)
908 afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING,
909 __FILE__, ICL_TYPE_INT32, __LINE__,
910 ICL_TYPE_POINTER, adc, ICL_TYPE_INT32,
916 code = (*ops->close)(rock, avc, adc, tsmall);
917 (*ops->destroy)(&rock, code);
920 osi_GetuTime(&xferStopTime);
923 (xferP->numSuccesses)++;
924 afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] += bytesXferred;
926 (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] >> 10);
927 afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] &= 0x3FF;
928 if (bytesXferred < xferP->minBytes)
929 xferP->minBytes = bytesXferred;
930 if (bytesXferred > xferP->maxBytes)
931 xferP->maxBytes = bytesXferred;
934 * Tally the size of the object. Note: we tally the actual size,
935 * NOT the number of bytes that made it out over the wire.
937 if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0)
939 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1)
941 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2)
943 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3)
945 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4)
947 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5)
949 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6)
951 else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7)
956 afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime);
957 afs_stats_AddTo((xferP->sumTime), elapsedTime);
958 afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime);
959 if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) {
960 afs_stats_TimeAssign((xferP->minTime), elapsedTime);
962 if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) {
963 afs_stats_TimeAssign((xferP->maxTime), elapsedTime);