Windows: Do not execute tasks on deleted files
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 29 Jul 2011 22:09:53 +0000 (18:09 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Sun, 31 Jul 2011 17:21:38 +0000 (10:21 -0700)
If a cm_BkgDaemon thread finds a queued request whose cm_scache_t
has the CM_SCACHEFLAG_DELETED flag set, do not execute the request
and fail it immediately with CM_ERROR_BADFD.  Any attempt to execute
the request will fail with VNOVNODE from the file server.

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

src/WINNT/afsd/cm_daemon.c

index d05385d..ed35510 100644 (file)
@@ -118,7 +118,8 @@ void cm_BkgDaemon(void * parm)
         /* we found a request */
         for (rp = cm_bkgListEndp; rp; rp = (cm_bkgRequest_t *) osi_QPrev(&rp->q))
        {
-           if (cm_ServerAvailable(&rp->scp->fid, rp->userp))
+           if (cm_ServerAvailable(&rp->scp->fid, rp->userp) ||
+                rp->scp->flags & CM_SCACHEFLAG_DELETED)
                break;
        }
        if (rp == NULL) {
@@ -135,13 +136,18 @@ void cm_BkgDaemon(void * parm)
 
        osi_Log1(afsd_logp,"cm_BkgDaemon processing request 0x%p", rp);
 
+        if (rp->scp->flags & CM_SCACHEFLAG_DELETED) {
+            osi_Log1(afsd_logp,"cm_BkgDaemon DELETED scp 0x%x",rp->scp);
+            code = CM_ERROR_BADFD;
+        } else {
 #ifdef DEBUG_REFCOUNT
-       osi_Log2(afsd_logp,"cm_BkgDaemon (before) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
+            osi_Log2(afsd_logp,"cm_BkgDaemon (before) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
 #endif
-        code = (*rp->procp)(rp->scp, rp->p1, rp->p2, rp->p3, rp->p4, rp->userp);
+            code = (*rp->procp)(rp->scp, rp->p1, rp->p2, rp->p3, rp->p4, rp->userp);
 #ifdef DEBUG_REFCOUNT
-       osi_Log2(afsd_logp,"cm_BkgDaemon (after) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
+            osi_Log2(afsd_logp,"cm_BkgDaemon (after) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
 #endif
+        }
 
         /*
          * Keep the following list synchronized with the