From eeaa92c47116210a6b54f7a6ea2dd897073155d2 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Fri, 7 Sep 2012 18:16:25 -0700 Subject: [PATCH] rbd: add locking commands The locker (entity_name_t) will be different each time the rbd command line tool is run, so 'lock remove' is always breaking a lock. Fixes: #2556 Signed-off-by: Josh Durgin --- doc/man/8/rbd.rst | 33 ++++ man/rbd.8 | 44 +++++- qa/workunits/rbd/copy.sh | 28 ++++ src/rbd.cc | 173 +++++++++++++++++++-- src/test/cli/rbd/help.t | 4 + src/test/cli/rbd/invalid-snap-usage.t | 216 ++++++++++++++++++++++++++ 6 files changed, 480 insertions(+), 18 deletions(-) diff --git a/doc/man/8/rbd.rst b/doc/man/8/rbd.rst index 28ad570b978e6..92d77e61f7e86 100644 --- a/doc/man/8/rbd.rst +++ b/doc/man/8/rbd.rst @@ -82,6 +82,15 @@ Parameters to use with the map command. If not specified, the default keyring locations will be searched. +.. option:: --shared tag + + Option for `lock add` that allows multiple clients to lock the + same image if they use the same tag. The tag is an arbitrary + string. This is useful for situations where an image must + be open from more than one client at once, like during + live migration of a virtual machine, or for use underneath + a clustered filesystem. + Commands ======== @@ -182,6 +191,22 @@ Commands :command:`showmapped` Show the rbd images that are mapped via the rbd kernel module. +:command:`lock` list [*image-name*] + Show locks held on the image. The first column is the locker + to use with the `lock remove` command. + +:command:`lock` add [*image-name*] [*lock-id*] + Lock an image. The lock-id is an arbitrary name for the user's + convenience. By default, this is an exclusive lock, meaning it + will fail if the image is already locked. The --shared option + changes this behavior. Note that locking does not affect + any operation other than adding a lock. It does not + protect an image from being deleted. + +:command:`lock` remove [*image-name*] [*lock-id*] [*locker*] + Release a lock on an image. The lock id and locker are + as output by lock ls. + Image name ========== @@ -250,6 +275,14 @@ import it as the desired format:: rbd export mypool/myimage@snap /tmp/img rbd import --format 2 /tmp/img mypool/myimage2 +To lock an image for exclusive use:: + + rbd lock add mypool/myimage mylockid + +To release a lock:: + + rbd lock remove mypool/myimage mylockid client.2485 + Availability ============ diff --git a/man/rbd.8 b/man/rbd.8 index f2a6640b0587a..995fa3f4ff3cc 100644 --- a/man/rbd.8 +++ b/man/rbd.8 @@ -1,4 +1,4 @@ -.TH "RBD" "8" "August 29, 2012" "dev" "Ceph" +.TH "RBD" "8" "September 07, 2012" "dev" "Ceph" .SH NAME rbd \- manage rados block device (RBD) images . @@ -111,6 +111,16 @@ Specifies a keyring file containing a secret for the specified user to use with the map command. If not specified, the default keyring locations will be searched. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-shared tag +Option for \fIlock add\fP that allows multiple clients to lock the +same image if they use the same tag. The tag is an arbitrary +string. This is useful for situations where an image must +be open from more than one client at once, like during +live migration of a virtual machine, or for use underneath +a clustered filesystem. +.UNINDENT .SH COMMANDS .INDENT 0.0 .TP @@ -207,6 +217,22 @@ Unmaps the block device that was mapped via the rbd kernel module. .TP .B \fBshowmapped\fP Show the rbd images that are mapped via the rbd kernel module. +.TP +.B \fBlock\fP list [\fIimage\-name\fP] +Show locks held on the image. The first column is the locker +to use with the \fIlock remove\fP command. +.TP +.B \fBlock\fP add [\fIimage\-name\fP] [\fIlock\-id\fP] +Lock an image. The lock\-id is an arbitrary name for the user\(aqs +convenience. By default, this is an exclusive lock, meaning it +will fail if the image is already locked. The \-\-shared option +changes this behavior. Note that locking does not affect +any operation other than adding a lock. It does not +protect an image from being deleted. +.TP +.B \fBlock\fP remove [\fIimage\-name\fP] [\fIlock\-id\fP] [\fIlocker\fP] +Release a lock on an image. The lock id and locker are +as output by lock ls. .UNINDENT .SH IMAGE NAME .sp @@ -323,6 +349,22 @@ rbd export mypool/myimage@snap /tmp/img rbd import \-\-format 2 /tmp/img mypool/myimage2 .ft P .fi +.sp +To lock an image for exclusive use: +.sp +.nf +.ft C +rbd lock add mypool/myimage mylockid +.ft P +.fi +.sp +To release a lock: +.sp +.nf +.ft C +rbd lock remove mypool/myimage mylockid client.2485 +.ft P +.fi .SH AVAILABILITY .sp \fBrbd\fP is part of the Ceph distributed file system. Please refer to diff --git a/qa/workunits/rbd/copy.sh b/qa/workunits/rbd/copy.sh index ed6c9da9b58fb..94a7f33841534 100755 --- a/qa/workunits/rbd/copy.sh +++ b/qa/workunits/rbd/copy.sh @@ -148,12 +148,40 @@ test_remove() { rbd ls | wc -l | grep "^0$" } +test_locking() { + echo "testing locking..." + remove_images + + rbd create -s 1 test1 + rbd lock list test1 | wc -l | grep '^0$' + rbd lock add test1 id + rbd lock list test1 | grep ' 1 ' + LOCKER=$(rbd lock list test1 | tail -n 1 | cut -f 1) + rbd lock remove test1 id $LOCKER + rbd lock list test1 | wc -l | grep '^0$' + + rbd lock add test1 id --shared tag + rbd lock list test1 | grep ' 1 ' + rbd lock add test1 id --shared tag + rbd lock list test1 | grep ' 2 ' + rbd lock add test1 id2 --shared tag + rbd lock list test1 | grep ' 3 ' + LOCKER=$(rbd lock list test1 | tail -n 1 | cut -f 1) + ID=$(rbd lock list test1 | tail -n 1 | cut -f 2) + rbd lock remove test1 $ID $LOCKER + # locks don't prevent you from removing an image, + # just from taking a lock + rbd rm test1 +} + test_rename test_ls test_remove RBD_CREATE_ARGS="" test_others +test_locking RBD_CREATE_ARGS="--format 2" test_others +test_locking echo OK diff --git a/src/rbd.cc b/src/rbd.cc index 35b85842d49f8..b96d851de4952 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -98,6 +98,9 @@ void usage() " mapped by the kernel\n" " showmapped show the rbd images mapped\n" " by the kernel\n" +" lock list show locks held on an image\n" +" lock add [--shared ] take a lock called id on an image\n" +" lock remove release a lock on an image\n" "\n" ", are [pool/]name[@snap], or you may specify\n" "individual pieces of names with -p/--pool, --image, and/or --snap.\n" @@ -116,7 +119,8 @@ void usage() " format 1 is the original format (default)\n" " format 2 supports cloning\n" " --id rados user (without 'client.' prefix) to authenticate as\n" -" --keyfile file containing secret key for use with cephx\n"; +" --keyfile file containing secret key for use with cephx\n" +" --shared take a shared (rather than exclusive) lock\n"; } static string feature_str(uint64_t features) @@ -400,6 +404,48 @@ static int do_list_children(librbd::Image &image) return 0; } +static int do_lock_list(librbd::Image& image) +{ + list lockers; + bool exclusive; + string tag; + int r = image.list_lockers(&lockers, &exclusive, &tag); + if (r < 0) + return r; + + if (lockers.size()) { + cout << "There are " << lockers.size() + << (exclusive ? " exclusive" : " shared") + << " lock(s) on this image.\n"; + if (!exclusive) + cout << "Lock tag: " << tag << "\n"; + + cout << "\nLocker\tID\tAddress\n"; + for (list::const_iterator it = lockers.begin(); + it != lockers.end(); ++it) { + cout << it->client << "\t" + << it->cookie << "\t" + << it->address << std::endl; + } + } + return 0; +} + +static int do_lock_add(librbd::Image& image, const char *cookie, + const char *tag) +{ + if (tag) + return image.lock_shared(cookie, tag); + else + return image.lock_exclusive(cookie); +} + +static int do_lock_remove(librbd::Image& image, const char *client, + const char *cookie) +{ + return image.break_lock(client, cookie); +} + struct ExportContext { int fd; MyProgressContext pc; @@ -1006,11 +1052,14 @@ enum { OPT_MAP, OPT_UNMAP, OPT_SHOWMAPPED, + OPT_LOCK_LIST, + OPT_LOCK_ADD, + OPT_LOCK_REMOVE, }; -static int get_cmd(const char *cmd, bool snapcmd) +static int get_cmd(const char *cmd, bool snapcmd, bool lockcmd) { - if (!snapcmd) { + if (!snapcmd && !lockcmd) { if (strcmp(cmd, "ls") == 0 || strcmp(cmd, "list") == 0) return OPT_LIST; @@ -1046,17 +1095,17 @@ static int get_cmd(const char *cmd, bool snapcmd) return OPT_SHOWMAPPED; if (strcmp(cmd, "unmap") == 0) return OPT_UNMAP; - } else { - if (strcmp(cmd, "create") == 0|| + } else if (snapcmd) { + if (strcmp(cmd, "create") == 0 || strcmp(cmd, "add") == 0) return OPT_SNAP_CREATE; - if (strcmp(cmd, "rollback") == 0|| + if (strcmp(cmd, "rollback") == 0 || strcmp(cmd, "revert") == 0) return OPT_SNAP_ROLLBACK; - if (strcmp(cmd, "remove") == 0|| + if (strcmp(cmd, "remove") == 0 || strcmp(cmd, "rm") == 0) return OPT_SNAP_REMOVE; - if (strcmp(cmd, "ls") == 0|| + if (strcmp(cmd, "ls") == 0 || strcmp(cmd, "list") == 0) return OPT_SNAP_LIST; if (strcmp(cmd, "purge") == 0) @@ -1065,6 +1114,15 @@ static int get_cmd(const char *cmd, bool snapcmd) return OPT_SNAP_PROTECT; if (strcmp(cmd, "unprotect") == 0) return OPT_SNAP_UNPROTECT; + } else { + if (strcmp(cmd, "ls") == 0 || + strcmp(cmd, "list") == 0) + return OPT_LOCK_LIST; + if (strcmp(cmd, "add") == 0) + return OPT_LOCK_ADD; + if (strcmp(cmd, "remove") == 0 || + strcmp(cmd, "rm") == 0) + return OPT_LOCK_REMOVE; } return OPT_NO_CMD; @@ -1099,7 +1157,10 @@ int main(int argc, const char **argv) 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; + const char *imgname = NULL, *snapname = NULL, *destname = NULL, + *dest_poolname = NULL, *dest_snapname = NULL, *path = NULL, + *devpath = NULL, *lock_cookie = NULL, *lock_client = NULL, + *lock_tag = NULL; std::string val; std::ostringstream err; @@ -1149,6 +1210,8 @@ int main(int argc, const char **argv) destname = strdup(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--parent", (char *)NULL)) { imgname = strdup(val.c_str()); + } else if (ceph_argparse_witharg(args, i, &val, "--shared", (char *)NULL)) { + lock_tag = strdup(val.c_str()); } else { ++i; } @@ -1161,18 +1224,24 @@ int main(int argc, const char **argv) cerr << "you must specify a command." << std::endl; usage(); return EXIT_FAILURE; - } - else if (strcmp(*i, "snap") == 0) { + } else if (strcmp(*i, "snap") == 0) { i = args.erase(i); if (i == args.end()) { cerr << "which snap command do you want?" << std::endl; usage(); return EXIT_FAILURE; } - opt_cmd = get_cmd(*i, true); - } - else { - opt_cmd = get_cmd(*i, false); + opt_cmd = get_cmd(*i, true, false); + } else if (strcmp(*i, "lock") == 0) { + i = args.erase(i); + if (i == args.end()) { + cerr << "which lock command do you want?" << std::endl; + usage(); + return EXIT_FAILURE; + } + opt_cmd = get_cmd(*i, false, true); + } else { + opt_cmd = get_cmd(*i, false, false); } if (opt_cmd == OPT_NO_CMD) { cerr << "error parsing command '" << *i << "'" << std::endl; @@ -1200,6 +1269,7 @@ int main(int argc, const char **argv) case OPT_SNAP_UNPROTECT: case OPT_WATCH: case OPT_MAP: + case OPT_LOCK_LIST: set_conf_param(v, &imgname, NULL); break; case OPT_UNMAP: @@ -1228,7 +1298,27 @@ int main(int argc, const char **argv) case OPT_CHILDREN: set_conf_param(v, &imgname, NULL); break; - default: + case OPT_LOCK_ADD: + if (args.size() < 2) { + cerr << "error: not enough arguments to lock add" << std::endl; + return EXIT_FAILURE; + } + set_conf_param(v, &imgname, NULL); + v = *(++i); + set_conf_param(v, &lock_cookie, NULL); + break; + case OPT_LOCK_REMOVE: + if (args.size() < 3) { + cerr << "error: not enough arguments to lock remove" << std::endl; + return EXIT_FAILURE; + } + set_conf_param(v, &imgname, NULL); + v = *(++i); + set_conf_param(v, &lock_client, NULL); + v = *(++i); + set_conf_param(v, &lock_cookie, NULL); + break; + default: assert(0); break; } @@ -1264,6 +1354,20 @@ int main(int argc, const char **argv) if (opt_cmd == OPT_IMPORT && !destname) destname = imgname_from_path(path); + if (opt_cmd != OPT_LOCK_ADD && lock_tag) { + cerr << "error: only the lock add command uses the --shared option" + << std::endl; + usage(); + return EXIT_FAILURE; + } + + if ((opt_cmd == OPT_LOCK_ADD || opt_cmd == OPT_LOCK_REMOVE) && + !lock_cookie) { + cerr << "error: lock id was not specified" << std::endl; + usage(); + return EXIT_FAILURE; + } + if (opt_cmd != OPT_LIST && opt_cmd != OPT_IMPORT && opt_cmd != OPT_UNMAP && opt_cmd != OPT_SHOWMAPPED && !imgname) { cerr << "error: image name was not specified" << std::endl; @@ -1358,7 +1462,9 @@ int main(int argc, const char **argv) opt_cmd == OPT_SNAP_PURGE || opt_cmd == OPT_EXPORT || opt_cmd == OPT_SNAP_PROTECT || opt_cmd == OPT_SNAP_UNPROTECT || opt_cmd == OPT_WATCH || opt_cmd == OPT_COPY || - opt_cmd == OPT_FLATTEN || opt_cmd == OPT_CHILDREN)) { + opt_cmd == OPT_FLATTEN || opt_cmd == OPT_CHILDREN || + opt_cmd == OPT_LOCK_LIST || opt_cmd == OPT_LOCK_ADD || + opt_cmd == OPT_LOCK_REMOVE)) { r = rbd.open(io_ctx, image, imgname); if (r < 0) { cerr << "error opening image " << imgname << ": " << cpp_strerror(-r) << std::endl; @@ -1645,6 +1751,39 @@ int main(int argc, const char **argv) return EXIT_FAILURE; } break; + + case OPT_LOCK_LIST: + r = do_lock_list(image); + if (r < 0) { + cerr << "listing locks failed: " << cpp_strerror(r) << std::endl; + return EXIT_FAILURE; + } + break; + + case OPT_LOCK_ADD: + r = do_lock_add(image, lock_cookie, lock_tag); + if (r < 0) { + if (r == -EBUSY || r == -EEXIST) { + if (lock_tag) { + cerr << "lock is alrady held by someone else with a different tag" + << std::endl; + } else { + cerr << "lock is already held by someone else" << std::endl; + } + } else { + cerr << "taking lock failed: " << cpp_strerror(r) << std::endl; + } + return EXIT_FAILURE; + } + break; + + case OPT_LOCK_REMOVE: + r = do_lock_remove(image, lock_cookie, lock_client); + if (r < 0) { + cerr << "releasing lock failed: " << cpp_strerror(r) << std::endl; + return EXIT_FAILURE; + } + break; } return 0; diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t index e70bd10aaa9b6..ea02c1210c070 100644 --- a/src/test/cli/rbd/help.t +++ b/src/test/cli/rbd/help.t @@ -33,6 +33,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -52,3 +55,4 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock diff --git a/src/test/cli/rbd/invalid-snap-usage.t b/src/test/cli/rbd/invalid-snap-usage.t index aca9eafb0135a..2f4e8cf24a76d 100644 --- a/src/test/cli/rbd/invalid-snap-usage.t +++ b/src/test/cli/rbd/invalid-snap-usage.t @@ -34,6 +34,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -53,6 +56,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd resize img@snap error: snapname specified for a command that doesn't use it @@ -90,6 +94,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -109,6 +116,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd import --snap=snap1 /bin/ls ls error: snapname specified for a command that doesn't use it @@ -146,6 +154,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -165,6 +176,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd create --snap=snap img error: snapname specified for a command that doesn't use it @@ -202,6 +214,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -221,6 +236,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd rm --snap=snap img error: snapname specified for a command that doesn't use it @@ -258,6 +274,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -277,6 +296,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd rename --snap=snap img error: snapname specified for a command that doesn't use it @@ -314,6 +334,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -333,6 +356,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd ls --snap=snap rbd error: snapname specified for a command that doesn't use it @@ -370,6 +394,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -389,6 +416,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd snap ls --snap=snap img error: snapname specified for a command that doesn't use it @@ -426,6 +454,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -445,6 +476,7 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1] $ rbd watch --snap=snap img error: snapname specified for a command that doesn't use it @@ -482,6 +514,9 @@ mapped by the kernel showmapped show the rbd images mapped by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image , are [pool/]name[@snap], or you may specify individual pieces of names with -p/--pool, --image, and/or --snap. @@ -501,4 +536,185 @@ format 2 supports cloning --id rados user (without 'client.' prefix) to authenticate as --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock + [1] + $ rbd lock list --snap=snap img + error: snapname specified for a command that doesn't use it + usage: rbd [-n ] [OPTIONS] ... + where 'pool' is a rados pool name (default is 'rbd') and 'cmd' is one of: + (ls | list) [pool-name] list rbd images + info show information about image size, + striping, etc. + create [--order ] --size create an empty image + clone [--order ] + clone a snapshot into a COW + child image + children display children of snapshot + flatten fill clone with parent data + (make it independent) + resize --size resize (expand or contract) image + rm delete an image + export export image to file + import import image from file + (dest defaults) + as the filename part of file) + (cp | copy) copy src image to dest + (mv | rename) rename src image to dest + snap ls dump list of image snapshots + snap create create a snapshot + snap rollback rollback image to snapshot + snap rm deletes a snapshot + snap purge deletes all snapshots + snap protect prevent a snapshot from being deleted + snap unprotect allow a snapshot to be deleted + watch watch events on image + map map image to a block device + using the kernel + unmap unmap a rbd device that was + mapped by the kernel + showmapped show the rbd images mapped + by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image + + , are [pool/]name[@snap], or you may specify + individual pieces of names with -p/--pool, --image, and/or --snap. + + Other input options: + -p, --pool source pool name + --image image name + --dest destination [pool and] image name + --snap snapshot name + --dest-pool destination pool name + --path path name for import/export + --size size of image for create and resize + --order the object size in bits; object size will be + (1 << order) bytes. Default is 22 (4 MB). + --format format to use when creating an image + format 1 is the original format (default) + format 2 supports cloning + --id rados user (without 'client.' prefix) to authenticate as + --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock + [1] + $ rbd lock add --snap=snap img id + error: snapname specified for a command that doesn't use it + usage: rbd [-n ] [OPTIONS] ... + where 'pool' is a rados pool name (default is 'rbd') and 'cmd' is one of: + (ls | list) [pool-name] list rbd images + info show information about image size, + striping, etc. + create [--order ] --size create an empty image + clone [--order ] + clone a snapshot into a COW + child image + children display children of snapshot + flatten fill clone with parent data + (make it independent) + resize --size resize (expand or contract) image + rm delete an image + export export image to file + import import image from file + (dest defaults) + as the filename part of file) + (cp | copy) copy src image to dest + (mv | rename) rename src image to dest + snap ls dump list of image snapshots + snap create create a snapshot + snap rollback rollback image to snapshot + snap rm deletes a snapshot + snap purge deletes all snapshots + snap protect prevent a snapshot from being deleted + snap unprotect allow a snapshot to be deleted + watch watch events on image + map map image to a block device + using the kernel + unmap unmap a rbd device that was + mapped by the kernel + showmapped show the rbd images mapped + by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image + + , are [pool/]name[@snap], or you may specify + individual pieces of names with -p/--pool, --image, and/or --snap. + + Other input options: + -p, --pool source pool name + --image image name + --dest destination [pool and] image name + --snap snapshot name + --dest-pool destination pool name + --path path name for import/export + --size size of image for create and resize + --order the object size in bits; object size will be + (1 << order) bytes. Default is 22 (4 MB). + --format format to use when creating an image + format 1 is the original format (default) + format 2 supports cloning + --id rados user (without 'client.' prefix) to authenticate as + --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock + [1] + $ rbd lock remove --snap=snap img id client.1234 + error: snapname specified for a command that doesn't use it + usage: rbd [-n ] [OPTIONS] ... + where 'pool' is a rados pool name (default is 'rbd') and 'cmd' is one of: + (ls | list) [pool-name] list rbd images + info show information about image size, + striping, etc. + create [--order ] --size create an empty image + clone [--order ] + clone a snapshot into a COW + child image + children display children of snapshot + flatten fill clone with parent data + (make it independent) + resize --size resize (expand or contract) image + rm delete an image + export export image to file + import import image from file + (dest defaults) + as the filename part of file) + (cp | copy) copy src image to dest + (mv | rename) rename src image to dest + snap ls dump list of image snapshots + snap create create a snapshot + snap rollback rollback image to snapshot + snap rm deletes a snapshot + snap purge deletes all snapshots + snap protect prevent a snapshot from being deleted + snap unprotect allow a snapshot to be deleted + watch watch events on image + map map image to a block device + using the kernel + unmap unmap a rbd device that was + mapped by the kernel + showmapped show the rbd images mapped + by the kernel + lock list show locks held on an image + lock add [--shared ] take a lock called id on an image + lock remove release a lock on an image + + , are [pool/]name[@snap], or you may specify + individual pieces of names with -p/--pool, --image, and/or --snap. + + Other input options: + -p, --pool source pool name + --image image name + --dest destination [pool and] image name + --snap snapshot name + --dest-pool destination pool name + --path path name for import/export + --size size of image for create and resize + --order the object size in bits; object size will be + (1 << order) bytes. Default is 22 (4 MB). + --format format to use when creating an image + format 1 is the original format (default) + format 2 supports cloning + --id rados user (without 'client.' prefix) to authenticate as + --keyfile file containing secret key for use with cephx + --shared take a shared (rather than exclusive) lock [1]