]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os: use transparent comparator in ObjectStore::getattrs()
authorKefu Chai <kchai@redhat.com>
Mon, 28 Jun 2021 11:45:57 +0000 (19:45 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 29 Jun 2021 11:27:25 +0000 (11:27 +0000)
for two reasons:

- better performance when looking on in the return map if the key
  is not a string, as we don't need to create a temporary string
  as the key
- improve the performance of crimson::AlienStore, as the latter
  uses the transparent comparator. as, without this change, we'd
  have to perform a deep copy to fill up the returned map with
  its non-transparent-comparator version.

Signed-off-by: Kefu Chai <kchai@redhat.com>
34 files changed:
src/os/FuseStore.cc
src/os/ObjectStore.h
src/os/Transaction.cc
src/os/Transaction.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/filestore/FileStore.cc
src/os/filestore/FileStore.h
src/os/kstore/KStore.cc
src/os/kstore/KStore.h
src/os/kstore/kstore_types.h
src/os/memstore/MemStore.cc
src/os/memstore/MemStore.h
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/ECMsgTypes.h
src/osd/ECTransaction.cc
src/osd/PGBackend.cc
src/osd/PGBackend.h
src/osd/PGTransaction.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h
src/osd/ReplicatedBackend.cc
src/osd/ReplicatedBackend.h
src/osd/osd_internal_types.h
src/osd/osd_types.h
src/osdc/Objecter.h
src/test/fio/fio_ceph_objectstore.cc
src/test/objectstore/FileStoreDiff.cc
src/test/objectstore/FileStoreDiff.h
src/test/objectstore/store_test.cc
src/tools/RadosDump.h
src/tools/ceph_objectstore_tool.cc
src/tools/rados/PoolDump.cc

index e06131ce33ce57b2d6fc91985dc0778748b8d3f8..dd9833e0861feaac7b3a2ef1356e27756760392c 100644 (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) {
index fb58b0ad520b90597eaab539d75cc45ea4160a28..3b8d33706154edad22bf0f4f57f410454a765ddb 100644 (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);
index af82da3406dd1b79e2ebf75da853e3d583973b40..ac3513ef4a4fca1611094d0372e6f61e47482a8a 100644 (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);
index 93b6272254c77717e5640333dba43358d5e4d50a..f016aa6c315eec4a48693c984ee5a4888815114d 100644 (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;
index e93c87fc26e4273b6b015bef0b7dc791bc94c650..0c4b4adf33fe74bf83d4751f9245869687cbf157 100644 (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;
index a1249607a4d2ad5b000f4dfa0e455ff405e15896..c08cc6d61aac8d55ec064acf5aad9304708c6e07 100644 (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;
 
index 0c143d5721309cc4d854633577bc2cb6b0019ed7..323bb6521cefda32130f1e7d807b0d8abd9e0b69 100644 (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;
index 324dbbe4daf57b511780b1cc3811bf2663156679..e975abc3d483d1aa126686028489bdb5454752f3 100644 (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);
index 8f6b19bda38a291166430bba21161e4a6ec552a7..fe030859e22a6f5e5ee2a814704c4e719816d588 100644 (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());
index 16c4266ee8ed6528c94bf2993963ed72c40ab5f7..d7d95acdfbde5bcdc8801ab899910eb7770a4c2e 100644 (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;
index 859ea8f7dc879a3cd6a3b301cf3a1cdcf44b31d2..f264642e274afe6fe75612d84f9e71f0fa363a81 100644 (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
 
index dc29ab1b6fde88f6458c97003fc8cf73d60f93a6..6c6140df80923e361500fb65abc4cac92901e232 100644 (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;
index 7f0f58e423cdfcd7b5399baad46e2c63f480e851..2a123fae1519158294213b2b8bbd679f653898e8 100644 (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;
 
index 7938f5c0eb731c82afcdf09e2f75f39e9d1d028d..f9398c1722047ba50eccd23b4c53160166dbaa2b 100644 (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,
index c39de1bfeeb87b311da1d41d7607c9da75567d3b..e5e4acee87002fb79b4c5dca94f31164bdcff383 100644 (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,
index 77b4222b28b3a3a3a56d4c723b894a28b053c418..bf10704125c01a93092bc19247c358887977adcd 100644 (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);
index 603f9af0ea329f6c43d454055de21fdb0e68bf96..2a6c67d13eb93a8bba1d9fcd8e5068eb255097a7 100644 (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);
index b6357b12639a9054cef56cc2d38771cc45ecd22d..3b1525bd2713563ac3766bbe499b4c875c8f39d4 100644 (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();
index 12bdfc0d113b43be1d1ed44444c2cfdbc4298d0a..34d74025173e0239d4364bc226244da5add91d5a 100644 (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,
index 3b5b9e72cfa076bd29b7a8624ce8ddbbdbaebc2b..e6f57c90fa1ea62eef8049403c9357177f583ded 100644 (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();
     }
   }
index 7663170f043b4727c77a6eb8bd420db939fdcf1f..25545e079618035c9c6804409aa44aaff1ed09ad 100644 (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;
index 6018f366ca285f483b34cf46ce8c8581d2f00f0a..45cee803385f9894c681abcd943c2225061af9b3 100644 (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(
index 669cdbce0208e0a1c511e33f6b4badbb9ad5966f..f26650bb86d732c7d6ee21c453e41377414e048c 100644 (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)
 {
index f4b5063579a9e9237250774a1b545a14c8198a0f..b1cfe4dd2702bafef6d003db524bc4ef5d90d292 100644 (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,
index 17f4f314643415f9953d68a697ca198139ec34ab..80ecb67a8892f281d186253edc68e5bd0e94c2a9 100644 (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
index fe2fe7defa9a8ce2d1675750c3c567ef7a7d1b28..94693bdfc0faed1531b312e6a6aa0fd6711aad7e 100644 (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
index 5af605913c06d1cbffa8e43791aa35a89534fdd4..e081e832005b361356e52a167ac366ddee67be68 100644 (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,
index 86d38919426a3103b7cc8bb7e30d4fcd3683f104..0846904b1bc01468b934a3c70a84902523a46950 100644 (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);
index e68485701102fc010655ab715cfdb52ac90ad49b..a99e6f3d7d445a0816b9caf49efd0d6aef9aa5b2 100644 (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
index ba9cfb9837bce764012aa47ad7a80901301c5e76..56b53dddb1f9d12c583c92bb81b8ecfe23a7173b 100644 (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);
index 176d1d48b846883462e0449adfbff176773967e1..c77929b0c22ea18d7273b74201fdbfc9b48413c6 100644 (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();
index 83f02e69d5184003e5ab54219abd761545eb95e7..213351e17b0b448797ed288c2556c25bcb99c3b2 100644 (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) {
index 202695d89b08ba21555fd631ab6268cc96c3fd5b..5035e367d813bf5a5adc4737c593c4594f958ebb 100644 (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);
index 9bfafa107dc652f7da25ce44e8123bc8ed2e2b4b..207017036eec5dd1163e363c40dafd1b1b28a7d8 100644 (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)