diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 239c754f06391..9c48c18be4e60 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -3260,21 +3260,11 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) case CEPH_OSD_OP_GETXATTRS: ++ctx->num_read; { - map attrset; + map out; result = getattrs_maybe_cache( ctx->obc, - &attrset); - map out; - for (map::iterator i = attrset.begin(); - i != attrset.end(); - ++i) { - if (i->first[0] != '_') - continue; - if (i->first == "_") - continue; - out[i->first.substr(1, i->first.size())].claim( - i->second); - } + &out, + true); bufferlist bl; ::encode(out, bl); @@ -5233,7 +5223,10 @@ int ReplicatedPG::fill_in_copy_get( // attrs map& out_attrs = reply_obj.attrs; if (!cursor.attr_complete) { - result = osd->store->getattrs(coll, soid, out_attrs, true); + result = getattrs_maybe_cache( + ctx->obc, + &out_attrs, + true); if (result < 0) return result; cursor.attr_complete = true; @@ -11319,14 +11312,27 @@ int ReplicatedPG::getattr_maybe_cache( int ReplicatedPG::getattrs_maybe_cache( ObjectContextRef obc, - map *out) + map *out, + bool user_only) { + int r = 0; if (pool.info.require_rollback()) { if (out) *out = obc->attr_cache; - return 0; + } else { + r = pgbackend->objects_get_attrs(obc->obs.oi.soid, out); + } + if (out && user_only) { + map tmp; + for (map::iterator i = out->begin(); + i != out->end(); + ++i) { + if (i->first.size() > 1 && i->first[0] == '_') + tmp[i->first.substr(1, i->first.size())].claim(i->second); + } + tmp.swap(*out); } - return pgbackend->objects_get_attrs(obc->obs.oi.soid, out); + return r; } void intrusive_ptr_add_ref(ReplicatedPG *pg) { pg->get("intptr"); } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index b8a1f020cd345..a8aec999dd3f6 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -1322,7 +1322,8 @@ class ReplicatedPG : public PG, public PGBackend::Listener { bufferlist *val); int getattrs_maybe_cache( ObjectContextRef obc, - map *out); + map *out, + bool user_only = false); }; inline ostream& operator<<(ostream& out, ReplicatedPG::RepGather& repop)