]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/cyanstore: handle OP_RMATTR
authorKefu Chai <kchai@redhat.com>
Fri, 21 Aug 2020 08:15:08 +0000 (16:15 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 24 Aug 2020 09:51:32 +0000 (17:51 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h

index ec1bc5ce4bf319a01d9e6cc00d7ed45a44b52b2b..03d59d77cfd20d93b520781d018012979d7e879e 100644 (file)
@@ -379,6 +379,14 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch,
         r = _setattrs(cid, oid, to_set);
       }
       break;
+      case Transaction::OP_RMATTR:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        ghobject_t oid = i.get_oid(op->oid);
+        std::string name = i.decode_string();
+        r = _rm_attr(cid, oid, name);  
+      }
+      break;
       case Transaction::OP_MKCOLL:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -667,6 +675,26 @@ int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid,
   return 0;
 }
 
+int CyanStore::_rm_attr(const coll_t& cid, const ghobject_t& oid,
+                       std::string_view name)
+{
+  logger().debug("{} cid={} oid={} name={}", __func__, cid, oid, name);
+  auto c = _get_collection(cid);
+  if (!c) {
+    return -ENOENT;
+  }
+  ObjectRef o = c->get_object(oid);
+  if (!o) {
+    return -ENOENT;
+  }
+  auto i = o->xattr.find(name);
+  if (i == o->xattr.end()) {
+    return -ENODATA;
+  }
+  o->xattr.erase(i);
+  return 0;
+}
+
 int CyanStore::_create_collection(const coll_t& cid, int bits)
 {
   auto result = coll_map.try_emplace(cid);
index 86678042f305fdbded609d546e3c3b606612c164..2c773211af1ba5bbe71e74f3c898f160cb28aeed 100644 (file)
@@ -176,6 +176,8 @@ private:
   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,bufferptr>& aset);
+  int _rm_attr(const coll_t& cid, const ghobject_t& oid,
+              string_view name);
   int _create_collection(const coll_t& cid, int bits);
   boost::intrusive_ptr<Collection> _get_collection(const coll_t& cid);
 };