]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: add the judgment of resizing the image
authorzhengyin <zhengyin@huayun.com>
Wed, 2 May 2018 08:25:14 +0000 (16:25 +0800)
committerzhengyin <zhengyin@huayun.com>
Wed, 2 May 2018 14:00:04 +0000 (22:00 +0800)
Signed-off-by: Zheng Yin zhengyin@huayun.com
src/tools/rbd/action/Resize.cc

index dfa5c907b526b4475bb66860a41d55025addd7e4..aed5fdad137527dea4bf4f48ba22319b03d597e3 100644 (file)
@@ -71,7 +71,12 @@ int execute(const po::variables_map &vm,
     return r;
   }
 
-  r = do_resize(image, size, vm["allow-shrink"].as<bool>(), vm[at::NO_PROGRESS].as<bool>());
+  if (info.size > size && !vm["allow-shrink"].as<bool>()) {
+    r = -EINVAL;
+  } else {
+    r = do_resize(image, size, vm["allow-shrink"].as<bool>(), vm[at::NO_PROGRESS].as<bool>());
+  }
+
   if (r < 0) {
     if (r == -EINVAL && !vm["allow-shrink"].as<bool>()) {
       std::cerr << "rbd: shrinking an image is only allowed with the "