Skip to content

Commit

Permalink
librbd: update hidden global config when removing pool config override
Browse files Browse the repository at this point in the history
The remove notification was missed and therefore in-use images will not
properly remove pool config overrides.

Fixes: https://tracker.ceph.com/issues/48145
Signed-off-by: Jason Dillaman <[email protected]>
  • Loading branch information
Jason Dillaman committed Nov 7, 2020
1 parent 4cc179f commit 4ca1c49
Showing 1 changed file with 35 additions and 20 deletions.
55 changes: 35 additions & 20 deletions src/librbd/api/PoolMetadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@
namespace librbd {
namespace api {

namespace {

void update_pool_timestamp(librados::IoCtx& io_ctx) {
CephContext *cct = (CephContext *)io_ctx.cct();

auto now = ceph_clock_now();
std::string cmd =
R"({)"
R"("prefix": "config set", )"
R"("who": "global", )"
R"("name": "rbd_config_pool_override_update_timestamp", )"
R"("value": ")" + stringify(now.sec()) + R"(")"
R"(})";

librados::Rados rados(io_ctx);
bufferlist in_bl;
std::string ss;
int r = rados.mon_command(cmd, in_bl, nullptr, &ss);
if (r < 0) {
lderr(cct) << "failed to notify clients of pool config update: "
<< cpp_strerror(r) << dendl;
}
}

} // anonymous namespace

template <typename I>
int PoolMetadata<I>::get(librados::IoCtx& io_ctx,
const std::string &key, std::string *value) {
Expand All @@ -36,7 +62,7 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
const std::string &value) {
CephContext *cct = (CephContext *)io_ctx.cct();

bool update_pool_timestamp = false;
bool need_update_pool_timestamp = false;

std::string config_key;
if (util::is_metadata_config_override(key, &config_key)) {
Expand All @@ -52,7 +78,7 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
return -EINVAL;
}

update_pool_timestamp = true;
need_update_pool_timestamp = true;
}

ceph::bufferlist bl;
Expand All @@ -65,24 +91,8 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
return r;
}

if (update_pool_timestamp) {
auto now = ceph_clock_now();
std::string cmd =
R"({)"
R"("prefix": "config set", )"
R"("who": "global", )"
R"("name": "rbd_config_pool_override_update_timestamp", )"
R"("value": ")" + stringify(now.sec()) + R"(")"
R"(})";

librados::Rados rados(io_ctx);
bufferlist in_bl;
std::string ss;
r = rados.mon_command(cmd, in_bl, nullptr, &ss);
if (r < 0) {
lderr(cct) << "failed to notify clients of pool config update: "
<< cpp_strerror(r) << dendl;
}
if (need_update_pool_timestamp) {
update_pool_timestamp(io_ctx);
}

return 0;
Expand Down Expand Up @@ -111,6 +121,11 @@ int PoolMetadata<I>::remove(librados::IoCtx& io_ctx, const std::string &key) {
return r;
}

std::string config_key;
if (util::is_metadata_config_override(key, &config_key)) {
update_pool_timestamp(io_ctx);
}

return 0;
}

Expand Down

0 comments on commit 4ca1c49

Please sign in to comment.