if ((afs_indexFlags[index] & IFDataMod)
&& (afs_indexUnique[index] == avc->f.fid.Fid.Unique)) {
tdc = afs_GetValidDSlot(index); /* refcount+1. */
+ if (!tdc) {
+ ReleaseWriteLock(&afs_xdcache);
+ code = EIO;
+ goto done;
+ }
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid) && tdc->f.chunk >= minj) {
off = tdc->f.chunk - minj;
minj += NCHUNKSATONCE;
} while (!code && moredata);
+ done:
UpgradeSToWLock(&avc->lock, 29);
/* send a trivial truncation store if did nothing else */
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetValidDSlot(index);
+ if (!tdc) osi_Panic("afs_StoreAllSegments tdc dv");
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)
UpgradeSToWLock(&tdc->lock, 678);
hset(tdc->f.versionNo, avc->f.m.DataVersion);
tdc->dflags |= DFEntryMod;
+ /* DWriting may not have gotten cleared above, if all
+ * we did was a StoreMini */
+ tdc->f.states &= ~DWriting;
ConvertWToSLock(&tdc->lock);
}
}
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetValidDSlot(index);
+ if (!tdc) osi_Panic("afs_InvalidateAllSegments tdc count");
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid))
dcListMax++;
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetValidDSlot(index);
+ if (!tdc) osi_Panic("afs_InvalidateAllSegments tdc store");
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
/* same file? we'll zap it */
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetValidDSlot(index);
+ if (!tdc) {
+ ReleaseWriteLock(&afs_xdcache);
+ code = EIO;
+ goto done;
+ }
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid))
dcCount++;
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetValidDSlot(index);
+ if (!tdc) osi_Panic("afs_TruncateAllSegments tdc");
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
/* same file, and modified, we'll store it back */
ObtainSharedLock(&tdc->lock, 672);
if (newSize < tdc->f.chunkBytes && newSize < MAX_AFS_UINT32) {
UpgradeSToWLock(&tdc->lock, 673);
+ tdc->f.states |= DWriting;
tfile = afs_CFileOpen(&tdc->f.inode);
afs_CFileTruncate(tfile, (afs_int32)newSize);
afs_CFileClose(tfile);
osi_Free(tdcArray, dcCount * sizeof(struct dcache *));
+ code = 0;
+
+ done:
#if (defined(AFS_SUN5_ENV))
ObtainWriteLock(&avc->vlock, 547);
if (--avc->activeV == 0 && (avc->vstates & VRevokeWait)) {
ReleaseWriteLock(&avc->vlock);
#endif
- return 0;
+ return code;
}