summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2017-04-26 21:36:42 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2017-04-27 11:02:38 -0400
commit2df6ea3c5b70acc3927a08690f8d42b9d35b8709 (patch)
tree4486acca81ec6f452de3bd4bea6f69fc235e5338 /src
parent983ac10e3a1f37cc762e2d68ff4cf9e8263154e5 (diff)
downloadmongo-2df6ea3c5b70acc3927a08690f8d42b9d35b8709.tar.gz
SERVER-28967 Remove whitelist marks & break cycles
Some cycles were broken by fixing the initialization order dependency in `mmap_v1`.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/SConscript43
-rw-r--r--src/mongo/db/pipeline/SConscript5
-rw-r--r--src/mongo/db/prefetch.cpp54
-rw-r--r--src/mongo/db/s/SConscript1
-rw-r--r--src/mongo/db/storage/mmap_v1/SConscript5
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap.h4
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_posix.cpp27
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_windows.cpp24
-rw-r--r--src/mongo/s/catalog/SConscript2
-rw-r--r--src/mongo/s/client/SConscript2
10 files changed, 73 insertions, 94 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index b9917f42b14..cef9ffea77c 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -662,15 +662,11 @@ env.Library(
"cloner.cpp",
],
LIBDEPS=[
- "$BUILD_DIR/mongo/base",
- "dbdirectclient",
- "ops/write_ops",
- "repl/isself",
- #"catalog/catalog", # CYCLE
- ],
- LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-03-10): See `CYCLE` tags above.
- 'illegal_cyclic_or_unresolved_dependencies_whitelisted',
+ 'dbdirectclient',
+ 'ops/write_ops',
+ 'repl/isself',
+ '$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/db/catalog/index_create',
],
)
@@ -693,14 +689,10 @@ env.Library(
"index_rebuilder.cpp",
],
LIBDEPS=[
- "db_raii",
- "index/index_access_methods",
+ 'db_raii',
+ 'index/index_access_methods',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
- #"catalog/catalog", # CYCLE
- ],
- LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-03-10): See `CYCLE` tags above.
- 'illegal_cyclic_or_unresolved_dependencies_whitelisted',
+ '$BUILD_DIR/mongo/db/catalog/index_create',
],
)
@@ -715,18 +707,14 @@ env.Library(
)
env.Library(
- target="prefetch",
+ target='prefetch',
source=[
- "prefetch.cpp",
+ 'prefetch.cpp',
],
LIBDEPS=[
- #"catalog/catalog", # CYCLE
- "dbhelpers",
- "index/index_access_methods",
- ],
- LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-04-06): See `CYCLE` tags above.
- 'illegal_cyclic_or_unresolved_dependencies_whitelisted',
+ 'dbhelpers',
+ 'index/index_access_methods',
+ '$BUILD_DIR/mongo/db/storage/mmap_v1/mmap',
],
)
@@ -759,11 +747,6 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/collection',
'$BUILD_DIR/mongo/db/catalog/database',
"$BUILD_DIR/mongo/db/storage/mmap_v1/storage_mmapv1",
- #"catalog/catalog", # CYCLE
- ],
- LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-03-10): See `CYCLE` tags above.
- 'illegal_cyclic_or_unresolved_dependencies_whitelisted',
],
)
diff --git a/src/mongo/db/pipeline/SConscript b/src/mongo/db/pipeline/SConscript
index 4e1189c337e..642fd8fa72d 100644
--- a/src/mongo/db/pipeline/SConscript
+++ b/src/mongo/db/pipeline/SConscript
@@ -476,10 +476,5 @@ env.Library(
'$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/matcher/expressions_mongod_only',
'$BUILD_DIR/mongo/db/stats/serveronly',
- #'$BUILD_DIR/mongo/db/catalog/catalog', # CYCLE
- ],
- LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-03-10): See `CYCLE` tags above
- 'illegal_cyclic_or_unresolved_dependencies_whitelisted',
],
)
diff --git a/src/mongo/db/prefetch.cpp b/src/mongo/db/prefetch.cpp
index a9d7353ee83..f9f6beb455f 100644
--- a/src/mongo/db/prefetch.cpp
+++ b/src/mongo/db/prefetch.cpp
@@ -1,30 +1,30 @@
/**
-* Copyright (C) 2008-2014 MongoDB Inc.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License, version 3,
-* as published by the Free Software Foundation.
-*
-* 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 Affero General Public License for more details.
-*
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* As a special exception, the copyright holders give permission to link the
-* code of portions of this program with the OpenSSL library under certain
-* conditions as described in each individual source file and distribute
-* linked combinations including the program with the OpenSSL library. You
-* must comply with the GNU Affero General Public License in all respects for
-* all of the code used other than as permitted herein. If you modify file(s)
-* with this exception, you may extend this exception to your version of the
-* file(s), but you are not obligated to do so. If you do not wish to do so,
-* delete this exception statement from your version. If you delete this
-* exception statement from all source files in the program, then also delete
-* it in the license file.
-*/
+ * Copyright (C) 2008-2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kReplication
@@ -134,7 +134,7 @@ void prefetchRecordPages(OperationContext* opCtx,
volatile char _dummy_char = '\0'; // NOLINT
// Touch the first word on every page in order to fault it into memory
- for (int i = 0; i < result.objsize(); i += g_minOSPageSizeBytes) {
+ for (int i = 0; i < result.objsize(); i += getMinOSPageSizeBytes()) {
_dummy_char += *(result.objdata() + i);
}
// hit the last page, in case we missed it above
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 0c6b69d2c95..840991cc59a 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -97,6 +97,7 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/collection',
'$BUILD_DIR/mongo/db/catalog/database',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
+ '$BUILD_DIR/mongo/db/catalog/index_create',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/query/internal_plans',
diff --git a/src/mongo/db/storage/mmap_v1/SConscript b/src/mongo/db/storage/mmap_v1/SConscript
index 6fd91425ed5..a705b766764 100644
--- a/src/mongo/db/storage/mmap_v1/SConscript
+++ b/src/mongo/db/storage/mmap_v1/SConscript
@@ -56,6 +56,7 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/database',
'$BUILD_DIR/mongo/db/catalog/database_holder',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
+ '$BUILD_DIR/mongo/db/catalog/index_create',
'$BUILD_DIR/mongo/db/commands',
'$BUILD_DIR/mongo/db/commands/core',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
@@ -66,10 +67,10 @@ env.Library(
'$BUILD_DIR/mongo/db/storage/storage_engine_lock_file',
'$BUILD_DIR/mongo/db/storage/storage_engine_metadata',
'$BUILD_DIR/mongo/db/index/index_access_methods',
- #'$BUILD_DIR/mongo/db/catalog/catalog', # CYCLE
+ #'$BUILD_DIR/mongo/db/catalog/catalog', # CYCLE (CursorManager & applyUpdateOperators)
],
LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-01-06): See `CYCLE` tags above
+ # TODO(ADAM, 2017-04-25): See `CYCLE` tags above
'illegal_cyclic_or_unresolved_dependencies_whitelisted',
],
)
diff --git a/src/mongo/db/storage/mmap_v1/mmap.h b/src/mongo/db/storage/mmap_v1/mmap.h
index b1b32e37d7d..37a2e9e6fcd 100644
--- a/src/mongo/db/storage/mmap_v1/mmap.h
+++ b/src/mongo/db/storage/mmap_v1/mmap.h
@@ -1,5 +1,3 @@
-// mmap.h
-
/* Copyright 2009 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
@@ -44,7 +42,7 @@ namespace mongo {
typedef int HANDLE;
#endif
-extern const size_t g_minOSPageSizeBytes;
+extern std::size_t getMinOSPageSizeBytes();
void minOSPageSizeBytesTest(size_t minOSPageSizeBytes); // lame-o
// call this if syncing data fails
diff --git a/src/mongo/db/storage/mmap_v1/mmap_posix.cpp b/src/mongo/db/storage/mmap_v1/mmap_posix.cpp
index 2a9c1cc0458..b4f96412d9a 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_posix.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_posix.cpp
@@ -1,5 +1,3 @@
-// mmap_posix.cpp
-
/* Copyright 2009 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
@@ -52,7 +50,6 @@ using std::vector;
using namespace mongoutils;
-
namespace mongo {
namespace {
@@ -70,14 +67,18 @@ void printMemInfo() {
<< " mapped: " << MemoryMappedFile::totalMappedLengthInMB();
}
} // namespace
+} // namespace mongo
-static size_t fetchMinOSPageSizeBytes() {
- size_t minOSPageSizeBytes = sysconf(_SC_PAGESIZE);
- minOSPageSizeBytesTest(minOSPageSizeBytes);
- return minOSPageSizeBytes;
+std::size_t mongo::getMinOSPageSizeBytes() {
+ static const std::size_t cachedSize = [] {
+ std::size_t minOSPageSizeBytes = sysconf(_SC_PAGESIZE);
+ minOSPageSizeBytesTest(minOSPageSizeBytes);
+ return minOSPageSizeBytes;
+ }();
+ return cachedSize;
}
-const size_t g_minOSPageSizeBytes = fetchMinOSPageSizeBytes();
+namespace mongo {
void MemoryMappedFile::close(OperationContext* opCtx) {
for (vector<void*>::iterator i = views.begin(); i != views.end(); i++) {
@@ -104,21 +105,21 @@ void MemoryMappedFile::close(OperationContext* opCtx) {
namespace {
void* _pageAlign(void* p) {
- return (void*)((int64_t)p & ~(g_minOSPageSizeBytes - 1));
+ return (void*)((int64_t)p & ~(getMinOSPageSizeBytes() - 1));
}
class PageAlignTest : public StartupTest {
public:
void run() {
{
- int64_t x = g_minOSPageSizeBytes + 123;
+ int64_t x = getMinOSPageSizeBytes() + 123;
void* y = _pageAlign(reinterpret_cast<void*>(x));
- invariant(g_minOSPageSizeBytes == reinterpret_cast<size_t>(y));
+ invariant(getMinOSPageSizeBytes() == reinterpret_cast<size_t>(y));
}
{
int64_t a = static_cast<uint64_t>(numeric_limits<int>::max());
- a = a / g_minOSPageSizeBytes;
- a = a * g_minOSPageSizeBytes;
+ a = a / getMinOSPageSizeBytes();
+ a = a * getMinOSPageSizeBytes();
// a should now be page aligned
// b is not page aligned
diff --git a/src/mongo/db/storage/mmap_v1/mmap_windows.cpp b/src/mongo/db/storage/mmap_v1/mmap_windows.cpp
index e34bee74ade..c1b1ebc3306 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_windows.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_windows.cpp
@@ -1,5 +1,3 @@
-// mmap_win.cpp
-
/* Copyright 2009 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
@@ -41,20 +39,22 @@
#include "mongo/util/text.h"
#include "mongo/util/timer.h"
-namespace mongo {
-
using std::endl;
using std::string;
using std::vector;
-static size_t fetchMinOSPageSizeBytes() {
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- size_t minOSPageSizeBytes = si.dwPageSize;
- minOSPageSizeBytesTest(minOSPageSizeBytes);
- return minOSPageSizeBytes;
+std::size_t mongo::getMinOSPageSizeBytes() {
+ static const std::size_t cachedSize = [] {
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ std::size_t minOSPageSizeBytes = si.dwPageSize;
+ minOSPageSizeBytesTest(minOSPageSizeBytes);
+ return minOSPageSizeBytes;
+ }();
+ return cachedSize;
}
-const size_t g_minOSPageSizeBytes = fetchMinOSPageSizeBytes();
+
+namespace mongo {
// MapViewMutex
//
@@ -484,4 +484,4 @@ void MemoryMappedFile::flush(bool sync) {
MemoryMappedFile::Flushable* MemoryMappedFile::prepareFlush() {
return new WindowsFlushable(this, viewForFlushing(), fd, _uniqueId, filename(), _flushMutex);
}
-}
+} // namespace mongo
diff --git a/src/mongo/s/catalog/SConscript b/src/mongo/s/catalog/SConscript
index f32a443534a..dfad40c58d6 100644
--- a/src/mongo/s/catalog/SConscript
+++ b/src/mongo/s/catalog/SConscript
@@ -135,7 +135,7 @@ env.Library(
# '$BUILD_DIR/mongo/s/coreshard', # CYCLE
],
LIBDEPS_TAGS=[
- # TODO(ADAM, 2017-01-06): See `CYCLE` tags above
+ # TODO(ADAM, 2017-04-25): See `CYCLE` tags above
'illegal_cyclic_or_unresolved_dependencies_whitelisted',
],
)
diff --git a/src/mongo/s/client/SConscript b/src/mongo/s/client/SConscript
index 8fddfcbb6db..0ea64131ddc 100644
--- a/src/mongo/s/client/SConscript
+++ b/src/mongo/s/client/SConscript
@@ -30,7 +30,7 @@ env.Library(
#'$BUILD_DIR/mongo/s/coreshard', # CYCLE
],
LIBDEPS_TAGS=[
- # TODO(ADAM, 2017,01-06): See `CYCLE` tags above
+ # TODO(ADAM, 2017,04-25): See `CYCLE` tags above
'illegal_cyclic_or_unresolved_dependencies_whitelisted',
],
)