0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

add FileCreatedOp on first use of file, regardless of preexistence 180?

Previously FileCreatedOp wouldn't be done for preallocated files since they
already existed.
This commit is contained in:
Mathias Stearn 2011-03-01 18:02:38 -05:00
parent 9b534592f3
commit eede4ec2fc
4 changed files with 5 additions and 6 deletions

View File

@ -342,11 +342,7 @@ namespace mongo {
bool MongoMMF::create(string fname, unsigned long long& len, bool sequentialHint) {
setPath(fname);
bool preExisting = MemoryMappedFile::exists(fname.c_str());
_view_write = map(fname.c_str(), len, sequentialHint ? SEQUENTIAL : 0);
if( cmdLine.dur && _view_write && !preExisting ) {
getDur().createdFile(fname, len);
}
return finishOpening();
}

View File

@ -182,6 +182,7 @@ namespace mongo {
maybeMkdir();
unsigned long long l = lenForNewNsFiles;
if( f.create(pathString, l, true) ) {
getDur().createdFile(pathString, l); // always a new file
len = l;
assert( len == lenForNewNsFiles );
p = f.getView();
@ -194,6 +195,7 @@ namespace mongo {
dbexit( EXIT_FS );
}
assert( len <= 0x7fffffff );
ht = new HashTable<Namespace,NamespaceDetails>(p, (int) len, "namespace index");
if( checkNsFilesOnLoad )

View File

@ -407,7 +407,7 @@ namespace mongo {
uassert( 10084 , "can't map file memory - mongo requires 64 bit build for larger datasets", _mb != 0);
else
uassert( 10085 , "can't map file memory", _mb != 0);
header()->init(fileNo, size);
header()->init(fileNo, size, filename);
}
void MongoDataFile::flush( bool sync ) {

View File

@ -326,11 +326,12 @@ namespace mongo {
bool uninitialized() const { return version == 0; }
void init(int fileno, int filelength) {
void init(int fileno, int filelength, const char* filename) {
if ( uninitialized() ) {
if( !(filelength > 32768 ) ) {
massert(13640, str::stream() << "DataFileHeader looks corrupt at file open filelength:" << filelength << " fileno:" << fileno, false);
}
getDur().createdFile(filename, filelength);
assert( HeaderSize == 8192 );
DataFileHeader *h = getDur().writing(this);
h->fileLength = filelength;