diff options
author | dwight <dwight@10gen.com> | 2010-11-21 19:36:40 -0500 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2010-11-21 19:36:40 -0500 |
commit | b8555c9f52288ee8417dcfe2f1dc7eee98dab205 (patch) | |
tree | ebc1fd2a7a49c81e6a4e95373a51cda3fda89bd4 /db/dur.h | |
parent | 11e47198208ae2cc22cf01084209c57100a8d843 (diff) | |
download | mongo-b8555c9f52288ee8417dcfe2f1dc7eee98dab205.tar.gz |
dur optimizations to not journal too much
Diffstat (limited to 'db/dur.h')
-rw-r--r-- | db/dur.h | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -11,12 +11,16 @@ namespace mongo { #if !defined(_DURABLE)
inline void startup() { }
- inline void* writingPtr(void *x, size_t len) { return x; }
+ inline void* writingPtr(void *x, unsigned len) { return x; }
inline DiskLoc& writingDiskLoc(DiskLoc& d) { return d; }
inline int& writingInt(int& d) { return d; }
template <typename T> inline T* writing(T *x) { return x; }
inline void assertReading(void *p) { }
template <typename T> inline T* writingNoLog(T *x) { return x; }
+ void* writingAtOffset(void *buf, unsigned ofs, unsigned len) { return buf; }
+ template <typename T>
+ inline T* alreadyDeclared(T *x) { return x; }
+ inline void declareWriteIntent(void *, unsigned) { }
#else
/** call during startup so durability module can initialize
@@ -33,7 +37,22 @@ namespace mongo { verify that your length is correct though.
*/
- void* writingPtr(void *x, size_t len);
+ /** declare intent to write to x for up to len
+ @return pointer where to write. this is modified when testIntent is true.
+ */
+ void* writingPtr(void *x, unsigned len);
+
+ /** declare write intent; should already be in the write view to work correctly when testIntent is true.
+ if you aren't, use writingPtr() instead.
+ */
+ void declareWriteIntent(void *x, unsigned len);
+
+ /** declare intent to write
+ @param ofs offset within buf at which we will write
+ @param len the length at ofs we will write
+ @return new buffer pointer. this is modified when testIntent is true.
+ */
+ void* writingAtOffset(void *buf, unsigned ofs, unsigned len);
inline DiskLoc& writingDiskLoc(DiskLoc& d) {
return *((DiskLoc*) writingPtr(&d, sizeof(d)));
@@ -43,6 +62,19 @@ namespace mongo { return *((int*) writingPtr(&d, sizeof(d)));
}
+ /** "assume i've already indicated write intent, let me write"
+ */
+ template <typename T>
+ inline
+ T* alreadyDeclared(T *x) {
+#if defined(_TESTINTENT)
+ return (T*) MongoMMF::switchToPrivateView(x);
+#else
+ return x;
+#endif
+ }
+
+ /** declare intent to write to x for sizeof(*x) */
template <typename T>
inline
T* writing(T *x) {
@@ -67,6 +99,7 @@ namespace mongo { } // namespace dur
+ /** declare that we are modifying a diskloc and this is a datafile write. */
inline DiskLoc& DiskLoc::writing() const { return dur::writingDiskLoc(*const_cast< DiskLoc * >( this )); }
}
|