Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: When Ceph cluster becomes full, should allow user to remove rbd … #12627

Merged
merged 3 commits into from Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/include/rados/librados.hpp
Expand Up @@ -1187,6 +1187,9 @@ namespace librados

config_t cct();

void set_osdmap_full_try();
void unset_osdmap_full_try();

private:
/* You can only get IoCtx instances from Rados */
IoCtx(IoCtxImpl *io_ctx_impl_);
Expand Down
10 changes: 10 additions & 0 deletions src/librados/librados.cc
Expand Up @@ -2082,6 +2082,16 @@ librados::IoCtx::IoCtx(IoCtxImpl *io_ctx_impl_)
{
}

void librados::IoCtx::set_osdmap_full_try()
{
io_ctx_impl->objecter->set_osdmap_full_try();
}

void librados::IoCtx::unset_osdmap_full_try()
{
io_ctx_impl->objecter->unset_osdmap_full_try();
}

///////////////////////////// Rados //////////////////////////////
void librados::Rados::version(int *major, int *minor, int *extra)
{
Expand Down
3 changes: 3 additions & 0 deletions src/osdc/Objecter.cc
Expand Up @@ -3066,6 +3066,9 @@ MOSDOp *Objecter::_prepare_osd_op(Op *op)
if (!honor_osdmap_full)
flags |= CEPH_OSD_FLAG_FULL_FORCE;

if (osdmap_full_try)
flags |= CEPH_OSD_FLAG_FULL_TRY;

op->target.paused = false;
op->stamp = ceph::mono_clock::now();

Expand Down
6 changes: 5 additions & 1 deletion src/osdc/Objecter.h
Expand Up @@ -1144,6 +1144,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
atomic_t global_op_flags; // flags which are applied to each IO op
bool keep_balanced_budget;
bool honor_osdmap_full;
bool osdmap_full_try;

public:
void maybe_request_map();
Expand Down Expand Up @@ -1913,7 +1914,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
Dispatcher(cct_), messenger(m), monc(mc), finisher(fin),
osdmap(new OSDMap), initialized(0), last_tid(0), client_inc(-1),
max_linger_id(0), num_in_flight(0), global_op_flags(0),
keep_balanced_budget(false), honor_osdmap_full(true),
keep_balanced_budget(false), honor_osdmap_full(true), osdmap_full_try(false),
last_seen_osdmap_version(0), last_seen_pgmap_version(0),
logger(NULL), tick_event(0), m_request_state_hook(NULL),
num_homeless_ops(0),
Expand Down Expand Up @@ -1983,6 +1984,9 @@ class Objecter : public md_config_obs_t, public Dispatcher {
void set_honor_osdmap_full() { honor_osdmap_full = true; }
void unset_honor_osdmap_full() { honor_osdmap_full = false; }

void set_osdmap_full_try() { osdmap_full_try = true; }
void unset_osdmap_full_try() { osdmap_full_try = false; }

void _scan_requests(OSDSession *s,
bool force_resend,
bool cluster_full,
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rbd/action/Remove.cc
Expand Up @@ -53,6 +53,8 @@ int execute(const po::variables_map &vm) {
return r;
}

io_ctx.set_osdmap_full_try();

librbd::RBD rbd;
r = do_delete(rbd, io_ctx, image_name.c_str(),
vm[at::NO_PROGRESS].as<bool>());
Expand Down
27 changes: 21 additions & 6 deletions src/tools/rbd/action/Snap.cc
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down