Adjusted attr name too (chunk_refcount -> chunk_refs).
Signed-off-by: Sage Weil <sage@newdream.net>
static int chunk_read_refcount(
cls_method_context_t hctx,
- chunk_obj_refcount *objr)
+ chunk_refs_t *objr)
{
bufferlist bl;
objr->clear();
static int chunk_set_refcount(
cls_method_context_t hctx,
- const struct chunk_obj_refcount& objr)
+ const struct chunk_refs_t& objr)
{
bufferlist bl;
return -EINVAL;
}
- chunk_obj_refcount objr;
+ chunk_refs_t objr;
int ret = chunk_read_refcount(hctx, &objr);
if (ret == -ENOENT) {
// new chunk; init refs
return -EINVAL;
}
- chunk_obj_refcount objr;
+ chunk_refs_t objr;
int ret = chunk_read_refcount(hctx, &objr);
if (ret < 0) {
CLS_LOG(1, "ERROR: failed to read attr\n");
return -EINVAL;
}
- chunk_obj_refcount objr;
+ chunk_refs_t objr;
int ret = chunk_read_refcount(hctx, &objr);
if (ret < 0)
return ret;
#include "cls_cas_internal.h"
-struct refs_by_object : public chunk_obj_refcount::refs_t {
+struct refs_by_object : public chunk_refs_t::refs_t {
std::set<hobject_t> by_object;
uint8_t get_type() const {
- return chunk_obj_refcount::TYPE_BY_OBJECT;
+ return chunk_refs_t::TYPE_BY_OBJECT;
}
bool empty() const override {
return by_object.empty();
};
WRITE_CLASS_ENCODER(refs_by_object)
-struct refs_by_hash : public chunk_obj_refcount::refs_t {
+struct refs_by_hash : public chunk_refs_t::refs_t {
uint64_t total = 0;
uint32_t hash_bits = 32; ///< how many bits of mask to encode
std::map<std::pair<int64_t,uint32_t>,uint64_t> by_hash;
}
uint8_t get_type() const {
- return chunk_obj_refcount::TYPE_BY_HASH;
+ return chunk_refs_t::TYPE_BY_HASH;
}
bool empty() const override {
return by_hash.empty();
};
WRITE_CLASS_DENC(refs_by_hash)
-struct refs_by_pool : public chunk_obj_refcount::refs_t {
+struct refs_by_pool : public chunk_refs_t::refs_t {
uint64_t total = 0;
map<int64_t,uint64_t> by_pool;
}
uint8_t get_type() const {
- return chunk_obj_refcount::TYPE_BY_POOL;
+ return chunk_refs_t::TYPE_BY_POOL;
}
bool empty() const override {
return by_pool.empty();
};
WRITE_CLASS_DENC(refs_by_pool)
-struct refs_count : public chunk_obj_refcount::refs_t {
+struct refs_count : public chunk_refs_t::refs_t {
uint64_t total = 0;
refs_count() {}
}
uint8_t get_type() const {
- return chunk_obj_refcount::TYPE_COUNT;
+ return chunk_refs_t::TYPE_COUNT;
}
bool empty() const override {
return total == 0;
//
-void chunk_obj_refcount::clear()
+void chunk_refs_t::clear()
{
// default to most precise impl
r.reset(new refs_by_object);
}
-void chunk_obj_refcount::encode(ceph::buffer::list& bl) const
+void chunk_refs_t::encode(ceph::buffer::list& bl) const
{
bufferlist t;
_encode_r(t);
_encode_final(bl, t);
}
-void chunk_obj_refcount::_encode_r(ceph::bufferlist& bl) const
+void chunk_refs_t::_encode_r(ceph::bufferlist& bl) const
{
using ceph::encode;
switch (r->get_type()) {
}
}
-void chunk_obj_refcount::dynamic_encode(ceph::buffer::list& bl, size_t max)
+void chunk_refs_t::dynamic_encode(ceph::buffer::list& bl, size_t max)
{
bufferlist t;
while (true) {
_encode_final(bl, t);
}
-void chunk_obj_refcount::_encode_final(bufferlist& bl, bufferlist& t) const
+void chunk_refs_t::_encode_final(bufferlist& bl, bufferlist& t) const
{
ENCODE_START(1, 1, bl);
encode(r->get_type(), bl);
ENCODE_FINISH(bl);
}
-void chunk_obj_refcount::decode(ceph::buffer::list::const_iterator& p)
+void chunk_refs_t::decode(ceph::buffer::list::const_iterator& p)
{
DECODE_START(1, p);
uint8_t t;
#include "common/Formatter.h"
#include "common/hobject.h"
-#define CHUNK_REFCOUNT_ATTR "chunk_refcount"
+#define CHUNK_REFCOUNT_ATTR "chunk_refs"
-struct chunk_obj_refcount {
+struct chunk_refs_t {
enum {
TYPE_BY_OBJECT = 1,
TYPE_BY_HASH = 2,
std::unique_ptr<refs_t> r;
- chunk_obj_refcount() {
+ chunk_refs_t() {
clear();
}
void dump(Formatter *f) const {
r->dump(f);
}
- static void generate_test_instances(std::list<chunk_obj_refcount*>& ls) {
- ls.push_back(new chunk_obj_refcount());
+ static void generate_test_instances(std::list<chunk_refs_t*>& ls) {
+ ls.push_back(new chunk_refs_t());
}
};
-WRITE_CLASS_ENCODER(chunk_obj_refcount)
+WRITE_CLASS_ENCODER(chunk_refs_t)
return 1 + count_bits(n & (n - 1));
}
-TEST(chunk_obj_refcount, size)
+TEST(chunk_refs_t, size)
{
- chunk_obj_refcount r;
+ chunk_refs_t r;
size_t max = 1048576;
// mix in pool changes as i gets bigger
}
// verify reencoding is correct
- chunk_obj_refcount a;
+ chunk_refs_t a;
auto t = bl.cbegin();
decode(a, t);
bufferlist bl2;
{
bufferlist t;
cache_ioctx.getxattr("bar", CHUNK_REFCOUNT_ATTR, t);
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
try {
auto iter = t.cbegin();
decode(refs, iter);
{
bufferlist t;
cache_ioctx.getxattr("bar-chunk", CHUNK_REFCOUNT_ATTR, t);
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
try {
auto iter = t.cbegin();
decode(refs, iter);
{
bufferlist t;
cache_ioctx.getxattr("bar", CHUNK_REFCOUNT_ATTR, t);
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
try {
auto iter = t.cbegin();
decode(refs, iter);
{
bufferlist t;
cache_ioctx.getxattr("bar-chunk", CHUNK_REFCOUNT_ATTR, t);
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
try {
auto iter = t.cbegin();
decode(refs, iter);
sha1_gen.Final(fingerprint);
buf_to_hex(fingerprint, CEPH_CRYPTO_SHA1_DIGESTSIZE, p_str);
cache_ioctx.getxattr(p_str, CHUNK_REFCOUNT_ATTR, t);
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
try {
auto iter = t.cbegin();
decode(refs, iter);
TYPE(cls_cas_chunk_put_ref_op)
#include "cls/cas/cls_cas_internal.h"
-TYPE(chunk_obj_refcount)
+TYPE(chunk_refs_t)
#include "cls/lock/cls_lock_types.h"
TYPE(rados::cls::lock::locker_id_t)
}
auto oid = i.oid;
cout << oid << std::endl;
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
{
bufferlist t;
ret = chunk_io_ctx.getxattr(oid, CHUNK_REFCOUNT_ATTR, t);
}
examined_objects++;
- if (refs.get_type() != chunk_obj_refcount::TYPE_BY_OBJECT) {
+ if (refs.get_type() != chunk_refs_t::TYPE_BY_OBJECT) {
// we can't do anything here
continue;
}
// check all objects
- chunk_obj_refcount::refs_by_object *byo =
- static_cast<chunk_obj_refcount::refs_by_object*>(refs.r.get());
+ chunk_refs_t::refs_by_object *byo =
+ static_cast<chunk_refs_t::refs_by_object*>(refs.r.get());
set<hobject_t> real_refs;
uint64_t pool_missing = 0;
if (ret < 0) {
return ret;
}
- chunk_obj_refcount refs;
+ chunk_refs_t refs;
auto p = t.cbegin();
decode(refs, p);
auto f = Formatter::create("json-pretty");