return 0;
}
+/*!
+ * Check if a dcache is "fresh". That is, if the dcache's DV matches the DV of
+ * the vcache for that file.
+ *
+ * \param adc The dcache to check
+ * \param avc The vcache for adc
+ *
+ * \return 1 if the dcache does match avc's DV; 0 otherwise.
+ */
+int
+afs_IsDCacheFresh(struct dcache *adc, struct vcache *avc)
+{
+ if (!hsame(adc->f.versionNo, avc->f.m.DataVersion)) {
+ return 0;
+ }
+ return 1;
+}
+
/*
* afs_GetDCache
*
updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src)
{
if (!lockVc || 0 == NBObtainWriteLock(&v->lock, src)) {
- if (hsame(v->f.m.DataVersion, d->f.versionNo) && v->callback)
+ if (afs_IsDCacheFresh(d, v) && v->callback)
v->dchint = d;
if (lockVc)
ReleaseWriteLock(&v->lock);
ReleaseReadLock(&afs_xdcache);
shortcut = 1;
- if (hsame(tdc->f.versionNo, avc->f.m.DataVersion)
+ if (afs_IsDCacheFresh(tdc, avc)
&& !(tdc->dflags & DFFetching)) {
afs_stats_cmperf.dcacheHits++;
if (AFS_CHUNKTOBASE(chunk) >= avc->f.m.Length &&
#endif
#endif /* defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) */
- !hsame(avc->f.m.DataVersion, tdc->f.versionNo))
+ !afs_IsDCacheFresh(tdc, avc))
doReallyAdjustSize = 1;
if (doReallyAdjustSize || overWriteWholeChunk) {
* avc->lock(W) if !setLocks || slowPass
* tdc->lock(S)
*/
- if (!hsame(avc->f.m.DataVersion, tdc->f.versionNo) && !overWriteWholeChunk) {
+ if (!afs_IsDCacheFresh(tdc, avc) && !overWriteWholeChunk) {
/*
* Version number mismatch.
*/
*/
/* Watch for standard race condition around osi_FlushText */
- if (hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+ if (afs_IsDCacheFresh(tdc, avc)) {
updateV2DC(setLocks, avc, tdc, 569); /* set hint */
afs_stats_cmperf.dcacheHits++;
ConvertWToSLock(&tdc->lock);
tdc = afs_FindDCache(avc, filePos);
if (tdc) {
ObtainWriteLock(&tdc->lock, 658);
- if (!hsame(tdc->f.versionNo, avc->f.m.DataVersion)
+ if (!afs_IsDCacheFresh(tdc, avc)
|| (tdc->dflags & DFFetching)) {
ReleaseWriteLock(&tdc->lock);
afs_PutDCache(tdc);