"This patch fixes a deadlock in the new dcache locking scheme.
The underlying bug apparently existed before, but due to the
absence of locking, it probably resulted in spuriously high
refcounts rather than deadlock.
The problem happens when there are zero-length dcache entries
associated with a file; this is demonstrated by fsx, which
hangs after running on AFS for a while. The writeback loop
never releases dcache entries unless they're stored back to
the server as part of a sequential byte range."
tdc->dflags |= DFEntryMod;
ReleaseWriteLock(&tdc->lock);
afs_PutDCache(tdc);
+ /* Mark the entry as released */
+ dclist[i] = NULL;
}
if (code) {
if ( dcList[j] ) {
ReleaseSharedLock(&(dcList[j]->lock));
afs_PutDCache(dcList[j]);
+ /* Releasing entry */
+ dcList[j] = NULL;
}
}
}
bytes = 0;
}
}
+
+ /* Release any zero-length dcache entries in our interval
+ * that we locked but didn't store back above.
+ */
+ for (j = 0; j<=high; j++) {
+ tdc = dcList[j];
+ if (tdc) {
+ osi_Assert(tdc->f.chunkBytes == 0);
+ ReleaseSharedLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ }
+ }
} /* if (j) */
minj += NCHUNKSATONCE;