rbd: recognize exclusive map option

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Ilya Dryomov 2017-04-23 21:49:37 +02:00
parent 15e80fa2d8
commit c72d8b0409
3 changed files with 12 additions and 3 deletions

View File

@ -484,6 +484,8 @@ Per mapping (block device) `rbd map` options:
* lock_on_read - Acquire exclusive lock on reads, in addition to writes and
discards (since 4.9).
* exclusive - Disable automatic exclusive lock transitions (since 4.12).
`rbd unmap` options:
* force - Force the unmapping of a block device that is open (since 4.9). The

View File

@ -874,7 +874,7 @@
rbd help map
usage: rbd map [--pool <pool>] [--image <image>] [--snap <snap>]
[--options <options>] [--read-only]
[--options <options>] [--read-only] [--exclusive]
<image-or-snap-spec>
Map image to a block device using the kernel.
@ -889,6 +889,7 @@
--snap arg snapshot name
-o [ --options ] arg map options
--read-only map read-only
--exclusive disable automatic exclusive lock transitions
rbd help merge-diff
usage: rbd merge-diff [--path <path>] [--no-progress]

View File

@ -133,6 +133,8 @@ static int parse_map_options(char *options)
return -EINVAL;
} else if (!strcmp(this_char, "lock_on_read")) {
put_map_option("lock_on_read", this_char);
} else if (!strcmp(this_char, "exclusive")) {
put_map_option("exclusive", this_char);
} else {
std::cerr << "rbd: unknown map option '" << this_char << "'" << std::endl;
return -EINVAL;
@ -385,7 +387,8 @@ void get_map_arguments(po::options_description *positional,
at::ARGUMENT_MODIFIER_NONE);
options->add_options()
("options,o", po::value<std::string>(), "map options")
("read-only", po::bool_switch(), "map read-only");
("read-only", po::bool_switch(), "map read-only")
("exclusive", po::bool_switch(), "disable automatic exclusive lock transitions");
}
int execute_map(const po::variables_map &vm) {
@ -404,6 +407,9 @@ int execute_map(const po::variables_map &vm) {
if (vm["read-only"].as<bool>()) {
put_map_option("rw", "ro");
}
if (vm["exclusive"].as<bool>()) {
put_map_option("exclusive", "exclusive");
}
// parse default options first so they can be overwritten by cli options
char *default_map_options = strdup(g_conf->rbd_default_map_options.c_str());
@ -503,7 +509,7 @@ int execute_unmap(const po::variables_map &vm) {
return 0;
}
Shell::SwitchArguments switched_arguments({"read-only"});
Shell::SwitchArguments switched_arguments({"read-only", "exclusive"});
Shell::Action action_show(
{"showmapped"}, {}, "Show the rbd images mapped by the kernel.", "",
&get_show_arguments, &execute_show);