From: Jason Dillaman Date: Wed, 1 Oct 2014 20:12:21 +0000 (-0400) Subject: rbd: Allow CLI to optionally create shared images X-Git-Tag: v0.92~20^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4297e3bf8e6f9f6b90e6c40c55a0a8d8ffc0651f;p=ceph.git rbd: Allow CLI to optionally create shared images Images that are flagged as shared cannot use the RBD object map nor RBD mirroring features. Signed-off-by: Jason Dillaman --- diff --git a/doc/man/8/rbd.rst b/doc/man/8/rbd.rst index 542454715fa2c..29eb65e6d12e2 100644 --- a/doc/man/8/rbd.rst +++ b/doc/man/8/rbd.rst @@ -123,6 +123,11 @@ Parameters Map the image read-only. Equivalent to -o ro. +.. option:: --image-shared + + Specifies that the image will be used concurrently by multiple clients. + This will disable features that are dependent upon exclusive ownership + of the image. Commands ======== diff --git a/src/rbd.cc b/src/rbd.cc index 3e60aeff53791..453fea0a85d94 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -83,8 +83,9 @@ void usage() " (-l includes snapshots/clones)\n" " info show information about image size,\n" " striping, etc.\n" -" create [--order ] --size create an empty image\n" -" clone [--order ] \n" +" create [--order ] [--image-shared] --size \n" +" create an empty image\n" +" clone [--order ] [--image-shared] \n" " clone a snapshot into a COW\n" " child image\n" " children display children of snapshot\n" @@ -94,7 +95,7 @@ void usage() " rm delete an image\n" " export export image to file\n" " \"-\" for stdout\n" -" import import image from file\n" +" import [--image-shared] import image from file\n" " (dest defaults\n" " as the filename part of file)\n" " \"-\" for stdin\n" @@ -146,6 +147,8 @@ void usage() " --image-format format to use when creating an image\n" " format 1 is the original format (default)\n" " format 2 supports cloning\n" +" --image-shared image will be used concurrently (disables\n" +" RBD exclusive lock and dependent features)\n" " --id rados user (without 'client.'prefix) to\n" " authenticate as\n" " --keyfile file containing secret key for use with cephx\n" @@ -2091,7 +2094,7 @@ int main(int argc, const char **argv) bool format_specified = false, output_format_specified = false; int format = 1; - uint64_t features = RBD_FEATURE_LAYERING; + uint64_t features = RBD_FEATURE_LAYERING | RBD_FEATURE_EXCLUSIVE_LOCK; const char *imgname = NULL, *snapname = NULL, *destname = NULL, *dest_poolname = NULL, *dest_snapname = NULL, *path = NULL, *devpath = NULL, *lock_cookie = NULL, *lock_client = NULL, @@ -2193,6 +2196,8 @@ int main(int argc, const char **argv) progress = false; } else if (ceph_argparse_flag(args, i , "--allow-shrink", (char *)NULL)) { resize_allow_shrink = true; + } else if (ceph_argparse_flag(args, i, "--image-shared", (char *)NULL)) { + features &= ~RBD_FEATURE_EXCLUSIVE_LOCK; } else if (ceph_argparse_witharg(args, i, &val, "--format", (char *) NULL)) { long long ret = strict_strtoll(val.c_str(), 10, &parse_err); if (parse_err.empty()) { diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t index 3818ee3cac26d..3c38246b1d4ac 100644 --- a/src/test/cli/rbd/help.t +++ b/src/test/cli/rbd/help.t @@ -5,8 +5,9 @@ (-l includes snapshots/clones) info show information about image size, striping, etc. - create [--order ] --size create an empty image - clone [--order ] + create [--order ] [--image-shared] --size + create an empty image + clone [--order ] [--image-shared] clone a snapshot into a COW child image children display children of snapshot @@ -16,7 +17,7 @@ rm delete an image export export image to file "-" for stdout - import import image from file + import [--image-shared] import image from file (dest defaults as the filename part of file) "-" for stdin @@ -68,6 +69,8 @@ --image-format format to use when creating an image format 1 is the original format (default) format 2 supports cloning + --image-shared image will be used concurrently (disables + RBD exclusive lock and dependent features) --id rados user (without 'client.'prefix) to authenticate as --keyfile file containing secret key for use with cephx