op.trim_to,
op.trim_rollback_to,
!(op.t.empty()),
- &localt);
+ localt);
ReplicatedPG *_rPG = dynamic_cast<ReplicatedPG *>(get_parent());
if (_rPG && !_rPG->is_undersized() &&
void ECBackend::submit_transaction(
const hobject_t &hoid,
const eversion_t &at_version,
- PGTransaction *_t,
+ PGTransactionUPtr &&_t,
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
const vector<pg_log_entry_t> &log_entries,
op->reqid = reqid;
op->client_op = client_op;
- op->t = static_cast<ECTransaction*>(_t);
+ op->t.reset(static_cast<ECTransaction*>(_t.release()));
set<hobject_t, hobject_t::BitwiseComparator> need_hinfos;
op->t->get_append_objects(&need_hinfos);
void submit_transaction(
const hobject_t &hoid,
const eversion_t &at_version,
- PGTransaction *t,
+ PGTransactionUPtr &&t,
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
const vector<pg_log_entry_t> &log_entries,
osd_reqid_t reqid;
OpRequestRef client_op;
- ECTransaction *t;
+ std::unique_ptr<ECTransaction> t;
set<hobject_t, hobject_t::BitwiseComparator> temp_added;
set<hobject_t, hobject_t::BitwiseComparator> temp_cleared;
map<hobject_t, ECUtil::HashInfoRef, hobject_t::BitwiseComparator> unstable_hash_infos;
~Op() {
- delete t;
delete on_local_applied_sync;
delete on_all_applied;
delete on_all_commit;
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
bool transaction_applied,
- ObjectStore::Transaction *t) = 0;
+ ObjectStore::Transaction &t) = 0;
virtual void update_peer_last_complete_ondisk(
pg_shard_t fromosd,
virtual uint64_t get_bytes_written() const = 0;
virtual ~PGTransaction() {}
};
+ using PGTransactionUPtr = std::unique_ptr<PGTransaction>;
+
/// Get implementation specific empty transaction
virtual PGTransaction *get_transaction() = 0;
virtual void submit_transaction(
const hobject_t &hoid, ///< [in] object
const eversion_t &at_version, ///< [in] version
- PGTransaction *t, ///< [in] trans to execute
+ PGTransactionUPtr &&t, ///< [in] trans to execute (move)
const eversion_t &trim_to, ///< [in] trim log to here
const eversion_t &trim_rollback_to, ///< [in] trim rollback info to here
const vector<pg_log_entry_t> &log_entries, ///< [in] log entries for t
void ReplicatedBackend::submit_transaction(
const hobject_t &soid,
const eversion_t &at_version,
- PGTransaction *_t,
+ PGTransactionUPtr &&_t,
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
const vector<pg_log_entry_t> &log_entries,
osd_reqid_t reqid,
OpRequestRef orig_op)
{
- RPGTransaction *t = dynamic_cast<RPGTransaction*>(_t);
+ std::unique_ptr<RPGTransaction> t(
+ static_cast<RPGTransaction*>(_t.release()));
assert(t);
ObjectStore::Transaction op_t = t->get_transaction();
log_entries,
hset_history,
&op,
- &op_t);
+ op_t);
if (!(t->get_temp_added().empty())) {
add_temp_objs(t->get_temp_added());
trim_to,
trim_rollback_to,
true,
- &op_t);
+ op_t);
op_t.register_on_applied_sync(on_local_applied_sync);
op_t.register_on_applied(
op_t.register_on_commit(
parent->bless_context(
new C_OSD_OnOpCommit(this, &op)));
+
vector<ObjectStore::Transaction> tls;
tls.push_back(std::move(op_t));
+
parent->queue_transactions(tls, op.op);
- delete t;
}
void ReplicatedBackend::op_applied(
const vector<pg_log_entry_t> &log_entries,
boost::optional<pg_hit_set_history_t> &hset_hist,
InProgressOp *op,
- ObjectStore::Transaction *op_t,
+ ObjectStore::Transaction &op_t,
pg_shard_t peer,
const pg_info_t &pinfo)
{
<< ", pinfo.last_backfill "
<< pinfo.last_backfill << ")" << dendl;
ObjectStore::Transaction t;
- t.set_use_tbl(op_t->get_use_tbl());
+ t.set_use_tbl(op_t.get_use_tbl());
::encode(t, wr->get_data());
} else {
- ::encode(*op_t, wr->get_data());
+ ::encode(op_t, wr->get_data());
}
::encode(log_entries, wr->logbl);
const vector<pg_log_entry_t> &log_entries,
boost::optional<pg_hit_set_history_t> &hset_hist,
InProgressOp *op,
- ObjectStore::Transaction *op_t)
+ ObjectStore::Transaction &op_t)
{
if (parent->get_actingbackfill_shards().size() > 1) {
m->pg_trim_to,
m->pg_trim_rollback_to,
update_snaps,
- &(rm->localt));
+ rm->localt);
rm->opt.register_on_commit(
parent->bless_context(
void submit_transaction(
const hobject_t &hoid,
const eversion_t &at_version,
- PGTransaction *t,
+ PGTransactionUPtr &&t,
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
const vector<pg_log_entry_t> &log_entries,
const vector<pg_log_entry_t> &log_entries,
boost::optional<pg_hit_set_history_t> &hset_history,
InProgressOp *op,
- ObjectStore::Transaction *op_t,
+ ObjectStore::Transaction &op_t,
pg_shard_t peer,
const pg_info_t &pinfo);
void issue_op(
const vector<pg_log_entry_t> &log_entries,
boost::optional<pg_hit_set_history_t> &hset_history,
InProgressOp *op,
- ObjectStore::Transaction *op_t);
+ ObjectStore::Transaction &op_t);
void op_applied(InProgressOp *op);
void op_commit(InProgressOp *op);
template<typename T, int MSGTYPE>
// this method must be idempotent since we may call it several times
// before we finally apply the resulting transaction.
- delete ctx->op_t;
- ctx->op_t = pgbackend->get_transaction();
+ ctx->op_t.reset(pgbackend->get_transaction());
if (op->may_write() || op->may_cache()) {
// snap
ctx->release_snapset_obc = true;
ctx->at_version = get_next_version();
- PGBackend::PGTransaction *t = ctx->op_t;
+ PGBackend::PGTransaction *t = ctx->op_t.get();
if (new_snaps.empty()) {
// remove clone
bool first_read = true;
- PGBackend::PGTransaction* t = ctx->op_t;
+ PGBackend::PGTransaction* t = ctx->op_t.get();
dout(10) << "do_osd_op " << soid << " " << ops << dendl;
ObjectState& obs = ctx->new_obs;
object_info_t& oi = obs.oi;
const hobject_t& soid = oi.soid;
- PGBackend::PGTransaction* t = ctx->op_t;
+ PGBackend::PGTransaction* t = ctx->op_t.get();
if (!obs.exists || (obs.oi.is_whiteout() && !no_whiteout))
return -ENOENT;
ObjectState& obs = ctx->new_obs;
object_info_t& oi = obs.oi;
const hobject_t& soid = oi.soid;
- PGBackend::PGTransaction* t = ctx->op_t;
+ PGBackend::PGTransaction* t = ctx->op_t.get();
snapid_t snapid = (uint64_t)op.snap.snapid;
hobject_t missing_oid;
// prepend transaction to op_t
PGBackend::PGTransaction *t = pgbackend->get_transaction();
_make_clone(ctx, t, ctx->clone_obc, soid, coid, snap_oi);
- t->append(ctx->op_t);
- delete ctx->op_t;
- ctx->op_t = t;
+ t->append(ctx->op_t.get());
+ ctx->op_t.reset(t);
ctx->delta_stats.num_objects++;
if (snap_oi->is_dirty()) {
ctx->op_t->touch(snapoid);
attrs[OI_ATTR].claim(bv);
attrs[SS_ATTR].claim(bss);
- setattrs_maybe_cache(ctx->snapset_obc, ctx, ctx->op_t, attrs);
+ setattrs_maybe_cache(ctx->snapset_obc, ctx, ctx->op_t.get(), attrs);
if (pool.info.require_rollback()) {
map<string, boost::optional<bufferlist> > to_set;
to_set[SS_ATTR];
} else {
dout(10) << " no snapset (this is a clone)" << dendl;
}
- setattrs_maybe_cache(ctx->obc, ctx, ctx->op_t, attrs);
+ setattrs_maybe_cache(ctx->obc, ctx, ctx->op_t.get(), attrs);
if (pool.info.require_rollback()) {
set<string> changing;
if (cop->temp_cursor.is_initial()) {
ctx->new_temp_oid = cop->results.temp_oid;
}
- _write_copy_chunk(cop, ctx->op_t);
+ _write_copy_chunk(cop, ctx->op_t.get());
simple_opc_submit(std::move(ctx));
dout(10) << __func__ << " fetching more" << dendl;
_copy_some(cobc, cop);
pgbackend->submit_transaction(
soid,
repop->ctx->at_version,
- repop->ctx->op_t,
+ std::move(repop->ctx->op_t),
pg_trim_to,
min_last_complete_ondisk,
repop->ctx->log,
repop->rep_tid,
repop->ctx->reqid,
repop->ctx->op);
- repop->ctx->op_t = NULL;
}
ReplicatedPG::RepGather *ReplicatedPG::new_repop(
ceph_tid_t rep_tid = osd->get_tid();
osd_reqid_t reqid(osd->get_cluster_msgr_name(), 0, rep_tid);
OpContextUPtr ctx(new OpContext(OpRequestRef(), reqid, ops, obc, this));
- ctx->op_t = pgbackend->get_transaction();
+ ctx->op_t.reset(pgbackend->get_transaction());
ctx->mtime = ceph_clock_now(g_ceph_context);
return ctx;
}
});
- PGBackend::PGTransaction *t = ctx->op_t;
+ PGBackend::PGTransaction *t = ctx->op_t.get();
ctx->log.push_back(pg_log_entry_t(pg_log_entry_t::MODIFY, obc->obs.oi.soid,
ctx->at_version,
oi.version,
map <string, bufferlist> attrs;
attrs[OI_ATTR].claim(boi);
attrs[SS_ATTR].claim(bss);
- setattrs_maybe_cache(ctx->obc, ctx.get(), ctx->op_t, attrs);
+ setattrs_maybe_cache(ctx->obc, ctx.get(), ctx->op_t.get(), attrs);
ctx->log.push_back(
pg_log_entry_t(
pg_log_entry_t::MODIFY,
const eversion_t &trim_to,
const eversion_t &trim_rollback_to,
bool transaction_applied,
- ObjectStore::Transaction *t) {
+ ObjectStore::Transaction &t) {
if (hset_history) {
info.hit_set = *hset_history;
dirty_info = true;
}
- append_log(logv, trim_to, trim_rollback_to, *t, transaction_applied);
+ append_log(logv, trim_to, trim_rollback_to, t, transaction_applied);
}
void op_applied(
int current_osd_subop_num;
- PGBackend::PGTransaction *op_t;
+ PGBackend::PGTransactionUPtr op_t;
vector<pg_log_entry_t> log;
boost::optional<pg_hit_set_history_t> updated_hset_history;
ignore_cache(false), ignore_log_op_stats(false),
bytes_written(0), bytes_read(0), user_at_version(0),
current_osd_subop_num(0),
- op_t(NULL),
obc(obc),
data_off(0), reply(NULL), pg(_pg),
num_read(0),
ignore_cache(false), ignore_log_op_stats(false),
bytes_written(0), bytes_read(0), user_at_version(0),
current_osd_subop_num(0),
- op_t(NULL),
data_off(0), reply(NULL), pg(_pg),
num_read(0),
num_write(0),
*/
void close_op_ctx(OpContext *ctx, int r) {
release_op_ctx_locks(ctx);
- delete ctx->op_t;
- ctx->op_t = NULL;
+ ctx->op_t.reset();
for (auto p = ctx->on_finish.begin();
p != ctx->on_finish.end();
ctx->on_finish.erase(p++)) {