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);
  }
}

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 ) ; } }
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 .
