From 0daaa3c63b0c908e24dd12ea644e47811c08279c Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Sun, 26 Feb 2017 08:23:55 +0800 Subject: [PATCH] rbd: allow to remove snapshots of an image when Ceph cluster becomes full. Signed-off-by: Pan Liu --- src/tools/rbd/action/Snap.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/tools/rbd/action/Snap.cc b/src/tools/rbd/action/Snap.cc index 15b975aabf4..9d6d45f64c9 100644 --- a/src/tools/rbd/action/Snap.cc +++ b/src/tools/rbd/action/Snap.cc @@ -279,8 +279,13 @@ int execute_remove(const po::variables_map &vm) { librados::Rados rados; librados::IoCtx io_ctx; librbd::Image image; - r = utils::init_and_open_image(pool_name, image_name, "", false, &rados, - &io_ctx, &image); + r = utils::init(pool_name, &rados, &io_ctx); + if (r < 0) { + return r; + } + + io_ctx.set_osdmap_full_try(); + r = utils::open_image(io_ctx, image_name, false, &image); if (r < 0) { return r; } @@ -320,8 +325,13 @@ int execute_purge(const po::variables_map &vm) { librados::Rados rados; librados::IoCtx io_ctx; librbd::Image image; - r = utils::init_and_open_image(pool_name, image_name, "", false, &rados, - &io_ctx, &image); + r = utils::init(pool_name, &rados, &io_ctx); + if (r < 0) { + return r; + } + + io_ctx.set_osdmap_full_try(); + r = utils::open_image(io_ctx, image_name, false, &image); if (r < 0) { return r; } @@ -439,8 +449,13 @@ int execute_unprotect(const po::variables_map &vm) { librados::Rados rados; librados::IoCtx io_ctx; librbd::Image image; - r = utils::init_and_open_image(pool_name, image_name, "", false, &rados, - &io_ctx, &image); + r = utils::init(pool_name, &rados, &io_ctx); + if (r < 0) { + return r; + } + + io_ctx.set_osdmap_full_try(); + r = utils::open_image(io_ctx, image_name, false, &image); if (r < 0) { return r; } -- 2.47.3