question: private void writeMetaBits ( ) throws IOException { final byte buf [ ] = genMetabitsData ( ) ; final long addr = m_metaBitsAddr < 0 ? physicalAddress ( m_metaBitsAddr ) : ( ( long ) m_metaBitsAddr ) << ALLOCATION_SCALEUP ; if ( addr == 0 ) { throw new IllegalStateException ( "Invalid metabits address: " + m_metaBitsAddr ) ; } assert addr > 0 ; try { if ( log . isDebugEnabled ( ) ) log . debug ( "writing metabits at: " + addr ) ; m_writeCacheService . write ( addr , ByteBuffer . wrap ( buf ) , 0 , false , m_metaBitsAddr < 0 ? m_metaBitsAddr : 0 ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } }
target:  writeMetaBits must be called after all allocations have been made, the last one being the allocation for the metabits themselves (allowing for an extension!). Ticket #936: The meta-bits allocation is currently made from the FixedAllocator region. This works well providing the required allocation bits is less than the maximum FixedAllocator slot size.  While this is neat, there are problems at scale for maximum slot sizes less than 64K. To address the 8K bits in a 1K alloctor, 13 bits are required, this leaves 19 bits to index an Allocator, or 18 bits without the sign => 256K maximum index. To be able to commit changes to all 256K allocators requires 512K metabits => 64K bytes. We would like to associate the 64K allocations with the root block, so a single 128K allocation would be split into 64K demi-spaces, one for each root block. While a negative address indicates a standard RW allocation a ositive address can be used to indicate an explicitly allocated region. The trick is to ensure that the region is allocated on a 128K boundary, then the lower bits can indicate which demi-space is used with a simple XOR. Note that we must ensure that any previous demi-space write is removed from the WCS.