From 38c2524bd16f1e535ea28f9d0788b7eaa8d26c3d Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 17 Feb 2008 05:58:13 +0000 Subject: [PATCH] windows-invalidate-file-locks-vnovnode-20080217 LICENSE MIT Upon receiving a VNOVNODE error from a file server, be sure to invalidate any file locks. This prevents on-going attempts to extend the locks and will cause subsequent attempts to access the file to receive a invalid handle error. --- src/WINNT/afsd/cm_conn.c | 1 + src/WINNT/afsd/cm_vnodeops.c | 10 ++++------ src/WINNT/afsd/cm_vnodeops.h | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 91146f5832..5aa65c4a35 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -514,6 +514,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, lock_ObtainWrite(&cm_scacheLock); cm_RemoveSCacheFromHashTable(scp); lock_ReleaseWrite(&cm_scacheLock); + cm_LockMarkSCacheLost(scp); scp->flags |= CM_SCACHEFLAG_DELETED; lock_ReleaseMutex(&scp->mx); cm_ReleaseSCache(scp); diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 3d6c7710db..318886b717 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -3957,9 +3957,6 @@ long cm_LockCheckWrite(cm_scache_t *scp, #endif } -/* Forward dcl. */ -static void cm_LockMarkSCacheLost(cm_scache_t * scp); - /* Called with cm_scacheLock write locked */ static cm_file_lock_t * cm_GetFileLock(void) { cm_file_lock_t * l; @@ -4905,7 +4902,7 @@ long cm_Unlock(cm_scache_t *scp, } /* called with scp->mx held */ -static void cm_LockMarkSCacheLost(cm_scache_t * scp) +void cm_LockMarkSCacheLost(cm_scache_t * scp) { cm_file_lock_t *fileLock; osi_queue_t *q; @@ -5029,7 +5026,7 @@ void cm_CheckLocks() if (!IS_LOCK_ACTIVE(fileLock)) goto pre_syncopdone; - if (scp->serverLock != -1) { + if (scp->serverLock != -1 && !(scp->flags & CM_SCACHEFLAG_DELETED)) { cm_fid_t cfid; cm_user_t * userp; @@ -5106,7 +5103,8 @@ void cm_CheckLocks() } } - if (code == EINVAL || code == CM_ERROR_INVAL) { + if (code == EINVAL || code == CM_ERROR_INVAL || + code == CM_ERROR_BADFD) { cm_LockMarkSCacheLost(scp); } diff --git a/src/WINNT/afsd/cm_vnodeops.h b/src/WINNT/afsd/cm_vnodeops.h index b376efdaaf..91b616dc9c 100644 --- a/src/WINNT/afsd/cm_vnodeops.h +++ b/src/WINNT/afsd/cm_vnodeops.h @@ -224,6 +224,8 @@ extern void cm_CheckLocks(void); extern void cm_ReleaseAllLocks(void); +extern void cm_LockMarkSCacheLost(cm_scache_t * scp); + extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead); #define CM_SESSION_SMB 0xffff