Пример #1
0
 Extent* MmapV1ExtentManager::getExtent( const DiskLoc& loc, bool doSanityCheck ) const {
     loc.assertOk();
     Extent* e = reinterpret_cast<Extent*>( _getOpenFile( loc.a() )->p() + loc.getOfs() );
     if ( doSanityCheck )
         e->assertOk();
     return e;
 }
Пример #2
0
    DiskLoc MmapV1ExtentManager::_createExtent( OperationContext* txn,
                                                int size,
                                                bool enforceQuota ) {
        size = quantizeExtentSize( size );

        if ( size > maxSize() )
            size = maxSize();

        verify( size < DataFile::maxSize() );

        for ( int i = numFiles() - 1; i >= 0; i-- ) {
            DataFile* f = _getOpenFile(i);
            invariant(f);

            if ( f->getHeader()->unusedLength >= size ) {
                return _createExtentInFile( txn, i, f, size, enforceQuota );
            }
        }

        _checkQuota( enforceQuota, numFiles() );

        // no space in an existing file
        // allocate files until we either get one big enough or hit maxSize
        for ( int i = 0; i < 8; i++ ) {
            DataFile* f = _addAFile( txn, size, false );

            if ( f->getHeader()->unusedLength >= size ) {
                return _createExtentInFile( txn, numFiles() - 1, f, size, enforceQuota );
            }

        }

        // callers don't check for null return code, so assert
        msgasserted(14810, "couldn't allocate space for a new extent" );
    }
Пример #3
0
    Record* ExtentManager::recordFor( const DiskLoc& loc ) const {
        loc.assertOk();
        const DataFile* df = _getOpenFile( loc.a() );

        int ofs = loc.getOfs();
        if ( ofs < DataFileHeader::HeaderSize ) {
            df->badOfs(ofs); // will uassert - external call to keep out of the normal code path
        }

        return reinterpret_cast<Record*>( df->p() + ofs );
    }