[block] always use a validator, but default to a noop one
This commit is contained in:
89
block.tcc
89
block.tcc
@@ -68,58 +68,6 @@ block_manager<BlockSize>::~block_manager()
|
||||
::close(fd_);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::read_ref
|
||||
block_manager<BlockSize>::read_lock(block_address location) const
|
||||
{
|
||||
check(location);
|
||||
|
||||
buffer buf;
|
||||
read_buffer(location, buf);
|
||||
register_lock(location, READ_LOCK);
|
||||
return read_ref(
|
||||
typename block::ptr(
|
||||
new block(location, buf, lock_count_, ordinary_count_),
|
||||
bind(&block_manager::read_release, this, _1)));
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
optional<typename block_manager<BlockSize>::read_ref>
|
||||
block_manager<BlockSize>::read_try_lock(block_address location) const
|
||||
{
|
||||
return read_lock(location);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::write_ref
|
||||
block_manager<BlockSize>::write_lock(block_address location)
|
||||
{
|
||||
check(location);
|
||||
|
||||
buffer buf;
|
||||
read_buffer(location, buf);
|
||||
register_lock(location, WRITE_LOCK);
|
||||
return write_ref(
|
||||
typename block::ptr(
|
||||
new block(location, buf, lock_count_, ordinary_count_),
|
||||
bind(&block_manager::write_release, this, _1)));
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::write_ref
|
||||
block_manager<BlockSize>::write_lock_zero(block_address location)
|
||||
{
|
||||
check(location);
|
||||
|
||||
buffer buf;
|
||||
zero_buffer(buf);
|
||||
register_lock(location, WRITE_LOCK);
|
||||
typename block::ptr b(new block(location, buf, lock_count_, ordinary_count_),
|
||||
bind(&block_manager<BlockSize>::write_release, this, _1));
|
||||
|
||||
return write_ref(b);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::read_ref
|
||||
block_manager<BlockSize>::read_lock(block_address location,
|
||||
@@ -173,40 +121,6 @@ block_manager<BlockSize>::write_lock_zero(block_address location,
|
||||
return write_ref(b);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::write_ref
|
||||
block_manager<BlockSize>::superblock(block_address location)
|
||||
{
|
||||
check(location);
|
||||
|
||||
if (superblock_count_ > 0)
|
||||
throw runtime_error("already have superblock");
|
||||
|
||||
buffer buf;
|
||||
read_buffer(location, buf);
|
||||
typename block::ptr b(new block(location, buf, lock_count_, superblock_count_, true),
|
||||
bind(&block_manager::write_release, this, _1));
|
||||
register_lock(location, WRITE_LOCK);
|
||||
return write_ref(b);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::write_ref
|
||||
block_manager<BlockSize>::superblock_zero(block_address location)
|
||||
{
|
||||
check(location);
|
||||
|
||||
if (superblock_count_ > 0)
|
||||
throw runtime_error("already have superblock");
|
||||
|
||||
buffer buf;
|
||||
zero_buffer(buf);
|
||||
typename block::ptr b(new block(location, buf, lock_count_, superblock_count_, true),
|
||||
bind(&block_manager::write_release, this, _1));
|
||||
register_lock(location, WRITE_LOCK);
|
||||
return write_ref(b);
|
||||
}
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
typename block_manager<BlockSize>::write_ref
|
||||
block_manager<BlockSize>::superblock(block_address location,
|
||||
@@ -325,8 +239,7 @@ block_manager<BlockSize>::write_release(block *b)
|
||||
throw runtime_error("superblock isn't the last block");
|
||||
}
|
||||
|
||||
if (b->validator_)
|
||||
(*b->validator_)->prepare(*b);
|
||||
b->validator_->prepare(*b);
|
||||
|
||||
write_buffer(b->location_, b->data_);
|
||||
unregister_lock(b->location_, WRITE_LOCK);
|
||||
|
Reference in New Issue
Block a user