diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index d253390d561..31606130378 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -562,7 +562,7 @@ int main(int argc, const char **argv) ::encode(v, final); ::encode(mapbl, final); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); // save it t->put("monmap", v, mapbl); t->put("monmap", "latest", final); diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index ae7185d674b..93b73493823 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -188,7 +188,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) mon->key_server.set_ver(keys_ver); if (keys_ver == 1 && mon->is_keyring_required()) { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->erase("mkfs", "keyring"); mon->store->apply_transaction(t); } diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index fbcfae683ec..099eef73fc8 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -51,7 +51,7 @@ void Elector::bump_epoch(epoch_t e) dout(10) << "bump_epoch " << epoch << " to " << e << dendl; assert(epoch <= e); epoch = e; - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(Monitor::MONITOR_NAME, "election_epoch", epoch); mon->store->apply_transaction(t); @@ -81,7 +81,7 @@ void Elector::start() bump_epoch(epoch+1); // odd == election cycle } else { // do a trivial db write just to ensure it is writeable. - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(Monitor::MONITOR_NAME, "election_writeable_test", rand()); int r = mon->store->apply_transaction(t); assert(r >= 0); @@ -512,7 +512,7 @@ void Elector::dispatch(MonOpRequestRef op) << ", taking it" << dendl; mon->monmap->decode(em->monmap_bl); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put("monmap", mon->monmap->epoch, em->monmap_bl); t->put("monmap", "last_committed", mon->monmap->epoch); mon->store->apply_transaction(t); diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index c195c4f71ac..d85c550fb5b 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -730,7 +730,7 @@ ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog( << channel << "'" << dendl; if (graylogs.count(channel) == 0) { - ceph::logging::Graylog::Ref graylog = ceph::logging::Graylog::Ref(new ceph::logging::Graylog("mon")); + auto graylog(std::make_shared("mon")); graylog->set_fsid(g_conf->fsid); graylog->set_hostname(g_conf->host); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 4b76b9efc0b..a2c34fea29b 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -540,7 +540,7 @@ void Monitor::read_features_off_disk(MonitorDBStore *store, CompatSet *features) *features = get_legacy_features(); features->encode(featuresbl); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(MONITOR_NAME, COMPAT_SET_LOC, featuresbl); store->apply_transaction(t); } else { @@ -1341,7 +1341,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full) if (sync_full) { // stash key state, and mark that we are syncing - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); sync_stash_critical_state(t); t->put("mon_sync", "in_sync", 1); @@ -1405,7 +1405,7 @@ void Monitor::sync_finish(version_t last_committed) if (sync_full) { // finalize the paxos commits - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); paxos->read_and_prepare_transactions(tx, sync_start_version, last_committed); tx->put(paxos->get_name(), "last_committed", last_committed); @@ -1421,7 +1421,7 @@ void Monitor::sync_finish(version_t last_committed) assert(g_conf->mon_sync_requester_kill_at != 8); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->erase("mon_sync", "in_sync"); t->erase("mon_sync", "force_sync"); t->erase("mon_sync", "last_committed_floor"); @@ -1560,7 +1560,7 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op) } MMonSync *reply = new MMonSync(MMonSync::OP_CHUNK, sp.cookie); - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); int left = g_conf->mon_sync_max_payload_size; while (sp.last_committed < paxos->get_version() && left > 0) { @@ -1654,7 +1654,7 @@ void Monitor::handle_sync_chunk(MonOpRequestRef op) assert(state == STATE_SYNCHRONIZING); assert(g_conf->mon_sync_requester_kill_at != 5); - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); tx->append_from_encoded(m->chunk_bl); dout(30) << __func__ << " tx dump:\n"; @@ -1669,7 +1669,7 @@ void Monitor::handle_sync_chunk(MonOpRequestRef op) if (!sync_full) { dout(10) << __func__ << " applying recent paxos transactions as we go" << dendl; - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); paxos->read_and_prepare_transactions(tx, paxos->get_version() + 1, m->last_committed); tx->put(paxos->get_name(), "last_committed", m->last_committed); @@ -2238,7 +2238,7 @@ void Monitor::sync_force(Formatter *f, ostream& ss) free_formatter = true; } - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); sync_stash_critical_state(tx); tx->put("mon_sync", "force_sync", 1); store->apply_transaction(tx); @@ -5181,7 +5181,7 @@ int Monitor::check_fsid() int Monitor::write_fsid() { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); write_fsid(t); int r = store->apply_transaction(t); return r; @@ -5206,7 +5206,7 @@ int Monitor::write_fsid(MonitorDBStore::TransactionRef t) */ int Monitor::mkfs(bufferlist& osdmapbl) { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); // verify cluster fsid int r = check_fsid(); diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index dcd2b1554f3..540f7c67b45 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -184,7 +184,7 @@ class MonitorDBStore } void append_from_encoded(bufferlist& bl) { - TransactionRef other(new Transaction); + auto other(std::make_shared()); bufferlist::iterator it = bl.begin(); other->decode(it); append(other); @@ -374,7 +374,7 @@ class MonitorDBStore string &key, bufferlist &value, uint64_t max) { - TransactionRef tmp(new Transaction); + auto tmp(std::make_shared()); bufferlist tmp_bl; tmp->put(prefix, key, value); tmp->encode(tmp_bl); diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index c4512dc7dc2..b79e20f9ea8 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -66,7 +66,7 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap) mon->monmap->decode(monmap_bl); if (mon->store->exists("mkfs", "monmap")) { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->erase("mkfs", "monmap"); mon->store->apply_transaction(t); } @@ -161,7 +161,7 @@ void MonmapMonitor::on_active() single-threaded process and, truth be told, no one else relies on this thing besides us. */ - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(Monitor::MONITOR_NAME, "joined", 1); mon->store->apply_transaction(t); mon->has_ever_joined = true; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 970e0cdb786..67531ebd842 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -202,7 +202,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) // state, and we shouldn't want to work around it without knowing what // exactly happened. assert(latest_full > 0); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); put_version_latest_full(t, latest_full); mon->store->apply_transaction(t); dout(10) << __func__ << " updated the on-disk full map version to " diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index d473125b548..9c9a2f1f0ff 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -299,7 +299,7 @@ void Paxos::handle_collect(MonOpRequestRef op) dout(10) << "accepting pn " << accepted_pn << " from " << accepted_pn_from << dendl; - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(get_name(), "accepted_pn", accepted_pn); dout(30) << __func__ << " transaction dump:\n"; @@ -413,7 +413,7 @@ void Paxos::share_state(MMonPaxos *m, version_t peer_first_committed, */ bool Paxos::store_state(MMonPaxos *m) { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); map::iterator start = m->values.begin(); bool changed = false; @@ -670,7 +670,7 @@ void Paxos::begin(bufferlist& v) new_value = v; if (last_committed == 0) { - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); // initial base case; set first_committed too t->put(get_name(), "first_committed", 1); decode_append_transaction(t, new_value); @@ -683,7 +683,7 @@ void Paxos::begin(bufferlist& v) // store the proposed value in the store. IF it is accepted, we will then // have to decode it into a transaction and apply it. - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(get_name(), last_committed+1, new_value); // note which pn this pending value is for. @@ -694,7 +694,7 @@ void Paxos::begin(bufferlist& v) JSONFormatter f(true); t->dump(&f); f.flush(*_dout); - MonitorDBStore::TransactionRef debug_tx(new MonitorDBStore::Transaction); + auto debug_tx(std::make_shared()); bufferlist::iterator new_value_it = new_value.begin(); debug_tx->decode(new_value_it); debug_tx->dump(&f); @@ -772,7 +772,7 @@ void Paxos::handle_begin(MonOpRequestRef op) dout(10) << "accepting value for " << v << " pn " << accepted_pn << dendl; // store the accepted value onto our store. We will have to decode it and // apply its transaction once we receive permission to commit. - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(get_name(), v, begin->values[v]); // note which pn this pending value is for. @@ -873,7 +873,7 @@ void Paxos::commit_start() assert(g_conf->paxos_kill_at != 7); - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); // commit locally t->put(get_name(), "last_committed", last_committed + 1); @@ -1280,7 +1280,7 @@ version_t Paxos::get_new_proposal_number(version_t gt) last_pn += (version_t)mon->rank; // write - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); t->put(get_name(), "last_pn", last_pn); dout(30) << __func__ << " transaction dump:\n"; diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index adf252bf0b7..37007d03a41 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1142,7 +1142,7 @@ public: */ static void decode_append_transaction(MonitorDBStore::TransactionRef t, bufferlist& bl) { - MonitorDBStore::TransactionRef vt(new MonitorDBStore::Transaction); + auto vt(std::make_shared()); bufferlist::iterator it = bl.begin(); vt->decode(it); t->append(vt); @@ -1360,7 +1360,7 @@ inline ostream& operator<<(ostream& out, Paxos::C_Proposal& p) out << " " << proposed << " queued " << (ceph_clock_now(NULL) - p.proposal_time) << " tx dump:\n"; - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); bufferlist::iterator p_it = p.bl.begin(); t->decode(p_it); JSONFormatter f(true); diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 5ffb3d16727..aade0abae8e 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -436,7 +436,7 @@ int rewrite_crush(const char* progname, // store the transaction into store as a proposal const string prefix("paxos"); version_t pending_v = store.get(prefix, "last_committed") + 1; - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); bufferlist bl; rewrite_txn.encode(bl); cout << "adding pending commit " << pending_v @@ -482,7 +482,7 @@ int inflate_pgmap(MonitorDBStore& st, unsigned n, bool can_be_trimmed) { version_t first = st.get("pgmap", "first_committed"); version_t ver = last; - MonitorDBStore::TransactionRef txn(new MonitorDBStore::Transaction); + auto txn(std::make_shared()); for (unsigned i = 0; i < n; i++) { bufferlist trans_bl; bufferlist dirty_pgs; @@ -1012,7 +1012,7 @@ int main(int argc, char **argv) { if (bl.length() == 0) break; cout << "\n--- " << v << " ---" << std::endl; - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); Paxos::decode_append_transaction(tx, bl); JSONFormatter f(true); tx->dump(&f); @@ -1192,7 +1192,7 @@ int main(int argc, char **argv) { unsigned num = 0; for (unsigned i = 0; i < ntrans; ++i) { std::cerr << "Applying trans " << i << std::endl; - MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + auto t(std::make_shared()); string prefix; prefix.push_back((i%26)+'a'); for (unsigned j = 0; j < tsize; ++j) { @@ -1234,7 +1234,7 @@ int main(int argc, char **argv) { do { uint64_t num_keys = 0; - MonitorDBStore::TransactionRef tx(new MonitorDBStore::Transaction); + auto tx(std::make_shared()); while (it->valid() && num_keys < 128) { pair k = it->raw_key();