for (j = 0; index != NULLIDX;) {
if ((afs_indexFlags[index] & IFDataMod)
&& (afs_indexUnique[index] == avc->f.fid.Fid.Unique)) {
- tdc = afs_GetDSlot(index); /* refcount+1. */
+ 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 */
index != NULLIDX && safety < afs_cacheFiles + 2;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
- tdc = afs_GetDSlot(index);
+ tdc = afs_GetValidDSlot(index);
+ if (!tdc) osi_Panic("afs_StoreAllSegments tdc dv");
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
- tdc = afs_GetDSlot(index);
+ 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_GetDSlot(index);
+ 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 */
dcCount = 0;
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
- tdc = afs_GetDSlot(index);
+ 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_GetDSlot(index);
+ 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 */
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;
}