コード例 #1
0
ServerBlock* DiskBackedBlockMap::get_block_for_writing(const BlockId& block_id){
	/** If block is not in block map, allocate space for it
	 * Otherwise, if the block is not in memory, allocate space for it.
	 * Set in_memory and dirty_flag
	 */
	ServerBlock* block = block_map_.block(block_id);
	size_t block_size = sip_tables_.block_size(block_id);
	if (block == NULL) {
		std::stringstream msg;
		msg << "S " << sip_mpi_attr_.global_rank();
		msg << " : getting uninitialized block " << block_id << ".  Creating zero block for writing"<< std::endl;
		SIP_LOG(std::cout << msg.str() << std::flush);
		block = allocate_block(NULL, block_size);
	    block_map_.insert_block(block_id, block);
	} else {
		if (!block->is_in_memory())
			block->allocate_in_memory_data();
	}

	block->set_in_memory();
	block->set_dirty();

	policy_.touch(block_id);

	return block;
}