Index: openafs/src/WINNT/afs_setup_utils/afsrm.c diff -c openafs/src/WINNT/afs_setup_utils/afsrm.c:1.3 openafs/src/WINNT/afs_setup_utils/afsrm.c:1.3.20.1 *** openafs/src/WINNT/afs_setup_utils/afsrm.c:1.3 Tue Sep 18 00:26:47 2001 --- openafs/src/WINNT/afs_setup_utils/afsrm.c Wed Oct 31 00:09:10 2007 *************** *** 23,29 **** #include "forceremove.h" ! static int DoClient34(struct cmd_syndesc *as, char *arock) { DWORD status = Client34Eradicate(FALSE); --- 23,29 ---- #include "forceremove.h" ! static int DoClient34(struct cmd_syndesc *as, void *arock) { DWORD status = Client34Eradicate(FALSE); *************** *** 40,46 **** { struct cmd_syndesc *ts; ! ts = cmd_CreateSyntax("client34", DoClient34, 0, "remove AFS 3.4a client"); } --- 40,46 ---- { struct cmd_syndesc *ts; ! ts = cmd_CreateSyntax("client34", DoClient34, NULL, "remove AFS 3.4a client"); } Index: openafs/src/WINNT/afsd/afsd_init.c diff -c openafs/src/WINNT/afsd/afsd_init.c:1.79.2.18 openafs/src/WINNT/afsd/afsd_init.c:1.79.2.20 *** openafs/src/WINNT/afsd/afsd_init.c:1.79.2.18 Sat Oct 20 00:03:04 2007 --- openafs/src/WINNT/afsd/afsd_init.c Mon Nov 5 13:26:49 2007 *************** *** 23,28 **** --- 23,31 ---- #include #include "afsd.h" + #ifdef USE_BPLUS + #include "cm_btree.h" + #endif #include #include #include *************** *** 40,46 **** --- 43,51 ---- extern afs_int32 cryptall; extern int cm_enableServerLocks; extern int cm_deleteReadOnly; + #ifdef USE_BPLUS extern afs_int32 cm_BPlusTrees; + #endif extern afs_int32 cm_OfflineROIsValid; extern const char **smb_ExecutableExtensions; *************** *** 1069,1074 **** --- 1074,1080 ---- } afsi_log("CM DeleteReadOnly is %u", cm_deleteReadOnly); + #ifdef USE_BPLUS dummyLen = sizeof(DWORD); code = RegQueryValueEx(parmKey, "BPlusTrees", NULL, NULL, (BYTE *) &dwValue, &dummyLen); *************** *** 1077,1082 **** --- 1083,1096 ---- } afsi_log("CM BPlusTrees is %u", cm_BPlusTrees); + if (cm_BPlusTrees && !cm_InitBPlusDir()) { + cm_BPlusTrees = 0; + afsi_log("CM BPlusTree initialization failure; disabled for this session"); + } + #else + afsi_log("CM BPlusTrees is not supported"); + #endif + if ((RegQueryValueEx( parmKey, "PrefetchExecutableExtensions", 0, ®Type, NULL, &dummyLen) == ERROR_SUCCESS) && (regType == REG_MULTI_SZ)) *************** *** 1161,1167 **** smb_InitIoctl(); cm_InitCallback(); ! code = cm_InitMappedMemory(virtualCache, cm_CachePath, stats, cm_chunkSize, cacheBlocks, blockSize); afsi_log("cm_InitMappedMemory code %x", code); if (code != 0) { --- 1175,1181 ---- smb_InitIoctl(); cm_InitCallback(); ! code = cm_InitMappedMemory(virtualCache, cm_CachePath, stats, cm_chunkSize, cacheBlocks, blockSize); afsi_log("cm_InitMappedMemory code %x", code); if (code != 0) { *************** *** 1366,1372 **** void afsd_printStack(HANDLE hThread, CONTEXT *c) { - #if defined(_X86_) HANDLE hProcess = GetCurrentProcess(); int frameNum; #if defined(_AMD64_) --- 1380,1385 ---- *************** *** 1413,1421 **** #error The STACKFRAME initialization in afsd_printStack() for this platform #error must be properly configured #elif defined(_AMD64_) ! s.AddrPC.Offset = 0; s.AddrPC.Mode = AddrModeFlat; ! s.AddrFrame.Offset = 0; s.AddrFrame.Mode = AddrModeFlat; #else s.AddrPC.Offset = c->Eip; --- 1426,1434 ---- #error The STACKFRAME initialization in afsd_printStack() for this platform #error must be properly configured #elif defined(_AMD64_) ! s.AddrPC.Offset = c->Rip; s.AddrPC.Mode = AddrModeFlat; ! s.AddrFrame.Offset = c->Rbp; s.AddrFrame.Mode = AddrModeFlat; #else s.AddrPC.Offset = c->Eip; *************** *** 1515,1521 **** SymCleanup(hProcess); GlobalFree(pSym); - #endif /* _X86_ */ } #ifdef _DEBUG --- 1528,1533 ---- *************** *** 1665,1670 **** --- 1677,1685 ---- #if defined(_X86) ep->ContextRecord->Eip++; #endif + #if defined(_AMD64_) + ep->ContextRecord->Rip++; + #endif return EXCEPTION_CONTINUE_EXECUTION; } else Index: openafs/src/WINNT/afsd/afsd_service.c diff -c openafs/src/WINNT/afsd/afsd_service.c:1.52.4.17 openafs/src/WINNT/afsd/afsd_service.c:1.52.4.18 *** openafs/src/WINNT/afsd/afsd_service.c:1.52.4.17 Wed Sep 19 23:55:42 2007 --- openafs/src/WINNT/afsd/afsd_service.c Sun Nov 4 19:24:45 2007 *************** *** 61,66 **** --- 61,68 ---- #ifdef AFSIFS int i; #endif + if (!msgp) + msgp = "unspecified assert"; if (filep) LogEvent(EVENTLOG_ERROR_TYPE, MSG_SERVICE_ERROR_STOP_WITH_MSG_AND_LOCATION, Index: openafs/src/WINNT/afsd/cklog.c diff -c openafs/src/WINNT/afsd/cklog.c:1.4.4.1 openafs/src/WINNT/afsd/cklog.c:1.4.4.2 *** openafs/src/WINNT/afsd/cklog.c:1.4.4.1 Tue Apr 10 14:39:48 2007 --- openafs/src/WINNT/afsd/cklog.c Wed Oct 31 00:09:16 2007 *************** *** 22,28 **** #define BAD_ARGUMENT 1 #define KLOGEXIT(code) exit(code) ! int CommandProc(); static int zero_argc; static char **zero_argv; --- 22,28 ---- #define BAD_ARGUMENT 1 #define KLOGEXIT(code) exit(code) ! static int CommandProc(struct cmd_syndesc *, void *); static int zero_argc; static char **zero_argv; *************** *** 40,46 **** /* Start up sockets */ WSAStartup(0x0101, &WSAjunk); ! ts = cmd_CreateSyntax((char *) 0, CommandProc, 0, "obtain Kerberos authentication"); #define aXFLAG 0 #define aPRINCIPAL 1 --- 40,46 ---- /* Start up sockets */ WSAStartup(0x0101, &WSAjunk); ! ts = cmd_CreateSyntax(NULL, CommandProc, NULL, "obtain Kerberos authentication"); #define aXFLAG 0 #define aPRINCIPAL 1 *************** *** 135,143 **** return !ok; } ! CommandProc (as, arock) ! char *arock; ! struct cmd_syndesc *as; { char name[MAXKTCNAMELEN]; char instance[MAXKTCNAMELEN]; --- 135,142 ---- return !ok; } ! static int ! CommandProc (struct cmd_syndesc *as, void *arock) { char name[MAXKTCNAMELEN]; char instance[MAXKTCNAMELEN]; Index: openafs/src/WINNT/afsd/cm_aclent.c diff -c openafs/src/WINNT/afsd/cm_aclent.c:1.14.2.1 openafs/src/WINNT/afsd/cm_aclent.c:1.14.2.2 *** openafs/src/WINNT/afsd/cm_aclent.c:1.14.2.1 Thu Jun 1 11:39:51 2006 --- openafs/src/WINNT/afsd/cm_aclent.c Thu Oct 25 00:49:00 2007 *************** *** 92,100 **** } else { *rightsp = aclp->randomAccess; if (cm_data.aclLRUp != aclp) { - if (cm_data.aclLRUEndp == aclp) - cm_data.aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); - /* move to the head of the LRU queue */ osi_QRemoveHT((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); osi_QAddH((osi_queue_t **) &cm_data.aclLRUp, --- 92,97 ---- *************** *** 123,130 **** if (cm_data.aclLRUp == NULL) osi_panic("empty aclent LRU", __FILE__, __LINE__); aclp = cm_data.aclLRUEndp; - cm_data.aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); osi_QRemoveHT((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); if (aclp->backp && scp != aclp->backp) { --- 120,129 ---- if (cm_data.aclLRUp == NULL) osi_panic("empty aclent LRU", __FILE__, __LINE__); + if (cm_data.aclLRUEndp == NULL) + osi_panic("inconsistent aclent LRUEndp == NULL", __FILE__, __LINE__); + aclp = cm_data.aclLRUEndp; osi_QRemoveHT((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); if (aclp->backp && scp != aclp->backp) { Index: openafs/src/WINNT/afsd/cm_btree.c diff -c openafs/src/WINNT/afsd/cm_btree.c:1.1.2.7 openafs/src/WINNT/afsd/cm_btree.c:1.1.2.12 *** openafs/src/WINNT/afsd/cm_btree.c:1.1.2.7 Thu Oct 4 10:13:10 2007 --- openafs/src/WINNT/afsd/cm_btree.c Mon Nov 5 13:26:49 2007 *************** *** 66,71 **** --- 66,79 ---- static void _xferentry(Nptr srcNode, int srcEntry, Nptr destNode, int destEntry); static void _setentry(Nptr node, int entry, keyT key, Nptr downNode); + /* access key and data values for B+tree methods */ + /* pass values to getSlot(), descend...() */ + static keyT getfunkey(Tree *B); + static dataT getfundata(Tree *B); + static void setfunkey(Tree *B, keyT v); + static void setfundata(Tree *B, dataT v); + + #ifdef DEBUG_BTREE static int _isRoot(Tree *B, Nptr n) { *************** *** 114,119 **** --- 122,140 ---- /***********************************************************************\ | B+tree Initialization and Cleanup Routines | \***********************************************************************/ + static DWORD TlsKeyIndex; + static DWORD TlsDataIndex; + + long cm_InitBPlusDir(void) + { + if ((TlsKeyIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) + return 0; + + if ((TlsDataIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) + return 0; + + return 1; + } /******************** Set up B+tree structure **********************/ Tree *initBtree(unsigned int poolsz, unsigned int fanout, KeyCmp keyCmp) *************** *** 168,181 **** } /***********************************************************************\ ! | Find location for data | \***********************************************************************/ /********************** top level lookup **********************/ Nptr bplus_Lookup(Tree *B, keyT key) { ! Nptr findNode; #ifdef DEBUG_BTREE sprintf(B->message, "LOOKUP: key %s.\n", key.name); --- 189,269 ---- } + /* access key and data values for B+tree methods */ + /* pass values to getSlot(), descend...() */ + static keyT getfunkey(Tree *B) { + keyT *tlsKey; + + // Retrieve a data pointer for the current thread. + tlsKey = (keyT *) TlsGetValue(TlsKeyIndex); + if (tlsKey == NULL) { + if (GetLastError() != ERROR_SUCCESS) + osi_panic("TlsGetValue failed", __FILE__, __LINE__); + else + osi_panic("get before set", __FILE__, __LINE__); + } + + return *tlsKey; + } + + static dataT getfundata(Tree *B) { + dataT *tlsData; + + // Retrieve a data pointer for the current thread. + tlsData = (dataT *) TlsGetValue(TlsDataIndex); + if (tlsData == NULL) { + if (GetLastError() != ERROR_SUCCESS) + osi_panic("TlsGetValue failed", __FILE__, __LINE__); + else + osi_panic("get before set", __FILE__, __LINE__); + } + + return *tlsData; + } + + static void setfunkey(Tree *B, keyT theKey) { + keyT *tlsKey; + + tlsKey = (keyT *) TlsGetValue(TlsKeyIndex); + if (tlsKey == NULL) { + if (GetLastError() != ERROR_SUCCESS) + osi_panic("TlsGetValue failed", __FILE__, __LINE__); + + tlsKey = malloc(sizeof(keyT)); + + if (!TlsSetValue(TlsKeyIndex, tlsKey)) + osi_panic("TlsSetValue failed", __FILE__, __LINE__); + } + + *tlsKey = theKey; + } + + static void setfundata(Tree *B, dataT theData) { + dataT *tlsData; + + tlsData = (dataT *) TlsGetValue(TlsDataIndex); + if (tlsData == NULL) { + if (GetLastError() != ERROR_SUCCESS) + osi_panic("TlsGetValue failed", __FILE__, __LINE__); + + tlsData = malloc(sizeof(dataT)); + + if (!TlsSetValue(TlsDataIndex, tlsData)) + osi_panic("TlsSetValue failed", __FILE__, __LINE__); + } + + *tlsData = theData; + } + + /***********************************************************************\ ! | Find leaf node in which data nodes can be found | \***********************************************************************/ /********************** top level lookup **********************/ Nptr bplus_Lookup(Tree *B, keyT key) { ! Nptr leafNode; #ifdef DEBUG_BTREE sprintf(B->message, "LOOKUP: key %s.\n", key.name); *************** *** 183,203 **** #endif setfunkey(B, key); /* set search key */ ! findNode = descendToLeaf(B, getroot(B)); /* start search from root node */ #ifdef DEBUG_BTREE ! if (findNode) { int slot; Nptr dataNode; dataT data; ! slot = findKey(B, findNode, 1, numentries(findNode)); ! dataNode = getnode(findNode, slot); data = getdatavalue(dataNode); 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); --- 271,294 ---- #endif setfunkey(B, key); /* set search key */ ! leafNode = descendToLeaf(B, getroot(B)); /* start search from root node */ #ifdef DEBUG_BTREE ! if (leafNode) { int slot; Nptr dataNode; dataT data; ! slot = getSlot(B, leafNode); ! if (slot <= BTERROR) ! return NONODE; ! ! dataNode = getnode(leafNode, slot); data = getdatavalue(dataNode); sprintf(B->message, "LOOKUP: %s found on page %d value (%d.%d.%d).\n", key.name, ! getnodenumber(B, leafNode), data.fid.volume, data.fid.vnode, data.fid.unique); *************** *** 206,212 **** OutputDebugString(B->message); #endif ! return findNode; } /********************** `recurse' down B+tree **********************/ --- 297,303 ---- OutputDebugString(B->message); #endif ! return leafNode; } /********************** `recurse' down B+tree **********************/ *************** *** 219,230 **** memset(prev, 0, sizeof(prev)); ! for (depth = 0, slot = getSlot(B, curr); isinternal(curr); depth++, slot = getSlot(B, curr)) { prev[depth] = curr; if (slot == 0) curr = getfirstnode(curr); ! else curr = getnode(curr, slot); #ifdef DEBUG_BTREE if ( !isnode(curr) ) DebugBreak(); --- 310,325 ---- memset(prev, 0, sizeof(prev)); ! for (depth = 0, slot = getSlot(B, curr); (slot >= 0) && isinternal(curr); depth++, slot = getSlot(B, curr)) { prev[depth] = curr; if (slot == 0) curr = getfirstnode(curr); ! else if (slot > 0) curr = getnode(curr, slot); + else /* BTERROR, BTLOWER, BTUPPER */ { + curr = NONODE; + break; + } #ifdef DEBUG_BTREE if ( !isnode(curr) ) DebugBreak(); *************** *** 260,283 **** #ifdef DEBUG_BTREE if (findslot == BTERROR) { ! sprintf(B->message, "Bad key ordering on node %d\n", getnodenumber(B, curr)); ! OutputDebugString(B->message); } #endif } else { mid = (lo + hi) >> 1; switch (findslot = bestMatch(B, curr, mid)) { case BTLOWER: /* check lower half of range */ ! findslot = findKey(B, curr, lo, mid - 1); /* never in 2-3+trees */ break; case BTUPPER: /* check upper half of range */ ! findslot = findKey(B, curr, mid + 1, hi); break; case BTERROR: ! sprintf(B->message, "Bad key ordering on node %d\n", getnodenumber(B, curr)); ! OutputDebugString(B->message); } } return findslot; } --- 355,389 ---- #ifdef DEBUG_BTREE if (findslot == BTERROR) { ! sprintf(B->message, "FINDKEY: (lo %d hi %d) Bad key ordering on node %d (0x%p)\n", ! lo, hi, getnodenumber(B, curr), curr); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } #endif } else { mid = (lo + hi) >> 1; switch (findslot = bestMatch(B, curr, mid)) { case BTLOWER: /* check lower half of range */ ! if (mid > 1) ! findslot = findKey(B, curr, lo, mid - 1); /* never in 2-3+trees */ break; case BTUPPER: /* check upper half of range */ ! if (mid < getfanout(B)) ! findslot = findKey(B, curr, mid + 1, hi); break; case BTERROR: ! sprintf(B->message, "FINDKEY: (lo %d hi %d) Bad key ordering on node %d (0x%p)\n", ! lo, hi, getnodenumber(B, curr), curr); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } } + + if (isleaf(curr) && findslot == 0) + { + sprintf(B->message, "FINDKEY: (lo %d hi %d) findslot %d is invalid for leaf nodes, bad key ordering on node %d (0x%p)\n", + lo, hi, findslot, getnodenumber(B, curr), curr); + osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); + } return findslot; } *************** *** 285,327 **** /************ comparison of key with a target key slot *************/ static int bestMatch(Tree *B, Nptr curr, int slot) { ! int diff, comp, findslot; diff = comparekeys(B)(getfunkey(B), getkey(curr, slot), 0); ! if (diff < 0) { /* also check previous slot */ ! if ((slot == 1) || ! ((comp = comparekeys(B)(getfunkey(B), getkey(curr, slot - 1), 0)) >= 0)) ! { findslot = slot - 1; ! } ! else if (comp < diff) { findslot = BTERROR; /* inconsistent ordering of keys */ #ifdef DEBUG_BTREE DebugBreak(); #endif ! } ! else { findslot = BTLOWER; /* key must be below in node ordering */ } } else { /* or check following slot */ ! if ((slot == numentries(curr)) || ! ((comp = comparekeys(B)(getfunkey(B), getkey(curr, slot + 1), 0)) < 0)) ! { findslot = slot; ! } ! else if (comp == 0) { findslot = slot + 1; ! } ! else if (comp > diff) { findslot = BTERROR; /* inconsistent ordering of keys */ #ifdef DEBUG_BTREE DebugBreak(); #endif ! } ! else { findslot = BTUPPER; /* key must be above in node ordering */ } } return findslot; } --- 391,444 ---- /************ comparison of key with a target key slot *************/ static int bestMatch(Tree *B, Nptr curr, int slot) { ! int diff, comp=2, findslot; diff = comparekeys(B)(getfunkey(B), getkey(curr, slot), 0); ! if (diff == 0) { ! findslot = slot; ! } else if (diff < 0) { /* also check previous slot */ ! if (slot == 1) { ! if (isleaf(curr)) ! findslot = BTLOWER; /* not found in the tree */ ! else ! findslot = 0; ! } ! else if ((comp = comparekeys(B)(getfunkey(B), getkey(curr, slot - 1), 0)) >= 0) { findslot = slot - 1; ! } else if (comp < diff) { findslot = BTERROR; /* inconsistent ordering of keys */ #ifdef DEBUG_BTREE DebugBreak(); #endif ! } else { findslot = BTLOWER; /* key must be below in node ordering */ } } else { /* or check following slot */ ! if (slot == numentries(curr)) { ! if (isleaf(curr) && numentries(curr) == getfanout(B)) ! findslot = BTUPPER; ! else ! findslot = slot; ! } else if ((comp = comparekeys(B)(getfunkey(B), getkey(curr, slot + 1), 0)) < 0) { findslot = slot; ! } else if (comp == 0) { findslot = slot + 1; ! } else if (comp > diff) { findslot = BTERROR; /* inconsistent ordering of keys */ #ifdef DEBUG_BTREE DebugBreak(); #endif ! } else { findslot = BTUPPER; /* key must be above in node ordering */ } } + + if (findslot == BTERROR || isleaf(curr) && findslot == 0) + { + sprintf(B->message, "BESTMATCH: node %d (0x%p) slot %d diff %d comp %d findslot %d\n", + getnodenumber(B, curr), curr, slot, diff, comp, findslot); + osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); + } return findslot; } *************** *** 338,344 **** #ifdef DEBUG_BTREE sprintf(B->message, "INSERT: key %s.\n", key.name); ! OutputDebugString(B->message); #endif setfunkey(B, key); /* set insertion key */ --- 455,461 ---- #ifdef DEBUG_BTREE sprintf(B->message, "INSERT: key %s.\n", key.name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif setfunkey(B, key); /* set insertion key */ *************** *** 367,372 **** --- 484,499 ---- setsplitpath(B, curr); /* indicates where nodes must split */ slot = getSlot(B, curr); /* is null only if the root is empty */ + if (slot == BTERROR) + return NONODE; + + if (isleaf(curr)) { + if (slot == BTLOWER) + slot = 0; + else if (slot == BTUPPER) + slot = getfanout(B); + } + if (isinternal(curr)) { /* continue recursion to leaves */ if (slot == 0) downNode = descendSplit(B, getfirstnode(curr)); *************** *** 402,408 **** #ifdef DEBUG_BTREE sprintf(B->message, "INSERT: slot %d, down node %d.\n", slot, getnodenumber(B, downPtr)); ! OutputDebugString(B->message); #endif if (sibling == NONODE) { /* no split occurred */ --- 529,535 ---- #ifdef DEBUG_BTREE sprintf(B->message, "INSERT: slot %d, down node %d.\n", slot, getnodenumber(B, downPtr)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif if (sibling == NONODE) { /* no split occurred */ *************** *** 606,612 **** #ifdef DEBUG_BTREE sprintf(B->message, "DELETE: key %s.\n", key.name); ! OutputDebugString(B->message); #endif setfunkey(B, key); /* set deletion key */ --- 733,739 ---- #ifdef DEBUG_BTREE sprintf(B->message, "DELETE: key %s.\n", key.name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif setfunkey(B, key); /* set deletion key */ *************** *** 615,621 **** if (isnode(newNode)) { #ifdef DEBUG_BTREE sprintf(B->message, "DELETE: collapsing node %d", getnodenumber(B, newNode)); ! OutputDebugString(B->message); #endif collapseRoot(B, getroot(B), newNode); /* remove root when superfluous */ } --- 742,748 ---- if (isnode(newNode)) { #ifdef DEBUG_BTREE sprintf(B->message, "DELETE: collapsing node %d", getnodenumber(B, newNode)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif collapseRoot(B, getroot(B), newNode); /* remove root when superfluous */ } *************** *** 629,635 **** #ifdef DEBUG_BTREE sprintf(B->message, "COLLAPSE: old %d, new %d.\n", getnodenumber(B, oldRoot), getnodenumber(B, newRoot)); ! OutputDebugString(B->message); showNode(B, "collapseRoot oldRoot", oldRoot); showNode(B, "collapseRoot newRoot", newRoot); #endif --- 756,762 ---- #ifdef DEBUG_BTREE sprintf(B->message, "COLLAPSE: old %d, new %d.\n", getnodenumber(B, oldRoot), getnodenumber(B, newRoot)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); showNode(B, "collapseRoot oldRoot", oldRoot); showNode(B, "collapseRoot newRoot", newRoot); #endif *************** *** 657,663 **** lAnc ? getnodenumber(B, lAnc) : -1, rAnc ? getnodenumber(B, rAnc) : -1, parent ? getnodenumber(B, parent) : -1); ! OutputDebugString(B->message); #endif if (!isfew(curr)) --- 784,790 ---- lAnc ? getnodenumber(B, lAnc) : -1, rAnc ? getnodenumber(B, rAnc) : -1, parent ? getnodenumber(B, parent) : -1); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif if (!isfew(curr)) *************** *** 666,671 **** --- 793,807 ---- setmergepath(B, curr); /* mark which nodes may need rebalancing */ slot = getSlot(B, curr); + if (slot == BTERROR) + return NONODE; + + if (isleaf(curr)) { + if (slot == BTLOWER) + slot = 0; + else if (slot == BTUPPER) + slot = getfanout(B); + } if (isinternal(curr)) /* set up next recursion call's parameters */ { *************** *** 783,789 **** if (newMe != NONODE) { /* this node removal doesn't consider duplicates */ #ifdef DEBUG_BTREE sprintf(B->message, "descendBalance DELETE: slot %d, node %d.\n", slot, getnodenumber(B, curr)); ! OutputDebugString(B->message); #endif removeEntry(B, curr, slot + (newMe != newNode)); /* removes one of two */ --- 919,925 ---- if (newMe != NONODE) { /* this node removal doesn't consider duplicates */ #ifdef DEBUG_BTREE sprintf(B->message, "descendBalance DELETE: slot %d, node %d.\n", slot, getnodenumber(B, curr)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif removeEntry(B, curr, slot + (newMe != newNode)); /* removes one of two */ *************** *** 837,843 **** #ifdef DEBUG_BTREE sprintf(B->message, "descendBalance returns %d\n", getnodenumber(B, newNode)); ! OutputDebugString(B->message); #endif return newNode; } --- 973,979 ---- #ifdef DEBUG_BTREE sprintf(B->message, "descendBalance returns %d\n", getnodenumber(B, newNode)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #endif return newNode; } *************** *** 869,875 **** #ifdef DEBUG_BTREE sprintf(B->message, "MERGE: left %d, right %d.\n", getnodenumber(B, left), getnodenumber(B, right)); ! OutputDebugString(B->message); showNode(B, "pre-merge anchor", anchor); showNode(B, "pre-merge left", left); showNode(B, "pre-merge right", right); --- 1005,1011 ---- #ifdef DEBUG_BTREE sprintf(B->message, "MERGE: left %d, right %d.\n", getnodenumber(B, left), getnodenumber(B, right)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); showNode(B, "pre-merge anchor", anchor); showNode(B, "pre-merge left", left); showNode(B, "pre-merge right", right); *************** *** 883,888 **** --- 1019,1026 ---- #endif setfunkey(B, getkey(right, 1)); /* defined but maybe just deleted */ z = getSlot(B, anchor); /* needs the just calculated key */ + if (z <= BTERROR) + return NONODE; setfunkey(B, getkey(anchor, z)); /* set slot to delete in anchor */ setentry(left, numentries(left), getfunkey(B), getfirstnode(right)); } *************** *** 927,933 **** getnodenumber(B, left), getnodenumber(B, right), getnodenumber(B, anchor)); ! OutputDebugString(B->message); showNode(B, "pre-shift anchor", anchor); showNode(B, "pre-shift left", left); showNode(B, "pre-shift right", right); --- 1065,1071 ---- getnodenumber(B, left), getnodenumber(B, right), getnodenumber(B, anchor)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); showNode(B, "pre-shift anchor", anchor); showNode(B, "pre-shift left", left); showNode(B, "pre-shift right", right); *************** *** 940,945 **** --- 1078,1085 ---- x = numentries(left) + y; setfunkey(B, getkey(right, y + 1 - i)); /* set new anchor key value */ z = getSlot(B, anchor); /* find slot in anchor node */ + if (z <= BTERROR) + return NONODE; #ifdef DEBUG_BTREE if (z == 0 && !isroot(anchor)) DebugBreak(); *************** *** 977,983 **** pushentry(right, z, y); setfunkey(B, getkey(left, x)); /* set new anchor key value */ ! z = getSlot(B, anchor) + 1; if (i) { decentries(left); incentries(right); --- 1117,1127 ---- pushentry(right, z, y); setfunkey(B, getkey(left, x)); /* set new anchor key value */ ! z = getSlot(B, anchor); ! if (z <= BTERROR) ! return NONODE; ! z += 1; ! if (i) { decentries(left); incentries(right); *************** *** 1019,1025 **** #ifdef DEBUG_BTREE sprintf(B->message, "SHIFT: left %d, right %d.\n", getnodenumber(B, left), getnodenumber(B, right)); ! OutputDebugString(B->message); showNode(B, "post-shift anchor", anchor); showNode(B, "post-shift left", left); showNode(B, "post-shift right", right); --- 1163,1169 ---- #ifdef DEBUG_BTREE sprintf(B->message, "SHIFT: left %d, right %d.\n", getnodenumber(B, left), getnodenumber(B, right)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); showNode(B, "post-shift anchor", anchor); showNode(B, "post-shift left", left); showNode(B, "post-shift right", right); *************** *** 1237,1297 **** int x; sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); sprintf(B->message, "| %-20s |\n", where); ! OutputDebugString(B->message); sprintf(B->message, "| node %6d ", getnodenumber(B, n)); ! OutputDebugString(B->message); sprintf(B->message, " magic %4x |\n", getmagic(n)); ! OutputDebugString(B->message); sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); sprintf(B->message, "| flags %1d%1d%1d%1d ", isfew(n), isfull(n), isroot(n), isleaf(n)); ! OutputDebugString(B->message); sprintf(B->message, "| keys = %5d ", numentries(n)); ! OutputDebugString(B->message); sprintf(B->message, "| node = %6d |\n", getnodenumber(B, getfirstnode(n))); ! OutputDebugString(B->message); for (x = 1; x <= numentries(n); x++) { sprintf(B->message, "| entry %6d ", x); ! OutputDebugString(B->message); sprintf(B->message, "| key = %6s ", getkey(n, x).name); ! OutputDebugString(B->message); sprintf(B->message, "| node = %6d |\n", getnodenumber(B, getnode(n, x))); ! OutputDebugString(B->message); } sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); } /****************** B+tree class variable printer ******************/ void showBtree(Tree *B) { sprintf(B->message, "- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); sprintf(B->message, "| B+tree %10p |\n", (void *) B); ! OutputDebugString(B->message); sprintf(B->message, "- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); sprintf(B->message, "| root %6d |\n", getnodenumber(B, getroot(B))); ! OutputDebugString(B->message); sprintf(B->message, "| leaf %6d |\n", getnodenumber(B, getleaf(B))); ! OutputDebugString(B->message); sprintf(B->message, "| fanout %3d |\n", getfanout(B) + 1); ! OutputDebugString(B->message); sprintf(B->message, "| minfanout %3d |\n", getminfanout(B, getroot(B)) + 1); ! OutputDebugString(B->message); sprintf(B->message, "| height %3d |\n", gettreeheight(B)); ! OutputDebugString(B->message); sprintf(B->message, "| freenode %6d |\n", getnodenumber(B, getfirstfreenode(B))); ! OutputDebugString(B->message); sprintf(B->message, "| theKey %6s |\n", getfunkey(B).name); ! OutputDebugString(B->message); sprintf(B->message, "| theData %d.%d.%d |\n", getfundata(B).volume, getfundata(B).vnode, getfundata(B).unique); ! OutputDebugString(B->message); sprintf(B->message, "- -- -- -- -- -- -\n"); ! OutputDebugString(B->message); } void --- 1381,1441 ---- int x; sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| %-20s |\n", where); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| node %6d ", getnodenumber(B, n)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, " magic %4x |\n", getmagic(n)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| flags %1d%1d%1d%1d ", isfew(n), isfull(n), isroot(n), isleaf(n)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| keys = %5d ", numentries(n)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| node = %6d |\n", getnodenumber(B, getfirstnode(n))); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); for (x = 1; x <= numentries(n); x++) { sprintf(B->message, "| entry %6d ", x); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| key = %6s ", getkey(n, x).name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| node = %6d |\n", getnodenumber(B, getnode(n, x))); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } sprintf(B->message, "- -- -- -- -- -- -- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } /****************** B+tree class variable printer ******************/ void showBtree(Tree *B) { sprintf(B->message, "- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| B+tree %10p |\n", (void *) B); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| root %6d |\n", getnodenumber(B, getroot(B))); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| leaf %6d |\n", getnodenumber(B, getleaf(B))); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| fanout %3d |\n", getfanout(B) + 1); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| minfanout %3d |\n", getminfanout(B, getroot(B)) + 1); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| height %3d |\n", gettreeheight(B)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| freenode %6d |\n", getnodenumber(B, getfirstfreenode(B))); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| theKey %6s |\n", getfunkey(B).name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "| theData %d.%d.%d |\n", getfundata(B).volume, getfundata(B).vnode, getfundata(B).unique); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); sprintf(B->message, "- -- -- -- -- -- -\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } void *************** *** 1303,1309 **** if (isntnode(node)) { sprintf(B->message, "%s - NoNode!!!\n"); ! OutputDebugString(B->message); return; } --- 1447,1453 ---- if (isntnode(node)) { sprintf(B->message, "%s - NoNode!!!\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); return; } *************** *** 1313,1319 **** 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 showNode(B, parent_desc, node); --- 1457,1463 ---- 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); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); return; } else showNode(B, parent_desc, node); *************** *** 1321,1327 **** if ( isinternal(node) || isroot(node) ) { sprintf(thisnode, "parent %6d", getnodenumber(B , node)); ! OutputDebugString(B->message); for ( i= isinternal(node) ? 0 : 1; i <= numentries(node); i++ ) { listBtreeNodes(B, thisnode, i == 0 ? getfirstnode(node) : getnode(node, i)); } --- 1465,1471 ---- if ( isinternal(node) || isroot(node) ) { sprintf(thisnode, "parent %6d", getnodenumber(B , node)); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); for ( i= isinternal(node) ? 0 : 1; i <= numentries(node); i++ ) { listBtreeNodes(B, thisnode, i == 0 ? getfirstnode(node) : getnode(node, i)); } *************** *** 1339,1357 **** for (slot = 1; (n != NONODE) && num && numentries(n); num--) { if (comparekeys(B)(getkey(n, slot),prev, 0) < 0) { sprintf(B->message, "BOMB %8s\n", getkey(n, slot).name); ! OutputDebugString(B->message); DebugBreak(); } 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; } sprintf(B->message, "\n\n"); ! OutputDebugString(B->message); } /******************** entire B+tree data printer *******************/ --- 1483,1501 ---- for (slot = 1; (n != NONODE) && num && numentries(n); num--) { if (comparekeys(B)(getkey(n, slot),prev, 0) < 0) { sprintf(B->message, "BOMB %8s\n", getkey(n, slot).name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); DebugBreak(); } 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); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); if (++slot > numentries(n)) n = getnextnode(n), slot = 1; } sprintf(B->message, "\n\n"); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); } /******************** entire B+tree data printer *******************/ *************** *** 1373,1379 **** for (slot = 1; (n != NONODE) && num && numentries(n); num--) { if (comparekeys(B)(getkey(n, slot),prev, 0) < 0) { sprintf(B->message,"BOMB %8s\n", getkey(n, slot).name); ! OutputDebugString(B->message); #ifdef DEBUG_BTREE DebugBreak(); #endif --- 1517,1523 ---- for (slot = 1; (n != NONODE) && num && numentries(n); num--) { if (comparekeys(B)(getkey(n, slot),prev, 0) < 0) { sprintf(B->message,"BOMB %8s\n", getkey(n, slot).name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #ifdef DEBUG_BTREE DebugBreak(); #endif *************** *** 1385,1391 **** sprintf(B->message,"BOMB %8s cannot be found\n", prev.name); else sprintf(B->message,"BOMB lookup(%8s) finds wrong node\n", prev.name); ! OutputDebugString(B->message); #ifdef DEBUG_BTREE DebugBreak(); #endif --- 1529,1535 ---- sprintf(B->message,"BOMB %8s cannot be found\n", prev.name); else sprintf(B->message,"BOMB lookup(%8s) finds wrong node\n", prev.name); ! osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, B->message)); #ifdef DEBUG_BTREE DebugBreak(); #endif *************** *** 1399,1414 **** /* * the return must be -1, 0, or 1. stricmp() in MSVC 8.0 * does not return only those values. */ static int compareKeys(keyT key1, keyT key2, int flags) { int comp; ! if (flags & EXACT_MATCH) comp = strcmp(key1.name, key2.name); - else - comp = stricmp(key1.name, key2.name); return (comp < 0 ? -1 : (comp > 0 ? 1 : 0)); } --- 1543,1563 ---- /* * the return must be -1, 0, or 1. stricmp() in MSVC 8.0 * does not return only those values. + * + * the sorting of the tree is by case insensitive sort order + * therefore, unless the strings actually match via a case + * insensitive search do we want to perform the case sensitive + * match. Otherwise, the search order might be considered + * to be inconsistent when the EXACT_MATCH flag is set. */ static int compareKeys(keyT key1, keyT key2, int flags) { int comp; ! comp = stricmp(key1.name, key2.name); ! if (comp == 0 && (flags & EXACT_MATCH)) comp = strcmp(key1.name, key2.name); return (comp < 0 ? -1 : (comp > 0 ? 1 : 0)); } *************** *** 1434,1439 **** --- 1583,1590 ---- goto done; } + lock_AssertAny(&op->scp->dirlock); + QueryPerformanceCounter(&start); leafNode = bplus_Lookup(op->scp->dirBplus, key); *************** *** 1449,1455 **** * 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) { --- 1600,1611 ---- * If we have an ambiguous match, return an error. * If we have only one inexact match, return that. */ ! slot = getSlot(op->scp->dirBplus, leafNode); ! if (slot <= BTERROR) { ! op->scp->dirDataVersion = 0; ! rc = (slot == BTERROR ? EINVAL : ENOENT); ! goto done; ! } firstDataNode = getnode(leafNode, slot); for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { *************** *** 1508,1513 **** --- 1664,1672 ---- goto done; } + + lock_AssertWrite(&op->scp->dirlock); + data.fid.cell = cfid->cell; data.fid.volume = cfid->volume; data.fid.vnode = cfid->vnode; *************** *** 1559,1564 **** --- 1718,1725 ---- goto done; } + lock_AssertWrite(&op->scp->dirlock); + QueryPerformanceCounter(&start); bplus_remove_entry++; *************** *** 1582,1588 **** * 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) { --- 1743,1754 ---- * If we have an ambiguous match, return an error. * If we have only one inexact match, return that. */ ! slot = getSlot(op->scp->dirBplus, leafNode); ! if (slot <= BTERROR) { ! op->scp->dirDataVersion = 0; ! rc = EINVAL; ! goto done; ! } firstDataNode = getnode(leafNode, slot); for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { *************** *** 1634,1640 **** * 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) { --- 1800,1812 ---- * If we have an ambiguous match, return an error. * If we have only one inexact match, return that. */ ! slot = getSlot(op->scp->dirBplus, leafNode); ! if (slot <= BTERROR) { ! op->scp->dirDataVersion = 0; ! rc = EINVAL; ! goto done; ! ! } firstDataNode = getnode(leafNode, slot); for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { *************** *** 1658,1668 **** } if (rc != CM_ERROR_AMBIGUOUS_FILENAME) { ! if (longname) { ! key.name = longname; ! delete(op->scp->dirBplus, key); ! key.name = entry; ! } delete(op->scp->dirBplus, key); } } --- 1830,1840 ---- } if (rc != CM_ERROR_AMBIGUOUS_FILENAME) { ! if (longname) { ! key.name = longname; ! delete(op->scp->dirBplus, key); ! key.name = entry; ! } delete(op->scp->dirBplus, key); } } *************** *** 1723,1729 **** osi_hyper_t thyper; LARGE_INTEGER start, end; ! osi_assert(scp->dirBplus == NULL); QueryPerformanceCounter(&start); bplus_build_tree++; --- 1895,1903 ---- osi_hyper_t thyper; LARGE_INTEGER start, end; ! osi_assertx(scp->dirBplus == NULL, "cm_BPlusDirBuildTree called on non-empty tree"); ! ! lock_AssertWrite(&scp->dirlock); QueryPerformanceCounter(&start); bplus_build_tree++; *************** *** 1743,1748 **** --- 1917,1925 ---- bplus_build_time += (end.QuadPart - start.QuadPart); + #if 0 + cm_BPlusDirEnumTest(scp, 1); + #endif return rc; } *************** *** 1802,1805 **** --- 1979,2238 ---- afsi_log(" Build: %-16I64d", bplus_build_time); afsi_log(" Free: %-16I64d", bplus_free_time); } + + static cm_direnum_t * + cm_BPlusEnumAlloc(afs_uint32 entries) + { + cm_direnum_t * enump; + size_t size; + + if (entries == 0) + return NULL; + + size = sizeof(cm_direnum_t)+(entries-1)*sizeof(cm_direnum_entry_t); + enump = (cm_direnum_t *)malloc(size); + memset(enump, 0, size); + enump->count = entries; + return enump; + } + + long + cm_BPlusDirEnumerate(cm_scache_t *scp, afs_uint32 locked, + char * maskp, cm_direnum_t **enumpp) + { + afs_uint32 count = 0, slot, numentries; + Nptr leafNode = NONODE, nextLeafNode; + Nptr firstDataNode, dataNode, nextDataNode; + cm_direnum_t * enump; + long rc = 0; + char buffer[512]; + + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate start"); + + /* Read lock the bplus tree so the data can't change */ + if (!locked) + lock_ObtainRead(&scp->dirlock); + + if (scp->dirBplus == NULL) { + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate No BPlus Tree"); + goto done; + } + + /* Compute the number of entries */ + for (count = 0, leafNode = getleaf(scp->dirBplus); leafNode; leafNode = nextLeafNode) { + + for ( slot = 1, numentries = numentries(leafNode); slot <= numentries; slot++) { + firstDataNode = getnode(leafNode, slot); + + for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { + if (maskp == NULL) { + /* name is in getdatakey(dataNode) */ + if (getdatavalue(dataNode).longname != NULL || + cm_Is8Dot3(getdatakey(dataNode).name)) + count++; + } else { + if (cm_Is8Dot3(getdatakey(dataNode).name) && + smb_V3MatchMask(getdatakey(dataNode).name, maskp, CM_FLAG_CASEFOLD) || + getdatavalue(dataNode).longname == NULL && + smb_V3MatchMask(getdatavalue(dataNode).longname, maskp, CM_FLAG_CASEFOLD)) + count++; + } + nextDataNode = getdatanext(dataNode); + } + } + + nextLeafNode = getnextnode(leafNode); + } + + sprintf(buffer, "BPlusTreeEnumerate count = %d", count); + osi_Log1(afsd_logp, "BPlus: %s", osi_LogSaveString(afsd_logp, buffer)); + + /* Allocate the enumeration object */ + enump = cm_BPlusEnumAlloc(count); + if (enump == NULL) { + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate Alloc failed"); + rc = ENOMEM; + goto done; + } + + /* Copy the name and fid for each longname entry into the enumeration */ + for (count = 0, leafNode = getleaf(scp->dirBplus); leafNode; leafNode = nextLeafNode) { + + for ( slot = 1, numentries = numentries(leafNode); slot <= numentries; slot++) { + firstDataNode = getnode(leafNode, slot); + + for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) { + char * name; + int hasShortName; + int includeIt = 0; + + if (maskp == NULL) { + if (getdatavalue(dataNode).longname != NULL || + cm_Is8Dot3(getdatakey(dataNode).name)) + { + includeIt = 1; + } + } else { + if (cm_Is8Dot3(getdatakey(dataNode).name) && + smb_V3MatchMask(getdatakey(dataNode).name, maskp, CM_FLAG_CASEFOLD) || + getdatavalue(dataNode).longname == NULL && + smb_V3MatchMask(getdatavalue(dataNode).longname, maskp, CM_FLAG_CASEFOLD)) + { + includeIt = 1; + } + } + + if (includeIt) { + if (getdatavalue(dataNode).longname) { + name = strdup(getdatavalue(dataNode).longname); + hasShortName = 1; + } else { + name = strdup(getdatakey(dataNode).name); + hasShortName = 0; + } + + if (name == NULL) { + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate strdup failed"); + rc = ENOMEM; + goto done; + } + enump->entry[count].name = name; + enump->entry[count].fid = getdatavalue(dataNode).fid; + if (hasShortName) + strncpy(enump->entry[count].shortName, getdatakey(dataNode).name, + sizeof(enump->entry[count].shortName)); + else + enump->entry[count].shortName[0] = '\0'; + count++; + } + nextDataNode = getdatanext(dataNode); + } + } + + nextLeafNode = getnextnode(leafNode); + } + + done: + if (!locked) + lock_ReleaseRead(&scp->dirlock); + + /* if we failed, cleanup any mess */ + if (rc != 0) { + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate rc != 0"); + if (enump) { + for ( count = 0; count < enump->count && enump->entry[count].name; count++ ) { + free(enump->entry[count].name); + } + free(enump); + enump = NULL; + } + } + + osi_Log0(afsd_logp, "cm_BPlusDirEnumerate end"); + *enumpp = enump; + return rc; + } + + long + cm_BPlusDirNextEnumEntry(cm_direnum_t *enump, cm_direnum_entry_t **entrypp) + { + if (enump == NULL || entrypp == NULL || enump->next > enump->count) { + if (entrypp) + *entrypp = NULL; + osi_Log0(afsd_logp, "cm_BPlusDirNextEnumEntry invalid input"); + return CM_ERROR_INVAL; \ + } + + *entrypp = &enump->entry[enump->next++]; + if ( enump->next == enump->count ) { + osi_Log0(afsd_logp, "cm_BPlusDirNextEnumEntry STOPNOW"); + return CM_ERROR_STOPNOW; + } + else { + osi_Log0(afsd_logp, "cm_BPlusDirNextEnumEntry SUCCESS"); + return 0; + } + } + + long + cm_BPlusDirFreeEnumeration(cm_direnum_t *enump) + { + afs_uint32 count; + + osi_Log0(afsd_logp, "cm_BPlusDirFreeEnumeration"); + + if (enump) { + for ( count = 0; count < enump->count && enump->entry[count].name; count++ ) { + free(enump->entry[count].name); + } + free(enump); + } + return 0; + } + + long + cm_BPlusDirEnumTest(cm_scache_t * dscp, afs_uint32 locked) + { + cm_direnum_t * enump = NULL; + cm_direnum_entry_t * entryp; + long code; + + osi_Log0(afsd_logp, "cm_BPlusDirEnumTest start"); + + for (code = cm_BPlusDirEnumerate(dscp, locked, NULL, &enump); code == 0; ) { + code = cm_BPlusDirNextEnumEntry(enump, &entryp); + if (code == 0 || code == CM_ERROR_STOPNOW) { + char buffer[1024]; + cm_scache_t *scp; + char * type = "ScpNotFound"; + afs_int32 dv = -1; + + scp = cm_FindSCache(&entryp->fid); + if (scp) { + switch (scp->fileType) { + case CM_SCACHETYPE_FILE : + type = "File"; + break; + case CM_SCACHETYPE_DIRECTORY : + type = "Directory"; + break; + case CM_SCACHETYPE_SYMLINK : + type = "Symlink"; + break; + case CM_SCACHETYPE_MOUNTPOINT: + type = "MountPoint"; + break; + case CM_SCACHETYPE_DFSLINK : + type = "Dfs"; + break; + case CM_SCACHETYPE_INVALID : + type = "Invalid"; + break; + default: + type = "Unknown"; + break; + } + + dv = scp->dataVersion; + cm_ReleaseSCache(scp); + } + + sprintf(buffer, "'%s' Fid = (%d,%d,%d,%d) Short = '%s' Type %s DV %d", + entryp->name, + entryp->fid.cell, entryp->fid.volume, entryp->fid.vnode, entryp->fid.unique, + entryp->shortName, + type, + dv); + + osi_Log0(afsd_logp, osi_LogSaveString(afsd_logp, buffer)); + } + } + + if (enump) + cm_BPlusDirFreeEnumeration(enump); + + osi_Log0(afsd_logp, "cm_BPlusDirEnumTest end"); + + return 0; + } #endif /* USE_BPLUS */ Index: openafs/src/WINNT/afsd/cm_btree.h diff -c openafs/src/WINNT/afsd/cm_btree.h:1.1.2.5 openafs/src/WINNT/afsd/cm_btree.h:1.1.2.7 *** openafs/src/WINNT/afsd/cm_btree.h:1.1.2.5 Wed Sep 19 23:55:42 2007 --- openafs/src/WINNT/afsd/cm_btree.h Mon Nov 5 13:26:49 2007 *************** *** 107,116 **** unsigned int height; /* nodes traversed from root to leaves */ Nptr pool; /* list of all nodes */ Nptr empty; /* list of empty nodes */ - keyT theKey; /* the key value used in tree operations */ - dataT theData; /* data used for insertions/deletions */ union { /* nodes to change in insert and delete */ ! Nptr split; Nptr merge; } branch; KeyCmp keycmp; /* pointer to function comparing two keys */ --- 107,114 ---- unsigned int height; /* nodes traversed from root to leaves */ Nptr pool; /* list of all nodes */ Nptr empty; /* list of empty nodes */ union { /* nodes to change in insert and delete */ ! Nptr split; /* protected by scp->dirlock write-lock */ Nptr merge; } branch; KeyCmp keycmp; /* pointer to function comparing two keys */ *************** *** 145,154 **** --- 143,176 ---- void cm_BPlusDumpStats(void); int cm_MemDumpBPlusStats(FILE *outputFile, char *cookie, int lock); + + /******************* directory enumeration operations ****************/ + typedef struct cm_direnum_entry { + char * name; + cm_fid_t fid; + char shortName[13]; + } cm_direnum_entry_t; + + typedef struct cm_direnum { + afs_uint32 count; + afs_uint32 next; + cm_direnum_entry_t entry[1]; + } cm_direnum_t; + + long cm_BPlusDirEnumerate(cm_scache_t *scp, afs_uint32 locked, char *maskp, cm_direnum_t **enumpp); + long cm_BPlusDirNextEnumEntry(cm_direnum_t *enump, cm_direnum_entry_t **entrypp); + long cm_BPlusDirFreeEnumeration(cm_direnum_t *enump); + long cm_BPlusDirEnumTest(cm_scache_t * dscp, afs_uint32 locked); + + long cm_InitBPlusDir(void); + + /************ Statistic Counter ***************************************/ + extern afs_uint32 bplus_free_tree; extern afs_uint32 bplus_dv_error; extern afs_uint64 bplus_free_time; + /************ Accessor Macros *****************************************/ /* low level definition of Nptr value usage */ *************** *** 227,240 **** #define xferentry(j, q, v, z) _xferentry(j, q, v, z) #define setentry(j, q, v, z) _setentry(j, q, v, z) - - /* access key and data values for B+tree methods */ - /* pass values to getSlot(), descend...() */ - #define getfunkey(B) ((B)->theKey) - #define getfundata(B) ((B)->theData) - #define setfunkey(B,v) ((B)->theKey = (v)) - #define setfundata(B,v) ((B)->theData = (v)) - /* define number of B+tree nodes for free node pool */ #define getpoolsize(B) ((B)->poolsize) #define setpoolsize(B,v) ((B)->poolsize = (v)) --- 249,254 ---- Index: openafs/src/WINNT/afsd/cm_buf.c diff -c openafs/src/WINNT/afsd/cm_buf.c:1.31.2.20 openafs/src/WINNT/afsd/cm_buf.c:1.31.2.22 *** openafs/src/WINNT/afsd/cm_buf.c:1.31.2.20 Tue Sep 18 12:59:23 2007 --- openafs/src/WINNT/afsd/cm_buf.c Sun Nov 4 19:24:46 2007 *************** *** 91,97 **** void buf_HoldLocked(cm_buf_t *bp) { ! osi_assert(bp->magic == CM_BUF_MAGIC); bp->refCount++; } --- 91,97 ---- void buf_HoldLocked(cm_buf_t *bp) { ! osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic"); bp->refCount++; } *************** *** 107,118 **** void buf_ReleaseLocked(cm_buf_t *bp) { /* ensure that we're in the LRU queue if our ref count is 0 */ ! osi_assert(bp->magic == CM_BUF_MAGIC); #ifdef DEBUG if (bp->refCount == 0) osi_panic("buf refcount 0",__FILE__,__LINE__);; #else ! osi_assert(bp->refCount > 0); #endif if (--bp->refCount == 0) { if (!(bp->flags & CM_BUF_INLRU)) { --- 107,118 ---- void buf_ReleaseLocked(cm_buf_t *bp) { /* ensure that we're in the LRU queue if our ref count is 0 */ ! osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic"); #ifdef DEBUG if (bp->refCount == 0) osi_panic("buf refcount 0",__FILE__,__LINE__);; #else ! osi_assertx(bp->refCount > 0, "cm_buf_t refCount == 0"); #endif if (--bp->refCount == 0) { if (!(bp->flags & CM_BUF_INLRU)) { *************** *** 327,334 **** cm_data.buf_allp = NULL; for (i=0; i= cm_data.bufHeaderBaseAddress && bp < (cm_buf_t *)cm_data.bufDataBaseAddress); ! osi_assert(data >= cm_data.bufDataBaseAddress && data < cm_data.bufEndOfData); /* allocate and zero some storage */ memset(bp, 0, sizeof(cm_buf_t)); --- 327,336 ---- cm_data.buf_allp = NULL; for (i=0; i= cm_data.bufHeaderBaseAddress && bp < (cm_buf_t *)cm_data.bufDataBaseAddress, ! "invalid cm_buf_t address"); ! osi_assertx(data >= cm_data.bufDataBaseAddress && data < cm_data.bufEndOfData, ! "invalid cm_buf_t data address"); /* allocate and zero some storage */ memset(bp, 0, sizeof(cm_buf_t)); *************** *** 482,489 **** int release = 0; if (scp) ! osi_assert(scp->magic == CM_SCACHE_MAGIC); ! osi_assert(bp->magic == CM_BUF_MAGIC); while (1) { /* if no IO is happening, we're done */ --- 484,491 ---- int release = 0; if (scp) ! osi_assertx(scp->magic == CM_SCACHE_MAGIC, "invalid cm_scache_t magic"); ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); while (1) { /* if no IO is happening, we're done */ *************** *** 595,601 **** cm_scache_t * scp = NULL; osi_hyper_t offset; ! osi_assert(bp->magic == CM_BUF_MAGIC); while ((bp->flags & CM_BUF_DIRTY) == CM_BUF_DIRTY) { isdirty = 1; --- 597,603 ---- cm_scache_t * scp = NULL; osi_hyper_t offset; ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); while ((bp->flags & CM_BUF_DIRTY) == CM_BUF_DIRTY) { isdirty = 1; *************** *** 675,681 **** cm_buf_t *tbp; cm_buf_t *prevBp, *nextBp; ! osi_assert(bp->magic == CM_BUF_MAGIC); /* if we get here, we know that the buffer still has a 0 ref count, * and that it is clean and has no currently pending I/O. This is --- 677,683 ---- cm_buf_t *tbp; cm_buf_t *prevBp, *nextBp; ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); /* if we get here, we know that the buffer still has a 0 ref count, * and that it is clean and has no currently pending I/O. This is *************** *** 687,694 **** osi_Log3( buf_logp, "buf_Recycle recycles 0x%p, off 0x%x:%08x", bp, bp->offset.HighPart, bp->offset.LowPart); ! osi_assert(bp->refCount == 0); ! osi_assert(!(bp->flags & (CM_BUF_READING | CM_BUF_WRITING | CM_BUF_DIRTY))); lock_AssertWrite(&buf_globalLock); if (bp->flags & CM_BUF_INHASH) { --- 689,697 ---- osi_Log3( buf_logp, "buf_Recycle recycles 0x%p, off 0x%x:%08x", bp, bp->offset.HighPart, bp->offset.LowPart); ! osi_assertx(bp->refCount == 0, "cm_buf_t refcount != 0"); ! osi_assertx(!(bp->flags & (CM_BUF_READING | CM_BUF_WRITING | CM_BUF_DIRTY)), ! "incorrect cm_buf_t flags"); lock_AssertWrite(&buf_globalLock); if (bp->flags & CM_BUF_INHASH) { *************** *** 1036,1042 **** */ if (created) { /* load the page; freshly created pages should be idle */ ! osi_assert(!(bp->flags & (CM_BUF_READING | CM_BUF_WRITING))); /* start the I/O; may drop lock */ bp->flags |= CM_BUF_READING; --- 1039,1045 ---- */ if (created) { /* load the page; freshly created pages should be idle */ ! osi_assertx(!(bp->flags & (CM_BUF_READING | CM_BUF_WRITING)), "incorrect cm_buf_t flags"); /* start the I/O; may drop lock */ bp->flags |= CM_BUF_READING; *************** *** 1146,1152 **** long buf_CleanAsync(cm_buf_t *bp, cm_req_t *reqp) { long code; ! osi_assert(bp->magic == CM_BUF_MAGIC); lock_ObtainMutex(&bp->mx); code = buf_CleanAsyncLocked(bp, reqp); --- 1149,1155 ---- long buf_CleanAsync(cm_buf_t *bp, cm_req_t *reqp) { long code; ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); lock_ObtainMutex(&bp->mx); code = buf_CleanAsyncLocked(bp, reqp); *************** *** 1158,1164 **** /* wait for a buffer's cleaning to finish */ void buf_CleanWait(cm_scache_t * scp, cm_buf_t *bp) { ! osi_assert(bp->magic == CM_BUF_MAGIC); lock_ObtainMutex(&bp->mx); if (bp->flags & CM_BUF_WRITING) { --- 1161,1167 ---- /* wait for a buffer's cleaning to finish */ void buf_CleanWait(cm_scache_t * scp, cm_buf_t *bp) { ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); lock_ObtainMutex(&bp->mx); if (bp->flags & CM_BUF_WRITING) { *************** *** 1174,1181 **** */ void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length) { ! osi_assert(bp->magic == CM_BUF_MAGIC); ! osi_assert(bp->refCount > 0); lock_ObtainWrite(&buf_globalLock); if (bp->flags & CM_BUF_DIRTY) { --- 1177,1184 ---- */ void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length) { ! osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); ! osi_assertx(bp->refCount > 0, "cm_buf_t refcount 0"); lock_ObtainWrite(&buf_globalLock); if (bp->flags & CM_BUF_DIRTY) { *************** *** 1425,1431 **** * visible again. */ bufferPos = sizep->LowPart & (cm_data.buf_blockSize - 1); ! osi_assert(bufferPos != 0); memset(bufp->datap + bufferPos, 0, cm_data.buf_blockSize - bufferPos); } --- 1428,1434 ---- * visible again. */ bufferPos = sizep->LowPart & (cm_data.buf_blockSize - 1); ! osi_assertx(bufferPos != 0, "non-zero bufferPos"); memset(bufp->datap + bufferPos, 0, cm_data.buf_blockSize - bufferPos); } *************** *** 1554,1559 **** --- 1557,1564 ---- unsigned int i; int found = 0; + lock_AssertMutex(&scp->mx); + i = BUF_FILEHASH(&scp->fid); lock_ObtainWrite(&buf_globalLock); Index: openafs/src/WINNT/afsd/cm_callback.c diff -c openafs/src/WINNT/afsd/cm_callback.c:1.41.4.20 openafs/src/WINNT/afsd/cm_callback.c:1.41.4.21 *** openafs/src/WINNT/afsd/cm_callback.c:1.41.4.20 Sat Oct 20 00:03:04 2007 --- openafs/src/WINNT/afsd/cm_callback.c Sun Nov 4 19:24:46 2007 *************** *** 1420,1426 **** #ifndef SIZE_MAX #define SIZE_MAX UINT_MAX #endif ! osi_assert(allocsize < SIZE_MAX); #endif *configCount = (afs_uint32)allocsize; config->cacheConfig_val = t_config; --- 1420,1426 ---- #ifndef SIZE_MAX #define SIZE_MAX UINT_MAX #endif ! osi_assertx(allocsize < SIZE_MAX, "allocsize >= SIZE_MAX"); #endif *configCount = (afs_uint32)allocsize; config->cacheConfig_val = t_config; *************** *** 1551,1560 **** lock_ObtainWrite(&cm_callbackLock); if (flags & CM_CALLBACK_MAINTAINCOUNT) { ! osi_assert(cm_activeCallbackGrantingCalls > 0); } else { ! osi_assert(cm_activeCallbackGrantingCalls-- > 0); } if (cm_activeCallbackGrantingCalls == 0) freeFlag = 1; --- 1551,1562 ---- lock_ObtainWrite(&cm_callbackLock); if (flags & CM_CALLBACK_MAINTAINCOUNT) { ! osi_assertx(cm_activeCallbackGrantingCalls > 0, ! "CM_CALLBACK_MAINTAINCOUNT && cm_activeCallbackGrantingCalls == 0"); } else { ! osi_assertx(cm_activeCallbackGrantingCalls-- > 0, ! "!CM_CALLBACK_MAINTAINCOUNT && cm_activeCallbackGrantingCalls == 0"); } if (cm_activeCallbackGrantingCalls == 0) freeFlag = 1; Index: openafs/src/WINNT/afsd/cm_conn.c diff -c openafs/src/WINNT/afsd/cm_conn.c:1.49.2.22 openafs/src/WINNT/afsd/cm_conn.c:1.49.2.24 *** openafs/src/WINNT/afsd/cm_conn.c:1.49.2.22 Thu Sep 13 13:59:21 2007 --- openafs/src/WINNT/afsd/cm_conn.c Sun Nov 4 19:24:46 2007 *************** *** 36,42 **** void cm_PutConn(cm_conn_t *connp) { lock_ObtainWrite(&cm_connLock); ! osi_assert(connp->refCount-- > 0); lock_ReleaseWrite(&cm_connLock); } --- 36,42 ---- void cm_PutConn(cm_conn_t *connp) { lock_ObtainWrite(&cm_connLock); ! osi_assertx(connp->refCount-- > 0, "cm_conn_t refcount 0"); lock_ReleaseWrite(&cm_connLock); } *************** *** 236,242 **** cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, cellp); retry = 1; } ! } /* if there is nosuchvolume, then we have a situation in which a * previously known volume no longer has a set of servers --- 236,250 ---- cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, cellp); retry = 1; } ! } ! ! else if (errorCode == UAEWOULDBLOCK || errorCode == EWOULDBLOCK || ! errorCode == UAEAGAIN || errorCode == EAGAIN) { ! if (timeLeft > 5 ) { ! thrd_Sleep(1000); ! retry = 1; ! } ! } /* if there is nosuchvolume, then we have a situation in which a * previously known volume no longer has a set of servers *************** *** 625,630 **** --- 633,640 ---- case UAENOENT : s = "UAENOENT"; break; case VICECONNBAD : s = "VICECONNBAD"; break; case VICETOKENDEAD : s = "VICETOKENDEAD"; break; + case WSAEWOULDBLOCK : s = "WSAEWOULDBLOCK"; break; + case UAEWOULDBLOCK : s = "UAEWOULDBLOCK"; break; case CM_ERROR_NOSUCHCELL : s = "CM_ERROR_NOSUCHCELL"; break; case CM_ERROR_NOSUCHVOLUME : s = "CM_ERROR_NOSUCHVOLUME"; break; case CM_ERROR_TIMEDOUT : s = "CM_ERROR_TIMEDOUT"; break; *************** *** 832,838 **** serviceID = 52; } else { ! osi_assert(serverp->type == CM_SERVER_FILE); port = htons(7000); serviceID = 1; } --- 842,848 ---- serviceID = 52; } else { ! osi_assertx(serverp->type == CM_SERVER_FILE, "incorrect server type"); port = htons(7000); serviceID = 1; } *************** *** 852,858 **** tcp->cryptlevel = rxkad_clear; secObjp = rxnull_NewClientSecurityObject(); } ! osi_assert(secObjp != NULL); tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr, port, serviceID, --- 862,868 ---- tcp->cryptlevel = rxkad_clear; secObjp = rxnull_NewClientSecurityObject(); } ! osi_assertx(secObjp != NULL, "null rx_securityClass"); tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr, port, serviceID, Index: openafs/src/WINNT/afsd/cm_daemon.c diff -c openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.16 openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.17 *** openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.16 Thu Jul 5 15:22:15 2007 --- openafs/src/WINNT/afsd/cm_daemon.c Sun Nov 4 19:24:46 2007 *************** *** 101,107 **** } osi_QRemoveHT((osi_queue_t **) &cm_bkgListp, (osi_queue_t **) &cm_bkgListEndp, &rp->q); ! osi_assert(cm_bkgQueueCount-- > 0); lock_ReleaseWrite(&cm_daemonLock); osi_Log1(afsd_logp,"cm_BkgDaemon processing request 0x%p", rp); --- 101,107 ---- } osi_QRemoveHT((osi_queue_t **) &cm_bkgListp, (osi_queue_t **) &cm_bkgListEndp, &rp->q); ! osi_assertx(cm_bkgQueueCount-- > 0, "cm_bkgQueueCount 0"); lock_ReleaseWrite(&cm_daemonLock); osi_Log1(afsd_logp,"cm_BkgDaemon processing request 0x%p", rp); *************** *** 471,491 **** /* creating IP Address Change monitor daemon */ phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_IpAddrDaemon, 0, 0, &pid, "cm_IpAddrDaemon"); ! osi_assert(phandle != NULL); thrd_CloseHandle(phandle); #endif /* DJGPP */ /* creating pinging daemon */ phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_Daemon, 0, 0, &pid, "cm_Daemon"); ! osi_assert(phandle != NULL); thrd_CloseHandle(phandle); for(i=0; i < nDaemons; i++) { phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_BkgDaemon, 0, 0, &pid, "cm_BkgDaemon"); ! osi_assert(phandle != NULL); thrd_CloseHandle(phandle); } } --- 471,491 ---- /* creating IP Address Change monitor daemon */ phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_IpAddrDaemon, 0, 0, &pid, "cm_IpAddrDaemon"); ! osi_assertx(phandle != NULL, "cm_IpAddrDaemon thread creation failure"); thrd_CloseHandle(phandle); #endif /* DJGPP */ /* creating pinging daemon */ phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_Daemon, 0, 0, &pid, "cm_Daemon"); ! osi_assertx(phandle != NULL, "cm_Daemon thread creation failure"); thrd_CloseHandle(phandle); for(i=0; i < nDaemons; i++) { phandle = thrd_Create((SecurityAttrib) 0, 0, (ThreadFunc) cm_BkgDaemon, 0, 0, &pid, "cm_BkgDaemon"); ! osi_assertx(phandle != NULL, "cm_BkgDaemon thread creation failure"); thrd_CloseHandle(phandle); } } Index: openafs/src/WINNT/afsd/cm_dcache.c diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.19 openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.20 *** openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.19 Tue Sep 18 12:59:23 2007 --- openafs/src/WINNT/afsd/cm_dcache.c Sun Nov 4 19:24:46 2007 *************** *** 75,82 **** cm_bulkIO_t biod; /* bulk IO descriptor */ int require_64bit_ops = 0; ! osi_assert(userp != NULL); ! osi_assert(scp != NULL); /* now, the buffer may or may not be filled with good data (buf_GetNew * drops lots of locks, and may indeed return a properly initialized --- 75,82 ---- cm_bulkIO_t biod; /* bulk IO descriptor */ int require_64bit_ops = 0; ! osi_assertx(userp != NULL, "null cm_user_t"); ! osi_assertx(scp != NULL, "null cm_scache_t"); /* now, the buffer may or may not be filled with good data (buf_GetNew * drops lots of locks, and may indeed return a properly initialized *************** *** 207,213 **** qdp = biod.bufListEndp; else qdp = (osi_queueData_t *) osi_QPrev(&qdp->q); ! osi_assert(qdp != NULL); bufp = osi_GetQData(qdp); bufferp = bufp->datap; wbytes = nbytes; --- 207,213 ---- qdp = biod.bufListEndp; else qdp = (osi_queueData_t *) osi_QPrev(&qdp->q); ! osi_assertx(qdp != NULL, "null osi_queueData_t"); bufp = osi_GetQData(qdp); bufferp = bufp->datap; wbytes = nbytes; *************** *** 1573,1579 **** * our check above for nbytes being less than * biod.length should ensure this. */ ! osi_assert(bufferp != NULL); /* read rbytes of data */ rbytes = (nbytes > cm_data.buf_blockSize? cm_data.buf_blockSize : nbytes); --- 1573,1579 ---- * our check above for nbytes being less than * biod.length should ensure this. */ ! osi_assertx(bufferp != NULL, "null cm_buf_t"); /* read rbytes of data */ rbytes = (nbytes > cm_data.buf_blockSize? cm_data.buf_blockSize : nbytes); *************** *** 1624,1630 **** * all of the rest of the pages. */ /* bytes fetched */ ! osi_assert((bufferp - tbufp->datap) < LONG_MAX); rbytes = (long) (bufferp - tbufp->datap); /* bytes left to zero */ --- 1624,1630 ---- * all of the rest of the pages. */ /* bytes fetched */ ! osi_assertx((bufferp - tbufp->datap) < LONG_MAX, "data >= LONG_MAX"); rbytes = (long) (bufferp - tbufp->datap); /* bytes left to zero */ Index: openafs/src/WINNT/afsd/cm_dir.c diff -c openafs/src/WINNT/afsd/cm_dir.c:1.4.4.6 openafs/src/WINNT/afsd/cm_dir.c:1.4.4.8 *** openafs/src/WINNT/afsd/cm_dir.c:1.4.4.6 Wed Sep 19 23:55:42 2007 --- openafs/src/WINNT/afsd/cm_dir.c Sat Nov 3 12:19:28 2007 *************** *** 100,106 **** cm_DirOpDelBuffer(cm_dirOp_t * op, cm_buf_t * buffer, int flags); static long ! cm_DirCheckStatus(cm_dirOp_t * op); static long cm_DirReleasePage(cm_dirOp_t * op, cm_buf_t ** bufferpp, int modified); --- 100,106 ---- cm_DirOpDelBuffer(cm_dirOp_t * op, cm_buf_t * buffer, int flags); static long ! cm_DirCheckStatus(cm_dirOp_t * op, afs_uint32 locked); static long cm_DirReleasePage(cm_dirOp_t * op, cm_buf_t ** bufferpp, int modified); *************** *** 958,972 **** } } ! /* Begin a sequence of directory operations. scp->mx should be ! locked. ! */ long cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp, afs_uint32 lockType, cm_dirOp_t * op) { long code; ! int i, mxheld = 0; osi_Log3(afsd_logp, "Beginning dirOp[0x%p] for scp[0x%p], userp[0x%p]", op, scp, userp); --- 958,972 ---- } } ! /* Begin a sequence of directory operations. ! * Called with scp->mx unlocked. ! */ long cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp, afs_uint32 lockType, cm_dirOp_t * op) { long code; ! int i, mxheld = 0, haveWrite = 0; osi_Log3(afsd_logp, "Beginning dirOp[0x%p] for scp[0x%p], userp[0x%p]", op, scp, userp); *************** *** 986,993 **** op->buffers[i].flags = 0; } ! code = cm_DirCheckStatus(op); ! if (code == 0) { op->length = scp->length; op->newLength = op->length; --- 986,1001 ---- op->buffers[i].flags = 0; } ! if (lockType == CM_DIRLOCK_WRITE) { ! lock_ObtainWrite(&scp->dirlock); ! haveWrite = 1; ! } else { ! lock_ObtainRead(&scp->dirlock); ! haveWrite = 0; ! } ! lock_ObtainMutex(&scp->mx); ! mxheld = 1; ! code = cm_DirCheckStatus(op, 1); if (code == 0) { op->length = scp->length; op->newLength = op->length; *************** *** 995,1036 **** op->newDataVersion = op->dataVersion; #ifdef USE_BPLUS - lock_ObtainRead(&scp->dirlock); if (!cm_BPlusTrees || (scp->dirBplus && scp->dirDataVersion == scp->dataVersion)) { ! int mxheld = 0; ! switch (lockType) { case CM_DIRLOCK_NONE: ! lock_ReleaseRead(&scp->dirlock); break; case CM_DIRLOCK_READ: ! /* got it already */ break; case CM_DIRLOCK_WRITE: default: ! lock_ReleaseRead(&scp->dirlock); ! lock_ObtainWrite(&scp->dirlock); } } else { ! lock_ReleaseRead(&scp->dirlock); ! lock_ObtainWrite(&scp->dirlock); ! if (scp->dirBplus && ! scp->dirDataVersion != scp->dataVersion) { ! bplus_dv_error++; ! bplus_free_tree++; ! freeBtree(scp->dirBplus); ! scp->dirBplus = NULL; ! scp->dirDataVersion = -1; ! } ! if (!scp->dirBplus) { ! cm_BPlusDirBuildTree(scp, userp, reqp); ! if (scp->dirBplus) ! scp->dirDataVersion = scp->dataVersion; } switch (lockType) { --- 1003,1079 ---- op->newDataVersion = op->dataVersion; #ifdef USE_BPLUS if (!cm_BPlusTrees || (scp->dirBplus && scp->dirDataVersion == scp->dataVersion)) { ! /* we know that haveWrite matches lockType at this point */ switch (lockType) { case CM_DIRLOCK_NONE: ! if (haveWrite) ! lock_ReleaseWrite(&scp->dirlock); ! else ! lock_ReleaseRead(&scp->dirlock); break; case CM_DIRLOCK_READ: ! osi_assert(!haveWrite); break; case CM_DIRLOCK_WRITE: default: ! osi_assert(haveWrite); } } else { ! if (!(scp->dirBplus && ! scp->dirDataVersion == scp->dataVersion)) { ! repeat: ! if (!haveWrite) { ! if (mxheld) { ! lock_ReleaseMutex(&scp->mx); ! mxheld = 0; ! } ! lock_ReleaseRead(&scp->dirlock); ! lock_ObtainWrite(&scp->dirlock); ! haveWrite = 1; ! } ! if (!mxheld) { ! lock_ObtainMutex(&scp->mx); ! mxheld = 1; ! } ! if (scp->dirBplus && ! scp->dirDataVersion != scp->dataVersion) ! { ! bplus_dv_error++; ! bplus_free_tree++; ! freeBtree(scp->dirBplus); ! scp->dirBplus = NULL; ! scp->dirDataVersion = -1; ! } ! ! if (!scp->dirBplus) { ! if (mxheld) { ! lock_ReleaseMutex(&scp->mx); ! mxheld = 0; ! } ! cm_BPlusDirBuildTree(scp, userp, reqp); ! if (!mxheld) { ! lock_ObtainMutex(&scp->mx); ! mxheld = 1; ! } ! if (op->dataVersion != scp->dataVersion) { ! /* We lost the race, therefore we must update the ! * dirop state and retry to build the tree. ! */ ! op->length = scp->length; ! op->newLength = op->length; ! op->dataVersion = scp->dataVersion; ! op->newDataVersion = op->dataVersion; ! goto repeat; ! } ! if (scp->dirBplus) ! scp->dirDataVersion = scp->dataVersion; ! } } switch (lockType) { *************** *** 1044,1065 **** default: /* got it already */; } } #else switch (lockType) { case CM_DIRLOCK_NONE: break; case CM_DIRLOCK_READ: ! lock_ObtainRead(&scp->dirlock); break; case CM_DIRLOCK_WRITE: default: ! lock_ObtainWrite(&scp->dirlock); } #endif op->lockType = lockType; } else { ! cm_EndDirOp(op); } --- 1087,1121 ---- default: /* got it already */; } + haveWrite = 0; } #else + /* we know that haveWrite matches lockType at this point */ switch (lockType) { case CM_DIRLOCK_NONE: + if (haveWrite) + lock_ReleaseWrite(&scp->dirlock); + else + lock_ReleaseRead(&scp->dirlock); break; case CM_DIRLOCK_READ: ! osi_assert(!haveWrite); break; case CM_DIRLOCK_WRITE: default: ! osi_assert(haveWrite); } #endif op->lockType = lockType; + if (mxheld) + lock_ReleaseMutex(&scp->mx); } else { ! if (haveWrite) ! lock_ReleaseWrite(&scp->dirlock); ! else ! lock_ReleaseRead(&scp->dirlock); ! if (mxheld) ! lock_ReleaseMutex(&scp->mx); cm_EndDirOp(op); } *************** *** 1072,1082 **** cm_CheckDirOpForSingleChange(cm_dirOp_t * op) { long code; if (op->scp == NULL) return 0; ! code = cm_DirCheckStatus(op); if (code == 0 && op->dataVersion == op->scp->dataVersion - 1) { --- 1128,1140 ---- cm_CheckDirOpForSingleChange(cm_dirOp_t * op) { long code; + int rc = 0; if (op->scp == NULL) return 0; ! lock_ObtainMutex(&op->scp->mx); ! code = cm_DirCheckStatus(op, 1); if (code == 0 && op->dataVersion == op->scp->dataVersion - 1) { *************** *** 1086,1104 **** op->newDataVersion = op->scp->dataVersion; op->newLength = op->scp->serverLength; ! osi_Log0(afsd_logp, "cm_CheckDirOpForSingleChange succeeded"); ! ! return 1; } ! ! osi_Log3(afsd_logp, ! "cm_CheckDirOpForSingleChange failed. code=0x%x, old dv=%d, new dv=%d", ! code, op->dataVersion, op->scp->dataVersion); ! return 0; } ! /* End a sequence of directory operations. Called with op->scp->mx ! unlocked.*/ long cm_EndDirOp(cm_dirOp_t * op) { --- 1144,1164 ---- op->newDataVersion = op->scp->dataVersion; op->newLength = op->scp->serverLength; ! rc = 1; } ! lock_ReleaseMutex(&op->scp->mx); ! ! if (rc) ! osi_Log0(afsd_logp, "cm_CheckDirOpForSingleChange succeeded"); ! else ! osi_Log3(afsd_logp, ! "cm_CheckDirOpForSingleChange failed. code=0x%x, old dv=%d, new dv=%d", ! code, op->dataVersion, op->scp->dataVersion); ! return rc; } ! /* End a sequence of directory operations. ! * Called with op->scp->mx unlocked.*/ long cm_EndDirOp(cm_dirOp_t * op) { *************** *** 1111,1124 **** op, op->dirtyBufCount); if (op->dirtyBufCount > 0) { - /* we made changes. We should go through the list of buffers - and update the dataVersion for each. */ - code = buf_ForceDataVersion(op->scp, op->dataVersion, op->newDataVersion); - #ifdef USE_BPLUS ! /* and update the data version on the B+ tree */ if (op->scp->dirBplus && ! op->scp->dirDataVersion == op->dataVersion) { switch (op->lockType) { case CM_DIRLOCK_READ: --- 1171,1180 ---- op, op->dirtyBufCount); if (op->dirtyBufCount > 0) { #ifdef USE_BPLUS ! /* update the data version on the B+ tree */ if (op->scp->dirBplus && ! op->scp->dirDataVersion == op->dataVersion) { switch (op->lockType) { case CM_DIRLOCK_READ: *************** *** 1135,1140 **** --- 1191,1202 ---- op->scp->dirDataVersion = op->newDataVersion; } #endif + + /* we made changes. We should go through the list of buffers + * and update the dataVersion for each. */ + lock_ObtainMutex(&op->scp->mx); + code = buf_ForceDataVersion(op->scp, op->dataVersion, op->newDataVersion); + lock_ReleaseMutex(&op->scp->mx); } switch (op->lockType) { *************** *** 1203,1221 **** lock_ObtainMutex(&op->scp->mx); /* Make sure we are synchronized. */ code = cm_SyncOp(op->scp, bufferp, op->userp, &op->req, PRSFS_LOOKUP, CM_SCACHESYNC_NEEDCALLBACK | ! CM_SCACHESYNC_WRITE | CM_SCACHESYNC_BUFLOCKED); ! if (code == 0 && ! bufferp->dataVersion != op->dataVersion) { ! osi_Log2(afsd_logp, "cm_DirOpAddBuffer: buffer version mismatch. buf ver = %d. want %d", bufferp->dataVersion, op->dataVersion); cm_SyncOpDone(op->scp, bufferp, CM_SCACHESYNC_NEEDCALLBACK | ! CM_SCACHESYNC_WRITE | CM_SCACHESYNC_BUFLOCKED); code = CM_ERROR_INVAL; --- 1265,1283 ---- lock_ObtainMutex(&op->scp->mx); /* Make sure we are synchronized. */ + osi_assert(op->lockType != CM_DIRLOCK_NONE); + code = cm_SyncOp(op->scp, bufferp, op->userp, &op->req, PRSFS_LOOKUP, CM_SCACHESYNC_NEEDCALLBACK | ! (op->lockType == CM_DIRLOCK_WRITE ? CM_SCACHESYNC_WRITE : CM_SCACHESYNC_READ) | CM_SCACHESYNC_BUFLOCKED); ! if (code == 0 && bufferp->dataVersion != op->dataVersion) { osi_Log2(afsd_logp, "cm_DirOpAddBuffer: buffer version mismatch. buf ver = %d. want %d", bufferp->dataVersion, op->dataVersion); cm_SyncOpDone(op->scp, bufferp, CM_SCACHESYNC_NEEDCALLBACK | ! (op->lockType == CM_DIRLOCK_WRITE ? CM_SCACHESYNC_WRITE : CM_SCACHESYNC_READ) | CM_SCACHESYNC_BUFLOCKED); code = CM_ERROR_INVAL; *************** *** 1315,1321 **** cm_SyncOpDone(op->scp, bufferp, CM_SCACHESYNC_NEEDCALLBACK | ! CM_SCACHESYNC_WRITE); #ifdef DEBUG osi_assert(bufferp->dataVersion == op->dataVersion); --- 1377,1383 ---- cm_SyncOpDone(op->scp, bufferp, CM_SCACHESYNC_NEEDCALLBACK | ! (op->lockType == CM_DIRLOCK_WRITE ? CM_SCACHESYNC_WRITE : CM_SCACHESYNC_READ)); #ifdef DEBUG osi_assert(bufferp->dataVersion == op->dataVersion); *************** *** 1371,1393 **** This should be called before cm_DirGetPage() is called per scp. On entry: ! scp->mx unlocked On exit: ! scp->mx unlocked During: scp->mx may be released */ static long ! cm_DirCheckStatus(cm_dirOp_t * op) { long code; ! lock_ObtainMutex(&op->scp->mx); code = cm_SyncOp(op->scp, NULL, op->userp, &op->req, PRSFS_LOOKUP, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); ! lock_ReleaseMutex(&op->scp->mx); osi_Log2(afsd_logp, "cm_DirCheckStatus for op 0x%p returning code 0x%x", op, code); --- 1433,1457 ---- This should be called before cm_DirGetPage() is called per scp. On entry: ! scp->mx locked state indicated by parameter On exit: ! scp->mx same state as upon entry During: scp->mx may be released */ static long ! cm_DirCheckStatus(cm_dirOp_t * op, afs_uint32 locked) { long code; ! if (!locked) ! lock_ObtainMutex(&op->scp->mx); code = cm_SyncOp(op->scp, NULL, op->userp, &op->req, PRSFS_LOOKUP, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); ! if (!locked) ! lock_ReleaseMutex(&op->scp->mx); osi_Log2(afsd_logp, "cm_DirCheckStatus for op 0x%p returning code 0x%x", op, code); Index: openafs/src/WINNT/afsd/cm_dir.h diff -c openafs/src/WINNT/afsd/cm_dir.h:1.4.4.5 openafs/src/WINNT/afsd/cm_dir.h:1.4.4.6 *** openafs/src/WINNT/afsd/cm_dir.h:1.4.4.5 Wed Sep 19 23:55:42 2007 --- openafs/src/WINNT/afsd/cm_dir.h Sat Nov 3 12:19:28 2007 *************** *** 186,190 **** extern int cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock); ! extern afs_int64 dir_enums; #endif /* __CM_DIR_ENV__ */ --- 186,190 ---- extern int cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock); ! extern afs_uint64 dir_enums; #endif /* __CM_DIR_ENV__ */ Index: openafs/src/WINNT/afsd/cm_freelance.c diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.33.2.3 openafs/src/WINNT/afsd/cm_freelance.c:1.33.2.4 *** openafs/src/WINNT/afsd/cm_freelance.c:1.33.2.3 Thu Oct 18 01:28:39 2007 --- openafs/src/WINNT/afsd/cm_freelance.c Sun Nov 4 19:24:46 2007 *************** *** 169,180 **** /* Start the registry monitor */ phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier, NULL, 0, &lpid, "cm_FreelanceChangeNotifier"); ! osi_assert(phandle != NULL); thrd_CloseHandle(phandle); phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceSymlinkChangeNotifier, NULL, 0, &lpid, "cm_FreelanceSymlinkChangeNotifier"); ! osi_assert(phandle != NULL); thrd_CloseHandle(phandle); #endif } --- 169,180 ---- /* Start the registry monitor */ phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier, NULL, 0, &lpid, "cm_FreelanceChangeNotifier"); ! osi_assertx(phandle != NULL, "cm_FreelanceChangeNotifier thread create failure"); thrd_CloseHandle(phandle); phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceSymlinkChangeNotifier, NULL, 0, &lpid, "cm_FreelanceSymlinkChangeNotifier"); ! osi_assertx(phandle != NULL, "cm_FreelanceSymlinkChangeNotifier thread create failure"); thrd_CloseHandle(phandle); #endif } Index: openafs/src/WINNT/afsd/cm_ioctl.c diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.26 openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.27 *** openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.26 Fri Oct 19 00:27:03 2007 --- openafs/src/WINNT/afsd/cm_ioctl.c Sun Nov 4 19:24:46 2007 *************** *** 812,818 **** #endif { cellp = cm_FindCellByID(scp->fid.cell); ! osi_assert(cellp); if (scp->flags & CM_SCACHEFLAG_RO) { cm_ReleaseSCache(scp); --- 812,818 ---- #endif { cellp = cm_FindCellByID(scp->fid.cell); ! osi_assertx(cellp, "null cm_cell_t"); if (scp->flags & CM_SCACHEFLAG_RO) { cm_ReleaseSCache(scp); Index: openafs/src/WINNT/afsd/cm_scache.c diff -c openafs/src/WINNT/afsd/cm_scache.c:1.35.2.44 openafs/src/WINNT/afsd/cm_scache.c:1.35.2.47 *** openafs/src/WINNT/afsd/cm_scache.c:1.35.2.44 Thu Sep 13 13:59:21 2007 --- openafs/src/WINNT/afsd/cm_scache.c Mon Nov 5 13:24:34 2007 *************** *** 38,43 **** --- 38,45 ---- /* Dummy scache entry for use with pioctl fids */ cm_scache_t cm_fakeSCache; + osi_queue_t * cm_allFreeWaiters; /* protected by cm_scacheLock */ + #ifdef AFS_FREELANCE_CLIENT extern osi_mutex_t cm_Freelance_Lock; #endif *************** *** 147,154 **** buf_CleanDirtyBuffers(scp); } else { /* look for things that shouldn't still be set */ ! osi_assert(scp->bufWritesp == NULL); ! osi_assert(scp->bufReadsp == NULL); } #endif --- 149,156 ---- buf_CleanDirtyBuffers(scp); } else { /* look for things that shouldn't still be set */ ! osi_assertx(scp->bufWritesp == NULL, "non-null cm_scache_t bufWritesp"); ! osi_assertx(scp->bufReadsp == NULL, "non-null cm_scache_t bufReadsp"); } #endif *************** *** 166,171 **** --- 168,174 ---- scp->dataVersion = 0; scp->bulkStatProgress = hzero; scp->waitCount = 0; + scp->waitQueueT = NULL; if (scp->cbServerp) { cm_PutServer(scp->cbServerp); *************** *** 203,208 **** --- 206,212 ---- scp->serverLock = (-1); scp->exclusiveLocks = 0; scp->sharedLocks = 0; + scp->lockDataVersion = -1; /* not locked, but there can be no references to this guy * while we hold the global refcount lock. *************** *** 240,246 **** scp; scp = (cm_scache_t *) osi_QPrev(&scp->q)) { ! osi_assert(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.scacheHashTablep); if (scp->refCount == 0) { if (scp->flags & CM_SCACHEFLAG_DELETED) { --- 244,251 ---- scp; scp = (cm_scache_t *) osi_QPrev(&scp->q)) { ! osi_assertx(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.scacheHashTablep, ! "invalid cm_scache_t address"); if (scp->refCount == 0) { if (scp->flags & CM_SCACHEFLAG_DELETED) { *************** *** 309,315 **** * quota or we have a leak and need to allocate a new one to avoid panicing. */ scp = cm_data.scacheBaseAddress + cm_data.currentSCaches; ! osi_assert(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.scacheHashTablep); memset(scp, 0, sizeof(cm_scache_t)); scp->magic = CM_SCACHE_MAGIC; lock_InitializeMutex(&scp->mx, "cm_scache_t mutex"); --- 314,321 ---- * quota or we have a leak and need to allocate a new one to avoid panicing. */ scp = cm_data.scacheBaseAddress + cm_data.currentSCaches; ! osi_assertx(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.scacheHashTablep, ! "invalid cm_scache_t address"); memset(scp, 0, sizeof(cm_scache_t)); scp->magic = CM_SCACHE_MAGIC; lock_InitializeMutex(&scp->mx, "cm_scache_t mutex"); *************** *** 576,581 **** --- 582,588 ---- scp->dirBplus = NULL; scp->dirDataVersion = -1; #endif + scp->waitQueueT = NULL; scp->flags &= ~CM_SCACHEFLAG_WAITING; } } *************** *** 583,588 **** --- 590,596 ---- cm_freeFileLocks = NULL; cm_lockRefreshCycle = 0; cm_fakeSCacheInit(newFile); + cm_allFreeWaiters = NULL; cm_dnlcInit(newFile); osi_EndOnce(&once); } *************** *** 633,639 **** hash = CM_SCACHE_HASH(fidp); ! osi_assert(fidp->cell != 0); if (fidp->cell== cm_data.rootFid.cell && fidp->volume==cm_data.rootFid.volume && --- 641,647 ---- hash = CM_SCACHE_HASH(fidp); ! osi_assertx(fidp->cell != 0, "unassigned cell value"); if (fidp->cell== cm_data.rootFid.cell && fidp->volume==cm_data.rootFid.volume && *************** *** 779,785 **** osi_Log1(afsd_logp,"cm_GetSCache (3) outScpp 0x%p", scp); #endif cm_HoldSCacheNoLock(scp); ! osi_assert(scp->volp == volp); cm_AdjustScacheLRU(scp); lock_ReleaseWrite(&cm_scacheLock); if (volp) --- 787,793 ---- osi_Log1(afsd_logp,"cm_GetSCache (3) outScpp 0x%p", scp); #endif cm_HoldSCacheNoLock(scp); ! osi_assertx(scp->volp == volp, "cm_scache_t volume has unexpected value"); cm_AdjustScacheLRU(scp); lock_ReleaseWrite(&cm_scacheLock); if (volp) *************** *** 800,806 **** } osi_Log2(afsd_logp,"cm_GetNewSCache returns scp 0x%x flags 0x%x", scp, scp->flags); ! osi_assert(!(scp->flags & CM_SCACHEFLAG_INHASH)); #if not_too_dangerous /* dropping the cm_scacheLock allows more than one thread --- 808,814 ---- } osi_Log2(afsd_logp,"cm_GetNewSCache returns scp 0x%x flags 0x%x", scp, scp->flags); ! osi_assertx(!(scp->flags & CM_SCACHEFLAG_INHASH), "CM_SCACHEFLAG_INHASH set"); #if not_too_dangerous /* dropping the cm_scacheLock allows more than one thread *************** *** 884,889 **** --- 892,960 ---- return pscp; } + void cm_SyncOpAddToWaitQueue(cm_scache_t * scp, afs_int32 flags, cm_buf_t * bufp) + { + cm_scache_waiter_t * w; + + lock_ObtainWrite(&cm_scacheLock); + if (cm_allFreeWaiters == NULL) { + w = malloc(sizeof(*w)); + memset(w, 0, sizeof(*w)); + } else { + w = (cm_scache_waiter_t *) cm_allFreeWaiters; + osi_QRemove(&cm_allFreeWaiters, (osi_queue_t *) w); + } + + w->threadId = thrd_Current(); + w->scp = scp; + cm_HoldSCacheNoLock(scp); + w->flags = flags; + w->bufp = bufp; + + osi_QAddT(&scp->waitQueueH, &scp->waitQueueT, (osi_queue_t *) w); + lock_ReleaseWrite(&cm_scacheLock); + + osi_Log2(afsd_logp, "cm_SyncOpAddToWaitQueue : Adding thread to wait queue scp 0x%p w 0x%p", scp, w); + } + + int cm_SyncOpCheckContinue(cm_scache_t * scp, afs_int32 flags, cm_buf_t * bufp) + { + cm_scache_waiter_t * w; + int this_is_me; + + osi_Log0(afsd_logp, "cm_SyncOpCheckContinue checking for continuation"); + + lock_ObtainRead(&cm_scacheLock); + for (w = (cm_scache_waiter_t *)scp->waitQueueH; + w; + w = (cm_scache_waiter_t *)osi_QNext((osi_queue_t *) w)) { + if (w->flags == flags && w->bufp == bufp) { + break; + } + } + + osi_assertx(w != NULL, "null cm_scache_waiter_t"); + this_is_me = (w->threadId == thrd_Current()); + lock_ReleaseRead(&cm_scacheLock); + + if (!this_is_me) { + osi_Log1(afsd_logp, "cm_SyncOpCheckContinue MISS: Waiter 0x%p", w); + return 0; + } + + osi_Log1(afsd_logp, "cm_SyncOpCheckContinue HIT: Waiter 0x%p", w); + + lock_ObtainWrite(&cm_scacheLock); + osi_QRemoveHT(&scp->waitQueueH, &scp->waitQueueT, (osi_queue_t *) w); + cm_ReleaseSCacheNoLock(scp); + memset(w, 0, sizeof(*w)); + osi_QAdd(&cm_allFreeWaiters, (osi_queue_t *) w); + lock_ReleaseWrite(&cm_scacheLock); + + return 1; + } + + /* synchronize a fetch, store, read, write, fetch status or store status. * Called with scache mutex held, and returns with it held, but temporarily * drops it during the fetch. *************** *** 950,961 **** afs_uint32 sleep_scp_flags = 0; afs_uint32 sleep_buf_cmflags = 0; afs_uint32 sleep_scp_bufs = 0; /* lookup this first */ bufLocked = flags & CM_SCACHESYNC_BUFLOCKED; ! if (bufp) ! osi_assert(bufp->refCount > 0); /* Do the access check. Now we don't really do the access check --- 1021,1033 ---- afs_uint32 sleep_scp_flags = 0; afs_uint32 sleep_buf_cmflags = 0; afs_uint32 sleep_scp_bufs = 0; + int wakeupCycle; /* lookup this first */ bufLocked = flags & CM_SCACHESYNC_BUFLOCKED; ! if (bufp) ! osi_assertx(bufp->refCount > 0, "cm_buf_t refCount 0"); /* Do the access check. Now we don't really do the access check *************** *** 1147,1153 **** if (rights) { /* can't check access rights without a callback */ ! osi_assert(flags & CM_SCACHESYNC_NEEDCALLBACK); if ((rights & PRSFS_WRITE) && (scp->flags & CM_SCACHEFLAG_RO)) return CM_ERROR_READONLY; --- 1219,1225 ---- if (rights) { /* can't check access rights without a callback */ ! osi_assertx(flags & CM_SCACHESYNC_NEEDCALLBACK, "!CM_SCACHESYNC_NEEDCALLBACK"); if ((rights & PRSFS_WRITE) && (scp->flags & CM_SCACHEFLAG_RO)) return CM_ERROR_READONLY; *************** *** 1181,1186 **** --- 1253,1259 ---- if (flags & CM_SCACHESYNC_NOWAIT) return CM_ERROR_WOULDBLOCK; + /* These are used for minidump debugging */ sleep_scp_flags = scp->flags; /* so we know why we slept */ sleep_buf_cmflags = bufp ? bufp->cmFlags : 0; sleep_scp_bufs = (scp->bufReadsp ? 1 : 0) | (scp->bufWritesp ? 2 : 0); *************** *** 1197,1205 **** scp->flags |= CM_SCACHEFLAG_WAITING; scp->waitCount = scp->waitRequests = 1; } if (bufLocked) lock_ReleaseMutex(&bufp->mx); ! osi_SleepM((LONG_PTR) &scp->flags, &scp->mx); smb_UpdateServerPriority(); --- 1270,1286 ---- scp->flags |= CM_SCACHEFLAG_WAITING; scp->waitCount = scp->waitRequests = 1; } + if (bufLocked) lock_ReleaseMutex(&bufp->mx); ! ! cm_SyncOpAddToWaitQueue(scp, flags, bufp); ! wakeupCycle = 0; ! do { ! if (wakeupCycle++ != 0) ! lock_ObtainMutex(&scp->mx); ! osi_SleepM((LONG_PTR) &scp->flags, &scp->mx); ! } while (!cm_SyncOpCheckContinue(scp, flags, bufp)); smb_UpdateServerPriority(); *************** *** 1238,1244 **** if (bufp) { for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) { tbufp = osi_GetQData(qdp); ! osi_assert(tbufp != bufp); } } --- 1319,1325 ---- if (bufp) { for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) { tbufp = osi_GetQData(qdp); ! osi_assertx(tbufp != bufp, "unexpected cm_buf_t value"); } } *************** *** 1257,1263 **** if (bufp) { for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) { tbufp = osi_GetQData(qdp); ! osi_assert(tbufp != bufp); } } --- 1338,1344 ---- if (bufp) { for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) { tbufp = osi_GetQData(qdp); ! osi_assertx(tbufp != bufp, "unexpected cm_buf_t value"); } } *************** *** 1360,1366 **** if (flags & CM_SCACHESYNC_WRITE) { if (bufp) { ! osi_assert(bufp->cmFlags & CM_BUF_CMWRITING); bufp->cmFlags &= ~CM_BUF_CMWRITING; } --- 1441,1447 ---- if (flags & CM_SCACHESYNC_WRITE) { if (bufp) { ! osi_assertx(bufp->cmFlags & CM_BUF_CMWRITING, "!CM_BUF_CMWRITING"); bufp->cmFlags &= ~CM_BUF_CMWRITING; } *************** *** 1597,1603 **** void cm_HoldSCacheNoLock(cm_scache_t *scp) #endif { ! osi_assert(scp != 0); scp->refCount++; #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_HoldSCacheNoLock scp 0x%p ref %d",scp, scp->refCount); --- 1678,1684 ---- void cm_HoldSCacheNoLock(cm_scache_t *scp) #endif { ! osi_assertx(scp != NULL, "null cm_scache_t"); scp->refCount++; #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_HoldSCacheNoLock scp 0x%p ref %d",scp, scp->refCount); *************** *** 1611,1617 **** void cm_HoldSCache(cm_scache_t *scp) #endif { ! osi_assert(scp != 0); lock_ObtainWrite(&cm_scacheLock); scp->refCount++; #ifdef DEBUG_REFCOUNT --- 1692,1698 ---- void cm_HoldSCache(cm_scache_t *scp) #endif { ! osi_assertx(scp != NULL, "null cm_scache_t"); lock_ObtainWrite(&cm_scacheLock); scp->refCount++; #ifdef DEBUG_REFCOUNT *************** *** 1627,1636 **** void cm_ReleaseSCacheNoLock(cm_scache_t *scp) #endif { ! osi_assert(scp != NULL); if (scp->refCount == 0) osi_Log1(afsd_logp,"cm_ReleaseSCacheNoLock about to panic scp 0x%x",scp); ! osi_assert(scp->refCount-- >= 0); #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_ReleaseSCacheNoLock scp 0x%p ref %d",scp,scp->refCount); afsi_log("%s:%d cm_ReleaseSCacheNoLock scp 0x%p ref %d", file, line, scp, scp->refCount); --- 1708,1717 ---- void cm_ReleaseSCacheNoLock(cm_scache_t *scp) #endif { ! osi_assertx(scp != NULL, "null cm_scache_t"); if (scp->refCount == 0) osi_Log1(afsd_logp,"cm_ReleaseSCacheNoLock about to panic scp 0x%x",scp); ! osi_assertx(scp->refCount-- >= 0, "cm_scache_t refCount 0"); #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_ReleaseSCacheNoLock scp 0x%p ref %d",scp,scp->refCount); afsi_log("%s:%d cm_ReleaseSCacheNoLock scp 0x%p ref %d", file, line, scp, scp->refCount); *************** *** 1643,1653 **** void cm_ReleaseSCache(cm_scache_t *scp) #endif { ! osi_assert(scp != NULL); lock_ObtainWrite(&cm_scacheLock); if (scp->refCount == 0) osi_Log1(afsd_logp,"cm_ReleaseSCache about to panic scp 0x%x",scp); ! osi_assert(scp->refCount != 0); scp->refCount--; #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_ReleaseSCache scp 0x%p ref %d",scp,scp->refCount); --- 1724,1734 ---- void cm_ReleaseSCache(cm_scache_t *scp) #endif { ! osi_assertx(scp != NULL, "null cm_scache_t"); lock_ObtainWrite(&cm_scacheLock); if (scp->refCount == 0) osi_Log1(afsd_logp,"cm_ReleaseSCache about to panic scp 0x%x",scp); ! osi_assertx(scp->refCount != 0, "cm_scache_t refCount 0"); scp->refCount--; #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_ReleaseSCache scp 0x%p ref %d",scp,scp->refCount); *************** *** 1665,1671 **** hash = CM_SCACHE_HASH(fidp); ! osi_assert(fidp->cell != 0); lock_ObtainWrite(&cm_scacheLock); for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) { --- 1746,1752 ---- hash = CM_SCACHE_HASH(fidp); ! osi_assertx(fidp->cell != 0, "unassigned cell value"); lock_ObtainWrite(&cm_scacheLock); for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) { Index: openafs/src/WINNT/afsd/cm_scache.h diff -c openafs/src/WINNT/afsd/cm_scache.h:1.21.2.15 openafs/src/WINNT/afsd/cm_scache.h:1.21.2.16 *** openafs/src/WINNT/afsd/cm_scache.h:1.21.2.15 Mon Sep 10 15:08:17 2007 --- openafs/src/WINNT/afsd/cm_scache.h Sat Nov 3 12:33:54 2007 *************** *** 209,214 **** --- 209,220 ---- /* syncop state */ afs_uint32 waitCount; /* number of threads waiting */ afs_uint32 waitRequests; /* num of thread wait requests */ + osi_queue_t * waitQueueH; /* Queue of waiting threads. + Holds queue of + cm_scache_waiter_t + objects. Protected by + cm_cacheLock. */ + osi_queue_t * waitQueueT; /* locked by cm_scacheLock */ } cm_scache_t; /* mask field - tell what has been modified */ *************** *** 312,317 **** --- 318,332 ---- (fidp)->unique)) \ % cm_data.scacheHashTableSize) + typedef struct cm_scache_waiter { + osi_queue_t q; + afs_int32 threadId; + + cm_scache_t *scp; + afs_int32 flags; + void *bufp; + } cm_scache_waiter_t; + #include "cm_conn.h" #include "cm_buf.h" Index: openafs/src/WINNT/afsd/cm_server.c diff -c openafs/src/WINNT/afsd/cm_server.c:1.25.2.13 openafs/src/WINNT/afsd/cm_server.c:1.25.2.14 *** openafs/src/WINNT/afsd/cm_server.c:1.25.2.13 Thu Sep 13 13:59:21 2007 --- openafs/src/WINNT/afsd/cm_server.c Sun Nov 4 19:24:46 2007 *************** *** 277,289 **** void cm_PutServer(cm_server_t *serverp) { lock_ObtainWrite(&cm_serverLock); ! osi_assert(serverp->refCount-- > 0); lock_ReleaseWrite(&cm_serverLock); } void cm_PutServerNoLock(cm_server_t *serverp) { ! osi_assert(serverp->refCount-- > 0); } void cm_SetServerNo64Bit(cm_server_t * serverp, int no64bit) --- 277,289 ---- void cm_PutServer(cm_server_t *serverp) { lock_ObtainWrite(&cm_serverLock); ! osi_assertx(serverp->refCount-- > 0, "cm_server_t refCount 0"); lock_ReleaseWrite(&cm_serverLock); } void cm_PutServerNoLock(cm_server_t *serverp) { ! osi_assertx(serverp->refCount-- > 0, "cm_server_t refCount 0"); } void cm_SetServerNo64Bit(cm_server_t * serverp, int no64bit) *************** *** 368,374 **** cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cellp) { cm_server_t *tsp; ! osi_assert(socketp->sin_family == AF_INET); tsp = malloc(sizeof(*tsp)); if (tsp) { --- 368,374 ---- cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cellp) { cm_server_t *tsp; ! osi_assertx(socketp->sin_family == AF_INET, "unexpected socket family"); tsp = malloc(sizeof(*tsp)); if (tsp) { *************** *** 413,419 **** { cm_server_t *tsp; ! osi_assert(addrp->sin_family == AF_INET); lock_ObtainWrite(&cm_serverLock); for (tsp = cm_allServersp; tsp; tsp=tsp->allNextp) { --- 413,419 ---- { cm_server_t *tsp; ! osi_assertx(addrp->sin_family == AF_INET, "unexpected socket value"); lock_ObtainWrite(&cm_serverLock); for (tsp = cm_allServersp; tsp; tsp=tsp->allNextp) { Index: openafs/src/WINNT/afsd/cm_user.c diff -c openafs/src/WINNT/afsd/cm_user.c:1.8.4.1 openafs/src/WINNT/afsd/cm_user.c:1.8.4.3 *** openafs/src/WINNT/afsd/cm_user.c:1.8.4.1 Sat Jun 24 16:41:54 2006 --- openafs/src/WINNT/afsd/cm_user.c Sun Nov 4 19:24:46 2007 *************** *** 106,112 **** return; lock_ObtainWrite(&cm_userLock); ! osi_assert(userp->refCount-- > 0); if (userp->refCount == 0) { lock_FinalizeMutex(&userp->mx); for (ucp = userp->cellInfop; ucp; ucp = ncp) { --- 106,112 ---- return; lock_ObtainWrite(&cm_userLock); ! osi_assertx(userp->refCount-- > 0, "cm_user_t refCount 0"); if (userp->refCount == 0) { lock_FinalizeMutex(&userp->mx); for (ucp = userp->cellInfop; ucp; ucp = ncp) { *************** *** 137,143 **** void cm_ReleaseUserVCRef(cm_user_t *userp) { lock_ObtainMutex(&userp->mx); ! osi_assert(userp->vcRefs-- > 0); lock_ReleaseMutex(&userp->mx); } --- 137,143 ---- void cm_ReleaseUserVCRef(cm_user_t *userp) { lock_ObtainMutex(&userp->mx); ! osi_assertx(userp->vcRefs-- > 0, "cm_user_t refCount 0"); lock_ReleaseMutex(&userp->mx); } *************** *** 196,198 **** --- 196,215 ---- } lock_ReleaseWrite(&smb_rctLock); } + + #ifdef USE_ROOT_TOKENS + /* + * Service/Parameters/RootTokens// + * -> UseLSA + * -> Keytab (required if UseLSA is 0) + * -> Principal (required if there is more than one principal in the keytab) + * -> Realm (required if realm is not upper-case of + * -> RequireEncryption + */ + + void + cm_RefreshRootTokens(void) + { + + } + #endif Index: openafs/src/WINNT/afsd/cm_utils.c diff -c openafs/src/WINNT/afsd/cm_utils.c:1.11.4.5 openafs/src/WINNT/afsd/cm_utils.c:1.11.4.6 *** openafs/src/WINNT/afsd/cm_utils.c:1.11.4.5 Thu Aug 23 23:21:49 2007 --- openafs/src/WINNT/afsd/cm_utils.c Wed Oct 31 11:36:02 2007 *************** *** 14,20 **** #ifndef DJGPP #include #include - #include #ifndef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS --- 14,19 ---- *************** *** 64,69 **** --- 63,69 ---- #define EREMOTE WSAEREMOTE #endif /* EWOULDBLOCK */ #endif /* !DJGPP */ + #include #include #include *************** *** 251,258 **** error = CM_ERROR_NOTDIR; else if (error == 2) /* ENOENT */ error = CM_ERROR_NOSUCHFILE; ! else if (error == 11 /* EAGAIN, most servers */ ! || error == 35) /* EAGAIN, Digital UNIX */ error = CM_ERROR_WOULDBLOCK; else if (error == VDISKFULL || error == 28) /* ENOSPC */ --- 251,259 ---- error = CM_ERROR_NOTDIR; else if (error == 2) /* ENOENT */ error = CM_ERROR_NOSUCHFILE; ! else if (error == 11 /* EAGAIN, most servers */ ! || error == 35 /* EAGAIN, Digital UNIX */ ! || error == WSAEWOULDBLOCK) error = CM_ERROR_WOULDBLOCK; else if (error == VDISKFULL || error == 28) /* ENOSPC */ Index: openafs/src/WINNT/afsd/cm_vnodeops.c diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.44 openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.45 *** openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.44 Wed Sep 12 21:41:44 2007 --- openafs/src/WINNT/afsd/cm_vnodeops.c Sun Nov 4 19:24:46 2007 *************** *** 337,343 **** long rights; long code; ! osi_assert(ldpp != NULL); *ldpp = NULL; /* Always allow delete; the RPC will tell us if it's OK */ --- 337,343 ---- long rights; long code; ! osi_assertx(ldpp != NULL, "null cm_lock_data_t"); *ldpp = NULL; /* Always allow delete; the RPC will tell us if it's OK */ *************** *** 2286,2292 **** osi_Log1(afsd_logp, "cm_TryBulkStat dir 0x%p", dscp); /* should be on a buffer boundary */ ! osi_assert((offsetp->LowPart & (cm_data.buf_blockSize - 1)) == 0); memset(&bb, 0, sizeof(bb)); bb.bufOffset = *offsetp; --- 2286,2292 ---- osi_Log1(afsd_logp, "cm_TryBulkStat dir 0x%p", dscp); /* should be on a buffer boundary */ ! osi_assertx((offsetp->LowPart & (cm_data.buf_blockSize - 1)) == 0, "invalid offset"); memset(&bb, 0, sizeof(bb)); bb.bufOffset = *offsetp; *************** *** 3905,3911 **** osi_QRemove(&cm_freeFileLocks, &l->q); } else { l = malloc(sizeof(cm_file_lock_t)); ! osi_assert(l); } memset(l, 0, sizeof(cm_file_lock_t)); --- 3905,3911 ---- osi_QRemove(&cm_freeFileLocks, &l->q); } else { l = malloc(sizeof(cm_file_lock_t)); ! osi_assertx(l, "null cm_file_lock_t"); } memset(l, 0, sizeof(cm_file_lock_t)); *************** *** 4048,4054 **** rights |= PRSFS_WRITE | PRSFS_LOCK; else { /* hmmkay */ ! osi_assert(FALSE); return 0; } --- 4048,4054 ---- rights |= PRSFS_WRITE | PRSFS_LOCK; else { /* hmmkay */ ! osi_assertx(FALSE, "invalid lock type"); return 0; } *************** *** 4292,4298 **** newLock = Which; /* am I sane? */ ! osi_assert(newLock == LockRead); code = cm_IntSetLock(scp, userp, newLock, reqp); } --- 4292,4298 ---- newLock = Which; /* am I sane? */ ! osi_assertx(newLock == LockRead, "lock type not read"); code = cm_IntSetLock(scp, userp, newLock, reqp); } *************** *** 4508,4514 **** fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assert(FALSE); } #endif --- 4508,4514 ---- fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assertx(FALSE, "invalid fid value"); } #endif *************** *** 4683,4689 **** fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assert(FALSE); } #endif if (!IS_LOCK_DELETED(fileLock) && --- 4683,4689 ---- fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assertx(FALSE, "invalid fid value"); } #endif if (!IS_LOCK_DELETED(fileLock) && *************** *** 4850,4856 **** #ifdef DEBUG /* With the current code, we can't lose a lock on a RO scp */ ! osi_assert(!(scp->flags & CM_SCACHEFLAG_RO)); #endif /* cm_scacheLock needed because we are modifying fileLock->flags */ --- 4850,4856 ---- #ifdef DEBUG /* With the current code, we can't lose a lock on a RO scp */ ! osi_assertx(!(scp->flags & CM_SCACHEFLAG_RO), "CM_SCACHEFLAG_RO unexpected"); #endif /* cm_scacheLock needed because we are modifying fileLock->flags */ *************** *** 4911,4920 **** /* Server locks must have been enabled for us to have received an active non-client-only lock. */ ! osi_assert(cm_enableServerLocks); scp = fileLock->scp; ! osi_assert(scp != NULL); cm_HoldSCacheNoLock(scp); --- 4911,4920 ---- /* Server locks must have been enabled for us to have received an active non-client-only lock. */ ! osi_assertx(cm_enableServerLocks, "!cm_enableServerLocks"); scp = fileLock->scp; ! osi_assertx(scp != NULL, "null cm_scache_t"); cm_HoldSCacheNoLock(scp); *************** *** 4931,4937 **** fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assert(FALSE); } #endif /* Server locks are extended once per scp per refresh --- 4931,4937 ---- fileLock->scp->fid.volume, fileLock->scp->fid.vnode, fileLock->scp->fid.unique); ! osi_assertx(FALSE, "invalid fid"); } #endif /* Server locks are extended once per scp per refresh *************** *** 5137,5143 **** scp = oldFileLock->scp; ! osi_assert(scp != NULL); lock_ReleaseRead(&cm_scacheLock); lock_ObtainMutex(&scp->mx); --- 5137,5143 ---- scp = oldFileLock->scp; ! osi_assertx(scp != NULL, "null cm_scache_t"); lock_ReleaseRead(&cm_scacheLock); lock_ObtainMutex(&scp->mx); *************** *** 5243,5249 **** oldFileLock->flags |= CM_FILELOCK_FLAG_WAITLOCK; } ! osi_assert(IS_LOCK_WAITLOCK(oldFileLock)); if (force_client_lock || !SERVERLOCKS_ENABLED(scp) || --- 5243,5249 ---- oldFileLock->flags |= CM_FILELOCK_FLAG_WAITLOCK; } ! osi_assertx(IS_LOCK_WAITLOCK(oldFileLock), "!IS_LOCK_WAITLOCK"); if (force_client_lock || !SERVERLOCKS_ENABLED(scp) || *************** *** 5315,5321 **** if (scp->serverLock == LockRead) { ! osi_assert(newLock == LockWrite); osi_Log0(afsd_logp, " Attempting to UPGRADE from LockRead to LockWrite"); --- 5315,5321 ---- if (scp->serverLock == LockRead) { ! osi_assertx(newLock == LockWrite, "!LockWrite"); osi_Log0(afsd_logp, " Attempting to UPGRADE from LockRead to LockWrite"); *************** *** 5394,5402 **** cm_key_t cm_GenerateKey(unsigned int session_id, unsigned long process_id, unsigned int file_id) { #ifdef DEBUG ! osi_assert((process_id & 0xffffffff) == process_id); ! osi_assert((session_id & 0xffff) == session_id); ! osi_assert((file_id & 0xffff) == file_id); #endif return --- 5394,5402 ---- cm_key_t cm_GenerateKey(unsigned int session_id, unsigned long process_id, unsigned int file_id) { #ifdef DEBUG ! osi_assertx((process_id & 0xffffffff) == process_id, "unexpected process_id"); ! osi_assertx((session_id & 0xffff) == session_id, "unexpected session_id"); ! osi_assertx((file_id & 0xffff) == file_id, "unexpected file_id"); #endif return Index: openafs/src/WINNT/afsd/cm_volume.c diff -c openafs/src/WINNT/afsd/cm_volume.c:1.14.4.17 openafs/src/WINNT/afsd/cm_volume.c:1.14.4.18 *** openafs/src/WINNT/afsd/cm_volume.c:1.14.4.17 Sat Oct 20 00:03:06 2007 --- openafs/src/WINNT/afsd/cm_volume.c Sun Nov 4 19:24:46 2007 *************** *** 456,462 **** if ( !tsp->cellp ) tsp->cellp = cellp; ! osi_assert(tsp != NULL); /* and add it to the list(s). */ /* --- 456,462 ---- if ( !tsp->cellp ) tsp->cellp = cellp; ! osi_assertx(tsp != NULL, "null cm_server_t"); /* and add it to the list(s). */ /* *************** *** 605,611 **** } #ifdef SEARCH_ALL_VOLUMES ! osi_assert(volp == volp2); #endif lock_ReleaseRead(&cm_volumeLock); --- 605,611 ---- } #ifdef SEARCH_ALL_VOLUMES ! osi_assertx(volp == volp2, "unexpected cm_vol_t"); #endif lock_ReleaseRead(&cm_volumeLock); *************** *** 690,696 **** } #ifdef SEARCH_ALL_VOLUMES ! osi_assert(volp2 == volp); #endif if (!volp && (flags & CM_GETVOL_FLAG_CREATE)) { --- 690,696 ---- } #ifdef SEARCH_ALL_VOLUMES ! osi_assertx(volp2 == volp, "unexpected cm_vol_t"); #endif if (!volp && (flags & CM_GETVOL_FLAG_CREATE)) { *************** *** 856,862 **** } #ifdef SEARCH_ALL_VOLUMES ! osi_assert(volp == volp2); #endif lock_ReleaseRead(&cm_volumeLock); --- 856,862 ---- } #ifdef SEARCH_ALL_VOLUMES ! osi_assertx(volp == volp2, "unexpected cm_vol_t"); #endif lock_ReleaseRead(&cm_volumeLock); *************** *** 917,923 **** void cm_PutVolume(cm_volume_t *volp) { lock_ObtainWrite(&cm_volumeLock); ! osi_assert(volp->refCount-- > 0); lock_ReleaseWrite(&cm_volumeLock); } --- 917,923 ---- void cm_PutVolume(cm_volume_t *volp) { lock_ObtainWrite(&cm_volumeLock); ! osi_assertx(volp->refCount-- > 0, "cm_volume_t refCount 0"); lock_ReleaseWrite(&cm_volumeLock); } *************** *** 956,962 **** lock_ReleaseMutex(&volp->mx); lock_ObtainWrite(&cm_volumeLock); ! osi_assert(volp->refCount-- > 0); } lock_ReleaseWrite(&cm_volumeLock); --- 956,962 ---- lock_ReleaseMutex(&volp->mx); lock_ObtainWrite(&cm_volumeLock); ! osi_assertx(volp->refCount-- > 0, "cm_volume_t refCount 0"); } lock_ReleaseWrite(&cm_volumeLock); *************** *** 1112,1118 **** cm_CheckOfflineVolume(volp, 0); lock_ObtainWrite(&cm_volumeLock); ! osi_assert(volp->refCount-- > 0); } lock_ReleaseWrite(&cm_volumeLock); } --- 1112,1118 ---- cm_CheckOfflineVolume(volp, 0); lock_ObtainWrite(&cm_volumeLock); ! osi_assertx(volp->refCount-- > 0, "cm_volume_t refCount 0"); } lock_ReleaseWrite(&cm_volumeLock); } *************** *** 1205,1211 **** lock_ReleaseMutex(&volp->mx); lock_ObtainWrite(&cm_volumeLock); ! osi_assert(volp->refCount-- > 0); } lock_ReleaseWrite(&cm_volumeLock); } --- 1205,1211 ---- lock_ReleaseMutex(&volp->mx); lock_ObtainWrite(&cm_volumeLock); ! osi_assertx(volp->refCount-- > 0, "cm_volume_t refCount 0"); } lock_ReleaseWrite(&cm_volumeLock); } Index: openafs/src/WINNT/afsd/cunlog.c diff -c openafs/src/WINNT/afsd/cunlog.c:1.2 openafs/src/WINNT/afsd/cunlog.c:1.2.32.1 *** openafs/src/WINNT/afsd/cunlog.c:1.2 Sat Nov 4 05:01:41 2000 --- openafs/src/WINNT/afsd/cunlog.c Wed Oct 31 00:09:17 2007 *************** *** 15,23 **** #include #include ! CommandProc (as, arock) ! char *arock; ! struct cmd_syndesc *as; { afs_int32 code, ecode=0; struct ktc_principal server; --- 15,22 ---- #include #include ! static int ! CommandProc (struct cmd_syndesc *as, void *arock) { afs_int32 code, ecode=0; struct ktc_principal server; *************** *** 55,61 **** WSAStartup(0x0101, &WSAjunk); ! ts = cmd_CreateSyntax((char *) 0, CommandProc, 0, "Release Kerberos authentication"); cmd_AddParm(ts, "-cell", CMD_LIST, CMD_OPTIONAL, "cell name"); code = cmd_Dispatch(argc, argv); --- 54,60 ---- WSAStartup(0x0101, &WSAjunk); ! ts = cmd_CreateSyntax(NULL, CommandProc, NULL, "Release Kerberos authentication"); cmd_AddParm(ts, "-cell", CMD_LIST, CMD_OPTIONAL, "cell name"); code = cmd_Dispatch(argc, argv); Index: openafs/src/WINNT/afsd/fs.c diff -c openafs/src/WINNT/afsd/fs.c:1.32.4.13 openafs/src/WINNT/afsd/fs.c:1.32.4.14 *** openafs/src/WINNT/afsd/fs.c:1.32.4.13 Tue Oct 16 13:26:08 2007 --- openafs/src/WINNT/afsd/fs.c Wed Oct 31 00:09:17 2007 *************** *** 50,66 **** static struct ubik_client *uclient; ! static int GetClientAddrsCmd(struct cmd_syndesc *asp, char *arock); ! static int SetClientAddrsCmd(struct cmd_syndesc *asp, char *arock); ! static int FlushMountCmd(struct cmd_syndesc *asp, char *arock); ! static int RxStatProcCmd(struct cmd_syndesc *asp, char *arock); ! static int RxStatPeerCmd(struct cmd_syndesc *asp, char *arock); extern struct cmd_syndesc *cmd_CreateSyntax(); ! static int MemDumpCmd(struct cmd_syndesc *asp, char *arock); ! static int CSCPolicyCmd(struct cmd_syndesc *asp, char *arock); ! static int MiniDumpCmd(