From c72d8b040902aba9133fb7f4633808cb2d632872 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Sun, 23 Apr 2017 21:49:37 +0200 Subject: [PATCH] rbd: recognize exclusive map option Signed-off-by: Ilya Dryomov --- doc/man/8/rbd.rst | 2 ++ src/test/cli/rbd/help.t | 3 ++- src/tools/rbd/action/Kernel.cc | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/man/8/rbd.rst b/doc/man/8/rbd.rst index a3471ffc10c9b..d821c3de4866b 100644 --- a/doc/man/8/rbd.rst +++ b/doc/man/8/rbd.rst @@ -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 diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t index 8d4d5f59c3c43..e8bbb2d1353a0 100644 --- a/src/test/cli/rbd/help.t +++ b/src/test/cli/rbd/help.t @@ -874,7 +874,7 @@ rbd help map usage: rbd map [--pool ] [--image ] [--snap ] - [--options ] [--read-only] + [--options ] [--read-only] [--exclusive] 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 ] [--no-progress] diff --git a/src/tools/rbd/action/Kernel.cc b/src/tools/rbd/action/Kernel.cc index 3db901d3da75b..336dd597d86b0 100644 --- a/src/tools/rbd/action/Kernel.cc +++ b/src/tools/rbd/action/Kernel.cc @@ -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(), "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()) { put_map_option("rw", "ro"); } + if (vm["exclusive"].as()) { + 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); -- 2.39.5