[thin tools] Change the metadata contructors to take a block_manager<>::ptr

Also check any metadata snap passed in matches what's in the superblock.
This commit is contained in:
Joe Thornber
2015-12-14 15:29:57 +00:00
parent 2b12854ecd
commit 30a3bf67d1
6 changed files with 46 additions and 93 deletions

View File

@@ -6,6 +6,7 @@
#undef BLOCK_SIZE
#include "persistent-data/file_utils.h"
#include "thin-provisioning/commands.h"
#include "metadata.h"
#include "version.h"
@@ -118,7 +119,8 @@ namespace {
int trim(string const &metadata_dev, string const &data_dev) {
// We can trim any block that has zero count in the data
// space map.
metadata md(metadata_dev, 0);
block_manager<>::ptr bm = open_bm(metadata_dev, block_manager<>::READ_ONLY);
metadata md(bm);
if (!md.data_sm_->get_nr_free())
return 0;