Merge pull request #43033 from markhpc/wip-cyanstore-moreops

src/crimson: Add various missing ops to cyanstore

Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2021-09-02 11:30:40 -07:00 committed by GitHub
commit e8c78046c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 6 deletions

View 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);

View 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);
};