summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMykola Golub <mgolub@suse.com>2020-06-05 15:23:26 +0200
committerMykola Golub <mgolub@suse.com>2020-06-09 14:41:17 +0200
commit0d5c613f6a1b405f95a557bf5ef5ac5deff00d09 (patch)
treeec47df7badcea40ae703abab12f649984e6dbc47 /src
parentpybind/rbd: add optional flags param to create_snap (diff)
downloadceph-0d5c613f6a1b405f95a557bf5ef5ac5deff00d09.tar.xz
ceph-0d5c613f6a1b405f95a557bf5ef5ac5deff00d09.zip
rbd: add skip-quiesce and ignore-quiesce-error options
to `snap create` and `mirror image snapshot` commands. Signed-off-by: Mykola Golub <mgolub@suse.com>
Diffstat (limited to 'src')
-rw-r--r--src/test/cli/rbd/help.t38
-rw-r--r--src/tools/rbd/ArgumentTypes.cc7
-rw-r--r--src/tools/rbd/ArgumentTypes.h9
-rw-r--r--src/tools/rbd/Utils.cc18
-rw-r--r--src/tools/rbd/Utils.h3
-rw-r--r--src/tools/rbd/action/Device.cc2
-rw-r--r--src/tools/rbd/action/MirrorImage.cc16
-rw-r--r--src/tools/rbd/action/Snap.cc23
8 files changed, 93 insertions, 23 deletions
diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t
index 18d40de6724..5cf761e7526 100644
--- a/src/test/cli/rbd/help.t
+++ b/src/test/cli/rbd/help.t
@@ -602,7 +602,7 @@
--snap arg snapshot name
--read-only map read-only
--exclusive disable automatic exclusive lock transitions
- --quiesce use quiesce callbacks
+ --quiesce use quiesce hooks
--quiesce-hook arg quiesce hook path
-o [ --options ] arg device specific options
@@ -1603,19 +1603,22 @@
rbd help mirror image snapshot
usage: rbd mirror image snapshot [--pool <pool>] [--namespace <namespace>]
- [--image <image>]
+ [--image <image>] [--skip-quiesce]
+ [--ignore-quiesce-error]
<image-spec>
Create RBD mirroring image snapshot.
Positional arguments
- <image-spec> image specification
- (example: [<pool-name>/[<namespace>/]]<image-name>)
+ <image-spec> image specification
+ (example: [<pool-name>/[<namespace>/]]<image-name>)
Optional arguments
- -p [ --pool ] arg pool name
- --namespace arg namespace name
- --image arg image name
+ -p [ --pool ] arg pool name
+ --namespace arg namespace name
+ --image arg image name
+ --skip-quiesce do not run quiesce hooks
+ --ignore-quiesce-error ignore quiesce hook error
rbd help mirror image status
usage: rbd mirror image status [--pool <pool>] [--namespace <namespace>]
@@ -2102,21 +2105,26 @@
rbd help snap create
usage: rbd snap create [--pool <pool>] [--namespace <namespace>]
- [--image <image>] [--snap <snap>]
+ [--image <image>] [--snap <snap>] [--skip-quiesce]
+ [--ignore-quiesce-error] [--no-progress]
<snap-spec>
Create a snapshot.
Positional arguments
- <snap-spec> snapshot specification
- (example:
- [<pool-name>/[<namespace>/]]<image-name>@<snapshot-name>)
+ <snap-spec> snapshot specification
+ (example:
+ [<pool-name>/[<namespace>/]]<image-name>@<snapshot-nam
+ e>)
Optional arguments
- -p [ --pool ] arg pool name
- --namespace arg namespace name
- --image arg image name
- --snap arg snapshot name
+ -p [ --pool ] arg pool name
+ --namespace arg namespace name
+ --image arg image name
+ --snap arg snapshot name
+ --skip-quiesce do not run quiesce hooks
+ --ignore-quiesce-error ignore quiesce hook error
+ --no-progress disable progress output
rbd help snap limit clear
usage: rbd snap limit clear [--pool <pool>] [--namespace <namespace>]
diff --git a/src/tools/rbd/ArgumentTypes.cc b/src/tools/rbd/ArgumentTypes.cc
index 74a460fcf1e..f9c1d7cd6e9 100644
--- a/src/tools/rbd/ArgumentTypes.cc
+++ b/src/tools/rbd/ArgumentTypes.cc
@@ -321,6 +321,13 @@ void add_flatten_option(boost::program_options::options_description *opt) {
"fill clone with parent data (make it independent)");
}
+void add_snap_create_options(po::options_description *opt) {
+ opt->add_options()
+ (SKIP_QUIESCE.c_str(), po::bool_switch(), "do not run quiesce hooks")
+ (IGNORE_QUIESCE_ERROR.c_str(), po::bool_switch(),
+ "ignore quiesce hook error");
+}
+
std::string get_short_features_help(bool append_suffix) {
std::ostringstream oss;
bool first_feature = true;
diff --git a/src/tools/rbd/ArgumentTypes.h b/src/tools/rbd/ArgumentTypes.h
index 0554acceee9..793f12bbdb0 100644
--- a/src/tools/rbd/ArgumentTypes.h
+++ b/src/tools/rbd/ArgumentTypes.h
@@ -83,8 +83,13 @@ static const std::string NO_ERROR("no-error");
static const std::string LIMIT("limit");
+static const std::string SKIP_QUIESCE("skip-quiesce");
+static const std::string IGNORE_QUIESCE_ERROR("ignore-quiesce-error");
+
static const std::set<std::string> SWITCH_ARGUMENTS = {
- WHOLE_OBJECT, NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERROR};
+ WHOLE_OBJECT, NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERROR, SKIP_QUIESCE,
+ IGNORE_QUIESCE_ERROR
+};
struct ImageSize {};
struct ImageOrder {};
@@ -188,6 +193,8 @@ void add_no_error_option(boost::program_options::options_description *opt);
void add_flatten_option(boost::program_options::options_description *opt);
+void add_snap_create_options(boost::program_options::options_description *opt);
+
std::string get_short_features_help(bool append_suffix);
std::string get_long_features_help();
diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc
index 7698dae9a63..52c569f44fe 100644
--- a/src/tools/rbd/Utils.cc
+++ b/src/tools/rbd/Utils.cc
@@ -656,6 +656,24 @@ int get_formatter(const po::variables_map &vm,
return 0;
}
+int get_snap_create_flags(const po::variables_map &vm, uint32_t *flags) {
+ if (vm[at::SKIP_QUIESCE].as<bool>() &&
+ vm[at::IGNORE_QUIESCE_ERROR].as<bool>()) {
+ std::cerr << "rbd: " << at::IGNORE_QUIESCE_ERROR
+ << " cannot be used together with " << at::SKIP_QUIESCE
+ << std::endl;
+ return -EINVAL;
+ }
+
+ *flags = 0;
+ if (vm[at::SKIP_QUIESCE].as<bool>()) {
+ *flags |= RBD_SNAP_CREATE_SKIP_QUIESCE;
+ } else if (vm[at::IGNORE_QUIESCE_ERROR].as<bool>()) {
+ *flags |= RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR;
+ }
+ return 0;
+}
+
void init_context() {
g_conf().set_val_or_die("rbd_cache_writethrough_until_flush", "false");
g_conf().apply_changes(nullptr);
diff --git a/src/tools/rbd/Utils.h b/src/tools/rbd/Utils.h
index 14e46d5c478..94500340613 100644
--- a/src/tools/rbd/Utils.h
+++ b/src/tools/rbd/Utils.h
@@ -150,6 +150,9 @@ int get_path(const boost::program_options::variables_map &vm,
int get_formatter(const boost::program_options::variables_map &vm,
argument_types::Format::Formatter *formatter);
+int get_snap_create_flags(const boost::program_options::variables_map &vm,
+ uint32_t *flags);
+
void init_context();
int init_rados(librados::Rados *rados);
diff --git a/src/tools/rbd/action/Device.cc b/src/tools/rbd/action/Device.cc
index 94864d04c63..75988bd71c1 100644
--- a/src/tools/rbd/action/Device.cc
+++ b/src/tools/rbd/action/Device.cc
@@ -137,7 +137,7 @@ void get_map_arguments(po::options_description *positional,
options->add_options()
("read-only", po::bool_switch(), "map read-only")
("exclusive", po::bool_switch(), "disable automatic exclusive lock transitions")
- ("quiesce", po::bool_switch(), "use quiesce callbacks")
+ ("quiesce", po::bool_switch(), "use quiesce hooks")
("quiesce-hook", po::value<std::string>(), "quiesce hook path");
add_device_specific_options(options);
}
diff --git a/src/tools/rbd/action/MirrorImage.cc b/src/tools/rbd/action/MirrorImage.cc
index 02fdbf3a7e0..ab037b296e3 100644
--- a/src/tools/rbd/action/MirrorImage.cc
+++ b/src/tools/rbd/action/MirrorImage.cc
@@ -518,6 +518,12 @@ int execute_status(const po::variables_map &vm,
return 0;
}
+void get_snapshot_arguments(po::options_description *positional,
+ po::options_description *options) {
+ at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
+ at::add_snap_create_options(options);
+}
+
int execute_snapshot(const po::variables_map &vm,
const std::vector<std::string> &ceph_global_init_args) {
size_t arg_index = 0;
@@ -532,6 +538,12 @@ int execute_snapshot(const po::variables_map &vm,
return r;
}
+ uint32_t flags;
+ r = utils::get_snap_create_flags(vm, &flags);
+ if (r < 0) {
+ return r;
+ }
+
librados::Rados rados;
librados::IoCtx io_ctx;
librbd::Image image;
@@ -547,7 +559,7 @@ int execute_snapshot(const po::variables_map &vm,
}
uint64_t snap_id;
- r = image.mirror_image_create_snapshot(&snap_id);
+ r = image.mirror_image_create_snapshot2(flags, &snap_id);
if (r < 0) {
std::cerr << "rbd: error creating snapshot: " << cpp_strerror(r)
<< std::endl;
@@ -585,7 +597,7 @@ Shell::Action action_status(
Shell::Action action_snapshot(
{"mirror", "image", "snapshot"}, {},
"Create RBD mirroring image snapshot.", "",
- &get_arguments, &execute_snapshot);
+ &get_snapshot_arguments, &execute_snapshot);
} // namespace mirror_image
} // namespace action
diff --git a/src/tools/rbd/action/Snap.cc b/src/tools/rbd/action/Snap.cc
index 03a4f5b065f..b2011ebae23 100644
--- a/src/tools/rbd/action/Snap.cc
+++ b/src/tools/rbd/action/Snap.cc
@@ -232,12 +232,18 @@ int do_list_snaps(librbd::Image& image, Formatter *f, bool all_snaps, librados::
return 0;
}
-int do_add_snap(librbd::Image& image, const char *snapname)
+int do_add_snap(librbd::Image& image, const char *snapname,
+ uint32_t flags, bool no_progress)
{
- int r = image.snap_create(snapname);
- if (r < 0)
+ utils::ProgressContext pc("Creating snap", no_progress);
+
+ int r = image.snap_create2(snapname, flags, pc);
+ if (r < 0) {
+ pc.fail();
return r;
+ }
+ pc.finish();
return 0;
}
@@ -417,6 +423,8 @@ int execute_list(const po::variables_map &vm,
void get_create_arguments(po::options_description *positional,
po::options_description *options) {
at::add_snap_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
+ at::add_snap_create_options(options);
+ at::add_no_progress_option(options);
}
int execute_create(const po::variables_map &vm,
@@ -434,6 +442,12 @@ int execute_create(const po::variables_map &vm,
return r;
}
+ uint32_t flags;
+ r = utils::get_snap_create_flags(vm, &flags);
+ if (r < 0) {
+ return r;
+ }
+
librados::Rados rados;
librados::IoCtx io_ctx;
librbd::Image image;
@@ -443,7 +457,8 @@ int execute_create(const po::variables_map &vm,
return r;
}
- r = do_add_snap(image, snap_name.c_str());
+ r = do_add_snap(image, snap_name.c_str(), flags,
+ vm[at::NO_PROGRESS].as<bool>());
if (r < 0) {
cerr << "rbd: failed to create snapshot: " << cpp_strerror(r)
<< std::endl;