[OpenAFS-devel] patch: enable bulkstat

Nickolai Zeldovich kolya@MIT.EDU
Wed, 29 Nov 2000 04:55:34 -0500


The patch below should make bulkstat functional; in its current
state, afs_ProcessFS() called from afs_DoBulkStat() will always
modify tvcp->m.Length, thus causing the subsequent check of that
value to fail. I'm not very familiar with AFS locking semantics,
but it seems like obtaining the xcbhash lock prior to the second
check and then doing the afs_ProcessFS() should be ok; nothing
in afs_ProcessFS() should need afs_xcbhash, and we're already
holding tvcp->lock.

I've tested it somewhat, and it appears to work, with a noticeably
faster stat(). If someone more familiar with AFS locking could
look over it, and possibly commit it to the repository, I'd
appreciate it.

-- kolya

Index: VNOPS/afs_vnop_lookup.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v
retrieving revision 1.2
diff -c -r1.2 afs_vnop_lookup.c
*** VNOPS/afs_vnop_lookup.c	2000/11/04 10:03:31	1.2
--- VNOPS/afs_vnop_lookup.c	2000/11/29 09:44:33
***************
*** 637,642 ****
--- 637,643 ----
        /* actually a serious error, probably should panic. Probably will 
         * panic soon, oh well. */
        ReleaseReadLock(&afs_xvcache);
+       afs_warnuser("afs_DoBulkStat: VLRU empty!");
        goto done;
      }
      if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
***************
*** 739,750 ****
--- 740,754 ----
  	   refpanic ("Bulkstat VLRU inconsistent6");
  	ReleaseWriteLock(&afs_xvcache);
  
+ 	ObtainWriteLock(&afs_xcbhash, 494);
+ 
  	/* We need to check the flags again. We may have missed
  	 * something while we were waiting for a lock.
  	 */
  	if (!(tvcp->states & CBulkFetching) || (tvcp->m.Length != statSeqNo)) {
  	    flagIndex++;
  	    ReleaseWriteLock(&tvcp->lock);
+ 	    ReleaseWriteLock(&afs_xcbhash);
  	    afs_PutVCache(tvcp);
  	    continue;
  	}
***************
*** 760,778 ****
  	else if (vType(tvcp) == VLNK)
  	    tvcp->v.v_op = &afs_symlink_iops;
  #endif
- 
- 	ObtainWriteLock(&afs_xcbhash, 494);
- 
- 	/* We need to check the flags once more. We may have missed
- 	 * something while we were waiting for a lock.
- 	 */
- 	if (!(tvcp->states & CBulkFetching) || (tvcp->m.Length != statSeqNo)) {
- 	    flagIndex++;
- 	    ReleaseWriteLock(&afs_xcbhash);
- 	    ReleaseWriteLock(&tvcp->lock);
- 	    afs_PutVCache(tvcp);
- 	    continue;
- 	}
  
  	/* do some accounting for bulk stats: mark this entry as
  	 * loaded, so we can tell if we use it before it gets
--- 764,769 ----