Skip to content

Commit 9c0c4ff

Browse files
committed
SERVER-13635: ExtentManager no longer needed for stats in Database
1 parent d722cd3 commit 9c0c4ff

File tree

6 files changed

+38
-25
lines changed

6 files changed

+38
-25
lines changed

src/mongo/db/catalog/database.cpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@
4747
#include "mongo/db/instance.h"
4848
#include "mongo/db/introspect.h"
4949
#include "mongo/db/pdfile.h"
50-
#include "mongo/db/query/internal_plans.h"
51-
#include "mongo/db/ops/delete.h"
5250
#include "mongo/db/server_parameters.h"
53-
#include "mongo/db/storage/data_file.h"
54-
#include "mongo/db/storage/extent.h"
55-
#include "mongo/db/storage/extent_manager.h"
56-
#include "mongo/db/storage/mmap_v1/mmap_v1_engine.h"
57-
#include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h"
51+
#include "mongo/db/storage/data_file.h" //XXX
52+
#include "mongo/db/storage/mmap_v1/mmap_v1_engine.h" //XXX
53+
#include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h" //XXX
5854
#include "mongo/db/storage_options.h"
5955
#include "mongo/db/catalog/collection.h"
6056

@@ -256,11 +252,8 @@ namespace mongo {
256252
}
257253

258254
void Database::getStats( OperationContext* opCtx, BSONObjBuilder* output, double scale ) {
259-
bool empty = _dbEntry->isEmpty() || getExtentManager()->numFiles() == 0;
260-
261255
list<string> collections;
262-
if ( !empty )
263-
_dbEntry->getCollectionNamespaces( &collections );
256+
_dbEntry->getCollectionNamespaces( &collections );
264257

265258
long long ncollections = 0;
266259
long long objects = 0;
@@ -298,16 +291,8 @@ namespace mongo {
298291
output->appendNumber( "numExtents" , numExtents );
299292
output->appendNumber( "indexes" , indexes );
300293
output->appendNumber( "indexSize" , indexSize / scale );
301-
_dbEntry->appendExtraStats( output, scale );
302-
303-
BSONObjBuilder dataFileVersion( output->subobjStart( "dataFileVersion" ) );
304-
if ( !empty ) {
305-
int major, minor;
306-
getFileFormat( opCtx, &major, &minor );
307-
dataFileVersion.append( "major", major );
308-
dataFileVersion.append( "minor", minor );
309-
}
310-
dataFileVersion.done();
294+
295+
_dbEntry->appendExtraStats( opCtx, output, scale );
311296
}
312297

313298
Status Database::dropCollection( OperationContext* txn, const StringData& fullns ) {

src/mongo/db/catalog/database_catalog_entry.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ namespace mongo {
5252

5353
virtual bool isEmpty() const = 0;
5454

55-
virtual void appendExtraStats( BSONObjBuilder* out, double scale ) const = 0;
55+
virtual void appendExtraStats( OperationContext* opCtx,
56+
BSONObjBuilder* out,
57+
double scale ) const = 0;
5658

5759
// ----
5860

5961
virtual void getCollectionNamespaces( std::list<std::string>* out ) const = 0;
6062

61-
virtual Status dropCollection( OperationContext* txn, const StringData& ns ) = 0;
63+
virtual Status dropCollection( OperationContext* opCtx,
64+
const StringData& ns ) = 0;
6265

6366
private:
6467
std::string _name;

src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ namespace mongo {
288288
return Status::OK();
289289
}
290290

291-
void MMAP1DatabaseCatalogEntry::appendExtraStats( BSONObjBuilder* output, double scale ) const {
291+
void MMAP1DatabaseCatalogEntry::appendExtraStats( OperationContext* opCtx,
292+
BSONObjBuilder* output,
293+
double scale ) const {
292294
if ( isEmpty() ) {
293295
output->appendNumber( "fileSize", 0 );
294296
}
@@ -306,6 +308,18 @@ namespace mongo {
306308
extentFreeList.appendNumber( "totalSize",
307309
static_cast<long long>( freeListSpace / scale ) );
308310
extentFreeList.done();
311+
312+
{
313+
314+
int major = 0;
315+
int minor = 0;
316+
_extentManager.getFileFormat( opCtx, &major, &minor );
317+
318+
BSONObjBuilder dataFileVersion( output->subobjStart( "dataFileVersion" ) );
319+
dataFileVersion.append( "major", major );
320+
dataFileVersion.append( "minor", minor );
321+
dataFileVersion.done();
322+
}
309323
}
310324

311325
}

src/mongo/db/storage/mmap_v1/mmap_v1_engine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ namespace mongo {
6161
bool exists() const { return _namespaceIndex.pathExists(); }
6262
bool isEmpty() const { return !_namespaceIndex.allocated(); }
6363

64-
virtual void appendExtraStats( BSONObjBuilder* out, double scale ) const;
64+
virtual void appendExtraStats( OperationContext* opCtx,
65+
BSONObjBuilder* out,
66+
double scale ) const;
6567

6668
Status createCollection( OperationContext* txn,
6769
const StringData& ns,

src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,11 @@ namespace mongo {
552552
MAdvise::Sequential );
553553
}
554554

555+
void MmapV1ExtentManager::getFileFormat( OperationContext* txn, int* major, int* minor ) const {
556+
if ( numFiles() == 0 )
557+
return;
558+
const DataFile* df = _getOpenFile( 0 );
559+
*major = df->getHeader()->version;
560+
*minor = df->getHeader()->versionMinor;
561+
}
555562
}

src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ namespace mongo {
143143
*/
144144
Extent* getExtent( const DiskLoc& loc, bool doSanityCheck = true ) const;
145145

146+
void getFileFormat( OperationContext* txn, int* major, int* minor ) const;
147+
146148
virtual int maxSize() const;
147149

148150

0 commit comments

Comments
 (0)