[--data-pool <data-pool>]
[--journal-splay-width <journal-splay-width>]
[--journal-object-size <journal-object-size>]
- [--journal-pool <journal-pool>] [--no-progress]
+ [--journal-pool <journal-pool>] [--sparse-size <sparse-size>]
+ [--no-progress]
<source-image-or-snap-spec> <dest-image-spec>
Copy src image to dest.
--journal-splay-width arg number of active journal objects
--journal-object-size arg size of journal objects
--journal-pool arg pool for journal objects
+ --sparse-size arg sparse size in B/K/M [default: 4K]
--no-progress disable progress output
Image Features:
[--stripe-count <stripe-count>] [--data-pool <data-pool>]
[--journal-splay-width <journal-splay-width>]
[--journal-object-size <journal-object-size>]
- [--journal-pool <journal-pool>] [--no-progress]
+ [--journal-pool <journal-pool>]
+ [--sparse-size <sparse-size>] [--no-progress]
[--export-format <export-format>] [--pool <pool>]
[--image <image>]
<path-name> <dest-image-spec>
--journal-splay-width arg number of active journal objects
--journal-object-size arg size of journal objects
--journal-pool arg pool for journal objects
+ --sparse-size arg sparse size in B/K/M [default: 4K]
--no-progress disable progress output
--export-format arg format of image file
-p [ --pool ] arg pool name (deprecated)
rbd help import-diff
usage: rbd import-diff [--path <path>] [--pool <pool>] [--image <image>]
- [--no-progress]
+ [--sparse-size <sparse-size>] [--no-progress]
<path-name> <image-spec>
Import an incremental diff.
--path arg import file (or '-' for stdin)
-p [ --pool ] arg pool name
--image arg image name
+ --sparse-size arg sparse size in B/K/M [default: 4K]
--no-progress disable progress output
rbd help info
"image size (in M/G/T)");
}
+void add_sparse_size_option(boost::program_options::options_description *opt) {
+ opt->add_options()
+ (IMAGE_SPARSE_SIZE.c_str(), po::value<ImageObjectSize>(),
+ "sparse size in B/K/M [default: 4K]");
+}
+
void add_path_options(boost::program_options::options_description *pos,
boost::program_options::options_description *opt,
const std::string &description) {
static const std::string IMAGE_STRIPE_UNIT("stripe-unit");
static const std::string IMAGE_STRIPE_COUNT("stripe-count");
static const std::string IMAGE_DATA_POOL("data-pool");
+static const std::string IMAGE_SPARSE_SIZE("sparse-size");
static const std::string JOURNAL_OBJECT_SIZE("journal-object-size");
static const std::string JOURNAL_SPLAY_WIDTH("journal-splay-width");
void add_size_option(boost::program_options::options_description *opt);
+void add_sparse_size_option(boost::program_options::options_description *opt);
+
void add_path_options(boost::program_options::options_description *pos,
boost::program_options::options_description *opt,
const std::string &description);
return 0;
}
+bool calc_sparse_extent(const bufferptr &bp,
+ size_t sparse_size,
+ uint64_t length,
+ size_t *write_offset,
+ size_t *write_length,
+ size_t *offset) {
+ size_t extent_size;
+ if (*offset + sparse_size > length) {
+ extent_size = length - *offset;
+ } else {
+ extent_size = sparse_size;
+ }
+
+ bufferptr extent(bp, *offset, extent_size);
+ *offset += extent_size;
+
+ bool extent_is_zero = extent.is_zero();
+ if (!extent_is_zero) {
+ *write_length += extent_size;
+ }
+ if (extent_is_zero && *write_length == 0) {
+ *write_offset += extent_size;
+ }
+
+ if ((extent_is_zero || *offset == length) && *write_length != 0) {
+ return true;
+ }
+ return false;
+}
+
std::string image_id(librbd::Image& image) {
std::string id;
int r = image.get_id(&id);
} // namespace detail
static const std::string RBD_DIFF_BANNER ("rbd diff v1\n");
+static const size_t RBD_DEFAULT_SPARSE_SIZE = 4096;
static const std::string RBD_IMAGE_BANNER_V2 ("rbd image v2\n");
static const std::string RBD_IMAGE_DIFFS_BANNER_V2 ("rbd image diffss v2\n");
int snap_set(librbd::Image &image, const std::string &snap_name);
+bool calc_sparse_extent(const bufferptr &bp,
+ size_t sparse_size,
+ uint64_t length,
+ size_t *write_offset,
+ size_t *write_length,
+ size_t *offset);
+
std::string image_id(librbd::Image& image);
std::string mirror_image_state(librbd::mirror_image_state_t mirror_image_state);