summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/kv
diff options
context:
space:
mode:
authorXiangyu Yao <xiangyu.yao@mongodb.com>2018-11-28 19:12:16 -0500
committerXiangyu Yao <xiangyu.yao@mongodb.com>2018-11-30 13:05:09 -0500
commite0be8ba5aa04df21f6a9a42578a349a4c303776d (patch)
tree24308277dda3cf06f4870761beb9a817c1f511fd /src/mongo/db/storage/kv
parent839d887bbb5c857c80ad50eb329c0017cb69190d (diff)
downloadmongo-e0be8ba5aa04df21f6a9a42578a349a4c303776d.tar.gz
SERVER-35732 Fix dbStats.fsUsedSize behavior for database with hyphenated names
Diffstat (limited to 'src/mongo/db/storage/kv')
-rw-r--r--src/mongo/db/storage/kv/kv_catalog.cpp8
-rw-r--r--src/mongo/db/storage/kv/kv_catalog.h2
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.cpp4
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.h2
4 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp
index 28736f8598e..b28f509e80a 100644
--- a/src/mongo/db/storage/kv/kv_catalog.cpp
+++ b/src/mongo/db/storage/kv/kv_catalog.cpp
@@ -347,6 +347,14 @@ std::string KVCatalog::newTempIdent() {
return buf.str();
}
+std::string KVCatalog::getFilesystemPathForDb(const std::string& dbName) const {
+ if (_directoryPerDb) {
+ return storageGlobalParams.dbpath + '/' + escapeDbName(dbName);
+ } else {
+ return storageGlobalParams.dbpath;
+ }
+}
+
std::string KVCatalog::_newUniqueIdent(StringData ns, const char* kind) {
// If this changes to not put _rand at the end, _hasEntryCollidingWithRand will need fixing.
StringBuilder buf;
diff --git a/src/mongo/db/storage/kv/kv_catalog.h b/src/mongo/db/storage/kv/kv_catalog.h
index bc99e4e1e7c..fe670d3795a 100644
--- a/src/mongo/db/storage/kv/kv_catalog.h
+++ b/src/mongo/db/storage/kv/kv_catalog.h
@@ -113,6 +113,8 @@ public:
*/
StatusWith<std::string> newOrphanedIdent(OperationContext* opCtx, std::string ident);
+ std::string getFilesystemPathForDb(const std::string& dbName) const;
+
/**
* Generate a temporary ident name.
*/
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp
index 7738d4eb160..11f4d4f125d 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.cpp
+++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp
@@ -455,6 +455,10 @@ KVStorageEngine::reconcileCatalogAndIdents(OperationContext* opCtx) {
return ret;
}
+std::string KVStorageEngine::getFilesystemPathForDb(const std::string& dbName) const {
+ return _catalog->getFilesystemPathForDb(dbName);
+}
+
void KVStorageEngine::cleanShutdown() {
for (DBMap::const_iterator it = _dbs.begin(); it != _dbs.end(); ++it) {
delete it->second;
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h
index 4da67bc631f..0b33e837e40 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.h
+++ b/src/mongo/db/storage/kv/kv_storage_engine.h
@@ -187,6 +187,8 @@ public:
StatusWith<std::vector<StorageEngine::CollectionIndexNamePair>> reconcileCatalogAndIdents(
OperationContext* opCtx) override;
+ std::string getFilesystemPathForDb(const std::string& dbName) const override;
+
/**
* When loading after an unclean shutdown, this performs cleanup on the KVCatalog and unsets the
* startingAfterUncleanShutdown decoration on the global ServiceContext.