solaris-locking-cleanup-20010806
[openafs.git] / src / afs / afs_dcache.c
index 478d3d8..1f14860 100644 (file)
 /*
  * Implements:
  */
-#include "../afs/param.h"       /*Should be always first*/
+#include <afsconfig.h>
+#include "../afs/param.h"
+
+RCSID("$Header$");
+
 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
 #include "../afs/afs_stats.h"  /* statistics */
@@ -1237,7 +1241,7 @@ static int afs_UFSCacheStoreProc(acall, afile, alen, avc, shouldWake,
        tlen = (alen > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : alen);
        got = afs_osi_Read(afile, -1, tbuffer, tlen);
        if ((got < 0) 
-#if    !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
+#if    !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
            || (got != tlen && getuerror())
 #endif
            ) {
@@ -1428,14 +1432,18 @@ struct tlocal1 {
 
 /* these fields are protected by the lock on the vcache and luck 
  * on the dcache */
-#define updateV2DC(l,v,d,src) { if (l) ObtainWriteLock(&((v)->lock),src);\
-    if (hsame((v)->m.DataVersion, (d)->f.versionNo) && (v)->callback) { \
-       (v)->quick.dc = (d);                                          \
-       (v)->quick.stamp = (d)->stamp = MakeStamp();                  \
-       (v)->quick.minLoc = AFS_CHUNKTOBASE((d)->f.chunk);            \
-  /* Don't think I need these next two lines forever */       \
-       (v)->quick.len = (d)->f.chunkBytes;                           \
-       (v)->h1.dchint = (d); }  if(l) ReleaseWriteLock(&((v)->lock)); }
+#define updateV2DC(l,v,d,src) { \
+    if (!l || 0 == NBObtainWriteLock(&((v)->lock),src)) { \
+       if (hsame((v)->m.DataVersion, (d)->f.versionNo) && (v)->callback) { \
+           (v)->quick.dc = (d);                                          \
+           (v)->quick.stamp = (d)->stamp = MakeStamp();                  \
+           (v)->quick.minLoc = AFS_CHUNKTOBASE((d)->f.chunk);            \
+           /* Don't think I need these next two lines forever */         \
+           (v)->quick.len = (d)->f.chunkBytes;                           \
+           (v)->h1.dchint = (d);                                         \
+       }                                                                 \
+       if(l) ReleaseWriteLock(&((v)->lock));                             \
+    } }
 
 struct dcache *afs_GetDCache(avc, abyte, areq, aoffset, alen, aflags)
     register struct vcache *avc;    /*Held*/
@@ -2300,7 +2308,7 @@ struct dcache *afs_UFSGetDSlot(aslot, tmpdc)
        tdc->f.chunk = -1;
        hones(tdc->f.versionNo);
        tdc->flags |= DFEntryMod;
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
        last_error = getuerror();
 #endif
        lasterrtime = osi_Time();