]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/crimson: Add various missing ops to cyanstore 43033/head
authorMark Nelson <mnelson@redhat.com>
Thu, 2 Sep 2021 14:46:26 +0000 (14:46 +0000)
committerMark Nelson <mnelson@redhat.com>
Thu, 2 Sep 2021 14:47:00 +0000 (14:47 +0000)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h

index a7c89d2d2af5823402e6685b0f96b2e11c8d91b9..cafcf8559ee1f6abe00e4de21a858e8a6480a969 100644 (file)
@@ -377,8 +377,17 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch,
         ceph::bufferlist bl;
         i.decode_bl(bl);
         std::map<std::string, bufferlist> to_set;
-       to_set.emplace(name, std::move(bl));
-        r = _setattrs(cid, oid, to_set);
+        to_set.emplace(name, std::move(bl));
+        r = _setattrs(cid, oid, std::move(to_set));
+      }
+      break;
+      case Transaction::OP_SETATTRS:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        ghobject_t oid = i.get_oid(op->oid);
+        std::map<std::string, bufferlist> aset;
+        i.decode_attrset(aset);
+        r = _setattrs(cid, oid, std::move(aset));
       }
       break;
       case Transaction::OP_RMATTR:
@@ -389,12 +398,24 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch,
         r = _rm_attr(cid, oid, name);  
       }
       break;
+      case Transaction::OP_RMATTRS:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        ghobject_t oid = i.get_oid(op->oid);
+        r = _rm_attrs(cid, oid);
+      }
+      break;
       case Transaction::OP_MKCOLL:
       {
         coll_t cid = i.get_cid(op->cid);
         r = _create_collection(cid, op->split_bits);
       }
       break;
+      case Transaction::OP_SETALLOCHINT:
+      {
+        r = 0;
+      }
+      break;
       case Transaction::OP_OMAP_CLEAR:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -660,7 +681,7 @@ int CyanStore::_truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size
 }
 
 int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid,
-                         std::map<std::string,bufferlist>& aset)
+                         std::map<std::string,bufferlist>&& aset)
 {
   logger().debug("{} cid={} oid={}",
                 __func__, cid, oid);
@@ -671,8 +692,7 @@ int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid,
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
-  for (std::map<std::string, bufferlist>::const_iterator p = aset.begin();
-       p != aset.end(); ++p)
+  for (auto p = aset.begin(); p != aset.end(); ++p)
     o->xattr[p->first] = p->second;
   return 0;
 }
@@ -697,6 +717,21 @@ int CyanStore::_rm_attr(const coll_t& cid, const ghobject_t& oid,
   return 0;
 }
 
+int CyanStore::_rm_attrs(const coll_t& cid, const ghobject_t& oid)
+{
+  logger().debug("{} cid={} oid={}", __func__, cid, oid);
+  auto c = _get_collection(cid);
+  if (!c) {
+    return -ENOENT;
+  }
+  ObjectRef o = c->get_object(oid);
+  if (!o) {
+    return -ENOENT;
+  }
+  o->xattr.clear();
+  return 0;
+}
+
 int CyanStore::_create_collection(const coll_t& cid, int bits)
 {
   auto result = coll_map.try_emplace(cid);
index 38f8f6d5ec92d1a540078218d511bfe8b75a0b48..8c182d0dd8afe40963af5a4a6aaf8041d59d18a1 100644 (file)
@@ -172,9 +172,10 @@ private:
     const std::string &last);
   int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size);
   int _setattrs(const coll_t& cid, const ghobject_t& oid,
-                std::map<std::string,bufferlist>& aset);
+                std::map<std::string,bufferlist>&& aset);
   int _rm_attr(const coll_t& cid, const ghobject_t& oid,
                std::string_view name);
+  int _rm_attrs(const coll_t& cid, const ghobject_t& oid);
   int _create_collection(const coll_t& cid, int bits);
   boost::intrusive_ptr<Collection> _get_collection(const coll_t& cid);
 };