Index: openafs/src/WINNT/afsadmsvr/NTMakefile diff -c openafs/src/WINNT/afsadmsvr/NTMakefile:1.8 openafs/src/WINNT/afsadmsvr/NTMakefile:1.8.4.1 *** openafs/src/WINNT/afsadmsvr/NTMakefile:1.8 Sun Nov 20 20:56:03 2005 --- openafs/src/WINNT/afsadmsvr/NTMakefile Wed Sep 19 13:58:45 2007 *************** *** 57,64 **** EXERES = $(OUT)\AfsAdmSvr.res ! $(EXERES):$$(@B).rc ! $(RC) $** EXEOBJS = \ $(OUT)\TaAfsAdmSvr.obj \ --- 57,63 ---- EXERES = $(OUT)\AfsAdmSvr.res ! $(EXERES): AfsAdmSvr.rc AFS_component_version_number.h EXEOBJS = \ $(OUT)\TaAfsAdmSvr.obj \ *************** *** 143,149 **** nmake /nologo /f ntmakefile clean $(CD) ..\afsadmsvr ! $(EXEFILE) : $(EXEOBJS) $(EXELIBS) $(EXECONLINK) $(VCLIBS) $(_VC_MANIFEST_EMBED_EXE) $(EXEPREP) --- 142,148 ---- nmake /nologo /f ntmakefile clean $(CD) ..\afsadmsvr ! $(EXEFILE) : $(EXEOBJS) $(EXERES) $(EXELIBS) $(EXECONLINK) $(VCLIBS) $(_VC_MANIFEST_EMBED_EXE) $(EXEPREP) *************** *** 161,174 **** if exist ITaAfsAdmSvr*.cpp del ITaAfsAdmSvr*.cpp if exist ITaAfsAdmSvr*.c del ITaAfsAdmSvr*.c if exist ITaAfsAdmSvr*.h del ITaAfsAdmSvr*.h ############################################################################ # # Dependencies # - $(OUT)\AfsAdmSvr.res : AFS_component_version_number.h - mkdir: -mkdir $(OUT)\..\afsapplib cd ..\afsapplib --- 160,173 ---- if exist ITaAfsAdmSvr*.cpp del ITaAfsAdmSvr*.cpp if exist ITaAfsAdmSvr*.c del ITaAfsAdmSvr*.c if exist ITaAfsAdmSvr*.h del ITaAfsAdmSvr*.h + $(DEL) AFS_component_version_number.h + $(DEL) $(EXERES) ############################################################################ # # Dependencies # mkdir: -mkdir $(OUT)\..\afsapplib cd ..\afsapplib Index: openafs/src/WINNT/afsd/afsd_init.c diff -c openafs/src/WINNT/afsd/afsd_init.c:1.79.2.16 openafs/src/WINNT/afsd/afsd_init.c:1.79.2.17 *** openafs/src/WINNT/afsd/afsd_init.c:1.79.2.16 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/afsd_init.c Mon Sep 10 15:08:17 2007 *************** *** 41,46 **** --- 41,47 ---- extern int cm_enableServerLocks; extern int cm_deleteReadOnly; extern afs_int32 cm_BPlusTrees; + extern const char **smb_ExecutableExtensions; osi_log_t *afsd_logp; *************** *** 278,291 **** KEY_READ|KEY_WRITE, &hkMSV10) == ERROR_SUCCESS ) { ! if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, ! &dwType, NULL, &dwAllocSize) == ERROR_SUCCESS) { dwAllocSize += 1 /* in case the source string is not nul terminated */ + strlen(cm_NetbiosName) + 2; pHostNames = malloc(dwAllocSize); dwSize = dwAllocSize; if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, &dwType, ! pHostNames, &dwSize) == ERROR_SUCCESS) { for (pName = pHostNames; (pName - pHostNames < dwSize) && *pName ; pName += strlen(pName) + 1) --- 279,295 ---- KEY_READ|KEY_WRITE, &hkMSV10) == ERROR_SUCCESS ) { ! if ((RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, ! &dwType, NULL, &dwAllocSize) == ERROR_SUCCESS) && ! (dwType == REG_MULTI_SZ)) ! { dwAllocSize += 1 /* in case the source string is not nul terminated */ + strlen(cm_NetbiosName) + 2; pHostNames = malloc(dwAllocSize); dwSize = dwAllocSize; if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, &dwType, ! pHostNames, &dwSize) == ERROR_SUCCESS) ! { for (pName = pHostNames; (pName - pHostNames < dwSize) && *pName ; pName += strlen(pName) + 1) *************** *** 726,734 **** blockSize = CM_CONFIGDEFAULT_BLOCKSIZE; } if (blockSize > cm_chunkSize) { ! afsi_log("Block size cannot be larger than Chunk size."); blockSize = cm_chunkSize; } afsi_log("Block size %u", blockSize); dummyLen = sizeof(numBkgD); --- 730,744 ---- blockSize = CM_CONFIGDEFAULT_BLOCKSIZE; } if (blockSize > cm_chunkSize) { ! afsi_log("Block size (%d) cannot be larger than Chunk size (%d).", ! blockSize, cm_chunkSize); blockSize = cm_chunkSize; } + if (cm_chunkSize % blockSize != 0) { + afsi_log("Block size (%d) must be a factor of Chunk size (%d).", + blockSize, cm_chunkSize); + blockSize = CM_CONFIGDEFAULT_BLOCKSIZE; + } afsi_log("Block size %u", blockSize); dummyLen = sizeof(numBkgD); *************** *** 1065,1071 **** cm_BPlusTrees = (unsigned short) dwValue; } afsi_log("CM BPlusTrees is %u", cm_BPlusTrees); ! RegCloseKey (parmKey); cacheBlocks = ((afs_uint64)cacheSize * 1024) / blockSize; --- 1075,1113 ---- cm_BPlusTrees = (unsigned short) dwValue; } afsi_log("CM BPlusTrees is %u", cm_BPlusTrees); ! ! if ((RegQueryValueEx( parmKey, "PrefetchExecutableExtensions", 0, ! ®Type, NULL, &dummyLen) == ERROR_SUCCESS) && ! (regType == REG_MULTI_SZ)) ! { ! char * pSz; ! dummyLen += 3; /* in case the source string is not nul terminated */ ! pSz = malloc(dummyLen); ! if ((RegQueryValueEx( parmKey, "PrefetchExecutableExtensions", 0, ®Type, ! pSz, &dummyLen) == ERROR_SUCCESS) && ! (regType == REG_MULTI_SZ)) ! { ! int cnt; ! char * p; ! ! for (cnt = 0, p = pSz; (p - pSz < dummyLen) && *p; cnt++, p += strlen(p) + 1); ! ! smb_ExecutableExtensions = malloc(sizeof(char *) * (cnt+1)); ! ! for (cnt = 0, p = pSz; (p - pSz < dummyLen) && *p; cnt++, p += strlen(p) + 1) ! { ! smb_ExecutableExtensions[cnt] = p; ! afsi_log("PrefetchExecutableExtension: \"%s\"", p); ! } ! smb_ExecutableExtensions[cnt] = NULL; ! } ! ! if (!smb_ExecutableExtensions) ! free(pSz); ! } ! if (!smb_ExecutableExtensions) ! afsi_log("No PrefetchExecutableExtensions"); ! RegCloseKey (parmKey); cacheBlocks = ((afs_uint64)cacheSize * 1024) / blockSize; Index: openafs/src/WINNT/afsd/afsd_service.c diff -c openafs/src/WINNT/afsd/afsd_service.c:1.52.4.16 openafs/src/WINNT/afsd/afsd_service.c:1.52.4.17 *** openafs/src/WINNT/afsd/afsd_service.c:1.52.4.16 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/afsd_service.c Wed Sep 19 23:55:42 2007 *************** *** 76,81 **** --- 76,83 ---- buf_ForceTrace(TRUE); afsi_log("--- begin dump ---"); + cm_MemDumpDirStats(afsi_file, "a", 0); + cm_MemDumpBPlusStats(afsi_file, "a", 0); cm_DumpCells(afsi_file, "a", 0); cm_DumpVolumes(afsi_file, "a", 0); cm_DumpSCache(afsi_file, "a", 0); Index: openafs/src/WINNT/afsd/afskfw-int.h diff -c openafs/src/WINNT/afsd/afskfw-int.h:1.3.14.3 openafs/src/WINNT/afsd/afskfw-int.h:1.3.14.4 *** openafs/src/WINNT/afsd/afskfw-int.h:1.3.14.3 Tue Apr 3 10:50:40 2007 --- openafs/src/WINNT/afsd/afskfw-int.h Wed Aug 29 17:53:36 2007 *************** *** 1,5 **** /* ! * Copyright (c) 2004, 2005, 2006 Secure Endpoints Inc. * Copyright (c) 2003 SkyRope, LLC * All rights reserved. * --- 1,5 ---- /* ! * Copyright (c) 2004, 2005, 2006, 2007 Secure Endpoints Inc. * Copyright (c) 2003 SkyRope, LLC * All rights reserved. * *************** *** 235,241 **** --- 235,246 ---- // cc_get_cache_names(). set to NULL on return ) ); + + #ifdef _WIN64 + #define CCAPI_DLL "krbcc64.dll" + #else #define CCAPI_DLL "krbcc32.dll" + #endif /* Function Prototypes */ DWORD GetServiceStatus(LPSTR, LPSTR, DWORD *); Index: openafs/src/WINNT/afsd/afskfw.c diff -c openafs/src/WINNT/afsd/afskfw.c:1.28.4.9 openafs/src/WINNT/afsd/afskfw.c:1.28.4.11 *** openafs/src/WINNT/afsd/afskfw.c:1.28.4.9 Tue Aug 21 04:44:06 2007 --- openafs/src/WINNT/afsd/afskfw.c Sun Sep 2 12:37:43 2007 *************** *** 56,63 **** */ - #define USE_MS2MIT #undef USE_KRB4 #include "afskfw-int.h" #include "afskfw.h" #include --- 56,68 ---- */ #undef USE_KRB4 + #ifndef _WIN64 + #define USE_KRB524 1 + #endif + #define USE_MS2MIT 1 + #define USE_LEASH 1 + #include "afskfw-int.h" #include "afskfw.h" #include *************** *** 94,99 **** --- 99,105 ---- DECL_FUNC_PTR(cc_get_NC_info); DECL_FUNC_PTR(cc_free_NC_info); + #ifdef USE_LEASH // leash functions DECL_FUNC_PTR(Leash_get_default_lifetime); DECL_FUNC_PTR(Leash_get_default_forwardable); *************** *** 108,113 **** --- 114,120 ---- DECL_FUNC_PTR(Leash_get_default_renew_max); DECL_FUNC_PTR(Leash_get_default_renewable); DECL_FUNC_PTR(Leash_get_default_mslsa_import); + #endif // krb5 functions DECL_FUNC_PTR(krb5_change_password); *************** *** 170,184 **** --- 177,195 ---- DECL_FUNC_PTR(krb5_free_addresses); DECL_FUNC_PTR(krb5_c_random_make_octets); + #ifdef USE_KRB524 // Krb524 functions DECL_FUNC_PTR(krb524_init_ets); DECL_FUNC_PTR(krb524_convert_creds_kdc); + #endif + #ifdef USE_KRB4 // krb4 functions DECL_FUNC_PTR(krb_get_cred); DECL_FUNC_PTR(tkt_string); DECL_FUNC_PTR(krb_get_tf_realm); DECL_FUNC_PTR(krb_mk_req); + #endif // ComErr functions DECL_FUNC_PTR(com_err); *************** *** 219,224 **** --- 230,236 ---- END_FUNC_INFO }; + #ifdef USE_LEASH FUNC_INFO leash_fi[] = { MAKE_FUNC_INFO(Leash_get_default_lifetime), MAKE_FUNC_INFO(Leash_get_default_renew_till), *************** *** 239,244 **** --- 251,257 ---- MAKE_FUNC_INFO(Leash_get_default_mslsa_import), END_FUNC_INFO }; + #endif FUNC_INFO k5_fi[] = { MAKE_FUNC_INFO(krb5_change_password), *************** *** 314,324 **** --- 327,339 ---- }; #endif + #ifdef USE_KRB524 FUNC_INFO k524_fi[] = { MAKE_FUNC_INFO(krb524_init_ets), MAKE_FUNC_INFO(krb524_convert_creds_kdc), END_FUNC_INFO }; + #endif FUNC_INFO profile_fi[] = { MAKE_FUNC_INFO(profile_init), *************** *** 375,381 **** --- 390,398 ---- #ifdef USE_KRB4 static HINSTANCE hKrb4 = 0; #endif /* USE_KRB4 */ + #ifdef USE_KRB524 static HINSTANCE hKrb524 = 0; + #endif #ifdef USE_MS2MIT static HINSTANCE hSecur32 = 0; #endif /* USE_MS2MIT */ *************** *** 383,390 **** --- 400,409 ---- static HINSTANCE hComErr = 0; static HINSTANCE hService = 0; static HINSTANCE hProfile = 0; + #ifdef USE_LEASH static HINSTANCE hLeash = 0; static HINSTANCE hLeashOpt = 0; + #endif static HINSTANCE hCCAPI = 0; static struct principal_ccache_data * princ_cc_data = NULL; static struct cell_principal_map * cell_princ_map = NULL; *************** *** 409,427 **** if ( !inited ) { inited = 1; LoadFuncs(KRB5_DLL, k5_fi, &hKrb5, 0, 1, 0, 0); #ifdef USE_KRB4 LoadFuncs(KRB4_DLL, k4_fi, &hKrb4, 0, 1, 0, 0); #endif /* USE_KRB4 */ - LoadFuncs(COMERR_DLL, ce_fi, &hComErr, 0, 0, 1, 0); LoadFuncs(SERVICE_DLL, service_fi, &hService, 0, 1, 0, 0); #ifdef USE_MS2MIT LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1); #endif /* USE_MS2MIT */ LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1); ! LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0); LoadFuncs(LEASH_DLL, leash_fi, &hLeash, 0, 1, 0, 0); - LoadFuncs(CCAPI_DLL, ccapi_fi, &hCCAPI, 0, 1, 0, 0); LoadFuncs(LEASH_DLL, leash_opt_fi, &hLeashOpt, 0, 1, 0, 0); if ( KFW_is_available() ) { char rootcell[MAXCELLCHARS+1]; --- 428,450 ---- if ( !inited ) { inited = 1; LoadFuncs(KRB5_DLL, k5_fi, &hKrb5, 0, 1, 0, 0); + LoadFuncs(COMERR_DLL, ce_fi, &hComErr, 0, 0, 1, 0); + LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0); #ifdef USE_KRB4 LoadFuncs(KRB4_DLL, k4_fi, &hKrb4, 0, 1, 0, 0); #endif /* USE_KRB4 */ LoadFuncs(SERVICE_DLL, service_fi, &hService, 0, 1, 0, 0); #ifdef USE_MS2MIT LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1); #endif /* USE_MS2MIT */ + #ifdef USE_KRB524 LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1); ! #endif ! #ifdef USE_LEASH LoadFuncs(LEASH_DLL, leash_fi, &hLeash, 0, 1, 0, 0); LoadFuncs(LEASH_DLL, leash_opt_fi, &hLeashOpt, 0, 1, 0, 0); + #endif + LoadFuncs(CCAPI_DLL, ccapi_fi, &hCCAPI, 0, 1, 0, 0); if ( KFW_is_available() ) { char rootcell[MAXCELLCHARS+1]; *************** *** 444,457 **** void KFW_cleanup(void) { if (hLeashOpt) FreeLibrary(hLeashOpt); - if (hCCAPI) - FreeLibrary(hCCAPI); if (hLeash) FreeLibrary(hLeash); if (hKrb524) FreeLibrary(hKrb524); #ifdef USE_MS2MIT if (hSecur32) FreeLibrary(hSecur32); --- 467,484 ---- void KFW_cleanup(void) { + #ifdef USE_LEASH if (hLeashOpt) FreeLibrary(hLeashOpt); if (hLeash) FreeLibrary(hLeash); + #endif + #ifdef USE_KRB524 if (hKrb524) FreeLibrary(hKrb524); + #endif + if (hCCAPI) + FreeLibrary(hCCAPI); #ifdef USE_MS2MIT if (hSecur32) FreeLibrary(hSecur32); *************** *** 533,540 **** #ifdef USE_MS2MIT hSecur32 && #endif /* USE_MS2MIT */ hKrb524 && ! hProfile && hLeash && hCCAPI ) return TRUE; return FALSE; } --- 560,572 ---- #ifdef USE_MS2MIT hSecur32 && #endif /* USE_MS2MIT */ + #ifdef USE_KRB524 hKrb524 && ! #endif ! #ifdef USE_LEASH ! hLeash && ! #endif ! hProfile && hCCAPI ) return TRUE; return FALSE; } *************** *** 929,939 **** if (!pkrb5_init_context) return; - #ifdef COMMENT - if ( !MSLSA_IsKerberosLogon() ) - return; - #endif - code = pkrb5_init_context(&ctx); if (code) goto cleanup; --- 961,966 ---- *************** *** 1157,1163 **** OutputDebugString("Calling KFW_AFS_klog() to obtain token\n"); } ! code = KFW_AFS_klog(ctx, cc, "afs", cell->data, realm->data, pLeash_get_default_lifetime(),NULL); if ( IsDebuggerPresent() ) { char message[256]; sprintf(message,"KFW_AFS_klog() returns: %d\n",code); --- 1184,1196 ---- OutputDebugString("Calling KFW_AFS_klog() to obtain token\n"); } ! code = KFW_AFS_klog(ctx, cc, "afs", cell->data, realm->data, ! #ifndef USE_LEASH ! 600, ! #else ! pLeash_get_default_lifetime(), ! #endif /* USE_LEASH */ ! NULL); if ( IsDebuggerPresent() ) { char message[256]; sprintf(message,"KFW_AFS_klog() returns: %d\n",code); *************** *** 1283,1300 **** if ( code ) goto cleanup; if ( lifetime == 0 ) lifetime = pLeash_get_default_lifetime(); if ( password && password[0] ) { code = KFW_kinit( ctx, cc, HWND_DESKTOP, pname, password, lifetime, pLeash_get_default_forwardable(), pLeash_get_default_proxiable(), pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0, pLeash_get_default_noaddresses(), ! pLeash_get_default_publicip()); if ( IsDebuggerPresent() ) { char message[256]; sprintf(message,"KFW_kinit() returns: %d\n",code); --- 1316,1347 ---- if ( code ) goto cleanup; if ( lifetime == 0 ) + #ifndef USE_LEASH + lifetime = 600; + #else lifetime = pLeash_get_default_lifetime(); + #endif if ( password && password[0] ) { code = KFW_kinit( ctx, cc, HWND_DESKTOP, pname, password, lifetime, + #ifndef USE_LEASH + 1, /* forwardable */ + 0, /* not proxiable */ + 1, /* renewable */ + 1, /* noaddresses */ + 0 /* no public ip */ + #else pLeash_get_default_forwardable(), pLeash_get_default_proxiable(), pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0, pLeash_get_default_noaddresses(), ! pLeash_get_default_publicip() ! #endif /* USE_LEASH */ ! ); ! if ( IsDebuggerPresent() ) { char message[256]; sprintf(message,"KFW_kinit() returns: %d\n",code); *************** *** 1889,1895 **** --- 1936,1946 ---- goto cleanup; if (lifetime == 0) + #ifndef USE_LEASH + lifetime = 600; + #else lifetime = pLeash_get_default_lifetime(); + #endif /* USE_LEASH */ lifetime *= 60; if (renew_life > 0) *************** *** 2990,2995 **** --- 3041,3049 ---- goto cleanup; /* We have successfully inserted the token */ try_krb524d: + #ifndef USE_KRB524 + goto cleanup; + #else /* Otherwise, the ticket could have been too large so try to * convert using the krb524d running with the KDC */ *************** *** 3004,3009 **** --- 3058,3064 ---- try_krb5 = 0; goto use_krb4; } + #endif /* USE_KRB524 */ } else { use_krb4: #ifdef USE_KRB4 Index: openafs/src/WINNT/afsd/cm.h diff -c openafs/src/WINNT/afsd/cm.h:1.17.2.5 openafs/src/WINNT/afsd/cm.h:1.17.2.6 *** openafs/src/WINNT/afsd/cm.h:1.17.2.5 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm.h Thu Aug 30 22:56:59 2007 *************** *** 302,307 **** --- 302,308 ---- #define CM_ERROR_BAD_LEVEL (CM_ERROR_BASE+52) #define CM_ERROR_NOT_A_DFSLINK (CM_ERROR_BASE+53) #define CM_ERROR_INEXACT_MATCH (CM_ERROR_BASE+54) + #define CM_ERROR_BPLUS_NOMATCH (CM_ERROR_BASE+55) /* Used by cm_FollowMountPoint and cm_GetVolumeByName */ #define RWVOL 0 Index: openafs/src/WINNT/afsd/cm_btree.c diff -c openafs/src/WINNT/afsd/cm_btree.c:1.1.2.4 openafs/src/WINNT/afsd/cm_btree.c:1.1.2.6 *** openafs/src/WINNT/afsd/cm_btree.c:1.1.2.4 Sun Aug 26 20:11:43 2007 --- openafs/src/WINNT/afsd/cm_btree.c Wed Sep 19 23:55:42 2007 *************** *** 198,206 **** sprintf(B->message, "LOOKUP: %s found on page %d value (%d.%d.%d).\n", key.name, getnodenumber(B, findNode), ! data.volume, ! data.vnode, ! data.unique); } else sprintf(B->message, "LOOKUP: not found!\n"); OutputDebugString(B->message); --- 198,206 ---- sprintf(B->message, "LOOKUP: %s found on page %d value (%d.%d.%d).\n", key.name, getnodenumber(B, findNode), ! data.fid.volume, ! data.fid.vnode, ! data.fid.unique); } else sprintf(B->message, "LOOKUP: not found!\n"); OutputDebugString(B->message); *************** *** 1138,1145 **** for ( i=0, node = getfirstallnode(B); node != NONODE && imessage, "%s - data node %d (%d.%d.%d)\n", parent_desc, getnodenumber(B, node), ! data.volume, data.vnode, data.unique); OutputDebugString(B->message); return; } else --- 1309,1315 ---- data = getdatavalue(node); sprintf(B->message, "%s - data node %d (%d.%d.%d)\n", parent_desc, getnodenumber(B, node), ! data.fid.volume, data.fid.vnode, data.fid.unique); OutputDebugString(B->message); return; } else *************** *** 1336,1342 **** prev = getkey(n, slot); data = getdatavalue(getnode(n, slot)); sprintf(B->message, "%8s (%d.%d.%d)\n", ! prev.name, data.volume, data.vnode, data.unique); OutputDebugString(B->message); if (++slot > numentries(n)) n = getnextnode(n), slot = 1; --- 1342,1348 ---- prev = getkey(n, slot); data = getdatavalue(getnode(n, slot)); sprintf(B->message, "%8s (%d.%d.%d)\n", ! prev.name, data.fid.volume, data.fid.vnode, data.fid.unique); OutputDebugString(B->message); if (++slot > numentries(n)) n = getnextnode(n), slot = 1; *************** *** 1453,1467 **** } if (exact) { ! *cfid = getdatavalue(dataNode); rc = 0; bplus_lookup_hits++; } else if (count == 1) { ! *cfid = getdatavalue(firstDataNode); rc = CM_ERROR_INEXACT_MATCH; bplus_lookup_hits_inexact++; } else { ! rc = CM_ERROR_AMBIGUOUS_FILENAME; bplus_lookup_ambiguous++; } } else { --- 1459,1473 ---- } if (exact) { ! *cfid = getdatavalue(dataNode).fid; rc = 0; bplus_lookup_hits++; } else if (count == 1) { ! *cfid = getdatavalue(firstDataNode).fid; rc = CM_ERROR_INEXACT_MATCH; bplus_lookup_hits_inexact++; } else { ! rc = CM_ERROR_AMBIGUOUS_FILENAME; bplus_lookup_ambiguous++; } } else { *************** *** 1489,1495 **** --- 1495,1503 ---- { long rc = 0; keyT key = {entry}; + dataT data; LARGE_INTEGER start, end; + char shortName[13]; if (op->scp->dirBplus == NULL || op->dataVersion != op->scp->dirDataVersion) { *************** *** 1497,1506 **** goto done; } QueryPerformanceCounter(&start); bplus_create_entry++; ! insert(op->scp->dirBplus, key, *cfid); QueryPerformanceCounter(&end); --- 1505,1531 ---- goto done; } + data.fid.cell = cfid->cell; + data.fid.volume = cfid->volume; + data.fid.vnode = cfid->vnode; + data.fid.unique = cfid->unique; + data.longname = NULL; + QueryPerformanceCounter(&start); bplus_create_entry++; ! insert(op->scp->dirBplus, key, data); ! if (!cm_Is8Dot3(entry)) { ! cm_dirFid_t dfid; ! dfid.vnode = htonl(data.fid.vnode); ! dfid.unique = htonl(data.fid.unique); ! ! cm_Gen8Dot3NameInt(entry, &dfid, shortName, NULL); ! ! key.name = shortName; ! data.longname = strdup(entry); ! insert(op->scp->dirBplus, key, data); ! } QueryPerformanceCounter(&end); *************** *** 1522,1527 **** --- 1547,1553 ---- { long rc = 0; keyT key = {entry}; + Nptr leafNode = NONODE; LARGE_INTEGER start, end; if (op->scp->dirBplus == NULL || *************** *** 1535,1541 **** bplus_remove_entry++; if (op->scp->dirBplus) { ! delete(op->scp->dirBplus, key); } QueryPerformanceCounter(&end); --- 1561,1668 ---- bplus_remove_entry++; if (op->scp->dirBplus) { ! if (!cm_Is8Dot3(entry)) { ! cm_dirFid_t dfid; ! cm_fid_t fid; ! char shortName[13]; ! ! leafNode = bplus_Lookup(op->scp->dirBplus, key); ! if (leafNode != NONODE) { ! int slot; ! Nptr firstDataNode, dataNode, nextDataNode; ! int exact = 0; ! int count = 0; ! ! /* Found a leaf that matches the key via a case-insensitive ! * match. There may be one or more data nodes that match. ! * If we have an exact match, return that. ! * If we have an ambiguous match, return an error. ! * If we have only one inexact match, return that. ! */ ! slot = findKey(op->scp->dirBplus, leafNode, 1, numentries(leafNode)); ! firstDataNode = getnode(leafNode, slot); ! ! for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { ! count++; ! if (!comparekeys(op->scp->dirBplus)(key, getdatakey(dataNode), EXACT_MATCH) ) { ! exact = 1; ! break; ! } ! nextDataNode = getdatanext(dataNode); ! } ! ! if (exact) { ! fid = getdatavalue(dataNode).fid; ! rc = 0; ! } else if (count == 1) { ! fid = getdatavalue(firstDataNode).fid; ! rc = CM_ERROR_INEXACT_MATCH; ! } else { ! rc = CM_ERROR_AMBIGUOUS_FILENAME; ! } ! } ! ! ! if (rc != CM_ERROR_AMBIGUOUS_FILENAME) { ! dfid.vnode = htonl(fid.vnode); ! dfid.unique = htonl(fid.unique); ! cm_Gen8Dot3NameInt(entry, &dfid, shortName, NULL); ! ! /* delete first the long name and then the short name */ ! delete(op->scp->dirBplus, key); ! key.name = shortName; ! delete(op->scp->dirBplus, key); ! } ! } else { ! char * longname = NULL; ! /* We need to lookup the 8dot3 name to determine what the ! * matching long name is ! */ ! leafNode = bplus_Lookup(op->scp->dirBplus, key); ! if (leafNode != NONODE) { ! int slot; ! Nptr firstDataNode, dataNode, nextDataNode; ! int exact = 0; ! int count = 0; ! ! /* Found a leaf that matches the key via a case-insensitive ! * match. There may be one or more data nodes that match. ! * If we have an exact match, return that. ! * If we have an ambiguous match, return an error. ! * If we have only one inexact match, return that. ! */ ! slot = findKey(op->scp->dirBplus, leafNode, 1, numentries(leafNode)); ! firstDataNode = getnode(leafNode, slot); ! ! for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { ! count++; ! if (!comparekeys(op->scp->dirBplus)(key, getdatakey(dataNode), EXACT_MATCH) ) { ! exact = 1; ! break; ! } ! nextDataNode = getdatanext(dataNode); ! } ! ! if (exact) { ! longname = getdatavalue(dataNode).longname; ! rc = 0; ! } else if (count == 1) { ! longname = getdatavalue(firstDataNode).longname; ! rc = CM_ERROR_INEXACT_MATCH; ! } else { ! rc = CM_ERROR_AMBIGUOUS_FILENAME; ! } ! } ! ! if (rc != CM_ERROR_AMBIGUOUS_FILENAME) { ! if (longname) { ! key.name = longname; ! delete(op->scp->dirBplus, key); ! key.name = entry; ! } ! delete(op->scp->dirBplus, key); ! } ! } } QueryPerformanceCounter(&end); *************** *** 1552,1561 **** void *dummy, osi_hyper_t *entryOffsetp) { keyT key = {dep->name}; ! dataT data = {scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique)}; /* the Write lock is held in cm_BPlusDirBuildTree() */ insert(scp->dirBplus, key, data); #ifdef BTREE_DEBUG findAllBtreeValues(scp->dirBplus); --- 1679,1706 ---- void *dummy, osi_hyper_t *entryOffsetp) { keyT key = {dep->name}; ! dataT data; ! char shortName[13]; ! ! data.fid.cell = scp->fid.cell; ! data.fid.volume = scp->fid.volume; ! data.fid.vnode = ntohl(dep->fid.vnode); ! data.fid.unique = ntohl(dep->fid.unique); ! data.longname = NULL; /* the Write lock is held in cm_BPlusDirBuildTree() */ insert(scp->dirBplus, key, data); + if (!cm_Is8Dot3(dep->name)) { + cm_dirFid_t dfid; + dfid.vnode = dep->fid.vnode; + dfid.unique = dep->fid.unique; + + cm_Gen8Dot3NameInt(dep->name, &dfid, shortName, NULL); + + key.name = shortName; + data.longname = strdup(dep->name); + insert(scp->dirBplus, key, data); + } #ifdef BTREE_DEBUG findAllBtreeValues(scp->dirBplus); *************** *** 1598,1603 **** --- 1743,1786 ---- return rc; } + int cm_MemDumpBPlusStats(FILE *outputFile, char *cookie, int lock) + { + int zilch; + char output[128]; + + sprintf(output, "%s - B+ Lookup Hits: %-8d\r\n", cookie, bplus_lookup_hits); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Inexact Hits: %-8d\r\n", cookie, bplus_lookup_hits_inexact); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Ambiguous Hits: %-8d\r\n", cookie, bplus_lookup_ambiguous); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Misses: %-8d\r\n", cookie, bplus_lookup_misses); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-8d\r\n", cookie, bplus_create_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-8d\r\n", cookie, bplus_remove_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Build Tree: %-8d\r\n", cookie, bplus_build_tree); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Free Tree: %-8d\r\n", cookie, bplus_free_tree); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - DV Error: %-8d\r\n", cookie, bplus_dv_error); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + sprintf(output, "%s - B+ Time Lookup: %-16I64d\r\n", cookie, bplus_lookup_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-16I64d\r\n", cookie, bplus_create_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-16I64d\r\n", cookie, bplus_remove_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Build: %-16I64d\r\n", cookie, bplus_build_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Free: %-16I64d\r\n", cookie, bplus_free_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + return(0); + } + void cm_BPlusDumpStats(void) { afsi_log("B+ Lookup Hits: %-8d", bplus_lookup_hits); Index: openafs/src/WINNT/afsd/cm_btree.h diff -c openafs/src/WINNT/afsd/cm_btree.h:1.1.2.3 openafs/src/WINNT/afsd/cm_btree.h:1.1.2.5 *** openafs/src/WINNT/afsd/cm_btree.h:1.1.2.3 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm_btree.h Wed Sep 19 23:55:42 2007 *************** *** 51,57 **** char *name; } keyT; ! typedef cm_fid_t dataT; typedef struct entry { keyT key; --- 51,61 ---- char *name; } keyT; ! ! typedef struct dirdata { ! cm_fid_t fid; ! char * longname; ! } dataT; typedef struct entry { keyT key; *************** *** 139,144 **** --- 143,149 ---- int cm_BPlusDirDeleteEntry(cm_dirOp_t * op, char *entry); long cm_BPlusDirBuildTree(cm_scache_t *scp, cm_user_t *userp, cm_req_t* reqp); void cm_BPlusDumpStats(void); + int cm_MemDumpBPlusStats(FILE *outputFile, char *cookie, int lock); extern afs_uint32 bplus_free_tree; extern afs_uint32 bplus_dv_error; Index: openafs/src/WINNT/afsd/cm_buf.c diff -c openafs/src/WINNT/afsd/cm_buf.c:1.31.2.18 openafs/src/WINNT/afsd/cm_buf.c:1.31.2.20 *** openafs/src/WINNT/afsd/cm_buf.c:1.31.2.18 Thu Aug 9 01:33:56 2007 --- openafs/src/WINNT/afsd/cm_buf.c Tue Sep 18 12:59:23 2007 *************** *** 622,633 **** * because we aren't going to be able to write this data to the file * server. */ ! if (code == CM_ERROR_NOSUCHFILE){ bp->flags &= ~CM_BUF_DIRTY; bp->flags |= CM_BUF_ERROR; bp->dirty_offset = 0; bp->dirty_length = 0; ! bp->error = CM_ERROR_NOSUCHFILE; bp->dataVersion = -1; /* bad */ bp->dirtyCounter++; } --- 622,633 ---- * because we aren't going to be able to write this data to the file * server. */ ! if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BADFD){ bp->flags &= ~CM_BUF_DIRTY; bp->flags |= CM_BUF_ERROR; bp->dirty_offset = 0; bp->dirty_length = 0; ! bp->error = code; bp->dataVersion = -1; /* bad */ bp->dirtyCounter++; } *************** *** 1490,1498 **** lock_ReleaseMutex(&bp->mx); code = (*cm_buf_opsp->Stabilizep)(scp, userp, reqp); ! if (code) goto skip; lock_ObtainWrite(&buf_globalLock); /* actually, we only know that buffer is clean if ref * count is 1, since we don't have buffer itself locked. --- 1490,1512 ---- lock_ReleaseMutex(&bp->mx); code = (*cm_buf_opsp->Stabilizep)(scp, userp, reqp); ! if (code && code != CM_ERROR_BADFD) goto skip; + /* if the scp's FID is bad its because we received VNOVNODE + * when attempting to FetchStatus before the write. This + * page therefore contains data that can no longer be stored. + */ + lock_ObtainMutex(&bp->mx); + bp->flags &= ~CM_BUF_DIRTY; + bp->flags |= CM_BUF_ERROR; + bp->error = code; + bp->dirty_offset = 0; + bp->dirty_length = 0; + bp->dataVersion = -1; /* known bad */ + bp->dirtyCounter++; + lock_ReleaseMutex(&bp->mx); + lock_ObtainWrite(&buf_globalLock); /* actually, we only know that buffer is clean if ref * count is 1, since we don't have buffer itself locked. *************** *** 1509,1515 **** } lock_ReleaseWrite(&buf_globalLock); ! (*cm_buf_opsp->Unstabilizep)(scp, userp); } skip: --- 1523,1530 ---- } lock_ReleaseWrite(&buf_globalLock); ! if (code != CM_ERROR_BADFD) ! (*cm_buf_opsp->Unstabilizep)(scp, userp); } skip: *************** *** 1770,1776 **** for (bp = cm_data.buf_allp; bp; bp=bp->allp, bcount++) { if (!cm_FidCmp(fidp, &bp->fid) && (bp->flags & CM_BUF_DIRTY)) { ! buf_Hold(bp); lock_ObtainMutex(&bp->mx); bp->cmFlags &= ~CM_BUF_CMSTORING; bp->flags &= ~CM_BUF_DIRTY; --- 1785,1791 ---- for (bp = cm_data.buf_allp; bp; bp=bp->allp, bcount++) { if (!cm_FidCmp(fidp, &bp->fid) && (bp->flags & CM_BUF_DIRTY)) { ! buf_Hold(bp); lock_ObtainMutex(&bp->mx); bp->cmFlags &= ~CM_BUF_CMSTORING; bp->flags &= ~CM_BUF_DIRTY; Index: openafs/src/WINNT/afsd/cm_buf.h diff -c openafs/src/WINNT/afsd/cm_buf.h:1.12.4.6 openafs/src/WINNT/afsd/cm_buf.h:1.12.4.7 *** openafs/src/WINNT/afsd/cm_buf.h:1.12.4.6 Thu Aug 9 01:33:56 2007 --- openafs/src/WINNT/afsd/cm_buf.h Mon Sep 10 15:08:17 2007 *************** *** 78,85 **** cm_user_t *userp; /* user who wrote to the buffer last */ /* fields added for the CM; locked by scp->mx */ ! long dataVersion; /* data version of this page */ ! long cmFlags; /* flags for cm */ /* syncop state */ afs_uint32 waitCount; /* number of threads waiting */ --- 78,85 ---- cm_user_t *userp; /* user who wrote to the buffer last */ /* fields added for the CM; locked by scp->mx */ ! afs_uint32 dataVersion; /* data version of this page */ ! afs_uint32 cmFlags; /* flags for cm */ /* syncop state */ afs_uint32 waitCount; /* number of threads waiting */ Index: openafs/src/WINNT/afsd/cm_callback.c diff -c openafs/src/WINNT/afsd/cm_callback.c:1.41.4.18 openafs/src/WINNT/afsd/cm_callback.c:1.41.4.19 *** openafs/src/WINNT/afsd/cm_callback.c:1.41.4.18 Thu Aug 2 16:46:12 2007 --- openafs/src/WINNT/afsd/cm_callback.c Thu Sep 13 13:59:21 2007 *************** *** 231,237 **** */ void cm_RevokeVolumeCallback(struct rx_call *callp, cm_cell_t *cellp, AFSFid *fidp) { ! long hash; cm_scache_t *scp; cm_fid_t tfid; --- 231,237 ---- */ void cm_RevokeVolumeCallback(struct rx_call *callp, cm_cell_t *cellp, AFSFid *fidp) { ! unsigned long hash; cm_scache_t *scp; cm_fid_t tfid; *************** *** 411,417 **** struct sockaddr_in taddr; cm_server_t *tsp; cm_scache_t *scp; ! int hash; int discarded; struct rx_connection *connp; struct rx_peer *peerp; --- 411,417 ---- struct sockaddr_in taddr; cm_server_t *tsp; cm_scache_t *scp; ! afs_uint32 hash; int discarded; struct rx_connection *connp; struct rx_peer *peerp; *************** *** 686,692 **** int SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep) { ! int i; cm_scache_t * scp; int code; struct rx_connection *connp; --- 686,692 ---- int SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep) { ! afs_uint32 i; cm_scache_t * scp; int code; struct rx_connection *connp; *************** *** 792,798 **** int SRXAFSCB_GetCE64(struct rx_call *callp, long index, AFSDBCacheEntry64 *cep) { ! int i; cm_scache_t * scp; int code; struct rx_connection *connp; --- 792,798 ---- int SRXAFSCB_GetCE64(struct rx_call *callp, long index, AFSDBCacheEntry64 *cep) { ! afs_uint32 i; cm_scache_t * scp; int code; struct rx_connection *connp; *************** *** 1799,1807 **** /* called periodically by cm_daemon to shut down use of expired callbacks */ void cm_CheckCBExpiration(void) { ! int i; cm_scache_t *scp; ! time_t now, downTime = 0; osi_Log0(afsd_logp, "CheckCBExpiration"); --- 1799,1807 ---- /* called periodically by cm_daemon to shut down use of expired callbacks */ void cm_CheckCBExpiration(void) { ! afs_uint32 i; cm_scache_t *scp; ! time_t now, downTime; osi_Log0(afsd_logp, "CheckCBExpiration"); *************** *** 1809,1815 **** lock_ObtainWrite(&cm_scacheLock); for (i=0; inextp) { ! if (scp->cbServerp && scp->cbExpires > 0 && now > scp->cbExpires && (cm_CBServersUp(scp, &downTime) || downTime == 0 || downTime >= scp->cbExpires)) { --- 1809,1815 ---- lock_ObtainWrite(&cm_scacheLock); for (i=0; inextp) { ! downTime = 0; if (scp->cbServerp && scp->cbExpires > 0 && now > scp->cbExpires && (cm_CBServersUp(scp, &downTime) || downTime == 0 || downTime >= scp->cbExpires)) { *************** *** 1835,1860 **** void ! cm_GiveUpAllCallbacks(cm_server_t *tsp) { long code; cm_conn_t *connp; struct rx_connection * rxconnp; ! if (tsp->type == CM_SERVER_FILE && !(tsp->flags & CM_SERVERFLAG_DOWN)) { code = cm_ConnByServer(tsp, cm_rootUserp, &connp); if (code == 0) { rxconnp = cm_GetRxConn(connp); rx_SetConnDeadTime(rxconnp, 10); ! code = RXAFS_GiveUpAllCallBacks(rxconnp); rx_SetConnDeadTime(rxconnp, ConnDeadtimeout); ! rx_PutConnection(rxconnp); } } } void ! cm_GiveUpAllCallbacksAllServers(void) { cm_server_t *tsp; --- 1835,1893 ---- void ! cm_GiveUpAllCallbacks(cm_server_t *tsp, afs_int32 markDown) { long code; cm_conn_t *connp; struct rx_connection * rxconnp; ! if ((tsp->type == CM_SERVER_FILE) && !(tsp->flags & CM_SERVERFLAG_DOWN)) ! { code = cm_ConnByServer(tsp, cm_rootUserp, &connp); if (code == 0) { rxconnp = cm_GetRxConn(connp); rx_SetConnDeadTime(rxconnp, 10); ! code = RXAFS_GiveUpAllCallBacks(rxconnp); rx_SetConnDeadTime(rxconnp, ConnDeadtimeout); ! rx_PutConnection(rxconnp); ! } ! ! if (markDown) { ! cm_server_vols_t * tsrvp; ! cm_volume_t * volp; ! int i; ! ! lock_ObtainMutex(&tsp->mx); ! if (!(tsp->flags & CM_SERVERFLAG_DOWN)) { ! tsp->flags |= CM_SERVERFLAG_DOWN; ! tsp->downTime = osi_Time(); ! } ! cm_ForceNewConnections(tsp); ! lock_ReleaseMutex(&tsp->mx); ! ! /* Now update the volume status */ ! for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) { ! for (i=0; iids[i] != 0) { ! cm_req_t req; ! ! cm_InitReq(&req); ! ! code = cm_GetVolumeByID(tsp->cellp, tsrvp->ids[i], cm_rootUserp, ! &req, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp); ! if (code == 0) { ! cm_UpdateVolumeStatus(volp, tsrvp->ids[i]); ! cm_PutVolume(volp); ! } ! } ! } ! } } } } void ! cm_GiveUpAllCallbacksAllServers(afs_int32 markDown) { cm_server_t *tsp; *************** *** 1862,1868 **** for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) { cm_GetServerNoLock(tsp); lock_ReleaseWrite(&cm_serverLock); ! cm_GiveUpAllCallbacks(tsp); lock_ObtainWrite(&cm_serverLock); cm_PutServerNoLock(tsp); } --- 1895,1901 ---- for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) { cm_GetServerNoLock(tsp); lock_ReleaseWrite(&cm_serverLock); ! cm_GiveUpAllCallbacks(tsp, markDown); lock_ObtainWrite(&cm_serverLock); cm_PutServerNoLock(tsp); } Index: openafs/src/WINNT/afsd/cm_callback.h diff -c openafs/src/WINNT/afsd/cm_callback.h:1.7.4.2 openafs/src/WINNT/afsd/cm_callback.h:1.7.4.3 *** openafs/src/WINNT/afsd/cm_callback.h:1.7.4.2 Thu Jun 28 00:50:15 2007 --- openafs/src/WINNT/afsd/cm_callback.h Thu Sep 13 13:59:21 2007 *************** *** 68,75 **** extern void cm_CallbackNotifyChange(cm_scache_t *scp); ! extern void cm_GiveUpAllCallbacks(cm_server_t *tsp); ! extern void cm_GiveUpAllCallbacksAllServers(void); #endif /* _CM_CALLBACK_H_ENV__ */ --- 68,75 ---- extern void cm_CallbackNotifyChange(cm_scache_t *scp); ! extern void cm_GiveUpAllCallbacks(cm_server_t *tsp, afs_int32 markDown); ! extern void cm_GiveUpAllCallbacksAllServers(afs_int32 markDown); #endif /* _CM_CALLBACK_H_ENV__ */ Index: openafs/src/WINNT/afsd/cm_conn.c diff -c openafs/src/WINNT/afsd/cm_conn.c:1.49.2.21 openafs/src/WINNT/afsd/cm_conn.c:1.49.2.22 *** openafs/src/WINNT/afsd/cm_conn.c:1.49.2.21 Tue Aug 7 00:00:49 2007 --- openafs/src/WINNT/afsd/cm_conn.c Thu Sep 13 13:59:21 2007 *************** *** 552,559 **** /* mark server as down */ lock_ObtainMutex(&serverp->mx); if (reqp->flags & CM_REQ_NEW_CONN_FORCED) { ! serverp->flags |= CM_SERVERFLAG_DOWN; ! serverp->downTime = osi_Time(); } else { reqp->flags |= CM_REQ_NEW_CONN_FORCED; forcing_new = 1; --- 552,561 ---- /* mark server as down */ lock_ObtainMutex(&serverp->mx); if (reqp->flags & CM_REQ_NEW_CONN_FORCED) { ! if (!(serverp->flags & CM_SERVERFLAG_DOWN)) { ! serverp->flags |= CM_SERVERFLAG_DOWN; ! serverp->downTime = osi_Time(); ! } } else { reqp->flags |= CM_REQ_NEW_CONN_FORCED; forcing_new = 1; Index: openafs/src/WINNT/afsd/cm_dcache.c diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.16 openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.19 *** openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.16 Thu Aug 9 01:33:56 2007 --- openafs/src/WINNT/afsd/cm_dcache.c Tue Sep 18 12:59:23 2007 *************** *** 57,63 **** */ long code; cm_scache_t *scp = vscp; ! long nbytes; long temp; AFSFetchStatus outStatus; AFSStoreStatus inStatus; --- 57,63 ---- */ long code; cm_scache_t *scp = vscp; ! afs_int32 nbytes; long temp; AFSFetchStatus outStatus; AFSStoreStatus inStatus; *************** *** 68,74 **** struct rx_connection *rxconnp; osi_queueData_t *qdp; cm_buf_t *bufp; ! long wbytes; char *bufferp; cm_conn_t *connp; osi_hyper_t truncPos; --- 68,74 ---- struct rx_connection *rxconnp; osi_queueData_t *qdp; cm_buf_t *bufp; ! afs_uint32 wbytes; char *bufferp; cm_conn_t *connp; osi_hyper_t truncPos; *************** *** 84,96 **** */ lock_ObtainMutex(&scp->mx); - cm_AFSFidFromFid(&tfid, &scp->fid); - if (scp->flags & CM_SCACHEFLAG_DELETED) { lock_ReleaseMutex(&scp->mx); return CM_ERROR_NOSUCHFILE; } code = cm_SetupStoreBIOD(scp, offsetp, length, &biod, userp, reqp); if (code) { osi_Log1(afsd_logp, "cm_SetupStoreBIOD code %x", code); --- 84,96 ---- */ lock_ObtainMutex(&scp->mx); if (scp->flags & CM_SCACHEFLAG_DELETED) { lock_ReleaseMutex(&scp->mx); return CM_ERROR_NOSUCHFILE; } + cm_AFSFidFromFid(&tfid, &scp->fid); + code = cm_SetupStoreBIOD(scp, offsetp, length, &biod, userp, reqp); if (code) { osi_Log1(afsd_logp, "cm_SetupStoreBIOD code %x", code); *************** *** 532,542 **** } /* used when deciding whether to do a prefetch or not */ ! long cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, long length, ! cm_user_t *up, cm_req_t *reqp, osi_hyper_t *realBasep) { - osi_hyper_t toffset; osi_hyper_t tbase; long code; cm_buf_t *bp; int stop; --- 532,543 ---- } /* used when deciding whether to do a prefetch or not */ ! long cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, osi_hyper_t *length, ! cm_user_t *userp, cm_req_t *reqp, osi_hyper_t *realBasep) { osi_hyper_t tbase; + osi_hyper_t tlength; + osi_hyper_t tblocksize; long code; cm_buf_t *bp; int stop; *************** *** 545,555 **** * they need work. */ tbase = *startBasep; stop = 0; lock_ObtainMutex(&scp->mx); ! while(length > 0) { /* get callback so we can do a meaningful dataVersion comparison */ ! code = cm_SyncOp(scp, NULL, up, reqp, 0, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); if (code) { scp->flags &= ~CM_SCACHEFLAG_PREFETCHING; --- 546,558 ---- * they need work. */ tbase = *startBasep; + tlength = *length; + tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize); stop = 0; lock_ObtainMutex(&scp->mx); ! while (LargeIntegerGreaterThanZero(tlength)) { /* get callback so we can do a meaningful dataVersion comparison */ ! code = cm_SyncOp(scp, NULL, userp, reqp, 0, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); if (code) { scp->flags &= ~CM_SCACHEFLAG_PREFETCHING; *************** *** 580,592 **** if (stop) break; ! toffset.LowPart = cm_data.buf_blockSize; ! toffset.HighPart = 0; ! tbase = LargeIntegerAdd(toffset, tbase); ! length -= cm_data.buf_blockSize; } ! /* if we get here, either everything is fine or stop stopped us at a * particular buffer in the range that definitely needs to be fetched. */ if (stop == 0) { --- 583,593 ---- if (stop) break; ! tbase = LargeIntegerAdd(tbase, tblocksize); ! tlength = LargeIntegerSubtract(tlength, tblocksize); } ! /* if we get here, either everything is fine or 'stop' stopped us at a * particular buffer in the range that definitely needs to be fetched. */ if (stop == 0) { *************** *** 639,657 **** } /* Called with scp locked */ ! void cm_ClearPrefetchFlag(long code, cm_scache_t *scp, osi_hyper_t *base) { ! osi_hyper_t thyper; if (code == 0) { ! thyper.LowPart = cm_chunkSize; ! thyper.HighPart = 0; ! thyper = LargeIntegerAdd(*base, thyper); ! thyper.LowPart &= (-cm_chunkSize); if (LargeIntegerGreaterThan(*base, scp->prefetch.base)) scp->prefetch.base = *base; ! if (LargeIntegerGreaterThan(thyper, scp->prefetch.end)) ! scp->prefetch.end = thyper; } scp->flags &= ~CM_SCACHEFLAG_PREFETCHING; } --- 640,655 ---- } /* Called with scp locked */ ! void cm_ClearPrefetchFlag(long code, cm_scache_t *scp, osi_hyper_t *base, osi_hyper_t *length) { ! osi_hyper_t end; if (code == 0) { ! end = LargeIntegerAdd(*base, *length); if (LargeIntegerGreaterThan(*base, scp->prefetch.base)) scp->prefetch.base = *base; ! if (LargeIntegerGreaterThan(end, scp->prefetch.end)) ! scp->prefetch.end = end; } scp->flags &= ~CM_SCACHEFLAG_PREFETCHING; } *************** *** 662,672 **** cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp) { ! long length; osi_hyper_t base; long code; cm_buf_t *bp = NULL; - int cpff = 0; /* cleared prefetch flag */ cm_req_t req; cm_InitReq(&req); --- 660,674 ---- cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp) { ! osi_hyper_t length; osi_hyper_t base; + osi_hyper_t offset; + osi_hyper_t end; + osi_hyper_t fetched; + osi_hyper_t tblocksize; long code; + int mxheld = 0; cm_buf_t *bp = NULL; cm_req_t req; cm_InitReq(&req); *************** *** 674,707 **** /* Retries will be performed by the BkgDaemon thread if appropriate */ req.flags |= CM_REQ_NORETRY; base.LowPart = p1; base.HighPart = p2; ! length = p3; ! osi_Log2(afsd_logp, "Starting BKG prefetch scp 0x%p, base 0x%x", scp, p1); ! code = buf_Get(scp, &base, &bp); ! lock_ObtainMutex(&scp->mx); ! if (code || (bp->cmFlags & CM_BUF_CMFETCHING)) { ! scp->flags &= ~CM_SCACHEFLAG_PREFETCHING; ! lock_ReleaseMutex(&scp->mx); ! if (bp) ! buf_Release(bp); ! return 0; } ! ! code = cm_GetBuffer(scp, bp, &cpff, userp, &req); ! if (!cpff) ! cm_ClearPrefetchFlag(code, scp, &base); lock_ReleaseMutex(&scp->mx); ! buf_Release(bp); return code; } /* a read was issued to offsetp, and we have to determine whether we should ! * do a prefetch. */ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, cm_user_t *userp, cm_req_t *reqp) --- 676,740 ---- /* Retries will be performed by the BkgDaemon thread if appropriate */ req.flags |= CM_REQ_NORETRY; + fetched.LowPart = 0; + fetched.HighPart = 0; + tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize); base.LowPart = p1; base.HighPart = p2; ! length.LowPart = p3; ! length.HighPart = p4; ! ! end = LargeIntegerAdd(base, length); ! osi_Log3(afsd_logp, "Starting BKG prefetch scp 0x%p, base 0x%x:%x", scp, p2, p1); ! for (code = 0, offset = base; ! code == 0 && LargeIntegerLessThan(offset, end); ! offset = LargeIntegerAdd(offset, tblocksize)) ! { ! if (mxheld) { ! lock_ReleaseMutex(&scp->mx); ! mxheld = 0; ! } ! code = buf_Get(scp, &base, &bp); ! if (!mxheld) { ! lock_ObtainMutex(&scp->mx); ! mxheld = 1; ! } ! if (code || (bp->cmFlags & CM_BUF_CMFETCHING)) { ! code = 0; ! if (bp) { ! buf_Release(bp); ! bp = NULL; ! } ! break; ! } ! code = cm_GetBuffer(scp, bp, NULL, userp, &req); ! if (code == 0) ! fetched = LargeIntegerAdd(fetched, tblocksize); } ! ! if (!mxheld) { ! lock_ObtainMutex(&scp->mx); ! mxheld = 1; ! } ! cm_ClearPrefetchFlag(LargeIntegerGreaterThanZero(fetched) ? 0 : code, ! scp, &base, &fetched); lock_ReleaseMutex(&scp->mx); ! if (bp) { ! buf_Release(bp); ! bp = NULL; ! } ! ! osi_Log4(afsd_logp, "Ending BKG prefetch scp 0x%p, code %d bytes 0x%x:%x", ! scp, code, fetched.HighPart, fetched.LowPart); return code; } /* a read was issued to offsetp, and we have to determine whether we should ! * do a prefetch of the next chunk. */ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, cm_user_t *userp, cm_req_t *reqp) *************** *** 709,720 **** --- 742,756 ---- long code; osi_hyper_t realBase; osi_hyper_t readBase; + osi_hyper_t readLength; readBase = *offsetp; /* round up to chunk boundary */ readBase.LowPart += (cm_chunkSize-1); readBase.LowPart &= (-cm_chunkSize); + readLength = ConvertLongToLargeInteger(cm_chunkSize); + lock_ObtainMutex(&scp->mx); if ((scp->flags & CM_SCACHEFLAG_PREFETCHING) || LargeIntegerLessThanOrEqualTo(readBase, scp->prefetch.base)) { *************** *** 731,737 **** lock_ReleaseMutex(&scp->mx); ! code = cm_CheckFetchRange(scp, &readBase, cm_chunkSize, userp, reqp, &realBase); if (code) return; /* can't find something to prefetch */ --- 767,773 ---- lock_ReleaseMutex(&scp->mx); ! code = cm_CheckFetchRange(scp, &readBase, &readLength, userp, reqp, &realBase); if (code) return; /* can't find something to prefetch */ *************** *** 739,746 **** osi_Log2(afsd_logp, "BKG Prefetch request scp 0x%p, base 0x%x", scp, realBase.LowPart); ! cm_QueueBKGRequest(scp, cm_BkgPrefetch, realBase.LowPart, ! realBase.HighPart, cm_chunkSize, 0, userp); } /* scp must be locked; temporarily unlocked during processing. --- 775,784 ---- osi_Log2(afsd_logp, "BKG Prefetch request scp 0x%p, base 0x%x", scp, realBase.LowPart); ! cm_QueueBKGRequest(scp, cm_BkgPrefetch, ! realBase.LowPart, realBase.HighPart, ! readLength.LowPart, readLength.HighPart, ! userp); } /* scp must be locked; temporarily unlocked during processing. *************** *** 783,790 **** bufp = NULL; for (temp = 0; temp < inSize; temp += cm_data.buf_blockSize) { ! thyper.HighPart = 0; ! thyper.LowPart = temp; tbase = LargeIntegerAdd(*inOffsetp, thyper); bufp = buf_Find(scp, &tbase); --- 821,827 ---- bufp = NULL; for (temp = 0; temp < inSize; temp += cm_data.buf_blockSize) { ! thyper = ConvertLongToLargeInteger(temp); tbase = LargeIntegerAdd(*inOffsetp, thyper); bufp = buf_Find(scp, &tbase); *************** *** 799,804 **** --- 836,842 ---- if (code) { lock_ReleaseMutex(&bufp->mx); buf_Release(bufp); + bufp = NULL; buf_UnreserveBuffers(cm_chunkSize / cm_data.buf_blockSize); return code; } *************** *** 846,853 **** /* compute the window surrounding *inOffsetp of size cm_chunkSize */ scanStart = *inOffsetp; scanStart.LowPart &= (-cm_chunkSize); ! thyper.LowPart = cm_chunkSize; ! thyper.HighPart = 0; scanEnd = LargeIntegerAdd(scanStart, thyper); flags = CM_SCACHESYNC_GETSTATUS --- 884,890 ---- /* compute the window surrounding *inOffsetp of size cm_chunkSize */ scanStart = *inOffsetp; scanStart.LowPart &= (-cm_chunkSize); ! thyper = ConvertLongToLargeInteger(cm_chunkSize); scanEnd = LargeIntegerAdd(scanStart, thyper); flags = CM_SCACHESYNC_GETSTATUS *************** *** 856,863 **** | CM_SCACHESYNC_NOWAIT; /* start by looking backwards until scanStart */ ! thyper.HighPart = 0; /* hyper version of cm_data.buf_blockSize */ ! thyper.LowPart = cm_data.buf_blockSize; tbase = LargeIntegerSubtract(firstModOffset, thyper); while(LargeIntegerGreaterThanOrEqualTo(tbase, scanStart)) { /* see if we can find the buffer */ --- 893,900 ---- | CM_SCACHESYNC_NOWAIT; /* start by looking backwards until scanStart */ ! /* hyper version of cm_data.buf_blockSize */ ! thyper = ConvertLongToLargeInteger(cm_data.buf_blockSize); tbase = LargeIntegerSubtract(firstModOffset, thyper); while(LargeIntegerGreaterThanOrEqualTo(tbase, scanStart)) { /* see if we can find the buffer */ *************** *** 916,923 **** } /* while loop looking for pages preceding the one we found */ /* now, find later dirty, contiguous pages, and add them to the list */ ! thyper.HighPart = 0; /* hyper version of cm_data.buf_blockSize */ ! thyper.LowPart = cm_data.buf_blockSize; tbase = LargeIntegerAdd(firstModOffset, thyper); while(LargeIntegerLessThan(tbase, scanEnd)) { /* see if we can find the buffer */ --- 953,960 ---- } /* while loop looking for pages preceding the one we found */ /* now, find later dirty, contiguous pages, and add them to the list */ ! /* hyper version of cm_data.buf_blockSize */ ! thyper = ConvertLongToLargeInteger(cm_data.buf_blockSize); tbase = LargeIntegerAdd(firstModOffset, thyper); while(LargeIntegerLessThan(tbase, scanEnd)) { /* see if we can find the buffer */ *************** *** 984,994 **** * If an error is returned, we don't return any buffers. */ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp, ! cm_bulkIO_t *biop, cm_user_t *up, cm_req_t *reqp) { long code; cm_buf_t *tbp; ! osi_hyper_t toffset; /* a long long temp variable */ osi_hyper_t pageBase; /* base offset we're looking at */ osi_queueData_t *qdp; /* one temp queue structure */ osi_queueData_t *tqdp; /* another temp queue structure */ --- 1021,1031 ---- * If an error is returned, we don't return any buffers. */ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp, ! cm_bulkIO_t *biop, cm_user_t *userp, cm_req_t *reqp) { long code; cm_buf_t *tbp; ! osi_hyper_t tblocksize; /* a long long temp variable */ osi_hyper_t pageBase; /* base offset we're looking at */ osi_queueData_t *qdp; /* one temp queue structure */ osi_queueData_t *tqdp; /* another temp queue structure */ *************** *** 1000,1005 **** --- 1037,1044 ---- osi_queueData_t *heldBufListEndp; /* first one */ int reserving; + tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize); + biop->scp = scp; /* do not hold; held by caller */ biop->offset = *offsetp; /* null out the list of buffers */ *************** *** 1007,1013 **** biop->reserved = 0; /* first lookup the file's length, so we know when to stop */ ! code = cm_SyncOp(scp, NULL, up, reqp, 0, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); if (code) return code; --- 1046,1052 ---- biop->reserved = 0; /* first lookup the file's length, so we know when to stop */ ! code = cm_SyncOp(scp, NULL, userp, reqp, 0, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); if (code) return code; *************** *** 1061,1070 **** } buf_Release(tbp); ! toffset.HighPart = 0; ! toffset.LowPart = cm_data.buf_blockSize; ! pageBase = LargeIntegerAdd(toffset, pageBase); collected += cm_data.buf_blockSize; } --- 1100,1108 ---- } buf_Release(tbp); + tbp = NULL; ! pageBase = LargeIntegerAdd(tblocksize, pageBase); collected += cm_data.buf_blockSize; } *************** *** 1102,1110 **** break; collected += cm_data.buf_blockSize; ! toffset.HighPart = 0; ! toffset.LowPart = cm_data.buf_blockSize; ! pageBase = LargeIntegerAdd(toffset, pageBase); } /* look at each buffer, adding it into the list if it looks idle and --- 1140,1146 ---- break; collected += cm_data.buf_blockSize; ! pageBase = LargeIntegerAdd(tblocksize, pageBase); } /* look at each buffer, adding it into the list if it looks idle and *************** *** 1140,1146 **** /* wait for the buffer to serialize, if required. Doesn't * release the scp or buffer lock(s) if NOWAIT is specified. */ ! code = cm_SyncOp(scp, tbp, up, reqp, 0, flags); if (code) { lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&tbp->mx); --- 1176,1182 ---- /* wait for the buffer to serialize, if required. Doesn't * release the scp or buffer lock(s) if NOWAIT is specified. */ ! code = cm_SyncOp(scp, tbp, userp, reqp, 0, flags); if (code) { lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&tbp->mx); *************** *** 1186,1191 **** --- 1222,1228 ---- &qdp->q); osi_QDFree(qdp); buf_Release(tbp); + tbp = NULL; } /* Caller expects this */ *************** *** 1279,1285 **** /* Fetch a buffer. Called with scp locked. * The scp is locked on return. */ ! long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *up, cm_req_t *reqp) { long code; --- 1316,1322 ---- /* Fetch a buffer. Called with scp locked. * The scp is locked on return. */ ! long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *userp, cm_req_t *reqp) { long code; *************** *** 1300,1306 **** cm_bulkIO_t biod; /* bulk IO descriptor */ cm_conn_t *connp; int getroot; ! long t1, t2; int require_64bit_ops = 0; /* now, the buffer may or may not be filled with good data (buf_GetNew --- 1337,1343 ---- cm_bulkIO_t biod; /* bulk IO descriptor */ cm_conn_t *connp; int getroot; ! afs_int32 t1,t2; int require_64bit_ops = 0; /* now, the buffer may or may not be filled with good data (buf_GetNew *************** *** 1321,1330 **** cm_AFSFidFromFid(&tfid, &scp->fid); ! code = cm_SetupFetchBIOD(scp, &bufp->offset, &biod, up, reqp); if (code) { /* couldn't even get the first page setup properly */ ! osi_Log1(afsd_logp, "SetupFetchBIOD failure code %d", code); return code; } --- 1358,1367 ---- cm_AFSFidFromFid(&tfid, &scp->fid); ! code = cm_SetupFetchBIOD(scp, &bufp->offset, &biod, userp, reqp); if (code) { /* couldn't even get the first page setup properly */ ! osi_Log1(afsd_logp, "GetBuffer: SetupFetchBIOD failure code %d", code); return code; } *************** *** 1336,1347 **** * which case we just retry. */ if (bufp->dataVersion == scp->dataVersion || biod.length == 0) { ! osi_Log3(afsd_logp, "Bad DVs %d, %d or length 0x%x", ! bufp->dataVersion, scp->dataVersion, biod.length); ! if ((bufp->dataVersion == -1 ! || bufp->dataVersion < scp->dataVersion) ! && LargeIntegerGreaterThanOrEqualTo(bufp->offset, ! scp->serverLength)) { if (bufp->dataVersion == -1) memset(bufp->datap, 0, cm_data.buf_blockSize); bufp->dataVersion = scp->dataVersion; --- 1373,1384 ---- * which case we just retry. */ if (bufp->dataVersion == scp->dataVersion || biod.length == 0) { ! if ((bufp->dataVersion == -1 || bufp->dataVersion < scp->dataVersion) && ! LargeIntegerGreaterThanOrEqualTo(bufp->offset, scp->serverLength)) ! { ! osi_Log3(afsd_logp, "Bad DVs %d, %d or length 0x%x", ! bufp->dataVersion, scp->dataVersion, biod.length); ! if (bufp->dataVersion == -1) memset(bufp->datap, 0, cm_data.buf_blockSize); bufp->dataVersion = scp->dataVersion; *************** *** 1408,1414 **** bufferp=tbufp->datap; memset(bufferp, 0, cm_data.buf_blockSize); t2 = cm_fakeDirSize - t1; ! if (t2>cm_data.buf_blockSize) t2=cm_data.buf_blockSize; if (t2 > 0) { memcpy(bufferp, cm_FakeRootDir+t1, t2); } else { --- 1445,1452 ---- bufferp=tbufp->datap; memset(bufferp, 0, cm_data.buf_blockSize); t2 = cm_fakeDirSize - t1; ! if (t2> (afs_int32)cm_data.buf_blockSize) ! t2=cm_data.buf_blockSize; if (t2 > 0) { memcpy(bufferp, cm_FakeRootDir+t1, t2); } else { *************** *** 1431,1437 **** /* now make the call */ do { ! code = cm_ConnFromFID(&scp->fid, up, reqp, &connp); if (code) continue; --- 1469,1475 ---- /* now make the call */ do { ! code = cm_ConnFromFID(&scp->fid, userp, reqp, &connp); if (code) continue; *************** *** 1557,1564 **** osi_Wakeup((LONG_PTR) &scp->flags); } if (cpffp && !*cpffp && !osi_QPrev(&qdp->q)) { *cpffp = 1; ! cm_ClearPrefetchFlag(0, scp, &biod.offset); } lock_ReleaseMutex(&scp->mx); --- 1595,1603 ---- osi_Wakeup((LONG_PTR) &scp->flags); } if (cpffp && !*cpffp && !osi_QPrev(&qdp->q)) { + osi_hyper_t tlength = ConvertLongToLargeInteger(biod.length); *cpffp = 1; ! cm_ClearPrefetchFlag(0, scp, &biod.offset, &tlength); } lock_ReleaseMutex(&scp->mx); *************** *** 1623,1629 **** osi_Log0(afsd_logp, "CALL FetchData DONE"); ! } while (cm_Analyze(connp, up, reqp, &scp->fid, &volSync, NULL, NULL, code)); fetchingcompleted: code = cm_MapRPCError(code, reqp); --- 1662,1668 ---- osi_Log0(afsd_logp, "CALL FetchData DONE"); ! } while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync, NULL, NULL, code)); fetchingcompleted: code = cm_MapRPCError(code, reqp); *************** *** 1658,1664 **** lock_ObtainMutex(&scp->mx); if (code == 0) ! cm_MergeStatus(NULL, scp, &afsStatus, &volSync, up, 0); return code; } --- 1697,1703 ---- lock_ObtainMutex(&scp->mx); if (code == 0) ! cm_MergeStatus(NULL, scp, &afsStatus, &volSync, userp, 0); return code; } Index: openafs/src/WINNT/afsd/cm_dcache.h diff -c openafs/src/WINNT/afsd/cm_dcache.h:1.4.4.3 openafs/src/WINNT/afsd/cm_dcache.h:1.4.4.4 *** openafs/src/WINNT/afsd/cm_dcache.h:1.4.4.3 Sun Feb 4 10:39:14 2007 --- openafs/src/WINNT/afsd/cm_dcache.h Mon Sep 10 15:08:17 2007 *************** *** 32,38 **** struct cm_user *, struct cm_req *); extern long cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, ! long length, cm_user_t *up, cm_req_t *reqp, osi_hyper_t *realBasep); extern long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp, cm_bulkIO_t *biop, cm_user_t *up, cm_req_t *reqp); --- 32,39 ---- struct cm_user *, struct cm_req *); extern long cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, ! osi_hyper_t *length, cm_user_t *up, ! cm_req_t *reqp, osi_hyper_t *realBasep); extern long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp, cm_bulkIO_t *biop, cm_user_t *up, cm_req_t *reqp); Index: openafs/src/WINNT/afsd/cm_dir.c diff -c openafs/src/WINNT/afsd/cm_dir.c:1.4.4.4 openafs/src/WINNT/afsd/cm_dir.c:1.4.4.6 *** openafs/src/WINNT/afsd/cm_dir.c:1.4.4.4 Tue Aug 28 13:50:06 2007 --- openafs/src/WINNT/afsd/cm_dir.c Wed Sep 19 23:55:42 2007 *************** *** 34,45 **** afs_uint64 dir_create_time = 0; afs_uint64 dir_remove_time = 0; ! afs_int32 cm_BPlusTrees = 0; void cm_DirDumpStats(void) { afsi_log("Dir Lookup Hits: %-8d", dir_lookup_hits); afsi_log(" Misses: %-8d", dir_lookup_misses); afsi_log(" Create: %-8d", dir_create_entry); afsi_log(" Remove: %-8d", dir_remove_entry); --- 34,74 ---- afs_uint64 dir_create_time = 0; afs_uint64 dir_remove_time = 0; ! afs_uint64 dir_enums = 0; ! ! afs_int32 cm_BPlusTrees = 1; ! ! int cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock) ! { ! int zilch; ! char output[128]; ! ! sprintf(output, "%s - Dir Lookup Hits: %-8d\r\n", cookie, dir_lookup_hits); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Misses: %-8d\r\n", cookie, dir_lookup_misses); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Enums: %-8d\r\n", cookie, dir_enums); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Create: %-8d\r\n", cookie, dir_create_entry); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Remove: %-8d\r\n", cookie, dir_remove_entry); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! ! sprintf(output, "%s - Dir Times Lookup: %-16I64d\r\n", cookie, dir_lookup_time); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Create: %-16I64d\r\n", cookie, dir_create_time); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! sprintf(output, "%s - Remove: %-16I64d\r\n", cookie, dir_remove_time); ! WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); ! ! return(0); ! } void cm_DirDumpStats(void) { afsi_log("Dir Lookup Hits: %-8d", dir_lookup_hits); afsi_log(" Misses: %-8d", dir_lookup_misses); + afsi_log(" Enums: %-8d", dir_enums); afsi_log(" Create: %-8d", dir_create_entry); afsi_log(" Remove: %-8d", dir_remove_entry); Index: openafs/src/WINNT/afsd/cm_dir.h diff -c openafs/src/WINNT/afsd/cm_dir.h:1.4.4.3 openafs/src/WINNT/afsd/cm_dir.h:1.4.4.5 *** openafs/src/WINNT/afsd/cm_dir.h:1.4.4.3 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm_dir.h Wed Sep 19 23:55:42 2007 *************** *** 182,185 **** --- 182,190 ---- extern void cm_DirDumpStats(void); + + extern int + cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock); + + extern afs_int64 dir_enums; #endif /* __CM_DIR_ENV__ */ Index: openafs/src/WINNT/afsd/cm_ioctl.c diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.19 openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.20 *** openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.19 Sun Jul 22 19:10:17 2007 --- openafs/src/WINNT/afsd/cm_ioctl.c Wed Sep 19 23:55:42 2007 *************** *** 2756,2761 **** --- 2756,2763 ---- #endif /* dump all interesting data */ + cm_MemDumpDirStats(hLogFile, cookie, 1); + cm_MemDumpBPlusStats(hLogFile, cookie, 1); cm_DumpCells(hLogFile, cookie, 1); cm_DumpVolumes(hLogFile, cookie, 1); cm_DumpSCache(hLogFile, cookie, 1); Index: openafs/src/WINNT/afsd/cm_scache.c diff -c openafs/src/WINNT/afsd/cm_scache.c:1.35.2.42 openafs/src/WINNT/afsd/cm_scache.c:1.35.2.44 *** openafs/src/WINNT/afsd/cm_scache.c:1.35.2.42 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm_scache.c Thu Sep 13 13:59:21 2007 *************** *** 474,491 **** cm_SuspendSCache(void) { cm_scache_t * scp; ! cm_GiveUpAllCallbacksAllServers(); lock_ObtainWrite(&cm_scacheLock); ! for ( scp = cm_data.allSCachesp; scp; ! scp = scp->allNextp ) { ! if (scp->cbServerp) { ! cm_PutServer(scp->cbServerp); ! scp->cbServerp = NULL; ! } ! scp->cbExpires = 0; ! scp->flags &= ~CM_SCACHEFLAG_CALLBACK; } lock_ReleaseWrite(&cm_scacheLock); } --- 474,499 ---- cm_SuspendSCache(void) { cm_scache_t * scp; + time_t now; ! cm_GiveUpAllCallbacksAllServers(TRUE); ! ! /* ! * After this call all servers are marked down. ! * Do not clear the callbacks, instead change the ! * expiration time so that the callbacks will be expired ! * when the servers are marked back up. However, we ! * want the callbacks to be preserved as long as the ! * servers are down. That way if the machine resumes ! * without network, the stat cache item will still be ! * considered valid. ! */ ! now = osi_Time(); lock_ObtainWrite(&cm_scacheLock); ! for ( scp = cm_data.allSCachesp; scp; scp = scp->allNextp ) { ! if (scp->cbServerp) ! scp->cbExpires = now+1; } lock_ReleaseWrite(&cm_scacheLock); } *************** *** 524,530 **** } lock_ReleaseWrite(&cm_scacheLock); ! cm_GiveUpAllCallbacksAllServers(); return cm_dnlcShutdown(); } --- 532,538 ---- } lock_ReleaseWrite(&cm_scacheLock); ! cm_GiveUpAllCallbacksAllServers(FALSE); return cm_dnlcShutdown(); } Index: openafs/src/WINNT/afsd/cm_scache.h diff -c openafs/src/WINNT/afsd/cm_scache.h:1.21.2.14 openafs/src/WINNT/afsd/cm_scache.h:1.21.2.15 *** openafs/src/WINNT/afsd/cm_scache.h:1.21.2.14 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm_scache.h Mon Sep 10 15:08:17 2007 *************** *** 14,20 **** #include "largeint95.h" #endif /* DJGPP */ ! #define MOUNTPOINTLEN 1024 typedef struct cm_fid { unsigned long cell; --- 14,20 ---- #include "largeint95.h" #endif /* DJGPP */ ! #define MOUNTPOINTLEN 1024 /* max path length for symlink; same as AFSPATHMAX */ typedef struct cm_fid { unsigned long cell; Index: openafs/src/WINNT/afsd/cm_server.c diff -c openafs/src/WINNT/afsd/cm_server.c:1.25.2.12 openafs/src/WINNT/afsd/cm_server.c:1.25.2.13 *** openafs/src/WINNT/afsd/cm_server.c:1.25.2.12 Thu Aug 2 16:46:12 2007 --- openafs/src/WINNT/afsd/cm_server.c Thu Sep 13 13:59:21 2007 *************** *** 152,159 **** } } else { /* mark server as down */ ! tsp->flags |= CM_SERVERFLAG_DOWN; ! tsp->downTime = osi_Time(); if (code != VRESTARTING) cm_ForceNewConnections(tsp); --- 152,161 ---- } } else { /* mark server as down */ ! if (!(tsp->flags & CM_SERVERFLAG_DOWN)) { ! tsp->flags |= CM_SERVERFLAG_DOWN; ! tsp->downTime = osi_Time(); ! } if (code != VRESTARTING) cm_ForceNewConnections(tsp); Index: openafs/src/WINNT/afsd/cm_vnodeops.c diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.41 openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.44 *** openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.41 Sun Aug 26 20:05:24 2007 --- openafs/src/WINNT/afsd/cm_vnodeops.c Wed Sep 12 21:41:44 2007 *************** *** 666,672 **** return 0; } ! return CM_ERROR_NOSUCHFILE; } #endif } --- 666,672 ---- return 0; } ! return CM_ERROR_BPLUS_NOMATCH; } #endif } *************** *** 1076,1082 **** --- 1076,1084 ---- strncpy(cellNamep, mpNamep+1, cp - mpNamep - 1); strcpy(volNamep, cp+1); /* now look up the cell */ + lock_ReleaseMutex(&scp->mx); cellp = cm_GetCell(cellNamep, CM_FLAG_CREATE); + lock_ObtainMutex(&scp->mx); } else { /* normal mt pt */ *************** *** 1224,1230 **** goto haveFid; } ! return CM_ERROR_NOSUCHFILE; } #endif } --- 1226,1232 ---- goto haveFid; } ! return CM_ERROR_BPLUS_NOMATCH; } #endif } *************** *** 1500,1506 **** #endif { long code; ! char tname[256]; int sysNameIndex = 0; cm_scache_t *scp = NULL; --- 1502,1508 ---- #endif { long code; ! char tname[AFSPATHMAX]; int sysNameIndex = 0; cm_scache_t *scp = NULL; *************** *** 1621,1628 **** else osi_Log0(afsd_logp, "CALL RemoveFile SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_dnlcRemove(dscp, namep); cm_SyncOpDone(dscp, NULL, sflags); --- 1623,1632 ---- else osi_Log0(afsd_logp, "CALL RemoveFile SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_dnlcRemove(dscp, namep); cm_SyncOpDone(dscp, NULL, sflags); *************** *** 1814,1820 **** char *tp; /* ptr moving through input buffer */ char tc; /* temp char */ int haveComponent; /* has new component started? */ ! char component[256]; /* this is the new component */ char *cp; /* component name being assembled */ cm_scache_t *tscp; /* current location in the hierarchy */ cm_scache_t *nscp; /* next dude down */ --- 1818,1824 ---- char *tp; /* ptr moving through input buffer */ char tc; /* temp char */ int haveComponent; /* has new component started? */ ! char component[AFSPATHMAX]; /* this is the new component */ char *cp; /* component name being assembled */ cm_scache_t *tscp; /* current location in the hierarchy */ cm_scache_t *nscp; /* next dude down */ *************** *** 1930,1936 **** cm_ReleaseSCache(dirScp); if (psp) cm_FreeSpace(psp); ! if (code == CM_ERROR_NOSUCHFILE && tscp->fileType == CM_SCACHETYPE_SYMLINK) { osi_Log0(afsd_logp,"cm_NameI code CM_ERROR_NOSUCHPATH"); return CM_ERROR_NOSUCHPATH; } else { --- 1934,1942 ---- cm_ReleaseSCache(dirScp); if (psp) cm_FreeSpace(psp); ! if ((code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) && ! tscp->fileType == CM_SCACHETYPE_SYMLINK) ! { osi_Log0(afsd_logp,"cm_NameI code CM_ERROR_NOSUCHPATH"); return CM_ERROR_NOSUCHPATH; } else { *************** *** 2136,2142 **** CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW | CM_FLAG_DIRSEARCH, userp, NULL, reqp, outScpp); ! if (code == CM_ERROR_NOSUCHFILE) code = CM_ERROR_NOSUCHPATH; /* this stuff is allocated no matter what happened on the namei call, --- 2142,2148 ---- CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW | CM_FLAG_DIRSEARCH, userp, NULL, reqp, outScpp); ! if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) code = CM_ERROR_NOSUCHPATH; /* this stuff is allocated no matter what happened on the namei call, *************** *** 2688,2695 **** else osi_Log0(afsd_logp, "CALL CreateFile SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { --- 2694,2703 ---- else osi_Log0(afsd_logp, "CALL CreateFile SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { *************** *** 2836,2843 **** else osi_Log0(afsd_logp, "CALL MakeDir SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { --- 2844,2853 ---- else osi_Log0(afsd_logp, "CALL MakeDir SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { *************** *** 2944,2955 **** else osi_Log0(afsd_logp, "CALL Link SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0); if (cm_CheckDirOpForSingleChange(&dirop)) { cm_DirCreateEntry(&dirop, namep, &sscp->fid); #ifdef USE_BPLUS --- 2954,2971 ---- else osi_Log0(afsd_logp, "CALL Link SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0); + } + lock_ReleaseMutex(&dscp->mx); + + if (code == 0) { if (cm_CheckDirOpForSingleChange(&dirop)) { cm_DirCreateEntry(&dirop, namep, &sscp->fid); #ifdef USE_BPLUS *************** *** 2958,2964 **** } } cm_EndDirOp(&dirop); - lock_ReleaseMutex(&dscp->mx); return code; } --- 2974,2979 ---- *************** *** 3021,3032 **** else osi_Log0(afsd_logp, "CALL Symlink SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0); if (cm_CheckDirOpForSingleChange(&dirop)) { newFid.cell = dscp->fid.cell; newFid.volume = dscp->fid.volume; --- 3036,3053 ---- else osi_Log0(afsd_logp, "CALL Symlink SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0); + } + lock_ReleaseMutex(&dscp->mx); + + if (code == 0) { if (cm_CheckDirOpForSingleChange(&dirop)) { newFid.cell = dscp->fid.cell; newFid.volume = dscp->fid.volume; *************** *** 3040,3046 **** } } cm_EndDirOp(&dirop); - lock_ReleaseMutex(&dscp->mx); /* now try to create the new dir's entry, too, but be careful to * make sure that we don't merge in old info. Since we weren't locking --- 3061,3066 ---- *************** *** 3119,3126 **** else osi_Log0(afsd_logp, "CALL RemoveDir SUCCESS"); ! lock_ObtainWrite(&dscp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { --- 3139,3148 ---- else osi_Log0(afsd_logp, "CALL RemoveDir SUCCESS"); ! if (dirop.scp) { ! lock_ObtainWrite(&dirop.scp->dirlock); ! dirop.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&dscp->mx); cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) { *************** *** 3311,3318 **** osi_Log0(afsd_logp, "CALL Rename SUCCESS"); /* update the individual stat cache entries for the directories */ ! lock_ObtainWrite(&oldDscp->dirlock); ! oldDirOp.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&oldDscp->mx); cm_SyncOpDone(oldDscp, NULL, CM_SCACHESYNC_STOREDATA); --- 3333,3342 ---- osi_Log0(afsd_logp, "CALL Rename SUCCESS"); /* update the individual stat cache entries for the directories */ ! if (oldDirOp.scp) { ! lock_ObtainWrite(&oldDirOp.scp->dirlock); ! oldDirOp.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&oldDscp->mx); cm_SyncOpDone(oldDscp, NULL, CM_SCACHESYNC_STOREDATA); *************** *** 3353,3360 **** /* and update it for the new one, too, if necessary */ if (!oneDir) { ! lock_ObtainWrite(&newDscp->dirlock); ! newDirOp.lockType = CM_DIRLOCK_WRITE; lock_ObtainMutex(&newDscp->mx); cm_SyncOpDone(newDscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) --- 3377,3386 ---- /* and update it for the new one, too, if necessary */ if (!oneDir) { ! if (newDirOp.scp) { ! lock_ObtainWrite(&newDirOp.scp->dirlock); ! newDirOp.lockType = CM_DIRLOCK_WRITE; ! } lock_ObtainMutex(&newDscp->mx); cm_SyncOpDone(newDscp, NULL, CM_SCACHESYNC_STOREDATA); if (code == 0) Index: openafs/src/WINNT/afsd/smb.c diff -c openafs/src/WINNT/afsd/smb.c:1.118.2.40 openafs/src/WINNT/afsd/smb.c:1.118.2.43 *** openafs/src/WINNT/afsd/smb.c:1.118.2.40 Thu Aug 9 01:33:56 2007 --- openafs/src/WINNT/afsd/smb.c Tue Sep 18 12:59:23 2007 *************** *** 1651,1658 **** /* List available shares */ int smb_ListShares() { ! char sbmtpath[256]; ! char pathName[256]; char shareBuf[4096]; int num_shares=0; char *this_share; --- 1651,1658 ---- /* List available shares */ int smb_ListShares() { ! char sbmtpath[AFSPATHMAX]; ! char pathName[AFSPATHMAX]; char shareBuf[4096]; int num_shares=0; char *this_share; *************** *** 1689,1695 **** /*strcpy(shareNameList[num_shares], this_share);*/ len = GetPrivateProfileString("AFS Submounts", this_share, NULL, ! pathName, 256, sbmtpath); if (!len) return num_shares; --- 1689,1695 ---- /*strcpy(shareNameList[num_shares], this_share);*/ len = GetPrivateProfileString("AFS Submounts", this_share, NULL, ! pathName, AFSPATHMAX, sbmtpath); if (!len) return num_shares; *************** *** 2636,2642 **** outp->res[1] = inSmbp->res[1]; op->inCom = inSmbp->com; } ! outp->reb = SMB_FLAGS_SERVER_TO_CLIENT | SMB_FLAGS_CANONICAL_PATHNAMES; outp->flg2 = SMB_FLAGS2_KNOWS_LONG_NAMES; /* copy fields in generic packet area */ --- 2636,2645 ---- outp->res[1] = inSmbp->res[1]; op->inCom = inSmbp->com; } ! outp->reb = SMB_FLAGS_SERVER_TO_CLIENT; ! #ifdef SEND_CANONICAL_PATHNAMES ! outp->reb |= SMB_FLAGS_CANONICAL_PATHNAMES; ! #endif outp->flg2 = SMB_FLAGS2_KNOWS_LONG_NAMES; /* copy fields in generic packet area */ *************** *** 2744,2750 **** else if (code == CM_ERROR_READONLY) { NTStatus = 0xC00000A2L; /* Write protected */ } ! else if (code == CM_ERROR_NOSUCHFILE) { NTStatus = 0xC000000FL; /* No such file */ } else if (code == CM_ERROR_NOSUCHPATH) { --- 2747,2754 ---- else if (code == CM_ERROR_READONLY) { NTStatus = 0xC00000A2L; /* Write protected */ } ! else if (code == CM_ERROR_NOSUCHFILE || ! code == CM_ERROR_BPLUS_NOMATCH) { NTStatus = 0xC000000FL; /* No such file */ } else if (code == CM_ERROR_NOSUCHPATH) { *************** *** 2918,2924 **** class = 3; error = 19; /* read only */ } ! else if (code == CM_ERROR_NOSUCHFILE) { class = 1; error = 2; /* ENOENT! */ } --- 2922,2929 ---- class = 3; error = 19; /* read only */ } ! else if (code == CM_ERROR_NOSUCHFILE || ! code == CM_ERROR_BPLUS_NOMATCH) { class = 1; error = 2; /* ENOENT! */ } *************** *** 3138,3143 **** --- 3143,3155 ---- if (!fidp) goto send1; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + code = CM_ERROR_NOSUCHFILE; + goto send1a; + } + + pid = ((smb_t *) inp)->pid; { LARGE_INTEGER LOffset, LLength; *************** *** 3780,3786 **** smb_tid_t *tidp; smb_user_t *uidp; unsigned short newTid; ! char shareName[256]; char *sharePath; int shareFound; char *tp; --- 3792,3798 ---- smb_tid_t *tidp; smb_user_t *uidp; unsigned short newTid; ! char shareName[AFSPATHMAX]; char *sharePath; int shareFound; char *tp; *************** *** 5503,5509 **** /* Check if the file already exists; if so return error */ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp); ! if ((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) { osi_Log2(smb_logp, " lookup returns %ld for [%s]", code, osi_LogSaveString(smb_logp, newLastNamep)); --- 5515,5523 ---- /* Check if the file already exists; if so return error */ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp); ! if ((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_BPLUS_NOMATCH) && ! (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) ! { osi_Log2(smb_logp, " lookup returns %ld for [%s]", code, osi_LogSaveString(smb_logp, newLastNamep)); *************** *** 5701,5707 **** /* Check if the file already exists; if so return error */ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp); ! if ((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) { osi_Log2(smb_logp, " lookup returns %ld for [%s]", code, osi_LogSaveString(smb_logp, newLastNamep)); --- 5715,5723 ---- /* Check if the file already exists; if so return error */ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp); ! if ((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_BPLUS_NOMATCH) && ! (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) ! { osi_Log2(smb_logp, " lookup returns %ld for [%s]", code, osi_LogSaveString(smb_logp, newLastNamep)); *************** *** 5941,5946 **** --- 5957,5968 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 6699,6704 **** --- 6721,6732 ---- return CM_ERROR_BADFD; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 6822,6827 **** --- 6850,6861 ---- fd = smb_GetSMBParm(inp, 0); fidp = smb_FindFID(vcp, fd, 0); + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return; + } + osi_Log3(smb_logp, "Completing Raw Write offset 0x%x:%08x count %x", rwcp->offset.HighPart, rwcp->offset.LowPart, rwcp->count); *************** *** 6941,6946 **** --- 6975,6986 ---- return CM_ERROR_BADFD; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + { unsigned pid; cm_key_t key; *************** *** 7084,7089 **** --- 7124,7135 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 7227,7233 **** lastNamep++; code = cm_Lookup(dscp, lastNamep, 0, userp, &req, &scp); if (scp) cm_ReleaseSCache(scp); ! if (code != CM_ERROR_NOSUCHFILE) { if (code == 0) code = CM_ERROR_EXISTS; cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); --- 7273,7279 ---- lastNamep++; code = cm_Lookup(dscp, lastNamep, 0, userp, &req, &scp); if (scp) cm_ReleaseSCache(scp); ! if (code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { if (code == 0) code = CM_ERROR_EXISTS; cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); *************** *** 7364,7370 **** #endif code = cm_Lookup(dscp, lastNamep, 0, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); return code; --- 7410,7416 ---- #endif code = cm_Lookup(dscp, lastNamep, 0, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); return code; *************** *** 7491,7500 **** /* try to find the file descriptor */ fd = smb_ChainFID(fd, inp); fidp = smb_FindFID(vcp, fd, 0); - if (!fidp) return CM_ERROR_BADFD; lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); --- 7537,7551 ---- /* try to find the file descriptor */ fd = smb_ChainFID(fd, inp); fidp = smb_FindFID(vcp, fd, 0); if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 8422,8428 **** return; } else if (code != 0) { #ifndef DJGPP ! char tbuffer[256]; #endif /* terminate silently if shutdown flag is set */ --- 8473,8479 ---- return; } else if (code != 0) { #ifndef DJGPP ! char tbuffer[AFSPATHMAX]; #endif /* terminate silently if shutdown flag is set */ *************** *** 9257,9263 **** ); if (nts != STATUS_SUCCESS && ntsEx != STATUS_SUCCESS) { ! char message[256]; sprintf(message,"MsV1_0SetProcessOption failure: nts 0x%x ntsEx 0x%x", nts, ntsEx); OutputDebugString(message); --- 9308,9314 ---- ); if (nts != STATUS_SUCCESS && ntsEx != STATUS_SUCCESS) { ! char message[AFSPATHMAX]; sprintf(message,"MsV1_0SetProcessOption failure: nts 0x%x ntsEx 0x%x", nts, ntsEx); OutputDebugString(message); Index: openafs/src/WINNT/afsd/smb.h diff -c openafs/src/WINNT/afsd/smb.h:1.41.2.17 openafs/src/WINNT/afsd/smb.h:1.41.2.18 *** openafs/src/WINNT/afsd/smb.h:1.41.2.17 Thu Aug 23 12:46:07 2007 --- openafs/src/WINNT/afsd/smb.h Mon Sep 10 15:08:17 2007 *************** *** 404,409 **** --- 404,410 ---- #define SMB_FID_NTOPEN 0x100 /* have dscp and pathp */ #define SMB_FID_SEQUENTIAL 0x200 #define SMB_FID_RANDOM 0x400 + #define SMB_FID_EXECUTABLE 0x800 #define SMB_FID_SHARE_READ 0x1000 #define SMB_FID_SHARE_WRITE 0x2000 Index: openafs/src/WINNT/afsd/smb3.c diff -c openafs/src/WINNT/afsd/smb3.c:1.95.2.40 openafs/src/WINNT/afsd/smb3.c:1.95.2.46 *** openafs/src/WINNT/afsd/smb3.c:1.95.2.40 Fri Jul 27 22:51:16 2007 --- openafs/src/WINNT/afsd/smb3.c Wed Sep 19 17:29:29 2007 *************** *** 41,46 **** --- 41,48 ---- /* protected by the smb_globalLock */ smb_tran2Packet_t *smb_tran2AssemblyQueuep; + const char **smb_ExecutableExtensions = NULL; + /* retrieve a held reference to a user structure corresponding to an incoming * request */ cm_user_t *smb_GetTran2User(smb_vc_t *vcp, smb_tran2Packet_t *inp) *************** *** 59,64 **** --- 61,88 ---- return up; } + /* + * Return boolean specifying if the path name is thought to be an + * executable file. For now .exe or .dll. + */ + afs_uint32 smb_IsExecutableFileName(const char *name) + { + int i, j, len; + + if ( smb_ExecutableExtensions == NULL || name == NULL) + return 0; + + len = strlen(name); + + for ( i=0; smb_ExecutableExtensions[i]; i++) { + j = len - strlen(smb_ExecutableExtensions[i]); + if (_stricmp(smb_ExecutableExtensions[i], &name[j]) == 0) + return 1; + } + + return 0; + } + /* * Return extended attributes. * Right now, we aren't using any of the "new" bits, so this looks exactly *************** *** 134,140 **** } void OutputDebugHexDump(unsigned char * buffer, int len) { ! int i,j,k,pcts=0; char buf[256]; static char tr[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; --- 158,164 ---- } void OutputDebugHexDump(unsigned char * buffer, int len) { ! int i,j,k; char buf[256]; static char tr[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; *************** *** 159,171 **** buf[j] = tr[k / 16]; buf[j+1] = tr[k % 16]; j = (i%16); ! j = j + 56 + ((j>7)?1:0) + pcts; buf[j] = (k>32 && k<127)?k:'.'; - if (k == '%') { - buf[++j] = k; - pcts++; - } } if(i) { osi_Log0(smb_logp, osi_LogSaveString(smb_logp, buf)); --- 183,191 ---- buf[j] = tr[k / 16]; buf[j+1] = tr[k % 16]; j = (i%16); ! j = j + 56 + ((j>7)?1:0); buf[j] = (k>32 && k<127)?k:'.'; } if(i) { osi_Log0(smb_logp, osi_LogSaveString(smb_logp, buf)); *************** *** 984,990 **** smb_tid_t *tidp; smb_user_t *uidp = NULL; unsigned short newTid; ! char shareName[256]; char *sharePath; int shareFound; char *tp; --- 1004,1010 ---- smb_tid_t *tidp; smb_user_t *uidp = NULL; unsigned short newTid; ! char shareName[AFSPATHMAX]; char *sharePath; int shareFound; char *tp; *************** *** 1500,1506 **** smb_rap_share_info_1_t * shares; USHORT cshare = 0; char * cstrp; ! char thisShare[256]; int i,j; DWORD dw; int nonrootShares; --- 1520,1526 ---- smb_rap_share_info_1_t * shares; USHORT cshare = 0; char * cstrp; ! char thisShare[AFSPATHMAX]; int i,j; DWORD dw; int nonrootShares; *************** *** 2219,2225 **** lastNamep++; code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); smb_FreeTran2Packet(outp); --- 2239,2245 ---- lastNamep++; code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); smb_FreeTran2Packet(outp); *************** *** 2757,2764 **** code = CM_ERROR_NOSUCHFILE; else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) { cm_buf_t *bp = buf_Find(dscp, &hzero); ! if (bp) buf_Release(bp); else code = CM_ERROR_NOSUCHFILE; } --- 2777,2786 ---- code = CM_ERROR_NOSUCHFILE; else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) { cm_buf_t *bp = buf_Find(dscp, &hzero); ! if (bp) { buf_Release(bp); + bp = NULL; + } else code = CM_ERROR_NOSUCHFILE; } *************** *** 3025,3032 **** code = CM_ERROR_NOSUCHFILE; else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) { cm_buf_t *bp = buf_Find(dscp, &hzero); ! if (bp) buf_Release(bp); else code = CM_ERROR_NOSUCHFILE; } --- 3047,3056 ---- code = CM_ERROR_NOSUCHFILE; else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) { cm_buf_t *bp = buf_Find(dscp, &hzero); ! if (bp) { buf_Release(bp); + bp = NULL; + } else code = CM_ERROR_NOSUCHFILE; } *************** *** 3178,3183 **** --- 3202,3214 ---- return 0; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOSUCHFILE); + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return 0; + } + infoLevel = p->parmsp[1]; if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) responseSize = sizeof(qfi.u.QFbasicInfo); *************** *** 3306,3311 **** --- 3337,3349 ---- return 0; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOSUCHFILE); + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return 0; + } + infoLevel = p->parmsp[1]; osi_Log2(smb_logp,"ReceiveTran2SetFileInfo type 0x%x fid %d", infoLevel, fid); if (infoLevel > SMB_SET_FILE_END_OF_FILE_INFO || infoLevel < SMB_SET_FILE_BASIC_INFO) { *************** *** 4385,4391 **** /* if a case sensitive match failed, we try a case insensitive one next. */ ! if (code == CM_ERROR_NOSUCHFILE) { code = cm_Lookup(scp, maskp, CM_FLAG_NOMOUNTCHASE | CM_FLAG_CASEFOLD, userp, &req, &targetscp); } --- 4423,4429 ---- /* if a case sensitive match failed, we try a case insensitive one next. */ ! if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) { code = cm_Lookup(scp, maskp, CM_FLAG_NOMOUNTCHASE | CM_FLAG_CASEFOLD, userp, &req, &targetscp); } *************** *** 4400,4406 **** smb_ReceiveTran2SearchDir(). */ cm_ReleaseSCache(scp); cm_ReleaseUser(userp); ! if (code != CM_ERROR_NOSUCHFILE) { smb_SendTran2Error(vcp, p, opx, code); code = 0; } --- 4438,4444 ---- smb_ReceiveTran2SearchDir(). */ cm_ReleaseSCache(scp); cm_ReleaseUser(userp); ! if (code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { smb_SendTran2Error(vcp, p, opx, code); code = 0; } *************** *** 4593,4599 **** osi_Log0(smb_logp, "T2SDSingle done."); ! if (code != CM_ERROR_NOSUCHFILE) { if (code) smb_SendTran2Error(vcp, p, opx, code); else --- 4631,4637 ---- osi_Log0(smb_logp, "T2SDSingle done."); ! if (code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { if (code) smb_SendTran2Error(vcp, p, opx, code); else *************** *** 4695,4704 **** --- 4733,4747 ---- /* we only failover if we see a CM_ERROR_NOSUCHFILE */ if (code != CM_ERROR_NOSUCHFILE) { + #ifdef USE_BPLUS + if (code == CM_ERROR_BPLUS_NOMATCH) + code = CM_ERROR_NOSUCHFILE; + #endif return code; } } #endif + dir_enums++; dsp = smb_NewDirSearch(1); dsp->attribute = attribute; *************** *** 5526,5532 **** lastNamep++; code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); return code; --- 5569,5575 ---- lastNamep++; code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp, &req, &scp); ! if (code && code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); return code; *************** *** 5744,5749 **** --- 5787,5798 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { osi_Log0(smb_logp, "smb_ReceiveV3Locking BadFD"); *************** *** 6001,6006 **** --- 6050,6061 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 6078,6083 **** --- 6133,6144 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 6164,6169 **** --- 6225,6236 ---- if (!fidp) return CM_ERROR_BADFD; + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + lock_ObtainMutex(&fidp->mx); if (fidp->flags & SMB_FID_IOCTL) { lock_ReleaseMutex(&fidp->mx); *************** *** 6301,6306 **** --- 6368,6379 ---- return CM_ERROR_BADFD; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + pid = ((smb_t *) inp)->pid; key = cm_GenerateKey(vcp->vcID, pid, fd); { *************** *** 6594,6599 **** --- 6667,6681 ---- cm_ReleaseUser(userp); return CM_ERROR_INVAL; } + + if (baseFidp->scp && (baseFidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + free(realPathp); + cm_ReleaseUser(userp); + smb_CloseFID(vcp, baseFidp, NULL, 0); + smb_ReleaseFID(baseFidp); + return CM_ERROR_NOSUCHPATH; + } + baseDirp = baseFidp->scp; tidPathp = NULL; } *************** *** 6614,6619 **** --- 6696,6703 ---- fidflags |= SMB_FID_SEQUENTIAL; if (createOptions & FILE_RANDOM_ACCESS && !(createOptions & FILE_SEQUENTIAL_ONLY)) fidflags |= SMB_FID_RANDOM; + if (smb_IsExecutableFileName(lastNamep)) + fidflags |= SMB_FID_EXECUTABLE; /* and the share mode */ if (shareAccess & FILE_SHARE_READ) *************** *** 6646,6652 **** #endif /* DFS_SUPPORT */ code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW, userp, &req, &scp); ! if (code == CM_ERROR_NOSUCHFILE) { code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); if (code == 0 && realDirFlag == 1) { --- 6730,6736 ---- #endif /* DFS_SUPPORT */ code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW, userp, &req, &scp); ! if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) { code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); if (code == 0 && realDirFlag == 1) { *************** *** 6792,6798 **** CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); } ! if (code && code != CM_ERROR_NOSUCHFILE) { if (dscp) cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); --- 6876,6882 ---- CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); } ! if (code && (code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH)) { if (dscp) cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); *************** *** 6953,6959 **** * it will appear as a directory name of the nul-string * and a code of CM_ERROR_NOSUCHFILE */ ! if ( !*treeStartp && code == CM_ERROR_NOSUCHFILE) code = CM_ERROR_EXISTS; setAttr.mask = CM_ATTRMASK_CLIENTMODTIME; --- 7037,7043 ---- * it will appear as a directory name of the nul-string * and a code of CM_ERROR_NOSUCHFILE */ ! if ( !*treeStartp && (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH)) code = CM_ERROR_EXISTS; setAttr.mask = CM_ATTRMASK_CLIENTMODTIME; *************** *** 7192,7200 **** (scp->fileType == CM_SCACHETYPE_DIRECTORY || scp->fileType == CM_SCACHETYPE_MOUNTPOINT || scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0); /* is a dir? */ - lock_ReleaseMutex(&scp->mx); smb_SetSMBDataLength(outp, 0); osi_Log2(smb_logp, "SMB NT CreateX opening fid %d path %s", fidp->fid, osi_LogSaveString(smb_logp, realPathp)); --- 7276,7292 ---- (scp->fileType == CM_SCACHETYPE_DIRECTORY || scp->fileType == CM_SCACHETYPE_MOUNTPOINT || scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0); /* is a dir? */ smb_SetSMBDataLength(outp, 0); + if ((fidp->flags & SMB_FID_EXECUTABLE) && + LargeIntegerGreaterThanZero(fidp->scp->length) && + !(scp->flags & CM_SCACHEFLAG_PREFETCHING)) { + cm_QueueBKGRequest(fidp->scp, cm_BkgPrefetch, 0, 0, + fidp->scp->length.LowPart, fidp->scp->length.HighPart, + userp); + } + lock_ReleaseMutex(&scp->mx); + osi_Log2(smb_logp, "SMB NT CreateX opening fid %d path %s", fidp->fid, osi_LogSaveString(smb_logp, realPathp)); *************** *** 7376,7383 **** osi_Log1(smb_logp, "NTTranCreate Invalid fid [%d]", baseFid); free(realPathp); cm_ReleaseUser(userp); ! return CM_ERROR_INVAL; } baseDirp = baseFidp->scp; tidPathp = NULL; } --- 7468,7484 ---- osi_Log1(smb_logp, "NTTranCreate Invalid fid [%d]", baseFid); free(realPathp); cm_ReleaseUser(userp); ! return CM_ERROR_BADFD; } + + if (baseFidp->scp && (baseFidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + free(realPathp); + cm_ReleaseUser(userp); + smb_CloseFID(vcp, baseFidp, NULL, 0); + smb_ReleaseFID(baseFidp); + return CM_ERROR_NOSUCHPATH; + } + baseDirp = baseFidp->scp; tidPathp = NULL; } *************** *** 7396,7401 **** --- 7497,7504 ---- fidflags |= SMB_FID_SEQUENTIAL; if (createOptions & FILE_RANDOM_ACCESS && !(createOptions & FILE_SEQUENTIAL_ONLY)) fidflags |= SMB_FID_RANDOM; + if (smb_IsExecutableFileName(lastNamep)) + fidflags |= SMB_FID_EXECUTABLE; /* And the share mode */ if (shareAccess & FILE_SHARE_READ) *************** *** 7426,7432 **** #endif /* DFS_SUPPORT */ code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW, userp, &req, &scp); ! if (code == CM_ERROR_NOSUCHFILE) { code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); if (code == 0 && realDirFlag == 1) { --- 7529,7535 ---- #endif /* DFS_SUPPORT */ code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW, userp, &req, &scp); ! if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) { code = cm_Lookup(dscp, (lastNamep)?(lastNamep+1):realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); if (code == 0 && realDirFlag == 1) { *************** *** 7512,7518 **** CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); } ! if (code && code != CM_ERROR_NOSUCHFILE) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); free(realPathp); --- 7615,7621 ---- CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, userp, &req, &scp); } ! if (code && code != CM_ERROR_NOSUCHFILE && code != CM_ERROR_BPLUS_NOMATCH) { cm_ReleaseSCache(dscp); cm_ReleaseUser(userp); free(realPathp); *************** *** 7919,7924 **** --- 8022,8037 ---- lock_ReleaseMutex(&scp->mx); } + lock_ObtainMutex(&scp->mx); + if ((fidp->flags & SMB_FID_EXECUTABLE) && + LargeIntegerGreaterThanZero(fidp->scp->length) && + !(scp->flags & CM_SCACHEFLAG_PREFETCHING)) { + cm_QueueBKGRequest(fidp->scp, cm_BkgPrefetch, 0, 0, + fidp->scp->length.LowPart, fidp->scp->length.HighPart, + userp); + } + lock_ReleaseMutex(&scp->mx); + osi_Log1(smb_logp, "SMB NTTranCreate opening fid %d", fidp->fid); cm_ReleaseUser(userp); *************** *** 7949,7954 **** --- 8062,8073 ---- return CM_ERROR_BADFD; } + if (fidp->scp && (fidp->scp->flags & CM_SCACHEFLAG_DELETED)) { + smb_CloseFID(vcp, fidp, NULL, 0); + smb_ReleaseFID(fidp); + return CM_ERROR_NOSUCHFILE; + } + /* Create a copy of the Directory Watch Packet to use when sending the * notification if in the future a matching change is detected. */ *************** *** 8190,8199 **** lastWatch = watch; watch = watch->nextp; continue; ! } ! if (fidp->scp != dscp ! || (filter & notifyFilter) == 0 ! || (!isDirectParent && !wtree)) { osi_Log1(smb_logp," skipping fidp->scp[%x]", fidp->scp); smb_ReleaseFID(fidp); lastWatch = watch; --- 8309,8321 ---- lastWatch = watch; watch = watch->nextp; continue; ! } ! ! if (fidp->scp != dscp || ! fidp->scp->flags & CM_SCACHEFLAG_DELETED || ! (filter & notifyFilter) == 0 || ! (!isDirectParent && !wtree)) ! { osi_Log1(smb_logp," skipping fidp->scp[%x]", fidp->scp); smb_ReleaseFID(fidp); lastWatch = watch; *************** *** 8246,8252 **** lock_ReleaseMutex(&dscp->mx); /* Convert to response packet */ ! ((smb_t *) watch)->reb = SMB_FLAGS_SERVER_TO_CLIENT | SMB_FLAGS_CANONICAL_PATHNAMES; ((smb_t *) watch)->wct = 0; /* out parms */ --- 8368,8377 ---- lock_ReleaseMutex(&dscp->mx); /* Convert to response packet */ ! ((smb_t *) watch)->reb = SMB_FLAGS_SERVER_TO_CLIENT; ! #ifdef SEND_CANONICAL_PATHNAMES ! ((smb_t *) watch)->reb |= SMB_FLAGS_CANONICAL_PATHNAMES; ! #endif ((smb_t *) watch)->wct = 0; /* out parms */ Index: openafs/src/WINNT/aklog/aklog.c diff -c openafs/src/WINNT/aklog/aklog.c:1.14.4.5 openafs/src/WINNT/aklog/aklog.c:1.14.4.6 *** openafs/src/WINNT/aklog/aklog.c:1.14.4.5 Thu Aug 9 18:54:07 2007 --- openafs/src/WINNT/aklog/aklog.c Wed Aug 29 02:46:18 2007 *************** *** 13,18 **** --- 13,22 ---- * or implied warranty. */ + #ifndef _WIN64 + #define HAVE_KRB4 + #endif + #include #include #include *************** *** 21,27 **** --- 25,40 ---- #include #include #include + #ifdef HAVE_KRB4 #include + #else + #define REALM_SZ 64 + #define ANAME_SZ 64 + #define INST_SZ 64 + #define KSUCCESS 0 + + #define CREDENTIALS void + #endif #include #include #include *************** *** 43,52 **** --- 56,67 ---- #define DONT_HAVE_GET_AD_TKT #define MAXSYMLINKS 255 + #ifdef HAVE_KRB4 /* Win32 uses get_krb_err_txt_entry(status) instead of krb_err_txt[status], * so we use a bit of indirection like the GNU CVS sources. */ #define krb_err_text(status) get_krb_err_txt_entry(status) + #endif #define DRIVECOLON ':' /* Drive letter separator */ #define BDIR '\\' /* Other character that divides directories */ *************** *** 257,263 **** if ((*status = ktc_SetToken(aserver, atoken, aclient, 0))) { printf("%s: unable to set tokens for cell %s " ! "(status: %d).\n", progname, cell_to_use, status); *status = AKLOG_TOKEN; return ; } --- 272,278 ---- if ((*status = ktc_SetToken(aserver, atoken, aclient, 0))) { printf("%s: unable to set tokens for cell %s " ! "(status: %d).\n", progname, cell_to_use, *status); *status = AKLOG_TOKEN; return ; } *************** *** 270,276 **** */ if ((*status = pr_Initialize(1L, confname, aserver->cell))) { ! printf("Error %d\n", status); return; } --- 285,291 ---- */ if ((*status = pr_Initialize(1L, confname, aserver->cell))) { ! printf("Error %d\n", *status); return; } *************** *** 356,361 **** --- 371,377 ---- abort(); } + #ifdef HAVE_KRB4 static int get_cred(char *name, char *inst, char *realm, CREDENTIALS *c) { int status; *************** *** 375,380 **** --- 391,397 ---- return (status); } + #endif static int get_v5cred(krb5_context context, char *name, char *inst, char *realm, CREDENTIALS *c, *************** *** 387,393 **** memset((char *)&increds, 0, sizeof(increds)); if ((r = krb5_build_principal(context, &increds.server, ! strlen(realm), realm, name, (inst && strlen(inst)) ? inst : 0, 0))) { --- 404,410 ---- memset((char *)&increds, 0, sizeof(increds)); if ((r = krb5_build_principal(context, &increds.server, ! (int)strlen(realm), realm, name, (inst && strlen(inst)) ? inst : 0, 0))) { *************** *** 414,419 **** --- 431,437 ---- return((int)r); } + #ifdef HAVE_KRB4 /* There is no header for this function. It is supposed to be private */ int krb_get_admhst(char *h,char *r, int n); *************** *** 443,449 **** } return krbrlm; } ! /* As of MIT Kerberos 1.6, krb5_get_host_realm() will return the NUL-string * if there is no domain_realm mapping for the hostname's domain. This is --- 461,467 ---- } return krbrlm; } ! #endif /* As of MIT Kerberos 1.6, krb5_get_host_realm() will return the NUL-string * if there is no domain_realm mapping for the hostname's domain. This is *************** *** 510,541 **** static int get_cellconfig(char *cell, struct afsconf_cell *cellconfig, char *local_cell) { ! int status = AKLOG_SUCCESS; ! struct afsconf_dir *configdir = 0; ! memset(local_cell, 0, sizeof(local_cell)); ! memset(cellconfig, 0, sizeof(*cellconfig)); ! if (GetLocalCell(&configdir, local_cell)) ! { ! fprintf(stderr, "%s: can't determine local cell.\n", progname); ! exit(AKLOG_AFS); ! } ! if ((cell == NULL) || (cell[0] == 0)) ! cell = local_cell; ! if (GetCellInfo(&configdir, cell, &cellconfig)) ! { ! fprintf(stderr, "%s: Can't get information about cell %s.\n", ! progname, cell); ! status = AKLOG_AFS; ! } ! CloseConf(&configdir); ! return(status); } static int get_v5_user_realm(krb5_context context,char *realm) --- 528,559 ---- static int get_cellconfig(char *cell, struct afsconf_cell *cellconfig, char *local_cell) { ! int status = AKLOG_SUCCESS; ! struct afsconf_dir *configdir = 0; ! memset(local_cell, 0, sizeof(local_cell)); ! memset(cellconfig, 0, sizeof(*cellconfig)); ! if (GetLocalCell(&configdir, local_cell)) ! { ! fprintf(stderr, "%s: can't determine local cell.\n", progname); ! exit(AKLOG_AFS); ! } ! if ((cell == NULL) || (cell[0] == 0)) ! cell = local_cell; ! if (GetCellInfo(&configdir, cell, &cellconfig)) ! { ! fprintf(stderr, "%s: Can't get information about cell %s.\n", ! progname, cell); ! status = AKLOG_AFS; ! } ! CloseConf(&configdir); ! return(status); } static int get_v5_user_realm(krb5_context context,char *realm) *************** *** 572,578 **** --- 590,598 ---- char cell_to_use[MAXCELLCHARS+1]; /* Cell to authenticate to */ krb5_creds *v5cred = NULL; + #ifdef HAVE_KRB4 CREDENTIALS c; + #endif struct ktc_principal aserver; struct ktc_principal aclient; struct ktc_token atoken, btoken; *************** *** 646,652 **** if (dflag) printf("Getting v5 tickets: %s/%s@%s\n", name, instance, realm_of_cell); status = get_v5cred(context, name, instance, realm_of_cell, ! use524 ? &c : NULL, &v5cred); if (status == KRB5_ERR_HOST_REALM_UNKNOWN) { realm_fallback = 1; goto try_v5; --- 666,677 ---- if (dflag) printf("Getting v5 tickets: %s/%s@%s\n", name, instance, realm_of_cell); status = get_v5cred(context, name, instance, realm_of_cell, ! #ifdef HAVE_KRB4 ! use524 ? &c : NULL, ! #else ! NULL, ! #endif ! &v5cred); if (status == KRB5_ERR_HOST_REALM_UNKNOWN) { realm_fallback = 1; goto try_v5; *************** *** 658,664 **** if (dflag) printf("Getting v5 tickets: %s@%s\n", name, realm_of_cell); status = get_v5cred(context, name, "", realm_of_cell, ! use524 ? &c : NULL, &v5cred); } if ( status == KRB5KRB_AP_ERR_MSG_TYPE && retry ) { retry = 0; --- 683,694 ---- if (dflag) printf("Getting v5 tickets: %s@%s\n", name, realm_of_cell); status = get_v5cred(context, name, "", realm_of_cell, ! #ifdef HAVE_KRB4 ! use524 ? &c : NULL, ! #else ! NULL, ! #endif ! &v5cred); } if ( status == KRB5KRB_AP_ERR_MSG_TYPE && retry ) { retry = 0; *************** *** 668,673 **** --- 698,704 ---- } else { + #ifdef HAVE_KRB4 if (realm && realm[0]) strcpy(realm_of_cell, realm); else *************** *** 689,694 **** --- 720,728 ---- printf("Getting tickets: %s@%s\n", name, realm_of_cell); status = get_cred(name, "", realm_of_cell, &c); } + #else + ret