diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
---|---|---|
committer | <> | 2015-03-17 16:26:24 +0000 |
commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /src/mp/mp_stat.c | |
parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
download | berkeleydb-master.tar.gz |
Diffstat (limited to 'src/mp/mp_stat.c')
-rw-r--r-- | src/mp/mp_stat.c | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/src/mp/mp_stat.c b/src/mp/mp_stat.c index 246b44d7..81ea35c1 100644 --- a/src/mp/mp_stat.c +++ b/src/mp/mp_stat.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ @@ -133,7 +133,14 @@ __memp_stat(env, gspp, fspp, flags) sp->st_ro_evict += c_mp->stat.st_ro_evict; sp->st_rw_evict += c_mp->stat.st_rw_evict; sp->st_page_trickle += c_mp->stat.st_page_trickle; + sp->st_mvcc_reused += c_mp->stat.st_mvcc_reused; sp->st_pages += c_mp->pages; + /* Undocumented field used by tests only. */ + sp->st_oddfsize_detect += + c_mp->stat.st_oddfsize_detect; + /* Undocumented field used by tests only. */ + sp->st_oddfsize_resolve += + c_mp->stat.st_oddfsize_resolve; /* * st_page_dirty calculated by __memp_stat_hash * st_page_clean calculated here @@ -195,7 +202,12 @@ __memp_stat(env, gspp, fspp, flags) /* Count the MPOOLFILE structures. */ i = 0; - len = 0; + /* + * Allow space for the first __memp_get_files() to align the + * structure array to uintmax_t, DB_MPOOL_STAT's most + * restrictive field. [#23150] + */ + len = sizeof(uintmax_t); if ((ret = __memp_walk_files(env, mp, __memp_count_files, &len, &i, flags)) != 0) return (ret); @@ -252,6 +264,11 @@ __memp_file_stats(env, mfp, argp, countp, flags) return (0); } +/* + * __memp_count_files -- + * This __memp_walk_files() iterator counts the number of files as well as + * the space needed for their statistics, including file names. + */ static int __memp_count_files(env, mfp, argp, countp, flags) ENV *env; @@ -277,13 +294,25 @@ __memp_count_files(env, mfp, argp, countp, flags) /* * __memp_get_files -- - * get file specific statistics + * get another file's specific statistics * - * Build each individual entry. We assume that an array of pointers are - * aligned correctly to be followed by an array of structures, which should - * be safe (in this particular case, the first element of the structure - * is a pointer, so we're doubly safe). The array is followed by space - * for the text file names. + * Add a file statistics entry to the current list. The chunk of memory + * starts with an array of DB_MPOOL_FSTAT pointers, a null pointer to mark + * the last one, then an aligned array of DB_MPOOL_FSTAT structures, then + * characters space for the file names. + * +-----------------------------------------------+ + * | count * DB_MPOOL_FSTAT pointers | + * +-----------------------------------------------+ + * | null pointer + + * +-----------------------------------------------| + * | [space for aligning DB_MPOOL_FSTAT array] | + * +-----------------------------------------------+ + * | count * DB_MPOOL_FSTAT structs | + * +-----------------------------------------------+ + * | first file name | second file name | third... | + * +-----------------------------------------------+ + * | file name | ... | + * +-----------------------------------------------+ */ static int __memp_get_files(env, mfp, argp, countp, flags) @@ -305,11 +334,21 @@ __memp_get_files(env, mfp, argp, countp, flags) tfsp = *(DB_MPOOL_FSTAT ***)argp; if (*tfsp == NULL) { - /* Add 1 to count because we need to skip over the NULL. */ - tstruct = (DB_MPOOL_FSTAT *)(tfsp + *countp + 1); - tname = (char *)(tstruct + *countp); + /* + * Add 1 to count because to skip over the NULL end marker. + * Align it further for DB_MPOOL_STAT's most restrictive field + * because uintmax_t might require stricter alignment than + * pointers; e.g., IP32 LL64 SPARC. [#23150] + */ + tstruct = (DB_MPOOL_FSTAT *)&tfsp[*countp + 1]; + tstruct = ALIGNP_INC(tstruct, sizeof(uintmax_t)); + tname = (char *)&tstruct[*countp]; *tfsp = tstruct; } else { + /* + * This stat struct follows the previous one; the file name + * follows the previous entry's filename. + */ tstruct = *tfsp + 1; tname = (*tfsp)->file_name + strlen((*tfsp)->file_name) + 1; *++tfsp = tstruct; @@ -486,6 +525,8 @@ __memp_print_stats(env, flags) (u_long)gsp->st_mvcc_thawed); __db_dl(env, "The number of frozen buffers freed", (u_long)gsp->st_mvcc_freed); + __db_dl(env, "The number of outdated intermediate versions reused", + (u_long)gsp->st_mvcc_reused); __db_dl(env, "The number of page allocations", (u_long)gsp->st_alloc); __db_dl(env, "The number of hash buckets examined during allocations", @@ -744,11 +785,18 @@ __memp_print_hash(env, dbmp, reginfo, fmap, flags) vbhp != NULL; vbhp = SH_CHAIN_PREV(vbhp, vc, __bh)) { __memp_print_bh(env, dbmp, - " next:\t", vbhp, fmap); + " prev:\t", vbhp, fmap); } } MUTEX_UNLOCK(env, hp->mtx_hash); } +#ifdef DIAGNOSTIC + SH_TAILQ_FOREACH(bhp, &c_mp->free_frozen, hq, __bh) { + __db_msg(env, "free frozen %lu pgno %lu mtx_buf %lu", + (u_long)R_OFFSET(dbmp->reginfo, bhp), + (u_long)bhp->pgno, (u_long)bhp->mtx_buf); + } +#endif return (0); } @@ -775,6 +823,7 @@ __memp_print_bh(env, dbmp, prefix, bhp, fmap) { BH_FROZEN, "frozen" }, { BH_TRASH, "trash" }, { BH_THAWED, "thawed" }, + { BH_UNREACHABLE, "unreachable" }, { 0, NULL } }; DB_MSGBUF mb; |