From: zhengyin Date: Wed, 2 May 2018 08:25:14 +0000 (+0800) Subject: rbd: add the judgment of resizing the image X-Git-Tag: v14.0.0~172^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f03ad2ea6b343b34624cc0e4ba63239bfc740e2;p=ceph.git rbd: add the judgment of resizing the image Signed-off-by: Zheng Yin zhengyin@huayun.com --- diff --git a/src/tools/rbd/action/Resize.cc b/src/tools/rbd/action/Resize.cc index dfa5c907b526..aed5fdad1375 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 "