Parameters
==========
+.. option:: --format format
+
+ Specifies which object layout to use. The default is 1.
+
+ * format 1 - Use the original format for a new rbd image. This format is
+ understood by all versions of librbd and the kernel rbd module, but
+ does not support newer features like cloning.
+
+ * format 2 - Use the second rbd format, which is supported by
+ librbd (but not the kernel rbd module) at this time. This adds
+ support for cloning and is more easily extensible to allow more
+ features in the future.
+
.. option:: --size size-in-mb
Specifies the size (in megabytes) of the new rbd image.
" create [--order <bits>] --size <MB> <name> create an empty image\n"
" clone [--order <bits>] <parentsnap> <clonename>\n"
" clone a snapshot into a COW\n"
-" child image\n"
+" child image\n"
" children <snap-name> display children of snapshot\n"
" flatten <image-name> fill clone with parent data\n"
" (make it independent)\n"
" --size <size in MB> size of image for create and resize\n"
" --order <bits> the object size in bits; object size will be\n"
" (1 << order) bytes. Default is 22 (4 MB).\n"
-"\n"
-"For the map command:\n"
+" --format <format-number> format to use when creating an image\n"
+" format 1 is the original format (default)\n"
+" format 2 supports cloning\n"
" --id <username> rados user (without 'client.' prefix) to authenticate as\n"
" --keyfile <path> file containing secret key for use with cephx\n";
}
static int do_create(librbd::RBD &rbd, librados::IoCtx& io_ctx,
const char *imgname, uint64_t size, int *order,
- bool old_format, uint64_t features)
+ int format, uint64_t features)
{
int r;
if (features == 0)
features = RBD_FEATURES_ALL;
- if (old_format)
+ if (format == 1)
r = rbd.create(io_ctx, imgname, size, order);
else
r = rbd.create2(io_ctx, imgname, size, features, order);
<< std::endl
<< "\tblock_name_prefix: " << info.block_name_prefix
<< std::endl
- << "\told format: " << (old_format ? "True" : "False")
- << std::endl
- << "\tfeatures: " << feature_str(features)
+ << "\tformat: " << (old_format ? "1" : "2")
<< std::endl;
+ if (!old_format) {
+ cout << "\tfeatures: " << feature_str(features) << std::endl;
+ }
+
// snapshot info, if present
if (snapname) {
cout << "\tprotected: " << (snap_protected ? "True" : "False")
static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
const char *imgname, int *order, const char *path,
- bool old_format, uint64_t features, int64_t size)
+ int format, uint64_t features, int64_t size)
{
int fd, r;
struct stat stat_buf;
assert(imgname);
- r = do_create(rbd, io_ctx, imgname, size, order, old_format, features);
+ r = do_create(rbd, io_ctx, imgname, size, order, format, features);
if (r < 0) {
cerr << "image creation failed" << std::endl;
return r;
const char *poolname = NULL;
uint64_t size = 0; // in bytes
int order = 0;
- bool old_format = true;
+ bool format_specified = false;
+ int format = 1;
uint64_t features = RBD_FEATURE_LAYERING;
const char *imgname = NULL, *snapname = NULL, *destname = NULL, *dest_poolname = NULL, *dest_snapname = NULL, *path = NULL, *devpath = NULL;
usage();
return 0;
} else if (ceph_argparse_flag(args, i, "--new-format", (char*)NULL)) {
- old_format = false;
+ format = 2;
+ format_specified = true;
+ } else if (ceph_argparse_withint(args, i, &format, &err, "--format",
+ (char*)NULL)) {
+ if (!err.str().empty()) {
+ cerr << err.str() << std::endl;
+ return EXIT_FAILURE;
+ }
+ format_specified = true;
} else if (ceph_argparse_witharg(args, i, &val, "-p", "--pool", (char*)NULL)) {
poolname = strdup(val.c_str());
} else if (ceph_argparse_witharg(args, i, &val, "--dest-pool", (char*)NULL)) {
}
}
+ if (format_specified && opt_cmd != OPT_IMPORT && opt_cmd != OPT_CREATE) {
+ cerr << "error: format can only be set when "
+ << "creating or importing an image" << std::endl;
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if (format_specified) {
+ if (format < 1 || format > 2) {
+ cerr << "error: format must be 1 or 2" << std::endl;
+ usage();
+ return EXIT_FAILURE;
+ }
+ }
+
if (opt_cmd == OPT_EXPORT && !imgname) {
cerr << "error: image name was not specified" << std::endl;
usage();
usage();
return EXIT_FAILURE;
}
- r = do_create(rbd, io_ctx, imgname, size, &order, old_format, features);
+ r = do_create(rbd, io_ctx, imgname, size, &order, format, features);
if (r < 0) {
cerr << "create error: " << cpp_strerror(-r) << std::endl;
return EXIT_FAILURE;
return EXIT_FAILURE;
}
r = do_import(rbd, dest_io_ctx, destname, &order, path,
- old_format, features, size);
+ format, features, size);
if (r < 0) {
cerr << "import failed: " << cpp_strerror(-r) << std::endl;
return EXIT_FAILURE;
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]
create [--order <bits>] --size <MB> <name> create an empty image
clone [--order <bits>] <parentsnap> <clonename>
clone a snapshot into a COW
- child image
+ child image
children <snap-name> display children of snapshot
flatten <image-name> fill clone with parent data
(make it independent)
--size <size in MB> size of image for create and resize
--order <bits> the object size in bits; object size will be
(1 << order) bytes. Default is 22 (4 MB).
-
- For the map command:
+ --format <format-number> format to use when creating an image
+ format 1 is the original format (default)
+ format 2 supports cloning
--id <username> rados user (without 'client.' prefix) to authenticate as
--keyfile <path> file containing secret key for use with cephx
[1]