Windows: Do not release locks on deleted files
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 29 Jul 2011 22:07:42 +0000 (18:07 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Sun, 31 Jul 2011 17:21:06 +0000 (10:21 -0700)
If the cm_scache_t flags include CM_SCACHEFLAG_DELETED, do not
bother releasing an outstanding file lock to the file server.
The lock went away when the file was deleted.  Any attempt to
release will fail with VNOVNODE which is translated locally into
CM_ERROR_BADFD.

If a RXAFS_ReleaseLock RPC fails with VNOVNODE, treat it as
success.

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

src/WINNT/afsd/cm_vnodeops.c

index 6fcc938..bd2ed1e 100644 (file)
@@ -4409,6 +4409,11 @@ long cm_IntReleaseLock(cm_scache_t * scp, cm_user_t * userp,
     struct rx_connection * rxconnp;
     AFSVolSync volSync;
 
+    if (scp->flags & CM_SCACHEFLAG_DELETED) {
+        osi_Log1(afsd_logp, "CALL ReleaseLock on Deleted Vnode scp 0x%p", scp);
+        return 0;
+    }
+
     memset(&volSync, 0, sizeof(volSync));
 
     tfid.Volume = scp->fid.volume;
@@ -4441,7 +4446,7 @@ long cm_IntReleaseLock(cm_scache_t * scp, cm_user_t * userp,
 
     lock_ObtainWrite(&scp->rw);
 
-    return code;
+    return (code != CM_ERROR_BADFD ? code : 0);
 }
 
 /* called with scp->rw held.  May release it during processing, but