[thin_pool] Implement synchronous mapping insertion and removal
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
// with thin-provisioning-tools. If not, see
|
// with thin-provisioning-tools. If not, see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "persistent-data/math_utils.h"
|
||||||
#include "thin-provisioning/thin_pool.h"
|
#include "thin-provisioning/thin_pool.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -336,3 +337,39 @@ thin_pool::write_changed_details()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
void
|
||||||
|
thin_provisioning::process_read(thin::ptr td, thin_pool::ptr tp,
|
||||||
|
sector_t offset)
|
||||||
|
{
|
||||||
|
block_address blocknr = base::div_up<sector_t>(offset, tp->get_data_block_size());
|
||||||
|
td->lookup(blocknr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
thin_provisioning::process_write(thin::ptr td, thin_pool::ptr tp,
|
||||||
|
sector_t offset)
|
||||||
|
{
|
||||||
|
block_address blocknr = base::div_up<sector_t>(offset, tp->get_data_block_size());
|
||||||
|
thin::maybe_address result = td->lookup(blocknr);
|
||||||
|
if (!!result && !result->shared_)
|
||||||
|
return;
|
||||||
|
// TODO: handle out-of-space errors
|
||||||
|
block_address data_block = tp->alloc_data_block();
|
||||||
|
td->insert(blocknr, data_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
thin_provisioning::process_discard(thin::ptr td, thin_pool::ptr tp,
|
||||||
|
sector_t offset)
|
||||||
|
{
|
||||||
|
block_address blocknr = base::div_up<sector_t>(offset, tp->get_data_block_size());
|
||||||
|
thin::maybe_address result = td->lookup(blocknr);
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
td->remove(blocknr);
|
||||||
|
if (!result->shared_)
|
||||||
|
tp->free_data_block(result->block_);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
@@ -109,6 +109,10 @@ namespace thin_provisioning {
|
|||||||
metadata::ptr md_;
|
metadata::ptr md_;
|
||||||
device_map thin_devices_;
|
device_map thin_devices_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void process_read(thin::ptr td, thin_pool::ptr tp, sector_t offset);
|
||||||
|
void process_write(thin::ptr td, thin_pool::ptr tp, sector_t offset);
|
||||||
|
void process_discard(thin::ptr td, thin_pool::ptr tp, sector_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user