From 2f03ad2ea6b343b34624cc0e4ba63239bfc740e2 Mon Sep 17 00:00:00 2001 From: zhengyin Date: Wed, 2 May 2018 16:25:14 +0800 Subject: [PATCH] rbd: add the judgment of resizing the image Signed-off-by: Zheng Yin zhengyin@huayun.com --- src/tools/rbd/action/Resize.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/rbd/action/Resize.cc b/src/tools/rbd/action/Resize.cc index dfa5c907b52..aed5fdad137 100644 --- a/src/tools/rbd/action/Resize.cc +++ b/src/tools/rbd/action/Resize.cc @@ -71,7 +71,12 @@ int execute(const po::variables_map &vm, return r; } - r = do_resize(image, size, vm["allow-shrink"].as(), vm[at::NO_PROGRESS].as()); + if (info.size > size && !vm["allow-shrink"].as()) { + r = -EINVAL; + } else { + r = do_resize(image, size, vm["allow-shrink"].as(), vm[at::NO_PROGRESS].as()); + } + if (r < 0) { if (r == -EINVAL && !vm["allow-shrink"].as()) { std::cerr << "rbd: shrinking an image is only allowed with the " -- 2.39.5