to `snap create` and `mirror image snapshot` commands.
Signed-off-by: Mykola Golub <mgolub@suse.com>
--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
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>]
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>]
"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;
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 {};
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();
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);
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);
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);
}
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;
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;
}
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;
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
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;
}
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,
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;
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;