Windows: save fid/type for redirector invalidation
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 16 Dec 2011 05:12:39 +0000 (00:12 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 17 Dec 2011 16:25:34 +0000 (08:25 -0800)
Must save the fid/type fields of the cm_scache_t object before
recycling in order to invalidate the contents in the redirector.

Change-Id: I7914faaa80082033044980deb471eaffbddf3cfc
Reviewed-on: http://gerrit.openafs.org/6359
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_callback.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_scache.c

index 9889f79..c2408e4 100644 (file)
@@ -983,6 +983,8 @@ SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
     cm_cell_t* cellp = NULL;
     afs_uint32 hash;
     int discarded;
+    cm_fid_t discardFid;
+    afs_uint32 discardType;
     struct rx_connection *connp;
     struct rx_peer *peerp;
     unsigned long host = 0;
@@ -1073,6 +1075,8 @@ SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
                     if (cm_ServerEqual(scp->cbServerp, tsp)) {
                         osi_Log4(afsd_logp, "InitCallbackState3 Discarding SCache scp 0x%p vol %u vn %u uniq %u",
                                   scp, scp->fid.volume, scp->fid.vnode, scp->fid.unique);
+                        discardFid = scp->fid;
+                        discardType = scp->fileType;
                         cm_DiscardSCache(scp);
                         discarded = 1;
                     }
@@ -1081,8 +1085,8 @@ SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
                 if (discarded) {
                     cm_CallbackNotifyChange(scp);
                     if (RDR_Initialized)
-                        RDR_InvalidateObject(scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique,
-                                              scp->fid.hash, scp->fileType, AFS_INVALIDATE_EXPIRED);
+                        RDR_InvalidateObject(discardFid.cell, discardFid.volume, discardFid.vnode, discardFid.unique,
+                                             discardFid.hash, discardType, AFS_INVALIDATE_EXPIRED);
                 }
                 lock_ObtainWrite(&cm_scacheLock);
                 cm_ReleaseSCacheNoLock(scp);
@@ -2021,7 +2025,7 @@ void cm_CheckCBExpiration(void)
 
             if (RDR_Initialized)
                 RDR_InvalidateObject(scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique,
-                                      scp->fid.hash, scp->fileType, AFS_INVALIDATE_EXPIRED);
+                                     scp->fid.hash, scp->fileType, AFS_INVALIDATE_EXPIRED);
 
             cm_CallbackNotifyChange(scp);
 
index 15ec650..e9c0f0f 100644 (file)
@@ -678,6 +678,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
     } else if ( errorCode == VNOVNODE ) {
        if ( fidp ) {
            cm_scache_t * scp;
+
            osi_Log4(afsd_logp, "cm_Analyze passed VNOVNODE cell %u vol %u vn %u uniq %u.",
                      fidp->cell, fidp->volume, fidp->vnode, fidp->unique);
 
index ffbb06d..01a8eb7 100644 (file)
@@ -140,6 +140,10 @@ void cm_ResetSCacheDirectory(cm_scache_t *scp, afs_int32 dirlock)
 /* called with cm_scacheLock and scp write-locked; recycles an existing scp. */
 long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
 {
+    cm_fid_t fid;
+    afs_uint32 fileType;
+    int callback;
+
     lock_AssertWrite(&cm_scacheLock);
     lock_AssertWrite(&scp->rw);
 
@@ -147,6 +151,7 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
        return -1;
     }
 
+
     if (scp->flags & CM_SCACHEFLAG_SMB_FID) {
        osi_Log1(afsd_logp,"cm_RecycleSCache CM_SCACHEFLAG_SMB_FID detected scp 0x%p", scp);
 #ifdef DEBUG
@@ -159,6 +164,10 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
         return -1;
     }
 
+    fid = scp->fid;
+    fileType = scp->fileType;
+    callback = scp->cbExpires ? 1 : 0;
+
     cm_RemoveSCacheFromHashTable(scp);
 
     /* invalidate so next merge works fine;
@@ -220,6 +229,23 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
     cm_FreeAllACLEnts(scp);
 
     cm_ResetSCacheDirectory(scp, 0);
+
+    if (RDR_Initialized && callback) {
+        /*
+        * We drop the cm_scacheLock because it may be required to
+        * satisfy an ioctl request from the redirector.  It should
+        * be safe to hold the scp->rw lock here because at this
+        * point (a) the object has just been recycled so the fid
+        * is nul and there are no requests that could possibly
+        * be issued by the redirector that would depend upon it.
+        */
+        lock_ReleaseWrite(&cm_scacheLock);
+        RDR_InvalidateObject( fid.cell, fid.volume, fid.vnode,
+                              fid.unique, fid.hash,
+                              fileType, AFS_INVALIDATE_EXPIRED);
+        lock_ObtainWrite(&cm_scacheLock);
+    }
+
     return 0;
 }
 
@@ -284,22 +310,6 @@ cm_GetNewSCache(afs_uint32 locked)
                              */
                             cm_AdjustScacheLRU(scp);
 
-                            if (RDR_Initialized) {
-                                /*
-                                 * We drop the cm_scacheLock because it may be required to
-                                 * satisfy an ioctl request from the redirector.  It should
-                                 * be safe to hold the scp->rw lock here because at this
-                                 * point (a) the object has just been recycled so the fid
-                                 * is nul and there are no requests that could possibly
-                                 * be issued by the redirector that would depend upon it.
-                                 */
-                                lock_ReleaseWrite(&cm_scacheLock);
-                                RDR_InvalidateObject( fid.cell, fid.volume, fid.vnode,
-                                                      fid.unique, fid.hash,
-                                                      fileType, AFS_INVALIDATE_EXPIRED);
-                                lock_ObtainWrite(&cm_scacheLock);
-                            }
-
                             /* and we're done */
                             osi_assertx(!(scp->flags & CM_SCACHEFLAG_INHASH), "CM_SCACHEFLAG_INHASH set");
                             goto done;