summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDongsheng Yang <dongsheng.yang@easystack.cn>2016-09-09 10:53:25 +0200
committerDongsheng Yang <dongsheng.yang@easystack.cn>2016-09-18 07:50:26 +0200
commitce4c801cfc114f718ca51c32b657fec638ca9aaf (patch)
treeadefaab6fbe5b5a6cb500155ef82b3f65182695f /src
parentMerge pull request #9767 from dx9/wip-safe-io (diff)
downloadceph-ce4c801cfc114f718ca51c32b657fec638ca9aaf.tar.xz
ceph-ce4c801cfc114f718ca51c32b657fec638ca9aaf.zip
rbd: return error if we specified a wrong image name for rbd du
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Diffstat (limited to 'src')
-rw-r--r--src/tools/rbd/action/DiskUsage.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tools/rbd/action/DiskUsage.cc b/src/tools/rbd/action/DiskUsage.cc
index 9ef2e7e93a4..3a38a052fb3 100644
--- a/src/tools/rbd/action/DiskUsage.cc
+++ b/src/tools/rbd/action/DiskUsage.cc
@@ -110,12 +110,14 @@ static int do_disk_usage(librbd::RBD &rbd, librados::IoCtx &io_ctx,
uint64_t used_size = 0;
uint64_t total_prov = 0;
uint64_t total_used = 0;
+ bool found = false;
std::sort(names.begin(), names.end());
for (std::vector<string>::const_iterator name = names.begin();
name != names.end(); ++name) {
if (imgname != NULL && *name != imgname) {
continue;
}
+ found = true;
librbd::Image image;
r = rbd.open_read_only(io_ctx, image, name->c_str(), NULL);
@@ -206,6 +208,10 @@ static int do_disk_usage(librbd::RBD &rbd, librados::IoCtx &io_ctx,
++count;
}
}
+ if (!found) {
+ std::cerr << "specified image " << imgname << " is not found." << std::endl;
+ return -ENOENT;
+ }
out:
if (f) {