summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2013-08-05 08:22:04 -0400
committerDon Anderson <dda@ddanderson.com>2013-08-09 16:30:53 -0400
commit28eea14b9894a259861f97faba444e4b88ae2bd4 (patch)
tree578bc5118371e109e0b4314faa66b8f8fd64b76e
parent89fc0b70b1166db6c8d0b083278b7aabbde4c505 (diff)
downloadmongo-28eea14b9894a259861f97faba444e4b88ae2bd4.tar.gz
There are four possible states for the WT_PAGE.dsk memory: the WT_PAGE
disk-image is mapped into memory (unmap on page discard), is in allocated memory (free on page discard), is in memory belonging to a caller (ignore on page discard), or isn't set at all (ignore on page discard). We've been trying to figure out which based on the state of WT_PAGE.dsk and a single flag, and that's not enough. Use two explicit flags, one for mapped memory and one for allocated memory, and neither flag is set for the latter two states.
-rw-r--r--src/btree/bt_discard.c15
-rw-r--r--src/btree/bt_handle.c5
-rw-r--r--src/btree/bt_page.c7
-rw-r--r--src/btree/bt_read.c5
-rw-r--r--src/btree/bt_slvg.c4
-rw-r--r--src/btree/rec_write.c1
-rw-r--r--src/include/btmem.h5
-rw-r--r--src/include/extern.h2
8 files changed, 21 insertions, 23 deletions
diff --git a/src/btree/bt_discard.c b/src/btree/bt_discard.c
index e91234c050e..1f500960468 100644
--- a/src/btree/bt_discard.c
+++ b/src/btree/bt_discard.c
@@ -77,15 +77,12 @@ __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep)
break;
}
- /* Free any allocated disk image. */
- if (page->dsk != NULL) {
- if (F_ISSET_ATOMIC(page, WT_PAGE_DISK_NOT_ALLOC))
- __wt_mmap_discard(
- session, page->dsk, page->dsk->mem_size);
- else
- __wt_overwrite_and_free_len(
- session, page->dsk, page->dsk->mem_size);
- }
+ /* Discard any disk image. */
+ if (F_ISSET_ATOMIC(page, WT_PAGE_DISK_ALLOC))
+ __wt_overwrite_and_free_len(
+ session, page->dsk, page->dsk->mem_size);
+ if (F_ISSET_ATOMIC(page, WT_PAGE_DISK_MAPPED))
+ __wt_mmap_discard(session, page->dsk, page->dsk->mem_size);
__wt_overwrite_and_free(session, page);
}
diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c
index 6830bc83c3c..9f4e167b773 100644
--- a/src/btree/bt_handle.c
+++ b/src/btree/bt_handle.c
@@ -342,8 +342,9 @@ __wt_btree_tree_open(
/* Read the page, then build the in-memory version of the page. */
WT_ERR(__wt_bt_read(session, &dsk, addr, addr_size));
- WT_ERR(__wt_page_inmem(session,
- NULL, NULL, dsk.mem, F_ISSET(&dsk, WT_ITEM_MAPPED) ? 1 : 0, &page));
+ WT_ERR(__wt_page_inmem(session, NULL, NULL, dsk.mem,
+ F_ISSET(&dsk, WT_ITEM_MAPPED) ?
+ WT_PAGE_DISK_MAPPED : WT_PAGE_DISK_ALLOC, &page));
btree->root_page = page;
if (0) {
diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c
index 7577d23c088..8789411b883 100644
--- a/src/btree/bt_page.c
+++ b/src/btree/bt_page.c
@@ -198,7 +198,7 @@ __wt_page_alloc(WT_SESSION_IMPL *session,
int
__wt_page_inmem(
WT_SESSION_IMPL *session, WT_PAGE *parent, WT_REF *parent_ref,
- WT_PAGE_HEADER *dsk, int disk_not_alloc, WT_PAGE **pagep)
+ WT_PAGE_HEADER *dsk, uint32_t flags, WT_PAGE **pagep)
{
WT_DECL_RET;
WT_PAGE *page;
@@ -254,14 +254,13 @@ __wt_page_inmem(
WT_RET(__wt_page_alloc(session, dsk->type, alloc_entries, &page));
page->dsk = dsk;
page->read_gen = WT_READ_GEN_NOTSET;
- if (disk_not_alloc)
- F_SET_ATOMIC(page, WT_PAGE_DISK_NOT_ALLOC);
+ F_SET_ATOMIC(page, flags);
/*
* Track the memory allocated to build this page so we can update the
* cache statistics in a single call.
*/
- size = disk_not_alloc ? 0 : dsk->mem_size;
+ size = LF_ISSET(WT_PAGE_DISK_ALLOC) ? dsk->mem_size : 0;
switch (page->type) {
case WT_PAGE_COL_FIX:
diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c
index 3a9cb7f8221..85906414999 100644
--- a/src/btree/bt_read.c
+++ b/src/btree/bt_read.c
@@ -103,8 +103,9 @@ __wt_cache_read(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_REF *ref)
WT_ERR(__wt_bt_read(session, &tmp, addr, size));
/* Build the in-memory version of the page. */
- WT_ERR(__wt_page_inmem(session, parent, ref,
- tmp.mem, F_ISSET(&tmp, WT_ITEM_MAPPED) ? 1 : 0, &page));
+ WT_ERR(__wt_page_inmem(session, parent, ref, tmp.mem,
+ F_ISSET(&tmp, WT_ITEM_MAPPED) ?
+ WT_PAGE_DISK_MAPPED : WT_PAGE_DISK_ALLOC, &page));
/* If the page was deleted, instantiate that information. */
if (previous_state == WT_REF_DELETED)
diff --git a/src/btree/bt_slvg.c b/src/btree/bt_slvg.c
index 3bad6b84622..6fd26d1f5af 100644
--- a/src/btree/bt_slvg.c
+++ b/src/btree/bt_slvg.c
@@ -533,7 +533,7 @@ __slvg_trk_leaf(WT_SESSION_IMPL *session,
* on every leaf page, and if you need to speed up the salvage,
* it's probably a great place to start.
*/
- WT_ERR(__wt_page_inmem(session, NULL, NULL, dsk, 1, &page));
+ WT_ERR(__wt_page_inmem(session, NULL, NULL, dsk, 0, &page));
WT_ERR(__wt_row_leaf_key_copy(session,
page, &page->u.row.d[0], &trk->row_start));
WT_ERR(__wt_row_leaf_key_copy(session,
@@ -1591,7 +1591,7 @@ __slvg_row_trk_update_start(
*/
WT_RET(__wt_scr_alloc(session, trk->size, &dsk));
WT_ERR(__wt_bt_read(session, dsk, trk->addr.addr, trk->addr.size));
- WT_ERR(__wt_page_inmem(session, NULL, NULL, dsk->mem, 1, &page));
+ WT_ERR(__wt_page_inmem(session, NULL, NULL, dsk->mem, 0, &page));
/*
* Walk the page, looking for a key sorting greater than the specified
diff --git a/src/btree/rec_write.c b/src/btree/rec_write.c
index 3aeca87a2fa..6e1c1245b21 100644
--- a/src/btree/rec_write.c
+++ b/src/btree/rec_write.c
@@ -4007,7 +4007,6 @@ __rec_split_merge_new(WT_SESSION_IMPL *session,
page->u.intl.recno = r->bnd[0].recno;
page->read_gen = WT_READ_GEN_NOTSET;
page->entries = r->bnd_next;
- page->flags_atomic = WT_PAGE_DISK_NOT_ALLOC;
/*
* We don't re-write parent pages when child pages split, which means
diff --git a/src/include/btmem.h b/src/include/btmem.h
index 087f5079fb3..cefd4316972 100644
--- a/src/include/btmem.h
+++ b/src/include/btmem.h
@@ -324,8 +324,9 @@ struct __wt_page {
uint8_t type; /* Page type */
#define WT_PAGE_BUILD_KEYS 0x01 /* Keys have been built in memory */
-#define WT_PAGE_DISK_NOT_ALLOC 0x02 /* Ignore disk image on page discard */
-#define WT_PAGE_EVICT_LRU 0x04 /* Page is on the LRU queue */
+#define WT_PAGE_DISK_ALLOC 0x02 /* Disk image in allocated memory */
+#define WT_PAGE_DISK_MAPPED 0x04 /* Disk image in mapped memory */
+#define WT_PAGE_EVICT_LRU 0x08 /* Page is on the LRU queue */
uint8_t flags_atomic; /* Atomic flags, use F_*_ATOMIC */
};
diff --git a/src/include/extern.h b/src/include/extern.h
index ec0fa310de7..f7a5f21fa81 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -338,7 +338,7 @@ extern int __wt_page_inmem( WT_SESSION_IMPL *session,
WT_PAGE *parent,
WT_REF *parent_ref,
WT_PAGE_HEADER *dsk,
- int disk_not_alloc,
+ uint32_t flags,
WT_PAGE **pagep);
extern int __wt_cache_read(WT_SESSION_IMPL *session,
WT_PAGE *parent,