Merge pull request #42054 from tchaikov/wip-os-xattrs

os: use transparent comparator in ObjectStore::getattrs()

Reviewed-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Reviewed-by: Chunmei Liu <chunmei.liu@intel.com>
Reviewed-by: Ronen Friedman <rfriedma@redhat.com>
This commit is contained in:
Kefu Chai 2021-06-30 19:29:17 +08:00 committed by GitHub
commit 6772c71114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 114 additions and 112 deletions

View File

@ -338,13 +338,7 @@ AlienStore::get_attrs(CollectionRef ch,
return seastar::do_with(attrs_t{}, [=] (auto &aset) {
return tp->submit(ch->get_cid().hash_to_shard(tp->size()), [=, &aset] {
auto c = static_cast<AlienCollection*>(ch.get());
std::map<std::string, ceph::bufferptr> blueaset;
const auto r = store->getattrs(c->collection, oid, blueaset);
for (auto& [bluekey, blueval] : blueaset) {
ceph::bufferlist bl;
bl.push_back(std::move(blueval));
aset.emplace(std::move(bluekey), std::move(bl));
}
const auto r = store->getattrs(c->collection, oid, aset);
return r;
}).then([&aset] (int r) -> get_attrs_ertr::future<attrs_t> {
if (r == -ENOENT) {

View File

@ -927,7 +927,7 @@ ReplicatedRecoveryBackend::prep_push_target(
bool complete,
bool clear_omap,
ObjectStore::Transaction* t,
const map<string, bufferlist>& attrs,
const map<string, bufferlist, less<>>& attrs,
bufferlist&& omap_header)
{
if (!first) {
@ -1003,7 +1003,7 @@ ReplicatedRecoveryBackend::submit_push_data(
interval_set<uint64_t>&& intervals_included,
bufferlist&& data_included,
bufferlist&& omap_header,
const map<string, bufferlist> &attrs,
const map<string, bufferlist, less<>> &attrs,
map<string, bufferlist>&& omap_entries,
ObjectStore::Transaction *t)
{

View File

@ -82,7 +82,7 @@ protected:
interval_set<uint64_t>&& intervals_included,
ceph::bufferlist&& data_included,
ceph::bufferlist&& omap_header,
const std::map<string, bufferlist> &attrs,
const std::map<std::string, bufferlist, std::less<>> &attrs,
std::map<string, bufferlist>&& omap_entries,
ceph::os::Transaction *t);
void submit_push_complete(
@ -161,7 +161,7 @@ private:
bool complete,
bool clear_omap,
ObjectStore::Transaction* t,
const map<string, bufferlist> &attrs,
const std::map<std::string, bufferlist, std::less<>> &attrs,
bufferlist&& omap_header);
using interruptor = crimson::interruptible::interruptor<
crimson::osd::IOInterruptCondition>;

View File

@ -554,7 +554,7 @@ static int os_readdir(const char *path,
case FN_OBJECT_ATTR:
{
map<string,bufferptr> aset;
map<string,bufferptr,less<>> aset;
fs->store->getattrs(ch, oid, aset);
unsigned skip = offset;
for (auto a : aset) {

View File

@ -601,7 +601,7 @@ public:
* @returns 0 on success, negative error code on failure.
*/
virtual int getattrs(CollectionHandle &c, const ghobject_t& oid,
std::map<std::string,ceph::buffer::ptr>& aset) = 0;
std::map<std::string,ceph::buffer::ptr, std::less<>>& aset) = 0;
/**
* getattrs -- get all of the xattrs of an object
@ -612,8 +612,8 @@ public:
* @returns 0 on success, negative error code on failure.
*/
int getattrs(CollectionHandle &c, const ghobject_t& oid,
std::map<std::string,ceph::buffer::list>& aset) {
std::map<std::string,ceph::buffer::ptr> bmap;
std::map<std::string,ceph::buffer::list,std::less<>>& aset) {
std::map<std::string,ceph::buffer::ptr,std::less<>> bmap;
int r = getattrs(c, oid, bmap);
for (auto i = bmap.begin(); i != bmap.end(); ++i) {
aset[i->first].append(i->second);

View File

@ -554,7 +554,7 @@ void Transaction::generate_test_instances(list<Transaction*>& o)
t = new Transaction;
t->setattr(c, o1, "key", bl);
map<string,bufferptr> m;
map<string,bufferptr,less<>> m;
m["a"] = buffer::copy("this", 4);
m["b"] = buffer::copy("that", 4);
t->setattrs(c, o1, m);

View File

@ -912,7 +912,9 @@ public:
data.ops = data.ops + 1;
}
/// Set multiple xattrs of an object
void setattrs(const coll_t& cid, const ghobject_t& oid, const std::map<std::string,ceph::buffer::ptr>& attrset) {
void setattrs(const coll_t& cid,
const ghobject_t& oid,
const std::map<std::string,ceph::buffer::ptr,std::less<>>& attrset) {
using ceph::encode;
Op* _op = _get_next_op();
_op->op = OP_SETATTRS;
@ -922,7 +924,9 @@ public:
data.ops = data.ops + 1;
}
/// Set multiple xattrs of an object
void setattrs(const coll_t& cid, const ghobject_t& oid, const std::map<std::string,ceph::buffer::list>& attrset) {
void setattrs(const coll_t& cid,
const ghobject_t& oid,
const std::map<std::string,ceph::buffer::list,std::less<>>& attrset) {
using ceph::encode;
Op* _op = _get_next_op();
_op->op = OP_SETATTRS;

View File

@ -10431,7 +10431,7 @@ int BlueStore::getattr(
int BlueStore::getattrs(
CollectionHandle &c_,
const ghobject_t& oid,
map<string,bufferptr>& aset)
map<string,bufferptr,less<>>& aset)
{
Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->cid << " " << oid << dendl;

View File

@ -2836,7 +2836,7 @@ public:
ceph::buffer::ptr& value) override;
int getattrs(CollectionHandle &c, const ghobject_t& oid,
std::map<std::string,ceph::buffer::ptr>& aset) override;
std::map<std::string,ceph::buffer::ptr, std::less<>>& aset) override;
int list_collections(std::vector<coll_t>& ls) override;

View File

@ -3861,7 +3861,7 @@ int FileStore::_clone(const coll_t& cid, const ghobject_t& oldoid, const ghobjec
{
char buf[2];
map<string, bufferptr> aset;
map<string, bufferptr, less<>> aset;
r = _fgetattrs(**o, aset);
if (r < 0)
goto out3;
@ -4469,7 +4469,7 @@ int FileStore::_fgetattr(int fd, const char *name, bufferptr& bp)
return l;
}
int FileStore::_fgetattrs(int fd, map<string,bufferptr>& aset)
int FileStore::_fgetattrs(int fd, map<string,bufferptr,less<>>& aset)
{
// get attr list
char names1[100];
@ -4520,7 +4520,7 @@ int FileStore::_fgetattrs(int fd, map<string,bufferptr>& aset)
return 0;
}
int FileStore::_fsetattrs(int fd, map<string, bufferptr> &aset)
int FileStore::_fsetattrs(int fd, map<string, bufferptr, less<>> &aset)
{
for (map<string, bufferptr>::iterator p = aset.begin();
p != aset.end();
@ -4635,7 +4635,9 @@ int FileStore::getattr(CollectionHandle& ch, const ghobject_t& oid, const char *
}
}
int FileStore::getattrs(CollectionHandle& ch, const ghobject_t& oid, map<string,bufferptr>& aset)
int FileStore::getattrs(CollectionHandle& ch,
const ghobject_t& oid,
std::map<std::string,bufferptr,std::less<>>& aset)
{
tracepoint(objectstore, getattrs_enter, ch->cid.c_str());
const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
@ -4718,8 +4720,8 @@ int FileStore::_setattrs(const coll_t& cid, const ghobject_t& oid, map<string,bu
{
map<string, bufferlist> omap_set;
set<string> omap_remove;
map<string, bufferptr> inline_set;
map<string, bufferptr> inline_to_set;
map<string, bufferptr, less<>> inline_set;
map<string, bufferptr, less<>> inline_to_set;
FDRef fd;
int spill_out = -1;
bool incomplete_inline = false;
@ -4862,7 +4864,7 @@ int FileStore::_rmattrs(const coll_t& cid, const ghobject_t& oid,
{
dout(15) << __FUNC__ << ": " << cid << "/" << oid << dendl;
map<string,bufferptr> aset;
map<string,bufferptr,less<>> aset;
FDRef fd;
set<string> omap_attrs;
Index index;

View File

@ -646,8 +646,8 @@ public:
int _remove(const coll_t& cid, const ghobject_t& oid, const SequencerPosition &spos);
int _fgetattr(int fd, const char *name, ceph::bufferptr& bp);
int _fgetattrs(int fd, std::map<std::string, ceph::bufferptr>& aset);
int _fsetattrs(int fd, std::map<std::string, ceph::bufferptr> &aset);
int _fgetattrs(int fd, std::map<std::string, ceph::bufferptr,std::less<>>& aset);
int _fsetattrs(int fd, std::map<std::string, ceph::bufferptr,std::less<>>& aset);
void do_force_sync();
void start_sync(Context *onsafe);
@ -692,7 +692,7 @@ public:
using ObjectStore::getattr;
using ObjectStore::getattrs;
int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, ceph::bufferptr &bp) override;
int getattrs(CollectionHandle& c, const ghobject_t& oid, std::map<std::string,ceph::bufferptr>& aset) override;
int getattrs(CollectionHandle& c, const ghobject_t& oid, std::map<std::string,ceph::bufferptr,std::less<>>& aset) override;
int _setattrs(const coll_t& cid, const ghobject_t& oid, std::map<std::string,ceph::bufferptr>& aset,
const SequencerPosition &spos);

View File

@ -1362,7 +1362,7 @@ int KStore::getattr(
int KStore::getattrs(
CollectionHandle& ch,
const ghobject_t& oid,
map<string,bufferptr>& aset)
map<string,bufferptr,less<>>& aset)
{
dout(15) << __func__ << " " << ch->cid << " " << oid << dendl;
Collection *c = static_cast<Collection*>(ch.get());

View File

@ -486,7 +486,9 @@ public:
using ObjectStore::getattr;
int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, ceph::buffer::ptr& value) override;
using ObjectStore::getattrs;
int getattrs(CollectionHandle& c, const ghobject_t& oid, std::map<std::string,ceph::buffer::ptr>& aset) override;
int getattrs(CollectionHandle& c,
const ghobject_t& oid,
std::map<std::string,ceph::buffer::ptr,std::less<>>& aset) override;
int list_collections(std::vector<coll_t>& ls) override;
bool collection_exists(const coll_t& c) override;

View File

@ -41,7 +41,7 @@ WRITE_CLASS_ENCODER(kstore_cnode_t)
struct kstore_onode_t {
uint64_t nid; ///< numeric id (locally unique)
uint64_t size; ///< object size
std::map<std::string, ceph::buffer::ptr> attrs; ///< attrs
std::map<std::string, ceph::buffer::ptr, std::less<>> attrs; ///< attrs
uint64_t omap_head; ///< id for omap root node
uint32_t stripe_size; ///< stripe size

View File

@ -384,7 +384,7 @@ int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid,
}
int MemStore::getattrs(CollectionHandle &c_, const ghobject_t& oid,
std::map<std::string,ceph::buffer::ptr>& aset)
std::map<std::string,ceph::buffer::ptr,std::less<>>& aset)
{
Collection *c = static_cast<Collection*>(c_.get());
dout(10) << __func__ << " " << c->cid << " " << oid << dendl;

View File

@ -32,7 +32,7 @@ public:
struct Object : public RefCountedObject {
ceph::mutex xattr_mutex{ceph::make_mutex("MemStore::Object::xattr_mutex")};
ceph::mutex omap_mutex{ceph::make_mutex("MemStore::Object::omap_mutex")};
std::map<std::string,ceph::buffer::ptr> xattr;
std::map<std::string,ceph::buffer::ptr,std::less<>> xattr;
ceph::buffer::list omap_header;
std::map<std::string,ceph::buffer::list> omap;
@ -310,7 +310,7 @@ public:
int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name,
ceph::buffer::ptr& value) override;
int getattrs(CollectionHandle &c, const ghobject_t& oid,
std::map<std::string,ceph::buffer::ptr>& aset) override;
std::map<std::string,ceph::buffer::ptr,std::less<>>& aset) override;
int list_collections(std::vector<coll_t>& ls) override;

View File

@ -433,7 +433,7 @@ void ECBackend::handle_recovery_push_reply(
void ECBackend::handle_recovery_read_complete(
const hobject_t &hoid,
boost::tuple<uint64_t, uint64_t, map<pg_shard_t, bufferlist> > &to_read,
std::optional<map<string, bufferlist> > attrs,
std::optional<map<string, bufferlist, less<>> > attrs,
RecoveryMessages *m)
{
dout(10) << __func__ << ": returned " << hoid << " "
@ -478,7 +478,7 @@ void ECBackend::handle_recovery_read_complete(
}
// Need to remove ECUtil::get_hinfo_key() since it should not leak out
// of the backend (see bug #12983)
map<string, bufferlist> sanitized_attrs(op.xattrs);
map<string, bufferlist, less<>> sanitized_attrs(op.xattrs);
sanitized_attrs.erase(ECUtil::get_hinfo_key());
op.obc = get_parent()->get_obc(hoid, sanitized_attrs);
ceph_assert(op.obc);
@ -1231,7 +1231,7 @@ void ECBackend::handle_sub_read_reply(
dout(20) << __func__ << " to_read skipping" << dendl;
continue;
}
rop.complete[i->first].attrs = map<string, bufferlist>();
rop.complete[i->first].attrs.emplace();
(*(rop.complete[i->first].attrs)).swap(i->second);
}
for (auto i = op.errors.begin();
@ -1817,7 +1817,7 @@ void ECBackend::do_read_op(ReadOp &op)
}
ECUtil::HashInfoRef ECBackend::get_hash_info(
const hobject_t &hoid, bool checks, const map<string,bufferptr> *attrs)
const hobject_t &hoid, bool checks, const map<string,bufferptr,less<>> *attrs)
{
dout(10) << __func__ << ": Getting attr on " << hoid << dendl;
ECUtil::HashInfoRef ref = unstable_hashinfo_registry.lookup(hoid);
@ -2481,7 +2481,7 @@ int ECBackend::send_all_remaining_reads(
int ECBackend::objects_get_attrs(
const hobject_t &hoid,
map<string, bufferlist> *out)
map<string, bufferlist, less<>> *out)
{
int r = store->getattrs(
ch,

View File

@ -275,7 +275,7 @@ private:
// must be filled if state == WRITING
std::map<int, ceph::buffer::list> returned_data;
std::map<std::string, ceph::buffer::list> xattrs;
std::map<std::string, ceph::buffer::list, std::less<>> xattrs;
ECUtil::HashInfoRef hinfo;
ObjectContextRef obc;
std::set<pg_shard_t> waiting_on_pushes;
@ -298,7 +298,7 @@ private:
void handle_recovery_read_complete(
const hobject_t &hoid,
boost::tuple<uint64_t, uint64_t, std::map<pg_shard_t, ceph::buffer::list> > &to_read,
std::optional<std::map<std::string, ceph::buffer::list> > attrs,
std::optional<std::map<std::string, ceph::buffer::list, std::less<>> > attrs,
RecoveryMessages *m);
void handle_recovery_push(
const PushOp &op,
@ -340,7 +340,7 @@ public:
struct read_result_t {
int r;
std::map<pg_shard_t, int> errors;
std::optional<std::map<std::string, ceph::buffer::list> > attrs;
std::optional<std::map<std::string, ceph::buffer::list, std::less<>> > attrs;
std::list<
boost::tuple<
uint64_t, uint64_t, std::map<pg_shard_t, ceph::buffer::list> > > returned;
@ -630,7 +630,7 @@ public:
/// If modified, ensure that the ref is held until the update is applied
SharedPtrRegistry<hobject_t, ECUtil::HashInfo> unstable_hashinfo_registry;
ECUtil::HashInfoRef get_hash_info(const hobject_t &hoid, bool checks = true,
const std::map<std::string, ceph::buffer::ptr> *attr = NULL);
const std::map<std::string, ceph::buffer::ptr, std::less<>> *attr = NULL);
public:
ECBackend(
@ -661,7 +661,7 @@ public:
int objects_get_attrs(
const hobject_t &hoid,
std::map<std::string, ceph::buffer::list> *out) override;
std::map<std::string, ceph::buffer::list, std::less<>> *out) override;
void rollback_append(
const hobject_t &hoid,

View File

@ -119,7 +119,7 @@ struct ECSubReadReply {
pg_shard_t from;
ceph_tid_t tid;
std::map<hobject_t, std::list<std::pair<uint64_t, ceph::buffer::list> >> buffers_read;
std::map<hobject_t, std::map<std::string, ceph::buffer::list>> attrs_read;
std::map<hobject_t, std::map<std::string, ceph::buffer::list, std::less<>>> attrs_read;
std::map<hobject_t, int> errors;
void encode(ceph::buffer::list &bl) const;
void decode(ceph::buffer::list::const_iterator &bl);

View File

@ -330,7 +330,7 @@ void ECTransaction::generate_transactions(
ceph_assert(op.omap_updates.empty());
if (!op.attr_updates.empty()) {
map<string, bufferlist> to_set;
map<string, bufferlist, less<>> to_set;
for (auto &&j: op.attr_updates) {
if (j.second) {
to_set[j.first] = *(j.second);

View File

@ -467,7 +467,7 @@ int PGBackend::objects_get_attr(
int PGBackend::objects_get_attrs(
const hobject_t &hoid,
map<string, bufferlist> *out)
map<string, bufferlist, less<>> *out)
{
return store->getattrs(
ch,
@ -479,7 +479,7 @@ void PGBackend::rollback_setattrs(
const hobject_t &hoid,
map<string, std::optional<bufferlist> > &old_attrs,
ObjectStore::Transaction *t) {
map<string, bufferlist> to_set;
map<string, bufferlist, less<>> to_set;
ceph_assert(!hoid.is_temp());
for (map<string, std::optional<bufferlist> >::iterator i = old_attrs.begin();
i != old_attrs.end();

View File

@ -212,7 +212,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
virtual ObjectContextRef get_obc(
const hobject_t &hoid,
const std::map<std::string, ceph::buffer::list> &attrs) = 0;
const std::map<std::string, ceph::buffer::list, std::less<>> &attrs) = 0;
virtual bool try_lock_for_read(
const hobject_t &hoid,
@ -557,7 +557,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
virtual int objects_get_attrs(
const hobject_t &hoid,
std::map<std::string, ceph::buffer::list> *out);
std::map<std::string, ceph::buffer::list, std::less<>> *out);
virtual int objects_read_sync(
const hobject_t &hoid,

View File

@ -359,12 +359,12 @@ public:
/// Attr ops
void setattrs(
const hobject_t &hoid, ///< [in] object to write
std::map<std::string, ceph::buffer::list> &attrs ///< [in] attrs, may be cleared
std::map<std::string, ceph::buffer::list, std::less<>> &attrs ///< [in] attrs, may be cleared
) {
auto &op = get_object_op_for_modify(hoid);
for (auto &&i: attrs) {
auto& d = op.attr_updates[i.first];
d = i.second;
for (auto &[key, val]: attrs) {
auto& d = op.attr_updates[key];
d = val;
d->rebuild();
}
}

View File

@ -4846,7 +4846,7 @@ int PrimaryLogPG::trim_object(
head_obc->obs.oi.prior_version = head_obc->obs.oi.version;
head_obc->obs.oi.version = ctx->at_version;
map <string, bufferlist> attrs;
map <string, bufferlist, less<>> attrs;
bl.clear();
encode(snapset, bl);
attrs[SS_ATTR] = std::move(bl);
@ -6341,7 +6341,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
++ctx->num_read;
{
tracepoint(osd, do_osd_op_pre_getxattrs, soid.oid.name.c_str(), soid.snap.val);
map<string, bufferlist> out;
map<string, bufferlist,less<>> out;
result = getattrs_maybe_cache(
ctx->obc,
&out);
@ -7137,7 +7137,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
oi.user_version = target_version;
ctx->user_at_version = target_version;
/* rm_attrs */
map<string,bufferlist> rmattrs;
map<string,bufferlist,less<>> rmattrs;
result = getattrs_maybe_cache(ctx->obc, &rmattrs);
if (result < 0) {
dout(10) << __func__ << " error: " << cpp_strerror(result) << dendl;
@ -8937,7 +8937,7 @@ void PrimaryLogPG::finish_ctx(OpContext *ctx, int log_op_type, int result)
}
// object_info_t
map <string, bufferlist> attrs;
map <string, bufferlist, less<>> attrs;
bufferlist bv(sizeof(ctx->new_obs.oi));
encode(ctx->new_obs.oi, bv,
get_osdmap()->get_features(CEPH_ENTITY_TYPE_OSD, nullptr));
@ -9189,7 +9189,7 @@ int PrimaryLogPG::do_copy_get(OpContext *ctx, bufferlist::const_iterator& bp,
reply_obj.truncate_size = oi.truncate_size;
// attrs
map<string,bufferlist>& out_attrs = reply_obj.attrs;
map<string,bufferlist,less<>>& out_attrs = reply_obj.attrs;
if (!cursor.attr_complete) {
result = getattrs_maybe_cache(
ctx->obc,
@ -11776,7 +11776,7 @@ ObjectContextRef PrimaryLogPG::create_object_context(const object_info_t& oi,
ObjectContextRef PrimaryLogPG::get_object_context(
const hobject_t& soid,
bool can_create,
const map<string, bufferlist> *attrs)
const map<string, bufferlist, less<>> *attrs)
{
auto it_objects = recovery_state.get_pg_log().get_log().objects.find(soid);
ceph_assert(
@ -12196,7 +12196,7 @@ void PrimaryLogPG::kick_object_context_blocked(ObjectContextRef obc)
SnapSetContext *PrimaryLogPG::get_snapset_context(
const hobject_t& oid,
bool can_create,
const map<string, bufferlist> *attrs,
const map<string, bufferlist, less<>> *attrs,
bool oid_existed)
{
std::lock_guard l(snapset_contexts_lock);
@ -14579,9 +14579,10 @@ void PrimaryLogPG::hit_set_persist()
0, bl.length());
ctx->clean_regions.mark_data_region_dirty(0, bl.length());
}
map <string, bufferlist> attrs;
attrs[OI_ATTR] = std::move(boi);
attrs[SS_ATTR] = std::move(bss);
map<string, bufferlist, std::less<>> attrs = {
{OI_ATTR, std::move(boi)},
{SS_ATTR, std::move(bss)}
};
setattrs_maybe_cache(ctx->obc, ctx->op_t.get(), attrs);
ctx->log.push_back(
pg_log_entry_t(
@ -15684,7 +15685,7 @@ void PrimaryLogPG::setattr_maybe_cache(
void PrimaryLogPG::setattrs_maybe_cache(
ObjectContextRef obc,
PGTransaction *t,
map<string, bufferlist> &attrs)
map<string, bufferlist, less<>> &attrs)
{
t->setattrs(obc->obs.oi.soid, attrs);
}
@ -15717,7 +15718,7 @@ int PrimaryLogPG::getattr_maybe_cache(
int PrimaryLogPG::getattrs_maybe_cache(
ObjectContextRef obc,
map<string, bufferlist> *out)
map<string, bufferlist, less<>> *out)
{
int r = 0;
ceph_assert(out);
@ -15726,12 +15727,11 @@ int PrimaryLogPG::getattrs_maybe_cache(
} else {
r = pgbackend->objects_get_attrs(obc->obs.oi.soid, out);
}
map<string, bufferlist> tmp;
for (map<string, bufferlist>::iterator i = out->begin();
i != out->end();
++i) {
if (i->first.size() > 1 && i->first[0] == '_')
tmp[i->first.substr(1, i->first.size())] = std::move(i->second);
map<string, bufferlist, less<>> tmp;
for (auto& [key, val]: *out) {
if (key.size() > 1 && key[0] == '_') {
tmp[key.substr(1, key.size())] = std::move(val);
}
}
tmp.swap(*out);
return r;

View File

@ -97,7 +97,7 @@ public:
uint32_t data_digest, omap_digest;
mempool::osd_pglog::vector<std::pair<osd_reqid_t, version_t> > reqids; // [(reqid, user_version)]
mempool::osd_pglog::map<uint32_t, int> reqid_return_codes; // std::map reqids by index to error code
std::map<std::string, ceph::buffer::list> attrs; // xattrs
std::map<std::string, ceph::buffer::list, std::less<>> attrs; // xattrs
uint64_t truncate_seq;
uint64_t truncate_size;
bool is_data_digest() {
@ -135,7 +135,7 @@ public:
ceph_tid_t objecter_tid2;
object_copy_cursor_t cursor;
std::map<std::string,ceph::buffer::list> attrs;
std::map<std::string,ceph::buffer::list,std::less<>> attrs;
ceph::buffer::list data;
ceph::buffer::list omap_header;
ceph::buffer::list omap_data;
@ -422,7 +422,7 @@ public:
ObjectContextRef get_obc(
const hobject_t &hoid,
const std::map<std::string, ceph::buffer::list> &attrs) override {
const std::map<std::string, ceph::buffer::list, std::less<>> &attrs) override {
return get_object_context(hoid, true, &attrs);
}
@ -1019,7 +1019,7 @@ protected:
ObjectContextRef get_object_context(
const hobject_t& soid,
bool can_create,
const std::map<std::string, ceph::buffer::list> *attrs = 0
const std::map<std::string, ceph::buffer::list, std::less<>> *attrs = 0
);
void context_registry_on_change();
@ -1039,7 +1039,7 @@ protected:
SnapSetContext *get_snapset_context(
const hobject_t& oid,
bool can_create,
const std::map<std::string, ceph::buffer::list> *attrs = 0,
const std::map<std::string, ceph::buffer::list, std::less<>> *attrs = 0,
bool oid_existed = true //indicate this oid whether exsited in backend
);
void register_snapset_context(SnapSetContext *ssc) {
@ -1909,7 +1909,7 @@ public:
void setattrs_maybe_cache(
ObjectContextRef obc,
PGTransaction *t,
std::map<std::string, ceph::buffer::list> &attrs);
std::map<std::string, ceph::buffer::list, std::less<>> &attrs);
void rmattr_maybe_cache(
ObjectContextRef obc,
PGTransaction *t,
@ -1920,7 +1920,7 @@ public:
ceph::buffer::list *val);
int getattrs_maybe_cache(
ObjectContextRef obc,
std::map<std::string, ceph::buffer::list> *out);
std::map<std::string, ceph::buffer::list, std::less<>> *out);
public:
void set_dynamic_perf_stats_queries(

View File

@ -382,7 +382,7 @@ void generate_transaction(
}
if (!op.attr_updates.empty()) {
map<string, bufferlist> attrs;
map<string, bufferlist, less<>> attrs;
for (auto &&p: op.attr_updates) {
if (p.second)
attrs[p.first] = *(p.second);
@ -1599,7 +1599,7 @@ void ReplicatedBackend::submit_push_data(
const interval_set<uint64_t> &intervals_included,
bufferlist data_included,
bufferlist omap_header,
const map<string, bufferlist> &attrs,
const map<string, bufferlist, less<>> &attrs,
const map<string, bufferlist> &omap_entries,
ObjectStore::Transaction *t)
{

View File

@ -280,7 +280,7 @@ private:
const interval_set<uint64_t> &intervals_included,
ceph::buffer::list data_included,
ceph::buffer::list omap_header,
const std::map<std::string, ceph::buffer::list> &attrs,
const std::map<std::string, ceph::buffer::list, std::less<>> &attrs,
const std::map<std::string, ceph::buffer::list> &omap_entries,
ObjectStore::Transaction *t);
void submit_push_complete(const ObjectRecoveryInfo &recovery_info,

View File

@ -41,7 +41,7 @@ public:
std::map<std::pair<uint64_t, entity_name_t>, WatchRef> watchers;
// attr cache
std::map<std::string, ceph::buffer::list> attr_cache;
std::map<std::string, ceph::buffer::list, std::less<>> attr_cache;
RWState rwstate;
std::list<OpRequestRef> waiters; ///< ops waiting on state change

View File

@ -5310,7 +5310,7 @@ struct object_copy_data_t {
utime_t mtime;
uint32_t data_digest, omap_digest;
uint32_t flags;
std::map<std::string, ceph::buffer::list> attrs;
std::map<std::string, ceph::buffer::list, std::less<>> attrs;
ceph::buffer::list data;
ceph::buffer::list omap_header;
ceph::buffer::list omap_data;
@ -6031,7 +6031,7 @@ struct PushOp {
interval_set<uint64_t> data_included;
ceph::buffer::list omap_header;
std::map<std::string, ceph::buffer::list> omap_entries;
std::map<std::string, ceph::buffer::list> attrset;
std::map<std::string, ceph::buffer::list, std::less<>> attrset;
ObjectRecoveryInfo recovery_info;
ObjectRecoveryProgress before_progress;
@ -6056,7 +6056,7 @@ enum class scrub_type_t : bool { not_repair = false, do_repair = true };
*/
struct ScrubMap {
struct object {
std::map<std::string, ceph::buffer::ptr> attrs;
std::map<std::string, ceph::buffer::ptr, std::less<>> attrs;
uint64_t size;
__u32 omap_digest; ///< omap crc32c
__u32 digest; ///< data crc32c

View File

@ -1028,7 +1028,7 @@ struct ObjectOperation {
object_copy_cursor_t *cursor;
uint64_t *out_size;
ceph::real_time *out_mtime;
std::map<std::string,ceph::buffer::list> *out_attrs;
std::map<std::string,ceph::buffer::list,std::less<>> *out_attrs;
ceph::buffer::list *out_data, *out_omap_header, *out_omap_data;
std::vector<snapid_t> *out_snaps;
snapid_t *out_snap_seq;
@ -1043,7 +1043,7 @@ struct ObjectOperation {
C_ObjectOperation_copyget(object_copy_cursor_t *c,
uint64_t *s,
ceph::real_time *m,
std::map<std::string,ceph::buffer::list> *a,
std::map<std::string,ceph::buffer::list,std::less<>> *a,
ceph::buffer::list *d, ceph::buffer::list *oh,
ceph::buffer::list *o,
std::vector<snapid_t> *osnaps,
@ -1122,7 +1122,7 @@ struct ObjectOperation {
uint64_t max,
uint64_t *out_size,
ceph::real_time *out_mtime,
std::map<std::string,ceph::buffer::list> *out_attrs,
std::map<std::string,ceph::buffer::list,std::less<>> *out_attrs,
ceph::buffer::list *out_data,
ceph::buffer::list *out_omap_header,
ceph::buffer::list *out_omap_data,

View File

@ -743,7 +743,7 @@ enum fio_q_status fio_ceph_os_queue(thread_data* td, io_u* u)
bl.push_back(buffer::copy(reinterpret_cast<char*>(u->xfer_buf),
u->xfer_buflen ) );
map<string,bufferptr> attrset;
map<string,bufferptr,less<>> attrset;
map<string, bufferlist> omaps;
// enqueue a write transaction on the collection's handle
ObjectStore::Transaction t;
@ -827,7 +827,7 @@ enum fio_q_status fio_ceph_os_queue(thread_data* td, io_u* u)
}
}
if (attrset.size()) {
if (!attrset.empty()) {
t.setattrs(coll.cid, object.oid, attrset);
}
t.write(coll.cid, object.oid, u->offset, u->xfer_buflen, bl, flags);

View File

@ -43,12 +43,12 @@ FileStoreDiff::~FileStoreDiff()
}
bool FileStoreDiff::diff_attrs(std::map<std::string,bufferptr>& b,
std::map<std::string,bufferptr>& a)
bool FileStoreDiff::diff_attrs(std::map<std::string,bufferptr,std::less<>>& b,
std::map<std::string,bufferptr,std::less<>>& a)
{
bool ret = false;
std::map<std::string, bufferptr>::iterator b_it = b.begin();
std::map<std::string, bufferptr>::iterator a_it = a.begin();
auto b_it = b.begin();
auto a_it = a.begin();
for (; b_it != b.end(); ++b_it, ++a_it) {
if (b_it->first != a_it->first) {
cout << "diff_attrs name mismatch (verify: " << b_it->first
@ -204,7 +204,7 @@ bool FileStoreDiff::diff_objects(FileStore *a_store, FileStore *b_store, coll_t
ret = true;
}
std::map<std::string, bufferptr> a_obj_attrs_map, b_obj_attrs_map;
std::map<std::string, bufferptr, std::less<>> a_obj_attrs_map, b_obj_attrs_map;
err = a_store->getattrs(a_ch, a_obj, a_obj_attrs_map);
if (err < 0) {
cout << "diff_objects getattrs on A object " << coll << "/" << a_obj

View File

@ -29,8 +29,8 @@ class FileStoreDiff {
bool diff_objects(FileStore *a_store, FileStore *b_store, coll_t coll);
bool diff_objects_stat(struct stat& a, struct stat& b);
bool diff_attrs(std::map<std::string,bufferptr>& b,
std::map<std::string,bufferptr>& a);
bool diff_attrs(std::map<std::string,bufferptr,std::less<>>& b,
std::map<std::string,bufferptr,std::less<>>& a);
public:
FileStoreDiff(FileStore *a, FileStore *b);

View File

@ -2805,7 +2805,7 @@ TEST_P(StoreTest, SimpleAttrTest) {
bl.append(bp);
ASSERT_TRUE(bl_eq(val, bl));
map<string,bufferptr> bm;
map<string,bufferptr,less<>> bm;
r = store->getattrs(ch, hoid, bm);
ASSERT_EQ(0, r);
@ -4565,7 +4565,7 @@ public:
boost::uniform_int<> u3(0, 100);
uint64_t size = u0(*rng);
uint64_t name_len;
map<string, bufferlist> attrs;
map<string, bufferlist, less<>> attrs;
set<string> keys;
for (map<string, bufferlist>::iterator it = contents[obj].attrs.begin();
it != contents[obj].attrs.end(); ++it)
@ -4607,7 +4607,7 @@ public:
available_objects.erase(obj);
ObjectStore::Transaction t;
map<string, bufferlist> attrs;
map<string, bufferlist, less<>> attrs;
set<string> keys;
while (entries--) {
@ -4644,7 +4644,7 @@ public:
} while (contents[obj].attrs.empty());
expected = contents[obj].attrs;
}
map<string, bufferlist> attrs;
map<string, bufferlist, less<>> attrs;
int r = store->getattrs(ch, obj, attrs);
ASSERT_TRUE(r == 0);
ASSERT_TRUE(attrs.size() == expected.size());
@ -5736,7 +5736,7 @@ TEST_P(StoreTest, XattrTest) {
ASSERT_EQ(r, 0);
}
map<string, bufferptr> aset;
map<string, bufferptr, less<>> aset;
store->getattrs(ch, hoid, aset);
ASSERT_EQ(aset.size(), attrs.size());
for (map<string, bufferptr>::iterator i = aset.begin();

View File

@ -219,9 +219,9 @@ struct data_section {
};
struct attr_section {
map<string,bufferlist> data;
explicit attr_section(const map<string,bufferlist> &data) : data(data) { }
explicit attr_section(map<string, bufferptr> &data_)
map<string,bufferlist,less<>> data;
explicit attr_section(const map<string,bufferlist,less<>> &data) : data(data) { }
explicit attr_section(map<string, bufferptr, less<>> &data_)
{
for (std::map<std::string, bufferptr>::iterator i = data_.begin();
i != data_.end(); ++i) {

View File

@ -806,7 +806,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
}
//Handle attrs for this object
map<string,bufferptr> aset;
map<string,bufferptr,less<>> aset;
ret = store->getattrs(ch, obj, aset);
if (ret) return ret;
attr_section as(aset);
@ -2143,7 +2143,7 @@ int do_remove_object(ObjectStore *store, coll_t coll,
int do_list_attrs(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
auto ch = store->open_collection(coll);
map<string,bufferptr> aset;
map<string,bufferptr,less<>> aset;
int r = store->getattrs(ch, ghobj, aset);
if (r < 0) {
cerr << "getattrs: " << cpp_strerror(r) << std::endl;
@ -3005,7 +3005,7 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
ObjectStore::Transaction t;
t.touch(cid, oid);
map<string,bufferptr> attrs;
map<string,bufferptr,less<>> attrs;
src->getattrs(ch, oid, attrs);
if (!attrs.empty()) {
t.setattrs(cid, oid, attrs);

View File

@ -96,7 +96,7 @@ int PoolDump::dump(IoCtx *io_ctx)
// Compose TYPE_ATTRS chunk
// ========================
std::map<std::string, bufferlist> raw_xattrs;
std::map<std::string, bufferlist> xattrs;
std::map<std::string, bufferlist,less<>> xattrs;
r = io_ctx->getxattrs(oid, raw_xattrs);
if (r < 0) {
cerr << "error getting xattr set " << oid << ": " << cpp_strerror(r)