[OpenAFS-devel] another DCache locking bug

Pavel Semerad semerad@ss1000.ms.mff.cuni.cz
Wed, 19 Jun 2002 15:30:16 +0200


Hi,
I have found another small bug in DCache locking. When there is
IO error reading file (one of my disks has errors now), then
reading program segfaults instead of getting IO error.

Here is a patch:


--- src/afs/VNOPS/afs_vnop_read.c Feb 2002 15:05:58 -0000	1.1.1.9
+++ src/afs/VNOPS/afs_vnop_read.c Jun 2002 13:24:42 -0000
@@ -258,7 +258,7 @@ tagain:
 		ReleaseReadLock(&avc->lock);
 		tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1);
 		ObtainReadLock(&avc->lock);
-		ObtainReadLock(&tdc->lock);
+		if (tdc) ObtainReadLock(&tdc->lock);
 	    }
 	}
 
@@ -801,7 +801,7 @@ tagain:
 		ReleaseReadLock(&avc->lock);
 		tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1);
 		ObtainReadLock(&avc->lock);
-		ObtainReadLock(&tdc->lock);
+		if (tdc) ObtainReadLock(&tdc->lock);
 	    }
 	}
 	


Not sure, if there can be problems in following files (somebody with more
knoledge can decide it :-):


--- src/afs/VNOPS/afs_vnop_remove.c May 2002 15:00:58 -0000	1.1.1.13
+++ src/afs/VNOPS/afs_vnop_remove.c Jun 2002 13:20:33 -0000
@@ -313,7 +313,7 @@ tagain:
 
     tdc	= afs_GetDCache(adp, (afs_size_t) 0,	&treq, &offset,	&len, 1);  /* test for error below */
     ObtainWriteLock(&adp->lock,142);
-    ObtainSharedLock(&tdc->lock, 638);
+    if (tdc) ObtainSharedLock(&tdc->lock, 638);
 
     /*
      * Make sure that the data in the cache is current. We may have
--- src/afs/VNOPS/afs_vnop_symlink.c Apr 2002 09:53:23 -0000	1.1.1.10
+++ src/afs/VNOPS/afs_vnop_symlink.c Jun 2002 13:22:25 -0000
@@ -125,7 +125,7 @@ afs_symlink
     tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1);
     volp = afs_FindVolume(&adp->fid, READ_LOCK); /*parent is also in same vol*/
     ObtainWriteLock(&adp->lock,156);
-    ObtainWriteLock(&tdc->lock, 636);
+    if (tdc) ObtainWriteLock(&tdc->lock, 636);
     ObtainSharedLock(&afs_xvcache,17);  /* prevent others from creating this entry */
     /* XXX Pay attention to afs_xvcache around the whole thing!! XXX */
     do {


Pavel Semerad