diff options
Diffstat (limited to 'src/mongo')
48 files changed, 106 insertions, 287 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 84e32ad556b..b4494181da4 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -629,7 +629,6 @@ serverOnlyFiles = [ "db/curop.cpp", "db/catalog/collection_info_cache.cpp", "db/catalog/database_holder.cpp", "db/background.cpp", - "db/pdfile.cpp", "db/structure/catalog/index_details.cpp", "db/index_builder.cpp", "db/index_rebuilder.cpp", diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index a6010ab4d72..affa5d64195 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -47,7 +47,8 @@ #include "mongo/db/structure/catalog/index_details.h" #include "mongo/db/instance.h" #include "mongo/db/introspect.h" -#include "mongo/db/pdfile.h" +#include "mongo/db/repair_database.h" +#include "mongo/db/repl/oplog.h" #include "mongo/db/server_parameters.h" #include "mongo/db/storage_options.h" #include "mongo/db/storage/storage_engine.h" @@ -503,4 +504,91 @@ namespace mongo { return _dbEntry.get(); } + void dropAllDatabasesExceptLocal(OperationContext* txn) { + Lock::GlobalWrite lk(txn->lockState()); + + vector<string> n; + globalStorageEngine->listDatabases( &n ); + if( n.size() == 0 ) return; + log() << "dropAllDatabasesExceptLocal " << n.size() << endl; + for( vector<string>::iterator i = n.begin(); i != n.end(); i++ ) { + if( *i != "local" ) { + Client::Context ctx(*i); + dropDatabase(txn, ctx.db()); + } + } + } + + void dropDatabase(OperationContext* txn, Database* db ) { + invariant( db ); + + string name = db->name(); // just to have safe + LOG(1) << "dropDatabase " << name << endl; + + txn->lockState()->assertWriteLocked( name ); + + BackgroundOperation::assertNoBgOpInProgForDb(name.c_str()); + + audit::logDropDatabase( currentClient.get(), name ); + + // Not sure we need this here, so removed. If we do, we need to move it down + // within other calls both (1) as they could be called from elsewhere and + // (2) to keep the lock order right - groupcommitmutex must be locked before + // mmmutex (if both are locked). + // + // RWLockRecursive::Exclusive lk(MongoFile::mmmutex); + + txn->recoveryUnit()->syncDataAndTruncateJournal(); + + Database::closeDatabase(txn, name ); + db = 0; // d is now deleted + + _deleteDataFiles( name ); + } + + /** { ..., capped: true, size: ..., max: ... } + * @param createDefaultIndexes - if false, defers id (and other) index creation. + * @return true if successful + */ + Status userCreateNS( OperationContext* txn, + Database* db, + const StringData& ns, + BSONObj options, + bool logForReplication, + bool createDefaultIndexes ) { + + invariant( db ); + + LOG(1) << "create collection " << ns << ' ' << options; + + if ( !NamespaceString::validCollectionComponent(ns) ) + return Status( ErrorCodes::InvalidNamespace, + str::stream() << "invalid ns: " << ns ); + + Collection* collection = db->getCollection( txn, ns ); + + if ( collection ) + return Status( ErrorCodes::NamespaceExists, + "collection already exists" ); + + CollectionOptions collectionOptions; + Status status = collectionOptions.parse( options ); + if ( !status.isOK() ) + return status; + + invariant( db->createCollection( txn, ns, collectionOptions, true, createDefaultIndexes ) ); + + if ( logForReplication ) { + if ( options.getField( "create" ).eoo() ) { + BSONObjBuilder b; + b << "create" << nsToCollectionSubstring( ns ); + b.appendElements( options ); + options = b.obj(); + } + string logNs = nsToDatabase(ns) + ".$cmd"; + repl::logOp(txn, "c", logNs.c_str(), options); + } + + return Status::OK(); + } } // namespace mongo diff --git a/src/mongo/db/catalog/database.h b/src/mongo/db/catalog/database.h index 5b4a6e24cfb..773addcbb99 100644 --- a/src/mongo/db/catalog/database.h +++ b/src/mongo/db/catalog/database.h @@ -164,4 +164,15 @@ namespace mongo { friend class IndexCatalog; }; + void dropDatabase(OperationContext* txn, Database* db ); + + void dropAllDatabasesExceptLocal(OperationContext* txn); + + Status userCreateNS( OperationContext* txn, + Database* db, + const StringData& ns, + BSONObj options, + bool logForReplication, + bool createDefaultIndexes = true ); + } // namespace mongo diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp index ff3f3677625..e1f83b53e98 100644 --- a/src/mongo/db/catalog/database_holder.cpp +++ b/src/mongo/db/catalog/database_holder.cpp @@ -44,6 +44,12 @@ namespace mongo { + static DatabaseHolder _dbHolder; + + DatabaseHolder& dbHolder() { + return _dbHolder; + } + Database* DatabaseHolder::get(OperationContext* txn, const std::string& ns) const { diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 67da6bba6d6..a66df9aacbd 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -49,7 +49,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/pdfile.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp index bd0523dfa7d..29a0dbd0dd5 100644 --- a/src/mongo/db/commands/clone.cpp +++ b/src/mongo/db/commands/clone.cpp @@ -48,7 +48,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index 50222f3e2ba..c2cf2c885db 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -48,7 +48,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp index 990ce9f5719..7299f0abf29 100644 --- a/src/mongo/db/commands/collection_to_capped.cpp +++ b/src/mongo/db/commands/collection_to_capped.cpp @@ -32,7 +32,6 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/index_builder.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/query/new_find.h" #include "mongo/db/repl/oplog.h" diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp index 9dd674765cc..6582c1172eb 100644 --- a/src/mongo/db/commands/copydb.cpp +++ b/src/mongo/db/commands/copydb.cpp @@ -49,7 +49,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/commands/copydb_getnonce.cpp b/src/mongo/db/commands/copydb_getnonce.cpp index 937e9063f24..cc8bec23ad2 100644 --- a/src/mongo/db/commands/copydb_getnonce.cpp +++ b/src/mongo/db/commands/copydb_getnonce.cpp @@ -48,7 +48,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index c584f846944..9e35ef3b0c7 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -39,7 +39,6 @@ #include "mongo/db/commands.h" #include "mongo/db/instance.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/get_runner.h" #include "mongo/db/query/query_planner_common.h" #include "mongo/db/query/type_explain.h" diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index 4748595e610..9c11baab7f7 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -37,7 +37,6 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/index_key_validate.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/operation_context_impl.h" diff --git a/src/mongo/db/commands/geonear.cpp b/src/mongo/db/commands/geonear.cpp index a26699dea20..bbcc5ab19f5 100644 --- a/src/mongo/db/commands/geonear.cpp +++ b/src/mongo/db/commands/geonear.cpp @@ -40,7 +40,6 @@ #include "mongo/db/index_names.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/get_runner.h" #include "mongo/db/query/type_explain.h" #include "mongo/db/catalog/collection.h" diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index 4b5a1578f8c..c2363fcae09 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -29,7 +29,6 @@ */ #include "mongo/db/commands.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/query/runner.h" #include "mongo/db/operation_context_impl.h" diff --git a/src/mongo/db/db.h b/src/mongo/db/db.h index c9a3605c8df..c0a20aec069 100644 --- a/src/mongo/db/db.h +++ b/src/mongo/db/db.h @@ -33,7 +33,6 @@ #include "mongo/db/client.h" #include "mongo/db/curop.h" #include "mongo/db/catalog/database_holder.h" -#include "mongo/db/pdfile.h" #include "mongo/util/net/message.h" namespace mongo { diff --git a/src/mongo/db/dbcommands_admin.cpp b/src/mongo/db/dbcommands_admin.cpp index b28ddcdf1fd..7e3aa16cff7 100644 --- a/src/mongo/db/dbcommands_admin.cpp +++ b/src/mongo/db/dbcommands_admin.cpp @@ -52,7 +52,6 @@ #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/storage_options.h" #include "mongo/scripting/engine.h" diff --git a/src/mongo/db/dbcommands_generic.cpp b/src/mongo/db/dbcommands_generic.cpp index 5d6d967a017..427294ec90b 100644 --- a/src/mongo/db/dbcommands_generic.cpp +++ b/src/mongo/db/dbcommands_generic.cpp @@ -48,7 +48,6 @@ #include "mongo/db/json.h" #include "mongo/db/lasterror.h" #include "mongo/db/log_process_details.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/multicmd.h" #include "mongo/db/repl/write_concern.h" #include "mongo/db/server_options.h" diff --git a/src/mongo/db/dbeval.cpp b/src/mongo/db/dbeval.cpp index 1096f3570d2..f2076e97178 100644 --- a/src/mongo/db/dbeval.cpp +++ b/src/mongo/db/dbeval.cpp @@ -40,7 +40,6 @@ #include "mongo/db/introspect.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" -#include "mongo/db/pdfile.h" #include "mongo/scripting/engine.h" namespace mongo { diff --git a/src/mongo/db/driverHelpers.cpp b/src/mongo/db/driverHelpers.cpp index 5f140b6e069..3b37a39cafa 100644 --- a/src/mongo/db/driverHelpers.cpp +++ b/src/mongo/db/driverHelpers.cpp @@ -45,7 +45,6 @@ #include "mongo/db/commands.h" #include "mongo/db/curop.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/scripting/engine.h" #include "mongo/util/background.h" diff --git a/src/mongo/db/exec/2dcommon.h b/src/mongo/db/exec/2dcommon.h index 67307038482..9283e327ee0 100644 --- a/src/mongo/db/exec/2dcommon.h +++ b/src/mongo/db/exec/2dcommon.h @@ -30,7 +30,6 @@ #include "mongo/db/geo/core.h" #include "mongo/db/geo/hash.h" #include "mongo/db/geo/shapes.h" -#include "mongo/db/pdfile.h" #include "mongo/db/index/2d_access_method.h" diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp index c8c0ff105dd..8718786f0c8 100644 --- a/src/mongo/db/exec/fetch.cpp +++ b/src/mongo/db/exec/fetch.cpp @@ -31,7 +31,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/exec/filter.h" #include "mongo/db/exec/working_set_common.h" -#include "mongo/db/pdfile.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/exec/working_set_common.cpp b/src/mongo/db/exec/working_set_common.cpp index a0652ea5fc0..bd228f6e603 100644 --- a/src/mongo/db/exec/working_set_common.cpp +++ b/src/mongo/db/exec/working_set_common.cpp @@ -29,7 +29,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/exec/working_set.h" #include "mongo/db/exec/working_set_common.h" -#include "mongo/db/pdfile.h" namespace mongo { diff --git a/src/mongo/db/fts/fts_command_mongod.cpp b/src/mongo/db/fts/fts_command_mongod.cpp index 0a26ddc6240..ababd3e16bf 100644 --- a/src/mongo/db/fts/fts_command_mongod.cpp +++ b/src/mongo/db/fts/fts_command_mongod.cpp @@ -34,7 +34,6 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/fts/fts_command.h" #include "mongo/db/fts/fts_util.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/get_runner.h" #include "mongo/db/query/type_explain.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/geo/haystack.cpp b/src/mongo/db/geo/haystack.cpp index db88a10a35c..27cc3cb0633 100644 --- a/src/mongo/db/geo/haystack.cpp +++ b/src/mongo/db/geo/haystack.cpp @@ -38,7 +38,6 @@ #include "mongo/db/index/index_access_method.h" #include "mongo/db/index_names.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/commands.h" diff --git a/src/mongo/db/index/2d_access_method.cpp b/src/mongo/db/index/2d_access_method.cpp index c7b85ca1c28..c1af261b3b1 100644 --- a/src/mongo/db/index/2d_access_method.cpp +++ b/src/mongo/db/index/2d_access_method.cpp @@ -37,7 +37,6 @@ #include "mongo/db/index/expression_keys_private.h" #include "mongo/db/index/expression_params.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" namespace mongo { diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp index 7f7de5072c2..f417ab3b085 100644 --- a/src/mongo/db/index/btree_access_method.cpp +++ b/src/mongo/db/index/btree_access_method.cpp @@ -34,7 +34,6 @@ #include "mongo/db/index/btree_index_cursor.h" #include "mongo/db/jsobj.h" #include "mongo/db/keypattern.h" -#include "mongo/db/pdfile.h" #include "mongo/db/pdfile_private.h" namespace mongo { diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp index 0b27f41aa4f..0e09b1cb98a 100644 --- a/src/mongo/db/index/btree_based_access_method.cpp +++ b/src/mongo/db/index/btree_based_access_method.cpp @@ -37,7 +37,6 @@ #include "mongo/db/index/btree_index_cursor.h" #include "mongo/db/jsobj.h" #include "mongo/db/keypattern.h" -#include "mongo/db/pdfile.h" #include "mongo/db/pdfile_private.h" #include "mongo/db/server_parameters.h" #include "mongo/db/operation_context.h" diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp index e34ced1f2aa..02112d39f6f 100644 --- a/src/mongo/db/index/haystack_access_method.cpp +++ b/src/mongo/db/index/haystack_access_method.cpp @@ -34,7 +34,6 @@ #include "mongo/db/index/expression_params.h" #include "mongo/db/index/haystack_access_method_internal.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/internal_plans.h" namespace mongo { diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp index 9226866c8a4..c85c6b66f3f 100644 --- a/src/mongo/db/index_rebuilder.cpp +++ b/src/mongo/db/index_rebuilder.cpp @@ -35,7 +35,6 @@ #include "mongo/db/catalog/database_catalog_entry.h" #include "mongo/db/client.h" #include "mongo/db/instance.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/rs.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage/storage_engine.h" diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp index fe55d39de5a..667964aee1a 100644 --- a/src/mongo/db/introspect.cpp +++ b/src/mongo/db/introspect.cpp @@ -38,7 +38,6 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/introspect.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/storage_options.h" #include "mongo/db/catalog/collection.h" #include "mongo/util/goodies.h" diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 0919eef3599..c40bce96687 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -37,7 +37,6 @@ #include "mongo/db/auth/authorization_manager.h" #include "mongo/db/auth/authorization_manager_global.h" #include "mongo/db/instance.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/server_options.h" #include "mongo/db/server_options_helpers.h" diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp index 963109b2537..8e63b6dc5ee 100644 --- a/src/mongo/db/ops/update.cpp +++ b/src/mongo/db/ops/update.cpp @@ -43,7 +43,6 @@ #include "mongo/db/ops/update_driver.h" #include "mongo/db/ops/update_executor.h" #include "mongo/db/ops/update_lifecycle.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/get_runner.h" #include "mongo/db/query/lite_parsed_query.h" #include "mongo/db/query/query_planner_common.h" diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp deleted file mode 100644 index c35e68055fc..00000000000 --- a/src/mongo/db/pdfile.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// pdfile.cpp - -/** -* Copyright (C) 2008 10gen 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. -*/ - -/* -todo: -_ table scans must be sequential, not next/prev pointers -_ coalesce deleted -_ disallow system* manipulations from the database. -*/ - -#include "mongo/pch.h" - -#include "mongo/db/pdfile.h" - -#include <algorithm> -#include <boost/filesystem/operations.hpp> -#include <boost/optional/optional.hpp> -#include <list> - -#include "mongo/base/counter.h" -#include "mongo/base/owned_pointer_vector.h" -#include "mongo/db/audit.h" -#include "mongo/db/auth/auth_index_d.h" -#include "mongo/db/auth/user_document_parser.h" -#include "mongo/db/pdfile_private.h" -#include "mongo/db/background.h" -#include "mongo/db/clientcursor.h" -#include "mongo/db/commands/server_status.h" -#include "mongo/db/curop.h" -#include "mongo/db/db.h" -#include "mongo/db/dbhelpers.h" -#include "mongo/db/index_legacy.h" -#include "mongo/db/index_names.h" -#include "mongo/db/index/index_descriptor.h" -#include "mongo/db/index/index_access_method.h" -#include "mongo/db/lasterror.h" -#include "mongo/db/namespace_string.h" -#include "mongo/db/ops/delete.h" -#include "mongo/db/repair_database.h" -#include "mongo/db/repl/oplog.h" -#include "mongo/db/storage_options.h" -#include "mongo/db/storage/storage_engine.h" -#include "mongo/db/catalog/collection.h" -#include "mongo/util/assert_util.h" -#include "mongo/util/file.h" -#include "mongo/util/file_allocator.h" -#include "mongo/util/mmap.h" -#include "mongo/util/processinfo.h" -#include "mongo/db/stats/timer_stats.h" -#include "mongo/db/stats/counters.h" -#include "mongo/db/operation_context_impl.h" - -namespace mongo { - - /* ----------------------------------------- */ - string pidfilepath; - - DatabaseHolder _dbHolder; - - DatabaseHolder& dbHolder() { - return _dbHolder; - } - - /*---------------------------------------------------------------------*/ - - /** { ..., capped: true, size: ..., max: ... } - * @param createDefaultIndexes - if false, defers id (and other) index creation. - * @return true if successful - */ - Status userCreateNS( OperationContext* txn, - Database* db, - const StringData& ns, - BSONObj options, - bool logForReplication, - bool createDefaultIndexes ) { - - invariant( db ); - - LOG(1) << "create collection " << ns << ' ' << options; - - if ( !NamespaceString::validCollectionComponent(ns) ) - return Status( ErrorCodes::InvalidNamespace, - str::stream() << "invalid ns: " << ns ); - - Collection* collection = db->getCollection( txn, ns ); - - if ( collection ) - return Status( ErrorCodes::NamespaceExists, - "collection already exists" ); - - CollectionOptions collectionOptions; - Status status = collectionOptions.parse( options ); - if ( !status.isOK() ) - return status; - - invariant( db->createCollection( txn, ns, collectionOptions, true, createDefaultIndexes ) ); - - if ( logForReplication ) { - if ( options.getField( "create" ).eoo() ) { - BSONObjBuilder b; - b << "create" << nsToCollectionSubstring( ns ); - b.appendElements( options ); - options = b.obj(); - } - string logNs = nsToDatabase(ns) + ".$cmd"; - repl::logOp(txn, "c", logNs.c_str(), options); - } - - return Status::OK(); - } - - void dropAllDatabasesExceptLocal(OperationContext* txn) { - Lock::GlobalWrite lk(txn->lockState()); - - vector<string> n; - globalStorageEngine->listDatabases( &n ); - if( n.size() == 0 ) return; - log() << "dropAllDatabasesExceptLocal " << n.size() << endl; - for( vector<string>::iterator i = n.begin(); i != n.end(); i++ ) { - if( *i != "local" ) { - Client::Context ctx(*i); - dropDatabase(txn, ctx.db()); - } - } - } - - void dropDatabase(OperationContext* txn, Database* db ) { - invariant( db ); - - string name = db->name(); // just to have safe - LOG(1) << "dropDatabase " << name << endl; - - txn->lockState()->assertWriteLocked( name ); - - BackgroundOperation::assertNoBgOpInProgForDb(name.c_str()); - - audit::logDropDatabase( currentClient.get(), name ); - - // Not sure we need this here, so removed. If we do, we need to move it down - // within other calls both (1) as they could be called from elsewhere and - // (2) to keep the lock order right - groupcommitmutex must be locked before - // mmmutex (if both are locked). - // - // RWLockRecursive::Exclusive lk(MongoFile::mmmutex); - - txn->recoveryUnit()->syncDataAndTruncateJournal(); - - Database::closeDatabase(txn, name ); - db = 0; // d is now deleted - - _deleteDataFiles( name ); - } - -} // namespace mongo diff --git a/src/mongo/db/pdfile.h b/src/mongo/db/pdfile.h deleted file mode 100644 index a81ca752ade..00000000000 --- a/src/mongo/db/pdfile.h +++ /dev/null @@ -1,62 +0,0 @@ -/** -* Copyright (C) 2008 10gen 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. -*/ - -/* pdfile.h - - Files: - database.ns - namespace index - database.1 - data files - database.2 - ... -*/ - -#pragma once - -#include <string> - -#include "mongo/base/status.h" -#include "mongo/db/jsobj.h" - -namespace mongo { - - class Database; - class OperationContext; - - void dropDatabase(OperationContext* txn, Database* db ); - - void dropAllDatabasesExceptLocal(OperationContext* txn); - - Status userCreateNS( OperationContext* txn, - Database* db, - const StringData& ns, - BSONObj options, - bool logForReplication, - bool createDefaultIndexes = true ); - - -} // namespace mongo diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index 625a5f1d0b7..6f62767f999 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -34,7 +34,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" #include "mongo/db/instance.h" -#include "mongo/db/pdfile.h" #include "mongo/db/pipeline/document_source.h" #include "mongo/db/pipeline/pipeline.h" #include "mongo/db/query/get_runner.h" diff --git a/src/mongo/db/query/idhack_runner.cpp b/src/mongo/db/query/idhack_runner.cpp index 668707593a1..bcc6ac18810 100644 --- a/src/mongo/db/query/idhack_runner.cpp +++ b/src/mongo/db/query/idhack_runner.cpp @@ -36,7 +36,6 @@ #include "mongo/db/index/btree_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/type_explain.h" #include "mongo/db/query/plan_executor.h" diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp index 20885f39e2c..f045a6155f7 100644 --- a/src/mongo/db/repl/rs_initialsync.cpp +++ b/src/mongo/db/repl/rs_initialsync.cpp @@ -38,7 +38,6 @@ #include "mongo/db/dbhelpers.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/operation_context_impl.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/bgsync.h" #include "mongo/db/repl/initial_sync.h" #include "mongo/db/repl/initial_sync.h" diff --git a/src/mongo/db/repl/sync.cpp b/src/mongo/db/repl/sync.cpp index 45940715004..153e7e048e2 100644 --- a/src/mongo/db/repl/sync.cpp +++ b/src/mongo/db/repl/sync.cpp @@ -34,7 +34,6 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/client.h" #include "mongo/db/diskloc.h" -#include "mongo/db/pdfile.h" #include "mongo/db/repl/oplogreader.h" #include "mongo/db/catalog/collection.h" #include "mongo/util/assert_util.h" diff --git a/src/mongo/db/stats/counters.h b/src/mongo/db/stats/counters.h index 0313ff99e63..805df221036 100644 --- a/src/mongo/db/stats/counters.h +++ b/src/mongo/db/stats/counters.h @@ -35,7 +35,6 @@ #include "mongo/util/net/message.h" #include "mongo/util/processinfo.h" #include "mongo/util/concurrency/spin_lock.h" -#include "mongo/db/pdfile.h" namespace mongo { diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp index 452a227f0e8..9d4e679808a 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp @@ -47,7 +47,6 @@ #include "mongo/db/storage/mmap_v1/dur_stats.h" #include "mongo/db/storage/mmap_v1/durop.h" #include "mongo/db/storage/mmap_v1/durable_mapped_file.h" -#include "mongo/db/pdfile.h" #include "mongo/db/storage_options.h" #include "mongo/util/bufreader.h" #include "mongo/util/checksum.h" diff --git a/src/mongo/dbtests/pdfiletests.cpp b/src/mongo/dbtests/pdfiletests.cpp index 0db3cfc2052..55a6ee59b29 100644 --- a/src/mongo/dbtests/pdfiletests.cpp +++ b/src/mongo/dbtests/pdfiletests.cpp @@ -33,7 +33,6 @@ #include "mongo/db/db.h" #include "mongo/db/json.h" -#include "mongo/db/pdfile.h" #include "mongo/db/ops/insert.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/storage/mmap_v1/data_file.h" diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp index 529476b94b1..ab7ff6a5457 100644 --- a/src/mongo/dbtests/query_stage_and.cpp +++ b/src/mongo/dbtests/query_stage_and.cpp @@ -42,7 +42,6 @@ #include "mongo/db/instance.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/catalog/collection.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp index f1f6e33e9ed..6d64cd26bf0 100644 --- a/src/mongo/dbtests/query_stage_collscan.cpp +++ b/src/mongo/dbtests/query_stage_collscan.cpp @@ -38,7 +38,6 @@ #include "mongo/db/instance.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/storage/extent.h" #include "mongo/db/storage/extent_manager.h" diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp index ac0e7e80705..eaecb772981 100644 --- a/src/mongo/dbtests/query_stage_count.cpp +++ b/src/mongo/dbtests/query_stage_count.cpp @@ -38,7 +38,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/operation_context_impl.h" -#include "mongo/db/pdfile.h" #include "mongo/db/catalog/collection.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/fail_point.h" diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp index 2fa7b25b377..272e3ad822e 100644 --- a/src/mongo/dbtests/query_stage_fetch.cpp +++ b/src/mongo/dbtests/query_stage_fetch.cpp @@ -40,7 +40,6 @@ #include "mongo/db/instance.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/catalog/collection.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/dbtests/query_stage_keep.cpp b/src/mongo/dbtests/query_stage_keep.cpp index c56f8ae7c71..5959ee17bee 100644 --- a/src/mongo/dbtests/query_stage_keep.cpp +++ b/src/mongo/dbtests/query_stage_keep.cpp @@ -41,7 +41,6 @@ #include "mongo/db/instance.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/pdfile.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/catalog/collection.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/dbtests/runner_registry.cpp b/src/mongo/dbtests/runner_registry.cpp index ce84f65f446..2964e14be00 100644 --- a/src/mongo/dbtests/runner_registry.cpp +++ b/src/mongo/dbtests/runner_registry.cpp @@ -40,7 +40,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/operation_context_impl.h" -#include "mongo/db/pdfile.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/query/single_solution_runner.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp index eff7a2481fb..215ce852d59 100644 --- a/src/mongo/s/config.cpp +++ b/src/mongo/s/config.cpp @@ -36,7 +36,6 @@ #include "mongo/client/dbclientcursor.h" #include "mongo/db/client.h" #include "mongo/db/lasterror.h" -#include "mongo/db/pdfile.h" #include "mongo/db/write_concern.h" #include "mongo/s/chunk.h" #include "mongo/s/chunk_version.h" |