From: Jeffrey Altman Date: Wed, 9 Nov 2005 03:00:07 +0000 (+0000) Subject: windows-release-locks-at-shutdown-20051108 X-Git-Tag: openafs-devel-1_5_0~202 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=685ba16a0b9db8cf5df2e875ff9a6e5b72d6539c;p=packages%2Fo%2Fopenafs.git windows-release-locks-at-shutdown-20051108 remember to release all of the locks we obtained from the file server at shutdown. --- diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index 32c675294..999270853 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -1,37 +1,4 @@ -/* - * Copyright 2000, International Business Machines Corporation and others. - * All Rights Reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - */ -/* AFSIFS portions copyright (c) 2005 - * the regents of the university of michigan - * all rights reserved - * - * permission is granted to use, copy, create derivative works and - * redistribute this software and such derivative works for any purpose, - * so long as the name of the university of michigan is not used in - * any advertising or publicity pertaining to the use or distribution - * of this software without specific, written prior authorization. if - * the above copyright notice or any other identification of the - * university of michigan is included in any copy of any portion of - * this software, then the disclaimer below must also be included. - * - * this software is provided as is, without representation from the - * university of michigan as to its fitness for any purpose, and without - * warranty by the university of michigan of any kind, either express - * or implied, including without limitation the implied warranties of - * merchantability and fitness for a particular purpose. the regents - * of the university of michigan shall not be liable for any damages, - * including special, indirect, incidental, or consequential damages, - * with respect to any claim arising out or in connection with the use - * of the software, even if it has been or is hereafter advised of the - * possibility of such damages. - */ -#include #include #include @@ -1441,6 +1408,11 @@ afsd_Main(DWORD argc, LPTSTR *argv) RpcShutdown(); + cm_ReleaseAllLocks(); + + rx_Finalize(); + afsi_log("rx finalization complete"); + cm_ShutdownMappedMemory(); #ifdef REGISTER_POWER_NOTIFICATIONS diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 67f781f49..4fd8bd069 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -3606,10 +3606,10 @@ static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags); /* Called with scp->mx held */ long cm_UnlockByKey(cm_scache_t * scp, - cm_key_t key, - int flags, - cm_user_t * userp, - cm_req_t * reqp) + cm_key_t key, + int flags, + cm_user_t * userp, + cm_req_t * reqp) { long code = 0; AFSFid tfid; @@ -4537,3 +4537,38 @@ static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags) return (k1 == k2); } } + +void cm_ReleaseAllLocks(void) +{ + cm_scache_t *scp; + cm_req_t req; + cm_user_t *userp; + cm_key_t key; + cm_file_lock_t *fileLock; + int i; + + for (i = 0; i < cm_data.hashTableSize; i++) + { + for ( scp = cm_data.hashTablep[i]; scp; scp = scp->nextp ) { + while (scp->fileLocksH != NULL) { + lock_ObtainMutex(&scp->mx); + lock_ObtainWrite(&cm_scacheLock); + if (!scp->fileLocksH) { + lock_ReleaseWrite(&cm_scacheLock); + lock_ReleaseMutex(&scp->mx); + break; + } + fileLock = (cm_file_lock_t *)((char *) scp->fileLocksH - offsetof(cm_file_lock_t, fileq)); + userp = fileLock->userp; + cm_HoldUser(userp); + key = fileLock->key; + cm_HoldSCacheNoLock(scp); + lock_ReleaseWrite(&cm_scacheLock); + cm_UnlockByKey(scp, key, 0, userp, &req); + cm_ReleaseSCache(scp); + cm_ReleaseUser(userp); + lock_ReleaseMutex(&scp->mx); + } + } + } +} diff --git a/src/WINNT/afsd/cm_vnodeops.h b/src/WINNT/afsd/cm_vnodeops.h index 569f69880..bb2c2aadb 100644 --- a/src/WINNT/afsd/cm_vnodeops.h +++ b/src/WINNT/afsd/cm_vnodeops.h @@ -172,7 +172,9 @@ extern long cm_LockCheckWrite(cm_scache_t *scp, LARGE_INTEGER LLength, cm_key_t key); -extern void cm_CheckLocks(); +extern void cm_CheckLocks(void); + +extern void cm_ReleaseAllLocks(void); extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead);