summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-05-09 14:18:50 -0400
committerEliot Horowitz <eliot@10gen.com>2014-05-09 16:40:07 -0400
commitec8a13b45afa4fb3e7b465f975480319700d77c9 (patch)
tree12e0301e6cca891e70d81a2c303427527706b407 /src/mongo/db/storage
parent5e60ec670eb67680c08656367e207fa90a80e459 (diff)
downloadmongo-ec8a13b45afa4fb3e7b465f975480319700d77c9.tar.gz
SERVER-13635: pull out MAdvise interface, prove capped collection can compile in unit test
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r--src/mongo/db/storage/extent_manager.h7
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp19
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h3
3 files changed, 29 insertions, 0 deletions
diff --git a/src/mongo/db/storage/extent_manager.h b/src/mongo/db/storage/extent_manager.h
index f4bb4c1a8c5..6b8c997dfce 100644
--- a/src/mongo/db/storage/extent_manager.h
+++ b/src/mongo/db/storage/extent_manager.h
@@ -146,6 +146,13 @@ namespace mongo {
* quantizes extent size to >= min + page boundary
*/
virtual int quantizeExtentSize( int size ) const;
+
+ enum HintType { Sequential, Random };
+ class CacheHint {
+ public:
+ virtual ~CacheHint(){}
+ };
+ virtual CacheHint* cacheHint( const DiskLoc& extentLoc, const HintType& hint ) = 0;
};
}
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp
index 1073ba4e746..84bfae056e7 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp
@@ -532,5 +532,24 @@ namespace mongo {
log() << "end freelist" << endl;
}
+ namespace {
+ class CacheHintMadvise : public ExtentManager::CacheHint {
+ public:
+ CacheHintMadvise(void *p, unsigned len, MAdvise::Advice a)
+ : _advice( p, len, a ) {
+ }
+ private:
+ MAdvise _advice;
+ };
+ }
+
+ ExtentManager::CacheHint* MmapV1ExtentManager::cacheHint( const DiskLoc& extentLoc,
+ const ExtentManager::HintType& hint ) {
+ invariant ( hint == Sequential );
+ Extent* e = getExtent( extentLoc );
+ return new CacheHintMadvise( reinterpret_cast<void*>( e ),
+ e->length,
+ MAdvise::Sequential );
+ }
}
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h
index 8c5f4bb656d..c045a075df4 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h
@@ -145,6 +145,9 @@ namespace mongo {
virtual int maxSize() const;
+
+ virtual CacheHint* cacheHint( const DiskLoc& extentLoc, const HintType& hint );
+
private:
/**