From 87d87d33ea0b38cfa11ded288e6c24a1db7f13b1 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 20 Sep 2007 04:54:14 +0000 Subject: [PATCH] windows-fs-memdump-20070919 add directory lookup stats to "fs memdump" output --- src/WINNT/afsd/afsd_service.c | 2 ++ src/WINNT/afsd/cm_btree.c | 38 +++++++++++++++++++++++++++++++++++ src/WINNT/afsd/cm_btree.h | 1 + src/WINNT/afsd/cm_dir.c | 26 ++++++++++++++++++++++++ src/WINNT/afsd/cm_dir.h | 3 +++ src/WINNT/afsd/cm_ioctl.c | 2 ++ 6 files changed, 72 insertions(+) diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index ea3fdd4799..30e81d8b21 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -76,6 +76,8 @@ static void afsd_notifier(char *msgp, char *filep, long line) buf_ForceTrace(TRUE); afsi_log("--- begin dump ---"); + cm_MemDumpDirStats(afsi_file, "a", 0); + cm_MemDumpBPlusStats(afsi_file, "a", 0); cm_DumpCells(afsi_file, "a", 0); cm_DumpVolumes(afsi_file, "a", 0); cm_DumpSCache(afsi_file, "a", 0); diff --git a/src/WINNT/afsd/cm_btree.c b/src/WINNT/afsd/cm_btree.c index 240ccf8502..26128eb987 100644 --- a/src/WINNT/afsd/cm_btree.c +++ b/src/WINNT/afsd/cm_btree.c @@ -1743,6 +1743,44 @@ long cm_BPlusDirBuildTree(cm_scache_t *scp, cm_user_t *userp, cm_req_t* reqp) return rc; } +int cm_MemDumpBPlusStats(FILE *outputFile, char *cookie, int lock) +{ + int zilch; + char output[128]; + + sprintf(output, "%s - B+ Lookup Hits: %-8d\r\n", cookie, bplus_lookup_hits); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Inexact Hits: %-8d\r\n", cookie, bplus_lookup_hits_inexact); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Ambiguous Hits: %-8d\r\n", cookie, bplus_lookup_ambiguous); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Misses: %-8d\r\n", cookie, bplus_lookup_misses); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-8d\r\n", cookie, bplus_create_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-8d\r\n", cookie, bplus_remove_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Build Tree: %-8d\r\n", cookie, bplus_build_tree); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Free Tree: %-8d\r\n", cookie, bplus_free_tree); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - DV Error: %-8d\r\n", cookie, bplus_dv_error); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + sprintf(output, "%s - B+ Time Lookup: %-16I64d\r\n", cookie, bplus_lookup_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-16I64d\r\n", cookie, bplus_create_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-16I64d\r\n", cookie, bplus_remove_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Build: %-16I64d\r\n", cookie, bplus_build_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Free: %-16I64d\r\n", cookie, bplus_free_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + return(0); +} + void cm_BPlusDumpStats(void) { afsi_log("B+ Lookup Hits: %-8d", bplus_lookup_hits); diff --git a/src/WINNT/afsd/cm_btree.h b/src/WINNT/afsd/cm_btree.h index 6412f3c0ae..b157e58c1b 100644 --- a/src/WINNT/afsd/cm_btree.h +++ b/src/WINNT/afsd/cm_btree.h @@ -143,6 +143,7 @@ long cm_BPlusDirCreateEntry(cm_dirOp_t * op, char *entry, cm_fid_t * cfid); int cm_BPlusDirDeleteEntry(cm_dirOp_t * op, char *entry); long cm_BPlusDirBuildTree(cm_scache_t *scp, cm_user_t *userp, cm_req_t* reqp); void cm_BPlusDumpStats(void); +int cm_MemDumpBPlusStats(FILE *outputFile, char *cookie, int lock); extern afs_uint32 bplus_free_tree; extern afs_uint32 bplus_dv_error; diff --git a/src/WINNT/afsd/cm_dir.c b/src/WINNT/afsd/cm_dir.c index 01de1426cd..153d88ed2f 100644 --- a/src/WINNT/afsd/cm_dir.c +++ b/src/WINNT/afsd/cm_dir.c @@ -36,6 +36,32 @@ afs_uint64 dir_enums = 0; afs_int32 cm_BPlusTrees = 1; +int cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock) +{ + int zilch; + char output[128]; + + sprintf(output, "%s - Dir Lookup Hits: %-8d\r\n", cookie, dir_lookup_hits); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Misses: %-8d\r\n", cookie, dir_lookup_misses); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Enums: %-8d\r\n", cookie, dir_enums); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-8d\r\n", cookie, dir_create_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-8d\r\n", cookie, dir_remove_entry); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + sprintf(output, "%s - Dir Times Lookup: %-16I64d\r\n", cookie, dir_lookup_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Create: %-16I64d\r\n", cookie, dir_create_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + sprintf(output, "%s - Remove: %-16I64d\r\n", cookie, dir_remove_time); + WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); + + return(0); +} + void cm_DirDumpStats(void) { afsi_log("Dir Lookup Hits: %-8d", dir_lookup_hits); diff --git a/src/WINNT/afsd/cm_dir.h b/src/WINNT/afsd/cm_dir.h index 3a337c2ef7..37fe27f98f 100644 --- a/src/WINNT/afsd/cm_dir.h +++ b/src/WINNT/afsd/cm_dir.h @@ -183,5 +183,8 @@ cm_DirEntryListFree(cm_dirEntryList_t ** list); extern void cm_DirDumpStats(void); +extern int +cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock); + extern afs_int64 dir_enums; #endif /* __CM_DIR_ENV__ */ diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index 7b78034f84..88df41ab7e 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -2706,6 +2706,8 @@ long cm_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp) #endif /* dump all interesting data */ + cm_MemDumpDirStats(hLogFile, cookie, 1); + cm_MemDumpBPlusStats(hLogFile, cookie, 1); cm_DumpCells(hLogFile, cookie, 1); cm_DumpVolumes(hLogFile, cookie, 1); cm_DumpSCache(hLogFile, cookie, 1);