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

cleanup: use std::make_shared to replace new #12276

Merged
merged 6 commits into from Jan 6, 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
2 changes: 1 addition & 1 deletion src/ceph_mon.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
// save it
t->put("monmap", v, mapbl);
t->put("monmap", "latest", final);
Expand Down
2 changes: 1 addition & 1 deletion src/common/LogClient.cc
Expand Up @@ -197,7 +197,7 @@ void LogChannel::update_config(map<string,string> &log_to_monitors,
set_log_prio(prio);

if (to_graylog && !graylog) { /* should but isn't */
graylog = ceph::logging::Graylog::Ref(new ceph::logging::Graylog("clog"));
graylog = std::make_shared<ceph::logging::Graylog>("clog");
} else if (!to_graylog && graylog) { /* shouldn't but is */
graylog.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/LogClient.h
Expand Up @@ -219,7 +219,7 @@ class LogClient
if (channels.count(name))
c = channels[name];
else {
c = LogChannelRef(new LogChannel(cct, this, name));
c = std::make_shared<LogChannel>(cct, this, name);
channels[name] = c;
}
return c;
Expand Down
2 changes: 1 addition & 1 deletion src/compressor/zlib/CompressionPluginZlib.h
Expand Up @@ -43,7 +43,7 @@ class CompressionPluginZlib : public CompressionPlugin {
isal = false;
}
if (compressor == 0 || has_isal != isal) {
compressor = CompressorRef(new ZlibCompressor(isal));
compressor = std::make_shared<ZlibCompressor>(isal);
has_isal = isal;
}
*cs = compressor;
Expand Down
2 changes: 1 addition & 1 deletion src/log/Log.cc
Expand Up @@ -191,7 +191,7 @@ void Log::start_graylog()
{
pthread_mutex_lock(&m_flush_mutex);
if (! m_graylog.get())
m_graylog = Graylog::Ref(new Graylog(m_subs, "dlog"));
m_graylog = std::make_shared<Graylog>(m_subs, "dlog");
pthread_mutex_unlock(&m_flush_mutex);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mds/CInode.cc
Expand Up @@ -1889,7 +1889,7 @@ void CInode::finish_scatter_update(ScatterLock *lock, CDir *dir,
dout(10) << "finish_scatter_update " << fg << " journaling accounted scatterstat update v" << inode_version << dendl;

MDLog *mdlog = mdcache->mds->mdlog;
MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mdlog->get_current_segment();

inode_t *pi = get_projected_inode();
Expand Down
8 changes: 4 additions & 4 deletions src/mds/Locker.cc
Expand Up @@ -2260,7 +2260,7 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock,
}
}

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();

inode_t *pi = in->project_inode();
Expand Down Expand Up @@ -2924,7 +2924,7 @@ void Locker::_do_snap_update(CInode *in, snapid_t snap, int dirty, snapid_t foll

EUpdate *le = new EUpdate(mds->mdlog, "snap flush");
mds->mdlog->start_entry(le);
MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();

// normal metadata updates that we can apply to the head as well.
Expand Down Expand Up @@ -3219,7 +3219,7 @@ bool Locker::_do_cap_update(CInode *in, Capability *cap,
inode_t *pi = in->project_inode(px);
pi->version = in->pre_dirty();

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();

_update_cap_fields(in, dirty, m, pi);
Expand Down Expand Up @@ -4224,7 +4224,7 @@ void Locker::scatter_writebehind(ScatterLock *lock)
dout(10) << "scatter_writebehind " << in->inode.mtime << " on " << *lock << " on " << *in << dendl;

// journal
MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();

// forcefully take a wrlock
Expand Down
10 changes: 5 additions & 5 deletions src/mds/MDCache.cc
Expand Up @@ -508,7 +508,7 @@ void MDCache::_create_system_file(CDir *dir, const char *name, CInode *in, MDSIn
SnapRealm *realm = dir->get_inode()->find_snaprealm();
dn->first = in->first = realm->get_newest_seq() + 1;

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());

// force some locks. hacky.
mds->locker->wrlock_force(&dir->inode->filelock, mut);
Expand Down Expand Up @@ -957,7 +957,7 @@ void MDCache::try_subtree_merge_at(CDir *dir, bool do_eval)
inode_t *pi = in->project_inode();
pi->version = in->pre_dirty();

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();
EUpdate *le = new EUpdate(mds->mdlog, "subtree merge writebehind");
mds->mdlog->start_entry(le);
Expand Down Expand Up @@ -6066,7 +6066,7 @@ void MDCache::queue_file_recover(CInode *in)
inode_t *pi = in->project_inode();
pi->version = in->pre_dirty();

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();
EUpdate *le = new EUpdate(mds->mdlog, "queue_file_recover cow");
mds->mdlog->start_entry(le);
Expand Down Expand Up @@ -6279,7 +6279,7 @@ void MDCache::truncate_inode_finish(CInode *in, LogSegment *ls)
pi->truncate_from = 0;
pi->truncate_pending--;

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();
mut->add_projected_inode(in);

Expand Down Expand Up @@ -9175,7 +9175,7 @@ void MDCache::snaprealm_create(MDRequestRef& mdr, CInode *in)
return;
}

MutationRef mut(new MutationImpl);
auto mut(std::make_shared<MutationImpl>());
mut->ls = mds->mdlog->get_current_segment();
EUpdate *le = new EUpdate(mds->mdlog, "snaprealm_create");
mds->mdlog->start_entry(le);
Expand Down
4 changes: 2 additions & 2 deletions src/mds/Migrator.cc
Expand Up @@ -957,7 +957,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid)
return;
}

it->second.mut = MutationRef(new MutationImpl);
it->second.mut = std::make_shared<MutationImpl>();
if (diri->is_auth())
it->second.mut->auth_pin(diri);
mds->locker->rdlock_take_set(rdlocks, it->second.mut);
Expand Down Expand Up @@ -2165,7 +2165,7 @@ void Migrator::handle_export_prep(MExportDirPrep *m)
if (!mds->mdcache->is_readonly() &&
dir->get_inode()->filelock.can_wrlock(-1) &&
dir->get_inode()->nestlock.can_wrlock(-1)) {
it->second.mut = MutationRef(new MutationImpl);
it->second.mut = std::make_shared<MutationImpl>();
// force some locks. hacky.
mds->locker->wrlock_force(&dir->inode->filelock, it->second.mut);
mds->locker->wrlock_force(&dir->inode->nestlock, it->second.mut);
Expand Down
4 changes: 2 additions & 2 deletions src/mds/Server.cc
Expand Up @@ -5325,7 +5325,7 @@ void Server::do_link_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef&
mdcache->add_rollback(rollback.reqid, master); // need to finish this update before resolve finishes
assert(mdr || mds->is_resolve());

MutationRef mut(new MutationImpl(rollback.reqid));
auto mut(std::make_shared<MutationImpl>(rollback.reqid));
mut->ls = mds->mdlog->get_current_segment();

CInode *in = mdcache->get_inode(rollback.ino);
Expand Down Expand Up @@ -7577,7 +7577,7 @@ void Server::do_rename_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef
// need to finish this update before sending resolve to claim the subtree
mdcache->add_rollback(rollback.reqid, master);

MutationRef mut(new MutationImpl(rollback.reqid));
auto mut(std::make_shared<MutationImpl>(rollback.reqid));
mut->ls = mds->mdlog->get_current_segment();

CDentry *srcdn = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/mon/AuthMonitor.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
t->erase("mkfs", "keyring");
mon->store->apply_transaction(t);
}
Expand Down
6 changes: 3 additions & 3 deletions src/mon/Elector.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
t->put(Monitor::MONITOR_NAME, "election_epoch", epoch);
mon->store->apply_transaction(t);

Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
t->put(Monitor::MONITOR_NAME, "election_writeable_test", rand());
int r = mon->store->apply_transaction(t);
assert(r >= 0);
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
t->put("monmap", mon->monmap->epoch, em->monmap_bl);
t->put("monmap", "last_committed", mon->monmap->epoch);
mon->store->apply_transaction(t);
Expand Down
2 changes: 1 addition & 1 deletion src/mon/LogMonitor.cc
Expand Up @@ -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<ceph::logging::Graylog>("mon"));

graylog->set_fsid(g_conf->fsid);
graylog->set_hostname(g_conf->host);
Expand Down
20 changes: 10 additions & 10 deletions src/mon/Monitor.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
t->put(MONITOR_NAME, COMPAT_SET_LOC, featuresbl);
store->apply_transaction(t);
} else {
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
sync_stash_critical_state(t);
t->put("mon_sync", "in_sync", 1);

Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
paxos->read_and_prepare_transactions(tx, sync_start_version,
last_committed);
tx->put(paxos->get_name(), "last_committed", last_committed);
Expand All @@ -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<MonitorDBStore::Transaction>());
t->erase("mon_sync", "in_sync");
t->erase("mon_sync", "force_sync");
t->erase("mon_sync", "last_committed_floor");
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());

int left = g_conf->mon_sync_max_payload_size;
while (sp.last_committed < paxos->get_version() && left > 0) {
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
tx->append_from_encoded(m->chunk_bl);

dout(30) << __func__ << " tx dump:\n";
Expand All @@ -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<MonitorDBStore::Transaction>());
paxos->read_and_prepare_transactions(tx, paxos->get_version() + 1,
m->last_committed);
tx->put(paxos->get_name(), "last_committed", m->last_committed);
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
sync_stash_critical_state(tx);
tx->put("mon_sync", "force_sync", 1);
store->apply_transaction(tx);
Expand Down Expand Up @@ -5181,7 +5181,7 @@ int Monitor::check_fsid()

int Monitor::write_fsid()
{
MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
auto t(std::make_shared<MonitorDBStore::Transaction>());
write_fsid(t);
int r = store->apply_transaction(t);
return r;
Expand All @@ -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<MonitorDBStore::Transaction>());

// verify cluster fsid
int r = check_fsid();
Expand Down
4 changes: 2 additions & 2 deletions src/mon/MonitorDBStore.h
Expand Up @@ -184,7 +184,7 @@ class MonitorDBStore
}

void append_from_encoded(bufferlist& bl) {
TransactionRef other(new Transaction);
auto other(std::make_shared<Transaction>());
bufferlist::iterator it = bl.begin();
other->decode(it);
append(other);
Expand Down Expand Up @@ -374,7 +374,7 @@ class MonitorDBStore
string &key,
bufferlist &value,
uint64_t max) {
TransactionRef tmp(new Transaction);
auto tmp(std::make_shared<Transaction>());
bufferlist tmp_bl;
tmp->put(prefix, key, value);
tmp->encode(tmp_bl);
Expand Down
4 changes: 2 additions & 2 deletions src/mon/MonmapMonitor.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
t->erase("mkfs", "monmap");
mon->store->apply_transaction(t);
}
Expand Down Expand Up @@ -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<MonitorDBStore::Transaction>());
t->put(Monitor::MONITOR_NAME, "joined", 1);
mon->store->apply_transaction(t);
mon->has_ever_joined = true;
Expand Down
2 changes: 1 addition & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -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<MonitorDBStore::Transaction>());
put_version_latest_full(t, latest_full);
mon->store->apply_transaction(t);
dout(10) << __func__ << " updated the on-disk full map version to "
Expand Down