windows-afsd-reset-acl-cache-20090312
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 14 Mar 2009 04:59:23 +0000 (04:59 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 14 Mar 2009 04:59:23 +0000 (04:59 +0000)
LICENSE MIT

Modify the cm_ResetACLCache interface to accept an optional cm_cell_t *.
At the moment every time a token is set or cleared all of the acl info
for all cm_scache_t objects regardless of cell is reset.  This is both
a performance hit and unnecessary.  If we know the cell, only reset
the acl info for cm_scache_t objects in that cell.

If cell is not specified, reset for all cells.

src/WINNT/afsd/afsd.h
src/WINNT/afsd/cm_aclent.c
src/WINNT/afsd/cm_aclent.h
src/WINNT/afsd/cm_ioctl.c
src/WINNT/afsd/cm_user.c
src/WINNT/afsd/smb3.c
src/WINNT/afsd/smb_ioctl.c

index afa11a8..e0061f3 100644 (file)
@@ -38,9 +38,9 @@ BOOL APIENTRY About(HWND, unsigned int, unsigned int, long);
 #include "cm_diskcache95.h"
 #endif /* DISKCACHE95 */
 #include "cm_conn.h"
+#include "cm_cell.h"
 #include "cm_aclent.h"
 #include "cm_server.h"
-#include "cm_cell.h"
 #include "cm_volstat.h"
 #include "cm_volume.h"
 #include "cm_dcache.h"
index 9182b9a..77a1b5b 100644 (file)
@@ -342,7 +342,7 @@ void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp)
  * Invalidate ACL info for a user that has just        obtained or lost tokens.
  */
 void 
-cm_ResetACLCache(cm_user_t *userp)
+cm_ResetACLCache(cm_cell_t *cellp, cm_user_t *userp)
 {
     cm_scache_t *scp;
     int hash;
@@ -350,13 +350,16 @@ cm_ResetACLCache(cm_user_t *userp)
     lock_ObtainWrite(&cm_scacheLock);
     for (hash=0; hash < cm_data.scacheHashTableSize; hash++) {
         for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) {
-            cm_HoldSCacheNoLock(scp);
-            lock_ReleaseWrite(&cm_scacheLock);
-            lock_ObtainWrite(&scp->rw);
-            cm_InvalidateACLUser(scp, userp);
-            lock_ReleaseWrite(&scp->rw);
-            lock_ObtainWrite(&cm_scacheLock);
-            cm_ReleaseSCacheNoLock(scp);
+            if (cellp == NULL || 
+                scp->fid.cell == cellp->cellID) {
+                cm_HoldSCacheNoLock(scp);
+                lock_ReleaseWrite(&cm_scacheLock);
+                lock_ObtainWrite(&scp->rw);
+                cm_InvalidateACLUser(scp, userp);
+                lock_ReleaseWrite(&scp->rw);
+                lock_ObtainWrite(&cm_scacheLock);
+                cm_ReleaseSCacheNoLock(scp);
+            }
         }
     }
     lock_ReleaseWrite(&cm_scacheLock);
index 27e0ec3..fae82bb 100644 (file)
@@ -47,6 +47,6 @@ extern long cm_ValidateACLCache(void);
 
 extern long cm_ShutdownACLCache(void);
 
-extern void cm_ResetACLCache(cm_user_t *userp);
+extern void cm_ResetACLCache(cm_cell_t *cellp, cm_user_t *userp);
 
 #endif  /* _CM_ACLENT_H_ */
index c4abe3b..0167bc9 100644 (file)
@@ -2354,7 +2354,7 @@ cm_IoctlSetToken(struct cm_ioctl *ioctlp, struct cm_user *userp)
         ioctlp->flags |= CM_IOCTLFLAG_LOGON;
     }
 
-    cm_ResetACLCache(userp);
+    cm_ResetACLCache(cellp, userp);
 
     if (release_userp)
        cm_ReleaseUser(userp);
@@ -2577,7 +2577,7 @@ cm_IoctlDelToken(struct cm_ioctl *ioctlp, struct cm_user *userp)
 
     lock_ReleaseMutex(&userp->mx);
 
-    cm_ResetACLCache(userp);
+    cm_ResetACLCache(cellp, userp);
 
     return 0;
 }
@@ -2612,7 +2612,7 @@ cm_IoctlDelAllToken(struct cm_ioctl *ioctlp, struct cm_user *userp)
 
     lock_ReleaseMutex(&userp->mx);
 
-    cm_ResetACLCache(userp);
+    cm_ResetACLCache(NULL, userp);
 
     return 0;
 }
index 47e00be..d3e4c93 100644 (file)
@@ -189,7 +189,7 @@ void cm_CheckTokenCache(time_t now)
             lock_ReleaseMutex(&userp->mx);
             if (bExpired) {
                 bExpired=FALSE;
-                cm_ResetACLCache(userp);
+                cm_ResetACLCache(NULL, userp);
             }
         }
     }
index fa27c50..17645ea 100644 (file)
@@ -6124,7 +6124,7 @@ long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
 
         key = cm_GenerateKey(vcp->vcID, pid, fidp->fid);
 
-        code = cm_Unlock(scp, LockType, LOffset, LLength, key, userp, &req);
+        code = cm_Unlock(scp, LockType, LOffset, LLength, key, 0, userp, &req);
 
         if (code) 
             goto done;
@@ -6246,7 +6246,7 @@ long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
 
                 wlNext = (smb_waitingLock_t *) osi_QNext(&wl->q);
 
-                ul_code = cm_Unlock(scp, LockType, wl->LOffset, wl->LLength, wl->key, userp, &req);
+                ul_code = cm_Unlock(scp, LockType, wl->LOffset, wl->LLength, wl->key, 0, userp, &req);
                 
                 if(ul_code != 0) {
                     osi_Log1(smb_logp, "smb_ReceiveV3Locking cm_Unlock returns code %d", ul_code);
index eb9e679..87be321 100644 (file)
@@ -1040,7 +1040,7 @@ smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
         ioctlp->ioctl.flags |= CM_IOCTLFLAG_LOGON;
     }
 
-    cm_ResetACLCache(userp);
+    cm_ResetACLCache(cellp, userp);
 
   done:
     if (release_userp)