* We're write-locked upon entry.
*/
-int
+static int
afs_StoreMini(register struct vcache *avc, struct vrequest *areq)
{
register struct afs_conn *tc;
struct AFSStoreStatus InStatus;
struct AFSFetchStatus OutStatus;
struct AFSVolSync tsync;
- register afs_int32 code;
+ register afs_int32 code, code2;
register struct rx_call *tcall;
afs_size_t tlen, xlen = 0;
XSTATS_DECLS;
l2 = tlen;
if ((avc->f.m.Length > 0x7fffffff) ||
(tlen > 0x7fffffff) ||
- ((0x7fffffff - tlen) < avc->f.m.Length))
+ ((0x7fffffff - tlen) < avc->f.m.Length)) {
+ RX_AFS_GLOCK();
return EFBIG;
+ }
code =
StartRXAFS_StoreData(tcall,
(struct AFSFid *)&avc->f.fid.Fid,
if (code == 0) {
code = EndRXAFS_StoreData(tcall, &OutStatus, &tsync);
}
- code = rx_EndCall(tcall, code);
+ code2 = rx_EndCall(tcall, code);
+ if (code2 && !code)
+ code = code2;
RX_AFS_GLOCK();
XSTATS_END_TIME;
#ifdef AFS_64BIT_CLIENT
(tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA,
SHARED_LOCK, NULL));
- if (code == 0) {
+ if (code == 0)
afs_ProcessFS(avc, &OutStatus, areq);
- } else {
- /* blew it away */
- afs_InvalidateAllSegments(avc);
- }
- return code;
+ return code;
} /*afs_StoreMini */
/*
unsigned int i, j, minj, moredata, high, off;
afs_size_t tlen;
afs_size_t maxStoredLength; /* highest offset we've written to server. */
- int safety;
+ int safety, marineronce = 0;
AFS_STATCNT(afs_StoreAllSegments);
minj = 0;
do {
- memset((char *)dcList, 0, NCHUNKSATONCE * sizeof(struct dcache *));
+ memset(dcList, 0, NCHUNKSATONCE * sizeof(struct dcache *));
high = 0;
moredata = FALSE;
/* lock and start over from beginning of hash chain
* in order to avoid a race condition. */
- MObtainWriteLock(&afs_xdcache, 284);
+ ObtainWriteLock(&afs_xdcache, 284);
index = afs_dvhashTbl[hash];
for (j = 0; index != NULLIDX;) {
if (off < NCHUNKSATONCE) {
if (dcList[off])
osi_Panic("dclist slot already in use!");
+ if (afs_mariner && !marineronce) {
+ /* first chunk only */
+ afs_MarinerLog("store$Storing", avc);
+ marineronce++;
+ }
dcList[off] = tdc;
if (off > high)
high = off;
}
index = afs_dvnextTbl[index];
}
- MReleaseWriteLock(&afs_xdcache);
+ ReleaseWriteLock(&afs_xdcache);
/* this guy writes chunks, puts back dcache structs, and bumps newDV */
/* "moredata" just says "there are more dirty chunks yet to come".
do {
moredata = FALSE;
- memset((char *)dcList, 0,
+ memset(dcList, 0,
NCHUNKSATONCE * sizeof(struct dcache *));
/* overkill, but it gets the lock in case GetDSlot needs it */
- MObtainWriteLock(&afs_xdcache, 285);
+ ObtainWriteLock(&afs_xdcache, 285);
for (j = 0, safety = 0, index = afs_dvhashTbl[hash];
index != NULLIDX && safety < afs_cacheFiles + 2;) {
index = afs_dvnextTbl[index];
}
- MReleaseWriteLock(&afs_xdcache);
+ ReleaseWriteLock(&afs_xdcache);
for (i = 0; i < j; i++) {
/* Iterate over the dcache entries we collected above */
* invalidated. Also discard data if it's a permanent error from the
* fileserver.
*/
- if (areq->permWriteError || (avc->f.states & (CCore1 | CCore))) {
+ if (areq->permWriteError || (avc->f.states & CCore)) {
afs_InvalidateAllSegments(avc);
}
}
/* Blow away pages; for now, only for Solaris */
#if (defined(AFS_SUN5_ENV))
if (WriteLocked(&avc->lock))
- osi_ReleaseVM(avc, (struct AFS_UCRED *)0);
+ osi_ReleaseVM(avc, (afs_ucred_t *)0);
#endif
/*
* Block out others from screwing with this table; is a read lock
* sufficient?
*/
- MObtainWriteLock(&afs_xdcache, 286);
+ ObtainWriteLock(&afs_xdcache, 286);
dcListMax = 0;
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
}
index = afs_dvnextTbl[index];
}
- MReleaseWriteLock(&afs_xdcache);
+ ReleaseWriteLock(&afs_xdcache);
for (i = 0; i < dcListCount; i++) {
tdc = dcList[i];
*/
int
afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen,
- struct vrequest *areq, struct AFS_UCRED *acred)
+ struct vrequest *areq, afs_ucred_t *acred)
{
register struct dcache *tdc;
register afs_int32 code;
register afs_int32 index;
- afs_int32 newSize;
+ afs_size_t newSize;
int dcCount, dcPos;
struct dcache **tdcArray;
code = DVHash(&avc->f.fid);
/* block out others from screwing with this table */
- MObtainWriteLock(&afs_xdcache, 287);
+ ObtainWriteLock(&afs_xdcache, 287);
dcCount = 0;
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
index = afs_dvnextTbl[index];
}
- MReleaseWriteLock(&afs_xdcache);
+ ReleaseWriteLock(&afs_xdcache);
/* Now we loop over the array of dcache entries and truncate them */
for (index = 0; index < dcPos; index++) {
if (newSize < 0)
newSize = 0;
ObtainSharedLock(&tdc->lock, 672);
- if (newSize < tdc->f.chunkBytes) {
+ if (newSize < tdc->f.chunkBytes && newSize < MAX_AFS_UINT32) {
UpgradeSToWLock(&tdc->lock, 673);
tfile = afs_CFileOpen(&tdc->f.inode);
- afs_CFileTruncate(tfile, newSize);
+ afs_CFileTruncate(tfile, (afs_int32)newSize);
afs_CFileClose(tfile);
- afs_AdjustSize(tdc, newSize);
+ afs_AdjustSize(tdc, (afs_int32)newSize);
if (alen < tdc->validPos) {
if (alen < AFS_CHUNKTOBASE(tdc->f.chunk))
tdc->validPos = 0;