rbd: du command should take spec as an argument

Change du to take <image-spec> | <snap-spec> as an argument instead of
going through --image option.  The new synopsis is

    (du | disk-usage) [<image-spec> | <snap-spec>]

This is to make it look more like the rest of the commands: the only
other command that takes pool as an argument is ls and it can't really
serve as a prototype for du, because the latter has to work on images
and snapshots as well.

Examples:

    # stats for pool rbd
    $ rbd du
    $ rbd -p rbd du

    # stats for pool foo
    $ rbd -p foo du

    # stats for snapshot mysnap of image baz in pool rbd
    $ rbd du baz@mysnap

    # stats for image bar in pool foo
    $ rbd du foo/bar

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Ilya Dryomov 2015-07-23 15:55:47 +03:00
parent 7d65bd9bd1
commit afbf90d5b5
3 changed files with 10 additions and 8 deletions

View File

@ -163,10 +163,10 @@ Commands
-l, also show snapshots, and use longer-format output including
size, parent (if clone), format, etc.
:command:`du` [--image *image-name*] [*pool-name*]
:command:`du` [-p | --pool *pool-name*] [*image-spec* | *snap-spec*]
Will calculate the provisioned and actual disk usage of all images and
associated snapshots within the specified pool. It can also be used against
individual images.
associated snapshots within the specified pool. It can also be used against
individual images and snapshots.
If the RBD fast-diff feature isn't enabled on images, this operation will
require querying the OSDs for every potential object within the image.

View File

@ -93,8 +93,9 @@ void usage()
"where 'pool' is a rados pool name (default is 'rbd') and 'cmd' is one of:\n"
" (ls | list) [-l | --long ] [pool-name] list rbd images\n"
" (-l includes snapshots/clones)\n"
" (du | disk-usage) [--image <name>] [pool-name]\n"
" show pool image disk usage stats\n"
" (du | disk-usage) [<image-spec> | <snap-spec>]\n"
" show disk usage stats for pool,\n"
" image or snapshot\n"
" info <image-spec> | <snap-spec> show information about image size,\n"
" striping, etc.\n"
" create [--order <bits>] [--image-features <features>] [--image-shared]\n"
@ -3182,7 +3183,6 @@ if (!set_conf_param(v, p1, p2, p3)) { \
const char *v = *i;
switch (opt_cmd) {
case OPT_LIST:
case OPT_DISK_USAGE:
SET_CONF_PARAM(v, &poolname, NULL, NULL);
break;
case OPT_INFO:
@ -3206,6 +3206,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \
case OPT_METADATA_LIST:
case OPT_DIFF:
case OPT_OBJECT_MAP_REBUILD:
case OPT_DISK_USAGE:
SET_CONF_PARAM(v, &imgname, NULL, NULL);
break;
case OPT_EXPORT:

View File

@ -3,8 +3,9 @@
where 'pool' is a rados pool name (default is 'rbd') and 'cmd' is one of:
(ls | list) [-l | --long ] [pool-name] list rbd images
(-l includes snapshots/clones)
(du | disk-usage) [--image <name>] [pool-name]
show pool image disk usage stats
(du | disk-usage) [<image-spec> | <snap-spec>]
show disk usage stats for pool,
image or snapshot
info <image-spec> | <snap-spec> show information about image size,
striping, etc.
create [--order <bits>] [--image-features <features>] [--image-shared]