Initialize xferStartTime for StoreData timings
[openafs.git] / src / afs / afs_fetchstore.c
index 06572a6..5688449 100644 (file)
@@ -193,29 +193,25 @@ rxfs_storeUfsWrite(void *r, afs_uint32 l, afs_uint32 *byteswritten)
 }
 
 afs_int32
-rxfs_storePadd(void *rock, afs_uint32 sbytes)
+rxfs_storePadd(void *rock, afs_uint32 size)
 {
     afs_int32 code = 0;
     int bsent, tlen;
     struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock;
-    char *tbuffer = v->tbuffer;
 
-    if ( !tbuffer )
-       tbuffer = v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+    if ( !v->tbuffer )
+       v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+    memset(v->tbuffer, 0, AFS_LRALLOCSIZ);
 
-    while (sbytes > 0) {
-       tlen = (sbytes > AFS_LRALLOCSIZ
-                           ? AFS_LRALLOCSIZ : sbytes);
-       memset(tbuffer, 0, tlen);
+    while (size > 0) {
+       tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
        RX_AFS_GUNLOCK();
-       bsent = rx_Write(v->call, tbuffer, tlen);
+       code = rx_Write(v->call, v->tbuffer, tlen);
        RX_AFS_GLOCK();
 
-       if (bsent != tlen) {
-           code = -33; /* XXX */
-           break;
-       }
-       sbytes -= tlen;
+       if (code != tlen)
+           return -33; /* XXX */
+       size -= tlen;
     }
     return code;
 }
@@ -446,6 +442,7 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
        bytesToXfer = alen;
        bytesXferred = 0;
 
+       GetuTime(&xferStartTime);
 #endif /* AFS_NOSTATS */
 
        while ( alen > 0 ) {
@@ -546,15 +543,11 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
  * \note Environment: Nothing interesting.
  */
 int
-afs_CacheStoreVCache(struct dcache **dcList,
-                       struct vcache *avc,
-                       struct vrequest *areq,
-                       int sync,
-                       unsigned int minj,
-                       unsigned int high,
+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_hyper_t *anewDV, afs_size_t *amaxStoredLength)
 {
     afs_int32 code = 0;
     struct storeOps *ops;
@@ -865,7 +858,7 @@ struct fetchOps rxfs_fetchMemOps = {
 
 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;
@@ -921,9 +914,8 @@ rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
            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);
@@ -963,7 +955,7 @@ rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
         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");
@@ -979,14 +971,13 @@ rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
         * 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;
 }