diff options
Diffstat (limited to 'db2/mp')
| -rw-r--r-- | db2/mp/mp_bh.c | 54 | ||||
| -rw-r--r-- | db2/mp/mp_fget.c | 41 | ||||
| -rw-r--r-- | db2/mp/mp_fopen.c | 34 | ||||
| -rw-r--r-- | db2/mp/mp_fput.c | 26 | ||||
| -rw-r--r-- | db2/mp/mp_fset.c | 18 | ||||
| -rw-r--r-- | db2/mp/mp_open.c | 9 | ||||
| -rw-r--r-- | db2/mp/mp_pr.c | 48 | ||||
| -rw-r--r-- | db2/mp/mp_region.c | 33 | ||||
| -rw-r--r-- | db2/mp/mp_sync.c | 393 |
9 files changed, 477 insertions, 179 deletions
diff --git a/db2/mp/mp_bh.c b/db2/mp/mp_bh.c index fb6bc96ae7..a707603eec 100644 --- a/db2/mp/mp_bh.c +++ b/db2/mp/mp_bh.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_bh.c 10.16 (Sleepycat) 9/23/97"; +static const char sccsid[] = "@(#)mp_bh.c 10.21 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -94,10 +94,10 @@ __memp_bhwrite(dbmp, mfp, bhp, restartp, wrotep) * files that we have previously tried (and failed) to open. */ dbt.size = mfp->pgcookie_len; - dbt.data = ADDR(dbmp, mfp->pgcookie_off); - if (__memp_fopen(dbmp, ADDR(dbmp, mfp->path_off), + dbt.data = R_ADDR(dbmp, mfp->pgcookie_off); + if (__memp_fopen(dbmp, R_ADDR(dbmp, mfp->path_off), mfp->ftype, 0, 0, mfp->stat.st_pagesize, - mfp->lsn_off, &dbt, ADDR(dbmp, mfp->fileid_off), 0, &dbmfp) != 0) + mfp->lsn_off, &dbt, R_ADDR(dbmp, mfp->fileid_off), 0, &dbmfp) != 0) return (0); found: return (__memp_pgwrite(dbmfp, bhp, restartp, wrotep)); @@ -137,7 +137,7 @@ __memp_pgread(dbmfp, bhp, can_create) ret = 0; LOCKHANDLE(dbmp, dbmfp->mutexp); if (dbmfp->fd == -1 || (ret = - __db_lseek(dbmfp->fd, pagesize, bhp->pgno, 0, SEEK_SET)) != 0) { + __db_seek(dbmfp->fd, pagesize, bhp->pgno, 0, SEEK_SET)) != 0) { if (!can_create) { if (dbmfp->fd == -1) ret = EINVAL; @@ -230,6 +230,7 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) dbmp = dbmfp->dbmp; dbenv = dbmp->dbenv; + mp = dbmp->mp; mfp = dbmfp->mfp; if (restartp != NULL) @@ -277,8 +278,7 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) } /* Write the page out. */ - if ((ret = - __db_lseek(dbmfp->fd, pagesize, bhp->pgno, 0, SEEK_SET)) != 0) + if ((ret = __db_seek(dbmfp->fd, pagesize, bhp->pgno, 0, SEEK_SET)) != 0) fail = "seek"; else if ((ret = __db_write(dbmfp->fd, bhp->buf, pagesize, &nw)) != 0) fail = "write"; @@ -309,15 +309,23 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) /* Clean up the flags based on a successful write. */ F_SET(bhp, BH_CALLPGIN); F_CLR(bhp, BH_DIRTY | BH_LOCKED); + + ++mp->stat.st_page_clean; + --mp->stat.st_page_dirty; + UNLOCKBUFFER(dbmp, bhp); /* - * If we wrote a buffer which a checkpoint is waiting for, update + * If we write a buffer for which a checkpoint is waiting, update * the count of pending buffers (both in the mpool as a whole and * for this file). If the count for this file goes to zero, flush * the writes. * * XXX: + * Don't lock the region around the sync, fsync(2) has no atomicity + * issues. + * + * XXX: * We ignore errors from the sync -- it makes no sense to return an * error to the calling process, so set a flag causing the sync to * be retried later. @@ -325,21 +333,15 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) * If the buffer we wrote has a LSN larger than the current largest * we've written for this checkpoint, update the saved value. */ - mp = dbmp->mp; if (F_ISSET(bhp, BH_WRITE)) { if (log_compare(&lsn, &mp->lsn) > 0) mp->lsn = lsn; F_CLR(bhp, BH_WRITE); --mp->lsn_cnt; - if (--mfp->lsn_cnt == 0) { - /* - * Don't lock -- there are no atomicity issues for - * fsync(2). - */ - if (__db_fsync(dbmfp->fd) != 0) - F_SET(mp, MP_LSN_RETRY); - } + + if (--mfp->lsn_cnt == 0 && __db_fsync(dbmfp->fd) != 0) + F_SET(mp, MP_LSN_RETRY); } /* Update I/O statistics. */ @@ -391,7 +393,7 @@ __memp_pg(dbmfp, bhp, is_pgin) dbtp = NULL; else { dbt.size = mfp->pgcookie_len; - dbt.data = ADDR(dbmp, mfp->pgcookie_off); + dbt.data = R_ADDR(dbmp, mfp->pgcookie_off); dbtp = &dbt; } UNLOCKHANDLE(dbmp, dbmp->mutexp); @@ -433,19 +435,21 @@ __memp_bhfree(dbmp, mfp, bhp, free_mem) { size_t off; - /* Delete the buffer header from the MPOOL hash list. */ - off = BUCKET(dbmp->mp, OFFSET(dbmp, mfp), bhp->pgno); - SH_TAILQ_REMOVE(&dbmp->htab[off], bhp, mq, __bh); + /* Delete the buffer header from the hash bucket queue. */ + off = BUCKET(dbmp->mp, R_OFFSET(dbmp, mfp), bhp->pgno); + SH_TAILQ_REMOVE(&dbmp->htab[off], bhp, hq, __bh); - /* Delete the buffer header from the LRU chain. */ + /* Delete the buffer header from the LRU queue. */ SH_TAILQ_REMOVE(&dbmp->mp->bhq, bhp, q, __bh); /* * If we're not reusing it immediately, free the buffer header * and data for real. */ - if (free_mem) + if (free_mem) { __db_shalloc_free(dbmp->addr, bhp); + --dbmp->mp->stat.st_page_clean; + } } /* @@ -474,13 +478,13 @@ __memp_upgrade(dbmp, dbmfp, mfp) return (1); /* Try the open. */ - if (__db_fdopen(ADDR(dbmp, mfp->path_off), 0, 0, 0, &fd) != 0) { + if (__db_open(R_ADDR(dbmp, mfp->path_off), 0, 0, 0, &fd) != 0) { F_SET(dbmfp, MP_UPGRADE_FAIL); return (1); } /* Swap the descriptors and set the upgrade flag. */ - (void)close(dbmfp->fd); + (void)__db_close(dbmfp->fd); dbmfp->fd = fd; F_SET(dbmfp, MP_UPGRADE); diff --git a/db2/mp/mp_fget.c b/db2/mp/mp_fget.c index a0364e92c3..3f99e60505 100644 --- a/db2/mp/mp_fget.c +++ b/db2/mp/mp_fget.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fget.c 10.25 (Sleepycat) 9/23/97"; +static const char sccsid[] = "@(#)mp_fget.c 10.30 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -87,14 +87,14 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp) * We want to switch threads as often as possible. Sleep every time * we get a new page to make it more likely. */ - if (__sleep_on_every_page_get && (dbmp->dbenv == NULL || - dbmp->dbenv->db_yield == NULL || dbmp->dbenv->db_yield() != 0)) + if (__sleep_on_every_page_get && + (__db_yield == NULL || __db_yield() != 0)) __db_sleep(0, 1); #endif mp = dbmp->mp; mfp = dbmfp->mfp; - mf_offset = OFFSET(dbmp, mfp); + mf_offset = R_OFFSET(dbmp, mfp); addr = NULL; bhp = NULL; b_incr = b_inserted = readonly_alloc = ret = 0; @@ -137,7 +137,7 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp) } } if (!readonly_alloc) { - addr = ADDR(dbmfp, *pgnoaddr * mfp->stat.st_pagesize); + addr = R_ADDR(dbmfp, *pgnoaddr * mfp->stat.st_pagesize); ++mp->stat.st_map; ++mfp->stat.st_map; @@ -159,9 +159,12 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp) */ if (dbmfp->fd == -1) size = 0; - else if ((ret = __db_stat(dbmp->dbenv, - dbmfp->path, dbmfp->fd, &size, NULL)) != 0) + else if ((ret = + __db_ioinfo(dbmfp->path, dbmfp->fd, &size, NULL)) != 0) { + __db_err(dbmp->dbenv, + "%s: %s", dbmfp->path, strerror(ret)); goto err; + } *pgnoaddr = size == 0 ? 0 : (size - 1) / mfp->stat.st_pagesize; @@ -190,26 +193,29 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp) goto found; } - /* If we haven't checked the BH list yet, do the search. */ + /* If we haven't checked the BH hash bucket queue, do the search. */ if (!LF_ISSET(DB_MPOOL_LAST | DB_MPOOL_NEW)) { - ++mp->stat.st_hash_searches; bucket = BUCKET(mp, mf_offset, *pgnoaddr); for (cnt = 0, bhp = SH_TAILQ_FIRST(&dbmp->htab[bucket], __bh); - bhp != NULL; bhp = SH_TAILQ_NEXT(bhp, mq, __bh)) { + bhp != NULL; bhp = SH_TAILQ_NEXT(bhp, hq, __bh)) { ++cnt; if (bhp->pgno == *pgnoaddr && bhp->mf_offset == mf_offset) { addr = bhp->buf; + ++mp->stat.st_hash_searches; if (cnt > mp->stat.st_hash_longest) mp->stat.st_hash_longest = cnt; mp->stat.st_hash_examined += cnt; goto found; } } - if (cnt > mp->stat.st_hash_longest) - mp->stat.st_hash_longest = cnt; - mp->stat.st_hash_examined += cnt; + if (cnt != 0) { + ++mp->stat.st_hash_searches; + if (cnt > mp->stat.st_hash_longest) + mp->stat.st_hash_longest = cnt; + mp->stat.st_hash_examined += cnt; + } } /* @@ -239,8 +245,9 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp) * our region lock without screwing up the world. */ bucket = BUCKET(mp, mf_offset, *pgnoaddr); - SH_TAILQ_INSERT_HEAD(&dbmp->htab[bucket], bhp, mq, __bh); + SH_TAILQ_INSERT_HEAD(&dbmp->htab[bucket], bhp, hq, __bh); SH_TAILQ_INSERT_TAIL(&mp->bhq, bhp, q); + ++mp->stat.st_page_clean; b_inserted = 1; /* Set the page number, and associated MPOOLFILE. */ @@ -281,7 +288,8 @@ reread: if ((ret = __memp_pgread(dbmfp, * !!! * The __memp_pgread call discarded and reacquired the region * lock. Because the buffer reference count was incremented - * before the region lock was discarded the buffer didn't move. + * before the region lock was discarded the buffer can't move + * and its contents can't change. */ ++mp->stat.st_cache_miss; ++mfp->stat.st_cache_miss; @@ -305,7 +313,8 @@ found: /* Increment the reference count. */ * BH_LOCKED -- * I/O in progress, wait for it to finish. Because the buffer * reference count was incremented before the region lock was - * discarded we know the buffer didn't move. + * discarded we know the buffer can't move and its contents + * can't change. */ if (F_ISSET(bhp, BH_LOCKED)) { UNLOCKREGION(dbmp); diff --git a/db2/mp/mp_fopen.c b/db2/mp/mp_fopen.c index 5ab807701c..de59c9ea9b 100644 --- a/db2/mp/mp_fopen.c +++ b/db2/mp/mp_fopen.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fopen.c 10.27 (Sleepycat) 9/23/97"; +static const char sccsid[] = "@(#)mp_fopen.c 10.30 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -92,7 +92,7 @@ __memp_fopen(dbmp, path, /* Allocate and initialize the per-process structure. */ if ((dbmfp = - (DB_MPOOLFILE *)calloc(1, sizeof(DB_MPOOLFILE))) == NULL) { + (DB_MPOOLFILE *)__db_calloc(1, sizeof(DB_MPOOLFILE))) == NULL) { __db_err(dbenv, "%s: %s", path == NULL ? TEMPORARY : path, strerror(ENOMEM)); return (ENOMEM); @@ -120,7 +120,7 @@ __memp_fopen(dbmp, path, /* Open the file. */ - if ((ret = __db_fdopen(dbmfp->path, + if ((ret = __db_open(dbmfp->path, LF_ISSET(DB_CREATE | DB_RDONLY), DB_CREATE | DB_RDONLY, mode, &dbmfp->fd)) != 0) { __db_err(dbenv, "%s: %s", dbmfp->path, strerror(ret)); @@ -128,9 +128,11 @@ __memp_fopen(dbmp, path, } /* Don't permit files that aren't a multiple of the pagesize. */ - if ((ret = __db_stat(dbenv, - dbmfp->path, dbmfp->fd, &size, NULL)) != 0) + if ((ret = + __db_ioinfo(dbmfp->path, dbmfp->fd, &size, NULL)) != 0) { + __db_err(dbenv, "%s: %s", dbmfp->path, strerror(ret)); goto err; + } if (size % pagesize) { __db_err(dbenv, "%s: file size not a multiple of the pagesize", @@ -198,7 +200,7 @@ __memp_fopen(dbmp, path, dbmfp->addr = NULL; if (mfp->can_mmap) { dbmfp->len = size; - if (__db_mmap(dbmfp->fd, dbmfp->len, 1, 1, &dbmfp->addr) != 0) { + if (__db_map(dbmfp->fd, dbmfp->len, 1, 1, &dbmfp->addr) != 0) { mfp->can_mmap = 0; dbmfp->addr = NULL; } @@ -264,7 +266,7 @@ __memp_mf_open(dbmp, dbmfp, for (mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile); mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) if (!memcmp(fileid, - ADDR(dbmp, mfp->fileid_off), DB_FILE_ID_LEN)) { + R_ADDR(dbmp, mfp->fileid_off), DB_FILE_ID_LEN)) { if (ftype != mfp->ftype || pagesize != mfp->stat.st_pagesize) { __db_err(dbmp->dbenv, @@ -325,10 +327,10 @@ alloc: if ((ret = __memp_ralloc(dbmp, sizeof(MPOOLFILE), NULL, &mfp)) != 0) if (0) { err: if (mfp->path_off != 0) __db_shalloc_free(dbmp->addr, - ADDR(dbmp, mfp->path_off)); + R_ADDR(dbmp, mfp->path_off)); if (!istemp) __db_shalloc_free(dbmp->addr, - ADDR(dbmp, mfp->fileid_off)); + R_ADDR(dbmp, mfp->fileid_off)); if (mfp != NULL) __db_shalloc_free(dbmp->addr, mfp); mfp = NULL; @@ -367,7 +369,7 @@ memp_fclose(dbmfp) /* Discard any mmap information. */ if (dbmfp->addr != NULL && - (ret = __db_munmap(dbmfp->addr, dbmfp->len)) != 0) + (ret = __db_unmap(dbmfp->addr, dbmfp->len)) != 0) __db_err(dbmp->dbenv, "%s: %s", dbmfp->path, strerror(ret)); /* Close the file; temporary files may not yet have been created. */ @@ -423,7 +425,7 @@ __memp_mf_close(dbmp, dbmfp) * fairly expensive to reintegrate the buffers back into the region for * no purpose. */ - mf_offset = OFFSET(dbmp, mfp); + mf_offset = R_OFFSET(dbmp, mfp); for (bhp = SH_TAILQ_FIRST(&mp->bhq, __bh); bhp != NULL; bhp = nbhp) { nbhp = SH_TAILQ_NEXT(bhp, q, __bh); @@ -436,6 +438,10 @@ __memp_mf_close(dbmp, dbmfp) #endif if (bhp->mf_offset == mf_offset) { + if (F_ISSET(bhp, BH_DIRTY)) { + ++mp->stat.st_page_clean; + --mp->stat.st_page_dirty; + } __memp_bhfree(dbmp, mfp, bhp, 0); SH_TAILQ_INSERT_HEAD(&mp->bhfq, bhp, q, __bh); } @@ -446,11 +452,11 @@ __memp_mf_close(dbmp, dbmfp) /* Free the space. */ __db_shalloc_free(dbmp->addr, mfp); - __db_shalloc_free(dbmp->addr, ADDR(dbmp, mfp->path_off)); + __db_shalloc_free(dbmp->addr, R_ADDR(dbmp, mfp->path_off)); if (mfp->fileid_off != 0) - __db_shalloc_free(dbmp->addr, ADDR(dbmp, mfp->fileid_off)); + __db_shalloc_free(dbmp->addr, R_ADDR(dbmp, mfp->fileid_off)); if (mfp->pgcookie_off != 0) - __db_shalloc_free(dbmp->addr, ADDR(dbmp, mfp->pgcookie_off)); + __db_shalloc_free(dbmp->addr, R_ADDR(dbmp, mfp->pgcookie_off)); ret1: UNLOCKREGION(dbmp); return (0); diff --git a/db2/mp/mp_fput.c b/db2/mp/mp_fput.c index 9ea7cd9d0d..892f179d3a 100644 --- a/db2/mp/mp_fput.c +++ b/db2/mp/mp_fput.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fput.c 10.12 (Sleepycat) 9/23/97"; +static const char sccsid[] = "@(#)mp_fput.c 10.14 (Sleepycat) 10/5/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -35,10 +35,12 @@ memp_fput(dbmfp, pgaddr, flags) { BH *bhp; DB_MPOOL *dbmp; + MPOOL *mp; MPOOLFILE *mfp; int wrote, ret; dbmp = dbmfp->dbmp; + mp = dbmp->mp; /* Validate arguments. */ if (flags) { @@ -82,10 +84,16 @@ memp_fput(dbmfp, pgaddr, flags) LOCKREGION(dbmp); /* Set/clear the page bits. */ - if (LF_ISSET(DB_MPOOL_CLEAN)) + if (LF_ISSET(DB_MPOOL_CLEAN) && F_ISSET(bhp, BH_DIRTY)) { + ++mp->stat.st_page_clean; + --mp->stat.st_page_dirty; F_CLR(bhp, BH_DIRTY); - if (LF_ISSET(DB_MPOOL_DIRTY)) + } + if (LF_ISSET(DB_MPOOL_DIRTY) && !F_ISSET(bhp, BH_DIRTY)) { + --mp->stat.st_page_clean; + ++mp->stat.st_page_dirty; F_SET(bhp, BH_DIRTY); + } if (LF_ISSET(DB_MPOOL_DISCARD)) F_SET(bhp, BH_DISCARD); @@ -108,11 +116,11 @@ memp_fput(dbmfp, pgaddr, flags) } /* Move the buffer to the head/tail of the LRU chain. */ - SH_TAILQ_REMOVE(&dbmp->mp->bhq, bhp, q, __bh); + SH_TAILQ_REMOVE(&mp->bhq, bhp, q, __bh); if (F_ISSET(bhp, BH_DISCARD)) - SH_TAILQ_INSERT_HEAD(&dbmp->mp->bhq, bhp, q, __bh); + SH_TAILQ_INSERT_HEAD(&mp->bhq, bhp, q, __bh); else - SH_TAILQ_INSERT_TAIL(&dbmp->mp->bhq, bhp, q); + SH_TAILQ_INSERT_TAIL(&mp->bhq, bhp, q); /* * If this buffer is scheduled for writing because of a checkpoint, @@ -125,14 +133,14 @@ memp_fput(dbmfp, pgaddr, flags) if (F_ISSET(bhp, BH_DIRTY)) { if (__memp_bhwrite(dbmp, dbmfp->mfp, bhp, NULL, &wrote) != 0 || !wrote) - F_SET(dbmp->mp, MP_LSN_RETRY); + F_SET(mp, MP_LSN_RETRY); } else { F_CLR(bhp, BH_WRITE); - mfp = ADDR(dbmp, bhp->mf_offset); + mfp = R_ADDR(dbmp, bhp->mf_offset); --mfp->lsn_cnt; - --dbmp->mp->lsn_cnt; + --mp->lsn_cnt; } UNLOCKREGION(dbmp); diff --git a/db2/mp/mp_fset.c b/db2/mp/mp_fset.c index a3a3dcef9c..a7d2706008 100644 --- a/db2/mp/mp_fset.c +++ b/db2/mp/mp_fset.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fset.c 10.9 (Sleepycat) 9/20/97"; +static const char sccsid[] = "@(#)mp_fset.c 10.10 (Sleepycat) 10/5/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -34,9 +34,13 @@ memp_fset(dbmfp, pgaddr, flags) { BH *bhp; DB_MPOOL *dbmp; + MPOOL *mp; + MPOOLFILE *mfp; int ret; dbmp = dbmfp->dbmp; + mfp = dbmfp->mfp; + mp = dbmp->mp; /* Validate arguments. */ if (flags != 0) { @@ -60,10 +64,16 @@ memp_fset(dbmfp, pgaddr, flags) LOCKREGION(dbmp); - if (LF_ISSET(DB_MPOOL_DIRTY)) - F_SET(bhp, BH_DIRTY); - if (LF_ISSET(DB_MPOOL_CLEAN)) + if (LF_ISSET(DB_MPOOL_CLEAN) && F_ISSET(bhp, BH_DIRTY)) { + ++mp->stat.st_page_clean; + --mp->stat.st_page_dirty; F_CLR(bhp, BH_DIRTY); + } + if (LF_ISSET(DB_MPOOL_DIRTY) && !F_ISSET(bhp, BH_DIRTY)) { + --mp->stat.st_page_clean; + ++mp->stat.st_page_dirty; + F_SET(bhp, BH_DIRTY); + } if (LF_ISSET(DB_MPOOL_DISCARD)) F_SET(bhp, BH_DISCARD); diff --git a/db2/mp/mp_open.c b/db2/mp/mp_open.c index f622b1ed26..4c19739ebd 100644 --- a/db2/mp/mp_open.c +++ b/db2/mp/mp_open.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_open.c 10.13 (Sleepycat) 9/23/97"; +static const char sccsid[] = "@(#)mp_open.c 10.15 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -54,7 +54,7 @@ memp_open(path, flags, mode, dbenv, retp) cachesize = dbenv == NULL ? 0 : dbenv->mp_size; /* Create and initialize the DB_MPOOL structure. */ - if ((dbmp = (DB_MPOOL *)calloc(1, sizeof(DB_MPOOL))) == NULL) + if ((dbmp = (DB_MPOOL *)__db_calloc(1, sizeof(DB_MPOOL))) == NULL) return (ENOMEM); LIST_INIT(&dbmp->dbregq); TAILQ_INIT(&dbmp->dbmfq); @@ -62,8 +62,7 @@ memp_open(path, flags, mode, dbenv, retp) dbmp->dbenv = dbenv; /* Decide if it's possible for anyone else to access the pool. */ - if ((dbenv == NULL && path == NULL) || - (dbenv != NULL && F_ISSET(dbenv, DB_MPOOL_PRIVATE))) + if ((dbenv == NULL && path == NULL) || LF_ISSET(DB_MPOOL_PRIVATE)) F_SET(dbmp, MP_ISPRIVATE); /* @@ -183,7 +182,7 @@ memp_register(dbmp, ftype, pgin, pgout) { DB_MPREG *mpr; - if ((mpr = (DB_MPREG *)malloc(sizeof(DB_MPREG))) == NULL) + if ((mpr = (DB_MPREG *)__db_malloc(sizeof(DB_MPREG))) == NULL) return (ENOMEM); mpr->ftype = ftype; diff --git a/db2/mp/mp_pr.c b/db2/mp/mp_pr.c index 7794cfa7f3..01f0920df4 100644 --- a/db2/mp/mp_pr.c +++ b/db2/mp/mp_pr.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_pr.c 10.13 (Sleepycat) 8/27/97"; +static const char sccsid[] = "@(#)mp_pr.c 10.18 (Sleepycat) 11/1/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -53,7 +53,7 @@ memp_stat(dbmp, gspp, fspp, db_malloc) *gspp = NULL; if ((*gspp = db_malloc == NULL ? - (DB_MPOOL_STAT *)malloc(sizeof(**gspp)) : + (DB_MPOOL_STAT *)__db_malloc(sizeof(**gspp)) : (DB_MPOOL_STAT *)db_malloc(sizeof(**gspp))) == NULL) return (ENOMEM); @@ -62,6 +62,10 @@ memp_stat(dbmp, gspp, fspp, db_malloc) /* Copy out the global statistics. */ **gspp = dbmp->mp->stat; (*gspp)->st_hash_buckets = dbmp->mp->htab_buckets; + (*gspp)->st_region_wait = + dbmp->mp->rlayout.lock.mutex_set_wait; + (*gspp)->st_region_nowait = + dbmp->mp->rlayout.lock.mutex_set_nowait; UNLOCKREGION(dbmp); } @@ -85,7 +89,7 @@ memp_stat(dbmp, gspp, fspp, db_malloc) /* Allocate space for the pointers. */ len = (len + 1) * sizeof(DB_MPOOL_FSTAT *); if ((*fspp = db_malloc == NULL ? - (DB_MPOOL_FSTAT **)malloc(len) : + (DB_MPOOL_FSTAT **)__db_malloc(len) : (DB_MPOOL_FSTAT **)db_malloc(len)) == NULL) return (ENOMEM); @@ -96,11 +100,11 @@ memp_stat(dbmp, gspp, fspp, db_malloc) mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile); mfp != NULL; ++tfsp, mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) { - name = ADDR(dbmp, mfp->path_off); + name = R_ADDR(dbmp, mfp->path_off); nlen = strlen(name); len = sizeof(DB_MPOOL_FSTAT) + nlen + 1; if ((*tfsp = db_malloc == NULL ? - (DB_MPOOL_FSTAT *)malloc(len) : + (DB_MPOOL_FSTAT *)__db_malloc(len) : (DB_MPOOL_FSTAT *)db_malloc(len)) == NULL) return (ENOMEM); **tfsp = mfp->stat; @@ -200,18 +204,19 @@ __memp_pmp(fp, dbmp, mp, data) (void)fprintf(fp, "references: %lu; cachesize: %lu\n", (u_long)mp->rlayout.refcnt, (u_long)mp->stat.st_cachesize); (void)fprintf(fp, - " %lu pages created\n", mp->stat.st_page_create); + " %lu pages created\n", (u_long)mp->stat.st_page_create); (void)fprintf(fp, - " %lu mmap pages returned\n", mp->stat.st_map); + " %lu mmap pages returned\n", (u_long)mp->stat.st_map); (void)fprintf(fp, " %lu I/O's (%lu read, %lu written)\n", - mp->stat.st_page_in + mp->stat.st_page_out, - mp->stat.st_page_in, mp->stat.st_page_out); + (u_long)mp->stat.st_page_in + mp->stat.st_page_out, + (u_long)mp->stat.st_page_in, (u_long)mp->stat.st_page_out); if (mp->stat.st_cache_hit + mp->stat.st_cache_miss != 0) (void)fprintf(fp, " %.0f%% cache hit rate (%lu hit, %lu miss)\n", ((double)mp->stat.st_cache_hit / (mp->stat.st_cache_hit + mp->stat.st_cache_miss)) * 100, - mp->stat.st_cache_hit, mp->stat.st_cache_miss); + (u_long)mp->stat.st_cache_hit, + (u_long)mp->stat.st_cache_miss); /* Display the MPOOLFILE structures. */ for (cnt = 0, mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile); @@ -230,17 +235,18 @@ __memp_pmp(fp, dbmp, mp, data) (void)fprintf(fp, "%s\nHASH table of BH's (%lu buckets):\n", DB_LINE, (u_long)mp->htab_buckets); (void)fprintf(fp, - "longest chain searched %lu\n", mp->stat.st_hash_longest); + "longest chain searched %lu\n", (u_long)mp->sta |
