mirror of
https://github.com/ceph/ceph
synced 2025-01-18 17:12:29 +00:00
Merge pull request #5580 from xinxinsh/wip-merge-two-setattr
merge two continuous OP_SETATTR ops into one OP_SETATTRS Reviewed-by: Sage Weil <sage@redhat.com> Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
commit
fb2d4f2139
@ -3243,13 +3243,15 @@ ReplicatedPG::RepGather *ReplicatedPG::trim_object(const hobject_t &coid)
|
||||
ctx->snapset_obc->obs.oi.version;
|
||||
ctx->snapset_obc->obs.oi.version = ctx->at_version;
|
||||
|
||||
map <string, bufferlist> attrs;
|
||||
bl.clear();
|
||||
::encode(snapset, bl);
|
||||
setattr_maybe_cache(ctx->snapset_obc, ctx, t, SS_ATTR, bl);
|
||||
attrs[SS_ATTR].claim(bl);
|
||||
|
||||
bl.clear();
|
||||
::encode(ctx->snapset_obc->obs.oi, bl);
|
||||
setattr_maybe_cache(ctx->snapset_obc, ctx, t, OI_ATTR, bl);
|
||||
attrs[OI_ATTR].claim(bl);
|
||||
setattrs_maybe_cache(ctx->snapset_obc, ctx, t, attrs);
|
||||
|
||||
if (pool.info.require_rollback()) {
|
||||
set<string> changing;
|
||||
@ -6202,11 +6204,13 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc
|
||||
ctx->snapset_obc->obs.oi.mtime = ctx->mtime;
|
||||
ctx->snapset_obc->obs.oi.local_mtime = now;
|
||||
|
||||
map<string, bufferlist> attrs;
|
||||
bufferlist bv(sizeof(ctx->new_obs.oi));
|
||||
::encode(ctx->snapset_obc->obs.oi, bv);
|
||||
ctx->op_t->touch(snapoid);
|
||||
setattr_maybe_cache(ctx->snapset_obc, ctx, ctx->op_t, OI_ATTR, bv);
|
||||
setattr_maybe_cache(ctx->snapset_obc, ctx, ctx->op_t, SS_ATTR, bss);
|
||||
attrs[OI_ATTR].claim(bv);
|
||||
attrs[SS_ATTR].claim(bss);
|
||||
setattrs_maybe_cache(ctx->snapset_obc, ctx, ctx->op_t, attrs);
|
||||
if (pool.info.require_rollback()) {
|
||||
map<string, boost::optional<bufferlist> > to_set;
|
||||
to_set[SS_ATTR];
|
||||
@ -6246,17 +6250,19 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc
|
||||
dout(10) << " mtime unchanged at " << ctx->new_obs.oi.mtime << dendl;
|
||||
}
|
||||
|
||||
map <string, bufferlist> attrs;
|
||||
bufferlist bv(sizeof(ctx->new_obs.oi));
|
||||
::encode(ctx->new_obs.oi, bv);
|
||||
setattr_maybe_cache(ctx->obc, ctx, ctx->op_t, OI_ATTR, bv);
|
||||
attrs[OI_ATTR].claim(bv);
|
||||
|
||||
if (soid.snap == CEPH_NOSNAP) {
|
||||
dout(10) << " final snapset " << ctx->new_snapset
|
||||
<< " in " << soid << dendl;
|
||||
setattr_maybe_cache(ctx->obc, ctx, ctx->op_t, SS_ATTR, bss);
|
||||
attrs[SS_ATTR].claim(bss);
|
||||
} else {
|
||||
dout(10) << " no snapset (this is a clone)" << dendl;
|
||||
}
|
||||
setattrs_maybe_cache(ctx->obc, ctx, ctx->op_t, attrs);
|
||||
|
||||
if (pool.info.require_rollback()) {
|
||||
set<string> changing;
|
||||
@ -10965,8 +10971,10 @@ void ReplicatedPG::hit_set_persist()
|
||||
::encode(ctx->new_obs.oi, boi);
|
||||
|
||||
ctx->op_t->append(oid, 0, bl.length(), bl, 0);
|
||||
setattr_maybe_cache(ctx->obc, ctx, ctx->op_t, OI_ATTR, boi);
|
||||
setattr_maybe_cache(ctx->obc, ctx, ctx->op_t, SS_ATTR, bss);
|
||||
map <string, bufferlist> attrs;
|
||||
attrs[OI_ATTR].claim(boi);
|
||||
attrs[SS_ATTR].claim(bss);
|
||||
setattrs_maybe_cache(ctx->obc, ctx, ctx->op_t, attrs);
|
||||
ctx->log.push_back(
|
||||
pg_log_entry_t(
|
||||
pg_log_entry_t::MODIFY,
|
||||
@ -12324,6 +12332,21 @@ void ReplicatedPG::setattr_maybe_cache(
|
||||
t->setattr(obc->obs.oi.soid, key, val);
|
||||
}
|
||||
|
||||
void ReplicatedPG::setattrs_maybe_cache(
|
||||
ObjectContextRef obc,
|
||||
OpContext *op,
|
||||
PGBackend::PGTransaction *t,
|
||||
map<string, bufferlist> &attrs)
|
||||
{
|
||||
if (pool.info.require_rollback()) {
|
||||
for (map<string, bufferlist>::iterator it = attrs.begin();
|
||||
it != attrs.end(); it++ ) {
|
||||
op->pending_attrs[obc][it->first] = it->second;
|
||||
}
|
||||
}
|
||||
t->setattrs(obc->obs.oi.soid, attrs);
|
||||
}
|
||||
|
||||
void ReplicatedPG::rmattr_maybe_cache(
|
||||
ObjectContextRef obc,
|
||||
OpContext *op,
|
||||
|
@ -1581,6 +1581,11 @@ public:
|
||||
PGBackend::PGTransaction *t,
|
||||
const string &key,
|
||||
bufferlist &val);
|
||||
void setattrs_maybe_cache(
|
||||
ObjectContextRef obc,
|
||||
OpContext *op,
|
||||
PGBackend::PGTransaction *t,
|
||||
map<string, bufferlist> &attrs);
|
||||
void rmattr_maybe_cache(
|
||||
ObjectContextRef obc,
|
||||
OpContext *op,
|
||||
|
Loading…
Reference in New Issue
Block a user