Commit 0d6edd44 authored by John Esmet's avatar John Esmet

fixes #189 Clean up huge page detection a bit. It's not perfect but it's

an improvement.
parent 9b875ae5
......@@ -98,7 +98,7 @@ PATENT RIGHTS GRANT:
#include "log-internal.h"
#include "txn_manager.h"
#include "rollback_log_node_cache.h"
#include "huge_page_detection.h"
#include <util/status.h>
static const int log_format_version=TOKU_LOG_VERSION;
......@@ -164,11 +164,6 @@ static bool is_a_logfile (const char *name, long long *number_result) {
// TODO: can't fail
int toku_logger_create (TOKULOGGER *resultp) {
if (complain_and_return_true_if_huge_pages_are_enabled()) {
*resultp = NULL;
errno = TOKUDB_HUGE_PAGES_ENABLED;
return TOKUDB_HUGE_PAGES_ENABLED;
}
TOKULOGGER CALLOC(result);
if (result==0) return get_error_errno();
result->is_open=false;
......
......@@ -93,11 +93,8 @@ PATENT RIGHTS GRANT:
#include <stdio.h>
#include <string.h>
#include <toku_assert.h>
#include "huge_page_detection.h"
extern "C" {
#include <toku_include/toku_assert.h>
#include <toku_include/toku_os.h>
static bool check_huge_pages_config_file(const char *fname)
// Effect: Return true if huge pages are there. If so, print diagnostics.
......@@ -120,20 +117,6 @@ static bool check_huge_pages_config_file(const char *fname)
return huge_pages_enabled;
}
/* struct mapinfo { */
/* void *addr; */
/* size_t size; */
/* }; */
/* static void* map_it(size_t size, struct mapinfo *mi, int *n_maps) { */
/* void *r = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); */
/* if ((long)r==-1) perror("mmap failed"); */
/* mi[*n_maps].addr = r; */
/* mi[*n_maps].size = size; */
/* (*n_maps)++; */
/* return r; */
/* } */
static bool check_huge_pages_in_practice(void)
// Effect: Return true if huge pages appear to be defined in practice.
{
......@@ -195,7 +178,7 @@ static bool check_huge_pages_in_practice(void)
#endif
}
bool complain_and_return_true_if_huge_pages_are_enabled(void)
bool toku_os_huge_pages_enabled(void)
// Effect: Return true if huge pages appear to be enabled. If so, print some diagnostics to stderr.
// If environment variable TOKU_HUGE_PAGES_OK is set, then don't complain.
{
......@@ -209,4 +192,3 @@ bool complain_and_return_true_if_huge_pages_are_enabled(void)
return conf1|conf2|prac;
}
}
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#pragma once
extern "C" bool complain_and_return_true_if_huge_pages_are_enabled(void);
// Effect: Return true if huge pages appear to be enabled. If so, print some diagnostics to stderr.
// If environment variable TOKU_HUGE_PAGES_OK is set, then don't complain.
......@@ -90,10 +90,10 @@ PATENT RIGHTS GRANT:
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdio.h>
#include <assert.h>
#include <huge_page_detection.h>
#include <toku_include/toku_os.h>
int main(void) {
bool enabled = complain_and_return_true_if_huge_pages_are_enabled();
bool enabled = toku_os_huge_pages_enabled();
assert(!enabled);
return 0;
}
......@@ -852,6 +852,12 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) {
goto cleanup;
}
if (toku_os_huge_pages_enabled()) {
r = toku_ydb_do_error(env, TOKUDB_HUGE_PAGES_ENABLED,
"Huge pages are enabled, disable them before continuing\n");
goto cleanup;
}
most_recent_env = NULL;
assert(sizeof(time_t) == sizeof(uint64_t));
......@@ -2564,8 +2570,8 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) {
result->i->bt_compare = toku_builtin_compare_fun;
r = toku_logger_create(&result->i->logger);
if (r!=0) goto cleanup; // In particular, logger_create can return the huge page error.
assert(result->i->logger);
invariant_zero(r);
invariant_notnull(result->i->logger);
// Create the locktree manager, passing in the create/destroy/escalate callbacks.
// The extra parameter for escalation is simply a pointer to this environment.
......
......@@ -95,7 +95,8 @@ PATENT RIGHTS GRANT:
#include <dirent.h>
#include <sys/time.h>
#include <toku_os_types.h>
#include <portability/toku_stdint.h>
#include <portability/toku_os_types.h>
// Returns: the current process id
int toku_os_getpid(void) __attribute__((__visibility__("default")));
......@@ -148,6 +149,9 @@ int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("d
bool toku_os_is_absolute_name(const char* path) __attribute__((__visibility__("default")));
// Return true if huge pages are enabled. See portability/huge_page_detection.cc for methodology.
bool toku_os_huge_pages_enabled(void) __attribute__((__visibility__("default")));
// Set whether or not writes assert when ENOSPC is returned or they wait for space
void toku_set_assert_on_write_enospc(int do_assert) __attribute__((__visibility__("default")));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment