{
struct afs_stats_xferData *xferP;
osi_timeval_t xferStopTime;
- XSTATS_DECLS;
+ osi_timeval_t elapsedTime;
xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[idx]);
osi_GetuTime(&xferStopTime);
struct rx_call *call;
char *tbuffer;
struct iovec *tiov;
- afs_uint32 tnio;
+ afs_int32 tnio;
afs_int32 hasNo64bit;
struct AFSStoreStatus InStatus;
};
RX_AFS_GLOCK();
if (code <= 0) {
code = rx_Error(v->call);
- if ( !code )
+ if (!code)
code = -33;
}
else {
rxfs_storePadd(void *rock, afs_uint32 size)
{
afs_int32 code = 0;
- int bsent, tlen;
+ afs_uint32 tlen;
struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock;
- if ( !v->tbuffer )
+ if (!v->tbuffer)
v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
memset(v->tbuffer, 0, AFS_LRALLOCSIZ);
- while (size > 0) {
+ while (size) {
tlen = (size > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : size);
RX_AFS_GUNLOCK();
code = rx_Write(v->call, v->tbuffer, tlen);
return -33; /* XXX */
size -= tlen;
}
- return code;
+ return 0;
}
afs_int32
*r = NULL;
if (v->call) {
- afs_int32 code2;
RX_AFS_GUNLOCK();
- code2 = rx_EndCall(v->call, code);
+ code = rx_EndCall(v->call, error);
RX_AFS_GLOCK();
- if (code2)
- code = code2;
+ if (!code && error)
+ code = error;
}
if (v->tbuffer)
osi_FreeLargeSpace(v->tbuffer);
};
afs_int32
-rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, afs_size_t tlen,
- afs_size_t bytes, afs_size_t base,
+rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, afs_size_t base,
+ afs_size_t bytes, afs_size_t length,
int sync, struct storeOps **ops, void **rock)
{
afs_int32 code;
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);
+ code = StartRXAFS_StoreData64(
+ v->call, (struct AFSFid*)&avc->f.fid.Fid,
+ &v->InStatus, base, bytes, length);
else
- if (tlen > 0xFFFFFFFF)
+ if (length > 0xFFFFFFFF)
code = EFBIG;
else {
- afs_int32 t1 = base, t2 = bytes, t3 = tlen;
+ afs_int32 t1 = base, t2 = bytes, t3 = length;
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);
+ &v->InStatus, base, bytes, length);
#endif /* AFS_64BIT_CLIENT */
} else
code = -1;
/* for now, only do 'continue from close' code if file fits in one
* chunk. Could clearly do better: if only one modified chunk
* then can still do this. can do this on *last* modified chunk */
- tlen = avc->f.m.Length - 1; /* byte position of last byte we'll store */
+ length = avc->f.m.Length - 1; /* byte position of last byte we'll store */
if (shouldWake) {
- if (AFS_CHUNK(tlen) != 0)
+ if (AFS_CHUNK(length) != 0)
*shouldWake = 0;
else
*shouldWake = 1;
for (i = 0; i < nchunks && !code; i++) {
int stored = 0;
- struct osi_file *fP;
+ struct osi_file *tfile;
int offset = 0;
struct dcache *tdc = dclist[i];
- afs_int32 alen = tdc->f.chunkBytes;
+ afs_int32 size = tdc->f.chunkBytes;
if (!tdc) {
afs_warn("afs: missing dcache!\n");
storeallmissing++;
else if ((afs_uint32) avc->asynchrony >= (bytes - stored))
shouldwake = &nomore;
}
- fP = afs_CFileOpen(&tdc->f.inode);
+ tfile = 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_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, size);
AFS_STATCNT(CacheStoreProc);
avc->f.truncPos = AFS_NOTRUNC;
#ifndef AFS_NOSTATS
/*
- * In this case, alen is *always* the amount of data we'll be trying
+ * In this case, size is *always* the amount of data we'll be trying
* to ship here.
*/
- bytesToXfer = alen;
+ bytesToXfer = size;
bytesXferred = 0;
osi_GetuTime(&xferStartTime);
#endif /* AFS_NOSTATS */
- while ( alen > 0 ) {
+ while ( size > 0 ) {
afs_uint32 tlen;
- afs_int32 bytesread, byteswritten;
- code = (*ops->prepare)(rock, alen, &tlen);
+ afs_uint32 bytesread, byteswritten;
+ code = (*ops->prepare)(rock, size, &tlen);
if ( code )
break;
- code = (*ops->read)(rock, fP, offset, tlen, &bytesread);
+ code = (*ops->read)(rock, tfile, offset, tlen, &bytesread);
if (code)
break;
#endif /* AFS_NOSTATS */
offset += tlen;
- alen -= tlen;
+ size -= tlen;
/*
* if file has been locked on server, can allow
* store to continue
}
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_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, size);
#ifndef AFS_NOSTATS
FillStoreStats(code, AFS_STATS_FS_XFERIDX_STOREDATA,
&xferStartTime, bytesToXfer, bytesXferred);
#endif /* AFS_NOSTATS */
- afs_CFileClose(fP);
+ afs_CFileClose(tfile);
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);
-
- 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);
- RX_AFS_GLOCK();
-
- if (bsent != tlen) {
- code = -33; /* XXX */
- break;
- }
- sbytes -= tlen;
- }
- osi_FreeLargeSpace(tbuffer);
+ code = (*ops->padd)(rock, afs_OtherCSize - tdc->f.chunkBytes);
}
stored += tdc->f.chunkBytes;
/* ideally, I'd like to unlock the dcache and turn
}
XSTATS_END_TIME;
}
- code = (*ops->destroy)(&rock, code);
+ if (ops)
+ code = (*ops->destroy)(&rock, code);
return code;
}
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;
}
}
if (bytes && (j == high || !dcList[j + 1])) {
+ afs_uint32 nchunks;
struct dcache **dclist = &dcList[first];
/* base = AFS_CHUNKTOBASE(dcList[first]->f.chunk); */
base = AFS_CHUNKTOBASE(first + minj);
ICL_HANDLE_OFFSET(length));
do {
- tc = afs_Conn(&avc->f.fid, areq, 0);
+ 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 )
- goto nocall;
-
- code = afs_CacheStoreDCaches(avc, dclist, bytes, anewDV,
- &doProcessFS, &OutStatus, nchunks, nomore, ops, rock);
+ code = rxfs_storeInit(avc, tc, base, bytes, length,
+ sync, &ops, &rock);
+ if ( !code ) {
+ code = afs_CacheStoreDCaches(avc, dclist, bytes, anewDV,
+ &doProcessFS, &OutStatus,
+ nchunks, nomore, ops, rock);
+ }
-nocall:
#ifdef AFS_64BIT_CLIENT
if (code == RXGEN_OPCODE && !afs_serverHasNo64Bit(tc)) {
afs_serverSetNo64Bit(tc);
goto restart;
}
-#else
- continue; /* dummy, label before block end won't work */
#endif /* AFS_64BIT_CLIENT */
} while (afs_Analyze
(tc, code, &avc->f.fid, areq,
struct rx_call *call;
char *tbuffer;
struct iovec *iov;
- afs_uint32 nio;
+ afs_int32 nio;
afs_int32 hasNo64bit;
afs_int32 iovno;
afs_int32 iovmax;
}
afs_int32
-rxfs_fetchMore(void *r, afs_uint32 *length, afs_uint32 *moredata)
+rxfs_fetchMore(void *r, afs_int32 *length, afs_uint32 *moredata)
{
afs_int32 code;
- register struct rxfs_fetchVariables *v
- = (struct rxfs_fetchVariables *)r;
+ struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r;
/*
* The fetch protocol is extended for the AFS/DFS translator
* We do not do this for AFS file servers because they sometimes
* return large negative numbers as the transfer size.
*/
- RX_AFS_GUNLOCK();
- code = rx_Read(v->call, (void *)length, sizeof(afs_int32));
- RX_AFS_GLOCK();
- *length = ntohl(*length);
- if (code != sizeof(afs_int32)) {
- code = rx_Error(v->call);
- *moredata = 0;
- return (code ? code : -1); /* try to return code, not -1 */
+ if (*moredata) {
+ RX_AFS_GUNLOCK();
+ code = rx_Read(v->call, (void *)length, sizeof(afs_int32));
+ RX_AFS_GLOCK();
+ *length = ntohl(*length);
+ if (code != sizeof(afs_int32)) {
+ code = rx_Error(v->call);
+ *moredata = 0;
+ return (code ? code : -1); /* try to return code, not -1 */
+ }
}
*moredata = *length & 0x80000000;
*length &= ~0x80000000;
};
afs_int32
-rxfs_fetchInit(register struct afs_conn *tc, struct vcache *avc,afs_offs_t base,
- afs_uint32 size, afs_uint32 *alength, afs_uint32 *moredata,
- struct dcache *adc,
+rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base,
+ afs_uint32 size, afs_int32 *alength, struct dcache *adc,
struct osi_file *fP, struct fetchOps **ops, void **rock)
{
struct rxfs_fetchVariables *v;
int code = 0, code1;
- afs_uint32 length_hi = 0, length, bytes;
+#ifdef AFS_64BIT_CLIENT
+ afs_uint32 length_hi = 0;
+#endif
+ afs_uint32 length, bytes;
v = (struct rxfs_fetchVariables *) osi_AllocSmallSpace(sizeof(struct rxfs_fetchVariables));
if (!v)
if (bytes == sizeof(afs_int32))
length = ntohl(length);
else {
+ RX_AFS_GUNLOCK();
code = rx_Error(v->call);
+ code1 = rx_EndCall(v->call, code);
+ v->call = NULL;
+ RX_AFS_GLOCK();
}
}
FillInt64(length64, length_hi, length);
ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,
ICL_TYPE_OFFSET,
ICL_HANDLE_OFFSET(length64));
- *alength = length64;
+ *alength = length;
#else /* AFS_64BIT_CLIENT */
RX_AFS_GUNLOCK();
code = StartRXAFS_FetchData(v->call, (struct AFSFid *)&avc->f.fid.Fid,
*alength = ntohl(length);
} else {
code = rx_Error(v->call);
+ code1 = rx_EndCall(v->call, code);
+ v->call = NULL;
}
}
#endif /* AFS_64BIT_CLIENT */
osi_FreeSmallSpace(v);
return code;
}
- /*
- * The fetch protocol is extended for the AFS/DFS translator
- * to allow multiple blocks of data, each with its own length,
- * to be returned. As long as the top bit is set, there are more
- * blocks expected.
- *
- * We do not do this for AFS file servers because they sometimes
- * return large negative numbers as the transfer size.
- *
- * Also omit if length > 2^32, as bit 31 is part of the number then.
- * Known to never be the case ifndef AFS_64BIT_CLIENT.
- */
- if (avc->f.states & CForeign && !length_hi) {
- *moredata = length & 0x80000000;
- length &= ~0x80000000;
- }
if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (!v->tbuffer)
* \note Environment: Nothing interesting.
*/
int
-afs_CacheFetchProc(register struct afs_conn *tc,
- register struct osi_file *fP, afs_size_t base,
- struct dcache *adc, struct vcache *avc,
- afs_int32 size,
+afs_CacheFetchProc(struct afs_conn *tc, struct osi_file *fP, afs_size_t base,
+ struct dcache *adc, struct vcache *avc, afs_int32 size,
struct afs_FetchOutput *tsmall)
{
- register afs_int32 code;
- afs_uint32 length;
+ afs_int32 code;
+ afs_int32 length;
afs_uint32 bytesread, byteswritten;
struct fetchOps *ops = NULL;
void *rock = NULL;
- int moredata = 0;
- register int offset = 0;
+ afs_uint32 moredata = 0;
+ int offset = 0;
XSTATS_DECLS;
#ifndef AFS_NOSTATS
* adc->lock(W)
*/
code = rxfs_fetchInit(
- tc, avc, base, size, &length, &moredata, adc, fP, &ops, &rock);
+ tc, avc, base, size, &length, adc, fP, &ops, &rock);
#ifndef AFS_NOSTATS
osi_GetuTime(&xferStartTime);
}
if ( !code ) do {
- if ((avc->f.states & CForeign) && moredata && !length) {
+ if (avc->f.states & CForeign) {
code = (*ops->more)(rock, &length, &moredata);
if ( code )
break;
} while (moredata);
if (!code)
code = (*ops->close)(rock, avc, adc, tsmall);
- (*ops->destroy)(&rock, code);
+ if (ops)
+ (*ops->destroy)(&rock, code);
#ifndef AFS_NOSTATS
- FillStoreStats(code, AFS_STATS_FS_XFERIDX_FETCHDATA,&xferStartTime,
+ FillStoreStats(code, AFS_STATS_FS_XFERIDX_FETCHDATA, &xferStartTime,
bytesToXfer, bytesXferred);
#endif
XSTATS_END_TIME;