[thin_generate_metadata] Support device deletion
This commit is contained in:
parent
a5614f7db2
commit
89409927b4
@ -39,6 +39,7 @@ namespace {
|
|||||||
METADATA_OP_OPEN,
|
METADATA_OP_OPEN,
|
||||||
METADATA_OP_CREATE_THIN,
|
METADATA_OP_CREATE_THIN,
|
||||||
METADATA_OP_CREATE_SNAP,
|
METADATA_OP_CREATE_SNAP,
|
||||||
|
METADATA_OP_DELETE_DEV,
|
||||||
METADATA_OP_LAST
|
METADATA_OP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,6 +83,11 @@ namespace {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (op == METADATA_OP_DELETE_DEV && !dev_id) {
|
||||||
|
cerr << "no device id provided." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +112,9 @@ namespace {
|
|||||||
case flags::METADATA_OP_CREATE_SNAP:
|
case flags::METADATA_OP_CREATE_SNAP:
|
||||||
pool->create_snap(*fs.dev_id, *fs.origin);
|
pool->create_snap(*fs.dev_id, *fs.origin);
|
||||||
break;
|
break;
|
||||||
|
case flags::METADATA_OP_DELETE_DEV:
|
||||||
|
pool->del(*fs.dev_id);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -132,6 +141,7 @@ thin_generate_metadata_cmd::usage(std::ostream &out) const
|
|||||||
<< " {--format}\n"
|
<< " {--format}\n"
|
||||||
<< " {--create-thin} <dev-id>\n"
|
<< " {--create-thin} <dev-id>\n"
|
||||||
<< " {--create-snap} <dev-id>\n"
|
<< " {--create-snap} <dev-id>\n"
|
||||||
|
<< " {--delete} <dev-id>\n"
|
||||||
<< " {--data-block-size} <block size>\n"
|
<< " {--data-block-size} <block size>\n"
|
||||||
<< " {--nr-data-blocks} <nr>\n"
|
<< " {--nr-data-blocks} <nr>\n"
|
||||||
<< " {--origin} <origin-id>\n"
|
<< " {--origin} <origin-id>\n"
|
||||||
@ -152,6 +162,7 @@ thin_generate_metadata_cmd::run(int argc, char **argv)
|
|||||||
{ "open", no_argument, NULL, 2 },
|
{ "open", no_argument, NULL, 2 },
|
||||||
{ "create-thin", required_argument, NULL, 3 },
|
{ "create-thin", required_argument, NULL, 3 },
|
||||||
{ "create-snap", required_argument, NULL, 4 },
|
{ "create-snap", required_argument, NULL, 4 },
|
||||||
|
{ "delete", required_argument, NULL, 5 },
|
||||||
{ "data-block-size", required_argument, NULL, 101 },
|
{ "data-block-size", required_argument, NULL, 101 },
|
||||||
{ "nr-data-blocks", required_argument, NULL, 102 },
|
{ "nr-data-blocks", required_argument, NULL, 102 },
|
||||||
{ "origin", required_argument, NULL, 401 },
|
{ "origin", required_argument, NULL, 401 },
|
||||||
@ -187,6 +198,11 @@ thin_generate_metadata_cmd::run(int argc, char **argv)
|
|||||||
fs.dev_id = parse_uint64(optarg, "device id");
|
fs.dev_id = parse_uint64(optarg, "device id");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
fs.op = flags::METADATA_OP_DELETE_DEV;
|
||||||
|
fs.dev_id = parse_uint64(optarg, "device id");
|
||||||
|
break;
|
||||||
|
|
||||||
case 101:
|
case 101:
|
||||||
fs.data_block_size = parse_uint64(optarg, "data block size");
|
fs.data_block_size = parse_uint64(optarg, "data block size");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user