From cc44652cc3c13a3cfc31631688c080bb43e5a5a2 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 25 Mar 2015 11:10:18 +0000 Subject: [PATCH] [thin_delta] support metadata snapshots --- thin-provisioning/thin_delta.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/thin-provisioning/thin_delta.cc b/thin-provisioning/thin_delta.cc index 196887d..7cb7d75 100644 --- a/thin-provisioning/thin_delta.cc +++ b/thin-provisioning/thin_delta.cc @@ -33,7 +33,7 @@ namespace local { << "Options:\n" << " {--thin1, --snap1}\n" << " {--thin2, --snap2}\n" - << " {-m, --metadata-snap}\n" + << " {-m, --metadata-snap} [block#]\n" << " {--verbose}\n" << " {-h|--help}\n" << " {-V|--version}" << endl; @@ -45,13 +45,13 @@ namespace local { exit(1); } - uint64_t parse_snap(string const &str) { + uint64_t parse_int(string const &str, string const &desc) { try { return boost::lexical_cast(str); } catch (...) { ostringstream out; - out << "Couldn't parse snapshot designator: '" << str << "'"; + out << "Couldn't parse " << desc << ": '" << str << "'"; die(out.str()); } @@ -68,6 +68,7 @@ namespace local { } boost::optional dev; + boost::optional metadata_snap; boost::optional snap1; boost::optional snap2; bool verbose; @@ -535,7 +536,7 @@ namespace local { block_manager<>::ptr bm = open_bm(*fs.dev); transaction_manager::ptr tm = open_tm(bm); - sb = read_superblock(bm); + sb = fs.metadata_snap ? read_superblock(bm, *fs.metadata_snap) : read_superblock(bm); data_sm = open_disk_sm(*tm, static_cast(&sb.data_space_map_root_)); dev_tree dtree(*tm, sb.data_mapping_root_, @@ -638,15 +639,15 @@ int thin_delta_main(int argc, char **argv) return 0; case 1: - fs.snap1 = app.parse_snap(optarg); + fs.snap1 = app.parse_int(optarg, "thin id 1"); break; case 2: - fs.snap2 = app.parse_snap(optarg); + fs.snap2 = app.parse_int(optarg, "thin id 2"); break; case 'm': - abort(); + fs.metadata_snap = app.parse_int(optarg, "metadata snapshot block"); break; case 4: