diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 6a030badd2..d3595d72d0 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -532,8 +532,13 @@ cm_scache_t *cm_FindSCache(cm_fid_t *fidp) return NULL; } +#ifdef DEBUG_REFCOUNT +long cm_GetSCacheDbg(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, + cm_req_t *reqp, char * file, long line) +#else long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, cm_req_t *reqp) +#endif { long hash; cm_scache_t *scp; @@ -561,6 +566,10 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, lock_ObtainWrite(&cm_scacheLock); for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) { if (cm_FidCmp(fidp, &scp->fid) == 0) { +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_GetSCache (1) outScpp 0x%p ref %d", file, line, scp, scp->refCount); + osi_Log1(afsd_logp,"cm_GetSCache (1) outScpp 0x%p", scp); +#endif cm_HoldSCacheNoLock(scp); *outScpp = scp; cm_AdjustLRU(scp); @@ -656,6 +665,10 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, #endif *outScpp = scp; lock_ReleaseWrite(&cm_scacheLock); +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_GetSCache (2) outScpp 0x%p ref %d", file, line, scp, scp->refCount); + osi_Log1(afsd_logp,"cm_GetSCache (2) outScpp 0x%p", scp); +#endif return 0; } // end of yj code @@ -679,6 +692,10 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, */ for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) { if (cm_FidCmp(fidp, &scp->fid) == 0) { +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_GetSCache (3) outScpp 0x%p ref %d", file, line, scp, scp->refCount); + osi_Log1(afsd_logp,"cm_GetSCache (3) outScpp 0x%p", scp); +#endif cm_HoldSCacheNoLock(scp); osi_assert(scp->volp == volp); cm_AdjustLRU(scp); @@ -747,6 +764,10 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp, /* now we have a held scache entry; just return it */ *outScpp = scp; +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_GetSCache (4) outScpp 0x%p ref %d", file, line, scp, scp->refCount); + osi_Log1(afsd_logp,"cm_GetSCache (4) outScpp 0x%p", scp); +#endif return 0; } diff --git a/src/WINNT/afsd/cm_scache.h b/src/WINNT/afsd/cm_scache.h index a4c83a2a8a..71810a7c24 100644 --- a/src/WINNT/afsd/cm_scache.h +++ b/src/WINNT/afsd/cm_scache.h @@ -304,10 +304,15 @@ typedef struct cm_scache { extern void cm_InitSCache(int, long); +#ifdef DEBUG_REFCOUNT +extern long cm_GetSCacheDbg(cm_fid_t *, cm_scache_t **, struct cm_user *, + struct cm_req *, char *, long); + +#define cm_GetSCache(a,b,c,d) cm_GetSCacheDbg(a,b,c,d,__FILE__,__LINE__) +#else extern long cm_GetSCache(cm_fid_t *, cm_scache_t **, struct cm_user *, struct cm_req *); - -extern void cm_PutSCache(cm_scache_t *); +#endif extern cm_scache_t *cm_GetNewSCache(void); diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 5132d86110..ccbd481164 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -1256,14 +1256,24 @@ int cm_ExpandSysName(char *inp, char *outp, long outSize, unsigned int index) return 1; } +#ifdef DEBUG_REFCOUNT +long cm_LookupDbg(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, + cm_req_t *reqp, cm_scache_t **outpScpp, char * file, long line) +#else long cm_Lookup(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp) +#endif { long code; char tname[256]; int sysNameIndex = 0; cm_scache_t *scp = NULL; +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_Lookup dscp 0x%p ref %d", file, line, dscp, dscp->refCount, file, line); + osi_Log2(afsd_logp, "cm_Lookup dscp 0x%p ref %d", dscp, dscp->refCount); +#endif + if ( stricmp(namep,SMB_IOCTL_FILENAME_NOSLASH) == 0 ) { if (flags & CM_FLAG_CHECKPATH) return CM_ERROR_NOSUCHPATH; @@ -1275,6 +1285,11 @@ long cm_Lookup(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, code = cm_ExpandSysName(namep, tname, sizeof(tname), sysNameIndex); if (code > 0) { code = cm_LookupInternal(dscp, tname, flags, userp, reqp, &scp); +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_LookupInternal (1) code 0x%x dscp 0x%p ref %d scp 0x%p ref %d", file, line, code, dscp, dscp->refCount, scp, scp ? scp->refCount : 0); + osi_Log3(afsd_logp, "cm_LookupInternal (1) code 0x%x dscp 0x%p scp 0x%p", code, dscp, scp); +#endif + if (code == 0) { *outpScpp = scp; return 0; @@ -1284,7 +1299,13 @@ long cm_Lookup(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, scp = NULL; } } else { - return cm_LookupInternal(dscp, namep, flags, userp, reqp, outpScpp); + code = cm_LookupInternal(dscp, namep, flags, userp, reqp, &scp); +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_LookupInternal (2) code 0x%x dscp 0x%p ref %d scp 0x%p ref %d", file, line, code, dscp, dscp->refCount, scp, scp ? scp->refCount : 0); + osi_Log3(afsd_logp, "cm_LookupInternal (2) code 0x%x dscp 0x%p scp 0x%p", code, dscp, scp); +#endif + *outpScpp = scp; + return code; } } @@ -1515,9 +1536,14 @@ long cm_AssembleLink(cm_scache_t *linkScp, char *pathSuffixp, lock_ReleaseMutex(&linkScp->mx); return code; } - +#ifdef DEBUG_REFCOUNT +long cm_NameIDbg(cm_scache_t *rootSCachep, char *pathp, long flags, + cm_user_t *userp, char *tidPathp, cm_req_t *reqp, cm_scache_t **outScpp, + char * file, long line) +#else long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags, cm_user_t *userp, char *tidPathp, cm_req_t *reqp, cm_scache_t **outScpp) +#endif { long code; char *tp; /* ptr moving through input buffer */ @@ -1538,8 +1564,12 @@ long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags, int extraFlag; /* avoid chasing mt pts for dir cmd */ int phase = 1; /* 1 = tidPathp, 2 = pathp */ +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_NameI rootscp 0x%p ref %d", file, line, rootSCachep, rootSCachep->refCount); osi_Log4(afsd_logp,"cm_NameI rootscp 0x%p path %s tidpath %s flags 0x%x", - rootSCachep, pathp, tidPathp, flags); + rootSCachep, pathp ? pathp : "", tidPathp ? tidPathp : "", + flags); +#endif tp = tidPathp; if (tp == NULL) { @@ -1748,6 +1778,10 @@ long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags, *outScpp = tscp; else if (tscp) cm_ReleaseSCache(tscp); + +#ifdef DEBUG_REFCOUNT + afsi_log("%s:%d cm_NameI code 0x%x outScpp 0x%p ref %d", file, line, code, *outScpp, (*outScpp)->refCount); +#endif osi_Log2(afsd_logp,"cm_NameI code 0x%x outScpp 0x%p", code, *outScpp); return code; } diff --git a/src/WINNT/afsd/cm_vnodeops.h b/src/WINNT/afsd/cm_vnodeops.h index ababc1b4c8..6b7d63bd44 100644 --- a/src/WINNT/afsd/cm_vnodeops.h +++ b/src/WINNT/afsd/cm_vnodeops.h @@ -65,12 +65,23 @@ extern void cm_Gen8Dot3Name(struct cm_dirEntry *dep, char *shortName, extern long cm_ReadMountPoint(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp); +#ifdef DEBUG_REFCOUNT +extern long cm_NameIDbg(cm_scache_t *rootSCachep, char *pathp, long flags, + cm_user_t *userp, char *tidPathp, cm_req_t *reqp, + cm_scache_t **outScpp, char *, long); + +extern long cm_LookupDbg(cm_scache_t *dscp, char *namep, long flags, + cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp, char *, long); + +#define cm_Lookup(a,b,c,d,e,f) cm_LookupDbg(a,b,c,d,e,f,__FILE__,__LINE__) +#define cm_NameI(a,b,c,d,e,f,g) cm_NameIDbg(a,b,c,d,e,f,g,__FILE__,__LINE__) +#else extern long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags, cm_user_t *userp, char *tidPathp, cm_req_t *reqp, cm_scache_t **outScpp); - extern long cm_Lookup(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp); +#endif extern long cm_LookupInternal(cm_scache_t *dscp, char *namep, long flags, cm_user_t *userp, cm_req_t *reqp,