return 0;
}
-int AuthMonitor::do_osd_destroy(
- const EntityName& cephx_entity,
- const EntityName& lockbox_entity)
+void AuthMonitor::do_osd_destroy(
+ const EntityName& cephx_entity,
+ const EntityName& lockbox_entity)
{
ceph_assert(paxos.is_plugged());
+ ceph_assert(is_writeable());
dout(10) << __func__ << " cephx " << cephx_entity
<< " lockbox " << lockbox_entity << dendl;
if (!removed) {
dout(10) << __func__ << " entities do not exist -- no-op." << dendl;
- return 0;
+ return;
}
// given we have paxos plugged, this will not result in a proposal
// being triggered, but it will still be needed so that we get our
// pending state encoded into the paxos' pending transaction.
propose_pending();
- return 0;
}
int _create_auth(
void KVMonitor::do_osd_destroy(int32_t id, uuid_d& uuid)
{
+ ceph_assert(is_writeable());
+
string dmcrypt_prefix = _get_dmcrypt_prefix(uuid, "");
string daemon_prefix =
"daemon-private/osd." + stringify(id) + "/";
const string& dmcrypt_key)
{
ceph_assert(paxos.is_plugged());
+ ceph_assert(is_writeable());
string dmcrypt_key_prefix = _get_dmcrypt_prefix(uuid, "luks");
bufferlist dmcrypt_key_value;
}
int OSDMonitor::prepare_command_osd_destroy(
+ MonOpRequestRef op,
int32_t id,
stringstream& ss)
{
EntityName cephx_entity, lockbox_entity;
bool idempotent_auth = false, idempotent_cks = false;
- int err = mon.authmon()->validate_osd_destroy(id, uuid,
- cephx_entity,
- lockbox_entity,
- ss);
+ auto&& authmon = mon.authmon();
+ int err = authmon->validate_osd_destroy(id, uuid,
+ cephx_entity,
+ lockbox_entity,
+ ss);
if (err < 0) {
if (err == -ENOENT) {
idempotent_auth = true;
}
}
- auto svc = mon.kvmon();
- err = svc->validate_osd_destroy(id, uuid);
+ auto&& kvmon = mon.kvmon();
+ err = kvmon->validate_osd_destroy(id, uuid);
if (err < 0) {
ceph_assert(err == -ENOENT);
err = 0;
idempotent_cks = true;
}
- if (!idempotent_auth) {
- err = mon.authmon()->do_osd_destroy(cephx_entity, lockbox_entity);
- ceph_assert(0 == err);
+ if (!idempotent_auth && !authmon->is_writeable()) {
+ authmon->wait_for_writeable(op, new C_RetryMessage(this, op));
+ return -EAGAIN;
+ }
+ if (!idempotent_cks && !kvmon->is_writeable()) {
+ kvmon->wait_for_writeable(op, new C_RetryMessage(this, op));
+ return -EAGAIN;
}
+ if (!idempotent_auth) {
+ authmon->do_osd_destroy(cephx_entity, lockbox_entity);
+ }
if (!idempotent_cks) {
- svc->do_osd_destroy(id, uuid);
+ kvmon->do_osd_destroy(id, uuid);
}
pending_inc.new_state[id] = CEPH_OSD_DESTROYED;
}
int OSDMonitor::prepare_command_osd_purge(
+ MonOpRequestRef op,
int32_t id,
stringstream& ss)
{
// no point destroying the osd again if it has already been marked destroyed
if (!osdmap.is_destroyed(id)) {
- err = prepare_command_osd_destroy(id, ss);
+ /* N.B.: up to this point, we've not changed pending at all.
+ * ::prepare_command_osd_destroy may return -EAGAIN if the kvmon/authmon is
+ * not writeable without changing pending. It will queue `op` if we should wait.
+ */
+ err = prepare_command_osd_destroy(op, id, ss);
if (err < 0) {
if (err == -ENOENT) {
err = 0;
paxos.plug();
if (is_destroy) {
- err = prepare_command_osd_destroy(id, ss);
+ err = prepare_command_osd_destroy(op, id, ss);
+ if (err == EAGAIN) {
+ return false;
+ }
// we checked above that it should exist.
ceph_assert(err != -ENOENT);
} else {
- err = prepare_command_osd_purge(id, ss);
+ err = prepare_command_osd_purge(op, id, ss);
+ if (err == EAGAIN) {
+ return false;
+ }
if (err == -ENOENT) {
err = 0;
ss << "osd." << id << " does not exist.";
void do_osd_create(const int32_t id, const uuid_d& uuid,
const std::string& device_class,
int32_t* new_id);
- int prepare_command_osd_purge(int32_t id, std::stringstream& ss);
- int prepare_command_osd_destroy(int32_t id, std::stringstream& ss);
+ int prepare_command_osd_purge(MonOpRequestRef op, int32_t id, std::stringstream& ss);
+ int prepare_command_osd_destroy(MonOpRequestRef op, int32_t id, std::stringstream& ss);
int _prepare_command_osd_crush_remove(
CrushWrapper &newcrush,
int32_t id,