diff options
author | Keith Bostic <keith@wiredtiger.com> | 2012-03-15 17:39:45 +0000 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2012-03-15 17:39:45 +0000 |
commit | 7ca5081be310a8b550b71b83136c5540c06f0aa3 (patch) | |
tree | 81d43e27d48e0eb71f3b52db8e50e7c72c3c5d57 | |
parent | f7ae41a1e44f635b6718a90d6a787fdf1b403526 (diff) | |
download | mongo-7ca5081be310a8b550b71b83136c5540c06f0aa3.tar.gz |
Inline __wt_page_modify_init (we call it in the search function), and
don't check if WT_PAGE.modify is NULL before calling it, the function
checks.
-rw-r--r-- | src/btree/bt_page.c | 24 | ||||
-rw-r--r-- | src/btree/col_modify.c | 3 | ||||
-rw-r--r-- | src/btree/col_srch.c | 3 | ||||
-rw-r--r-- | src/btree/row_srch.c | 3 | ||||
-rw-r--r-- | src/include/btree.i | 23 | ||||
-rw-r--r-- | src/include/extern.h | 1 |
6 files changed, 26 insertions, 31 deletions
diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c index e60735e8b48..583b43e0137 100644 --- a/src/btree/bt_page.c +++ b/src/btree/bt_page.c @@ -152,30 +152,6 @@ err: __wt_free(session, page); } /* - * __wt_page_modify_init -- - * A page is about to be modified, allocate the modification structure. - */ -int -__wt_page_modify_init(WT_SESSION_IMPL *session, WT_PAGE *page) -{ - WT_PAGE_MODIFY *modify; - - if (page->modify == NULL) { - WT_RET(__wt_calloc_def(session, 1, &modify)); - - /* - * Multiple threads of control may be searching and deciding - * to modify a page, if we don't do the update, discard the - * memory. - */ - if (!WT_ATOMIC_CAS(page->modify, NULL, modify)) - __wt_free(session, modify); - } - - return (0); -} - -/* * __inmem_col_fix -- * Build in-memory index for fixed-length column-store leaf pages. */ diff --git a/src/btree/col_modify.c b/src/btree/col_modify.c index e1352a4ae61..9780c9fbc35 100644 --- a/src/btree/col_modify.c +++ b/src/btree/col_modify.c @@ -59,8 +59,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op) } /* If we don't yet have a modify structure, we'll need one. */ - if (page->modify == NULL) - WT_RET(__wt_page_modify_init(session, page)); + WT_RET(__wt_page_modify_init(session, page)); ins = NULL; new_inshead = NULL; diff --git a/src/btree/col_srch.c b/src/btree/col_srch.c index d9462bac9e5..1fb692f2b05 100644 --- a/src/btree/col_srch.c +++ b/src/btree/col_srch.c @@ -81,8 +81,7 @@ __wt_col_search(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_modify) */ if (is_modify) { /* Initialize the page's modification information */ - if (page->modify == NULL) - WT_RET(__wt_page_modify_init(session, page)); + WT_RET(__wt_page_modify_init(session, page)); WT_ORDERED_READ(cbt->write_gen, page->modify->write_gen); } diff --git a/src/btree/row_srch.c b/src/btree/row_srch.c index 30c096eedae..5ac5dacdfa3 100644 --- a/src/btree/row_srch.c +++ b/src/btree/row_srch.c @@ -164,8 +164,7 @@ __wt_row_search(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_modify) */ if (is_modify) { /* Initialize the page's modification information */ - if (page->modify == NULL) - WT_RET(__wt_page_modify_init(session, page)); + WT_RET(__wt_page_modify_init(session, page)); WT_ORDERED_READ(cbt->write_gen, page->modify->write_gen); } diff --git a/src/include/btree.i b/src/include/btree.i index 5cee53d2fe4..a086ca81b7c 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -105,6 +105,29 @@ __wt_cache_bytes_inuse(WT_CACHE *cache) } /* + * __wt_page_modify_init -- + * A page is about to be modified, allocate the modification structure. + */ +static inline int +__wt_page_modify_init(WT_SESSION_IMPL *session, WT_PAGE *page) +{ + WT_PAGE_MODIFY *modify; + + if (page->modify != NULL) + return (0); + + WT_RET(__wt_calloc_def(session, 1, &modify)); + + /* + * Multiple threads of control may be searching and deciding to modify + * a page, if we don't do the update, discard the memory. + */ + if (!WT_ATOMIC_CAS(page->modify, NULL, modify)) + __wt_free(session, modify); + return (0); +} + +/* * __wt_page_modify_set -- * Mark the page dirty. */ diff --git a/src/include/extern.h b/src/include/extern.h index c8e35e89767..13b39c43d85 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -225,7 +225,6 @@ extern int __wt_page_inmem(WT_SESSION_IMPL *session, WT_PAGE_HEADER *dsk, size_t *inmem_sizep, WT_PAGE **pagep); -extern int __wt_page_modify_init(WT_SESSION_IMPL *session, WT_PAGE *page); extern int __wt_cache_read(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_REF *ref); |