From: myoungwon oh Date: Sun, 22 Jul 2018 16:35:58 +0000 (+0900) Subject: osd: using fingerprint OID if fingerprint is set X-Git-Tag: v14.0.1~340^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42e24a441f41f82576899a55dfe025320716d599;p=ceph.git osd: using fingerprint OID if fingerprint is set cas class is introduced(cas class includes a write_or_get op) This operation increase the reference count if the chunk is already stored. Signed-off-by: Myoungwon Oh --- diff --git a/src/cls/CMakeLists.txt b/src/cls/CMakeLists.txt index 2369f3c17966..fa0c05d9acfb 100644 --- a/src/cls/CMakeLists.txt +++ b/src/cls/CMakeLists.txt @@ -262,3 +262,17 @@ set(cls_lua_client_srcs lua/cls_lua_client.cc) add_library(cls_lua_client STATIC ${cls_lua_client_srcs}) +# cls_cas +set(cls_cas_srcs + cas/cls_cas.cc) +add_library(cls_cas SHARED ${cls_cas_srcs}) +set_target_properties(cls_cas PROPERTIES + VERSION "1.0.0" + SOVERSION "1" + INSTALL_RPATH "" + CXX_VISIBILITY_PRESET hidden) +install(TARGETS cls_cas DESTINATION ${cls_dir}) + +set(cls_cas_client_srcs + cas/cls_cas_client.cc) +add_library(cls_cas_client STATIC ${cls_cas_client_srcs}) diff --git a/src/cls/cas/cls_cas.cc b/src/cls/cas/cls_cas.cc new file mode 100644 index 000000000000..cfa808e0d632 --- /dev/null +++ b/src/cls/cas/cls_cas.cc @@ -0,0 +1,239 @@ +// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include + +#include "objclass/objclass.h" +#include "cls_cas_ops.h" + +#include "include/compat.h" +#include "osd/osd_types.h" + +CLS_VER(1,0) +CLS_NAME(cas) + +struct chunk_obj_refcount; + +static int chunk_read_refcount(cls_method_context_t hctx, chunk_obj_refcount *objr) +{ + bufferlist bl; + objr->refs.clear(); + int ret = cls_cxx_getxattr(hctx, CHUNK_REFCOUNT_ATTR, &bl); + if (ret == -ENODATA) { + return 0; + } + if (ret < 0) + return ret; + + try { + auto iter = bl.cbegin(); + decode(*objr, iter); + } catch (buffer::error& err) { + CLS_LOG(0, "ERROR: chunk_read_refcount(): failed to decode refcount entry\n"); + return -EIO; + } + + return 0; +} + +static int chunk_set_refcount(cls_method_context_t hctx, const struct chunk_obj_refcount& objr) +{ + bufferlist bl; + + encode(objr, bl); + + int ret = cls_cxx_setxattr(hctx, CHUNK_REFCOUNT_ATTR, &bl); + if (ret < 0) + return ret; + + return 0; +} + +static int cls_rc_chunk_refcount_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) +{ + auto in_iter = in->cbegin(); + + cls_chunk_refcount_get_op op; + try { + decode(op, in_iter); + } catch (buffer::error& err) { + CLS_LOG(1, "ERROR: cls_rc_refcount_get(): failed to decode entry\n"); + return -EINVAL; + } + + chunk_obj_refcount objr; + int ret = chunk_read_refcount(hctx, &objr); + if (ret < 0) + return ret; + + CLS_LOG(10, "cls_rc_chunk_refcount_get() oid=%s\n", op.source.oid.name.c_str()); + + objr.refs.insert(op.source); + + ret = chunk_set_refcount(hctx, objr); + if (ret < 0) + return ret; + + return 0; +} + +static int cls_rc_chunk_refcount_put(cls_method_context_t hctx, bufferlist *in, bufferlist *out) +{ + auto in_iter = in->cbegin(); + + cls_chunk_refcount_put_op op; + try { + decode(op, in_iter); + } catch (buffer::error& err) { + CLS_LOG(1, "ERROR: cls_rc_chunk_refcount_put(): failed to decode entry\n"); + return -EINVAL; + } + + chunk_obj_refcount objr; + int ret = chunk_read_refcount(hctx, &objr); + if (ret < 0) + return ret; + + if (objr.refs.empty()) {// shouldn't happen! + CLS_LOG(0, "ERROR: cls_rc_chunk_refcount_put() was called without any references!\n"); + return -EINVAL; + } + + CLS_LOG(10, "cls_rc_chunk_refcount_put() oid=%s\n", op.source.oid.name.c_str()); + + bool found = false; + for (auto &p : objr.refs) { + if (p == op.source) { + found = true; + break; + } + } + + if (!found) { + return 0; + } + + auto p = objr.refs.find(op.source); + objr.refs.erase(p); + + if (objr.refs.empty()) { + return cls_cxx_remove(hctx); + } + + ret = chunk_set_refcount(hctx, objr); + if (ret < 0) + return ret; + + return 0; +} + +static int cls_rc_chunk_refcount_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) +{ + auto in_iter = in->cbegin(); + + cls_chunk_refcount_set_op op; + try { + decode(op, in_iter); + } catch (buffer::error& err) { + CLS_LOG(1, "ERROR: cls_chunk_refcount_set(): failed to decode entry\n"); + return -EINVAL; + } + + if (!op.refs.size()) { + return cls_cxx_remove(hctx); + } + + chunk_obj_refcount objr; + objr.refs = op.refs; + + int ret = chunk_set_refcount(hctx, objr); + if (ret < 0) + return ret; + + return 0; +} + +static int cls_rc_chunk_refcount_read(cls_method_context_t hctx, bufferlist *in, bufferlist *out) +{ + chunk_obj_refcount objr; + + cls_chunk_refcount_read_ret read_ret; + int ret = chunk_read_refcount(hctx, &objr); + if (ret < 0) + return ret; + + for (auto &p : objr.refs) { + read_ret.refs.insert(p); + } + + encode(read_ret, *out); + + return 0; +} + +static int cls_rc_write_or_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) +{ + auto in_iter = in->cbegin(); + hobject_t src_obj; + bufferlist indata, outdata; + ceph_osd_op op; + try { + decode (op, in_iter); + decode(src_obj, in_iter); + in_iter.copy(op.extent.length, indata); + } + catch (buffer::error& e) { + return -EINVAL; + } + + CLS_LOG(10, " offset: %llu length: %llu \n", op.extent.offset, op.extent.length); + chunk_obj_refcount objr; + int ret = chunk_read_refcount(hctx, &objr); + if (ret == -ENOENT) { + objr.refs.insert(src_obj); + bufferlist set_bl; + encode(objr, set_bl); + ret = cls_cxx_chunk_write_and_set(hctx, op.extent.offset, op.extent.length, &indata, op.flags, + &set_bl, set_bl.length()); + if (ret < 0) + return ret; + + return 0; + } + + objr.refs.insert(src_obj); + ret = chunk_set_refcount(hctx, objr); + if (ret < 0) + return ret; + + return 0; +} + +CLS_INIT(cas) +{ + CLS_LOG(1, "Loaded cas class!"); + + cls_handle_t h_class; + cls_method_handle_t h_cas_write_or_get; + cls_method_handle_t h_chunk_refcount_get; + cls_method_handle_t h_chunk_refcount_put; + cls_method_handle_t h_chunk_refcount_set; + cls_method_handle_t h_chunk_refcount_read; + + cls_register("cas", &h_class); + + /* chunk refcount */ + cls_register_cxx_method(h_class, "chunk_get", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_get, + &h_chunk_refcount_get); + cls_register_cxx_method(h_class, "chunk_put", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_put, + &h_chunk_refcount_put); + cls_register_cxx_method(h_class, "chunk_set", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_set, + &h_chunk_refcount_set); + cls_register_cxx_method(h_class, "chunk_read", CLS_METHOD_RD, cls_rc_chunk_refcount_read, + &h_chunk_refcount_read); + cls_register_cxx_method(h_class, "cas_write_or_get", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_write_or_get, + &h_cas_write_or_get); + + return; +} + diff --git a/src/cls/cas/cls_cas_client.cc b/src/cls/cas/cls_cas_client.cc new file mode 100644 index 000000000000..bcea9d022086 --- /dev/null +++ b/src/cls/cas/cls_cas_client.cc @@ -0,0 +1,54 @@ +#include + +#include "cls/cas/cls_cas_client.h" +#include "cls/cas/cls_cas_ops.h" +#include "include/rados/librados.hpp" + +using namespace librados; + +void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid) +{ + bufferlist in; + cls_chunk_refcount_get_op call; + call.source = soid; + encode(call, in); + op.exec("refcount", "chunk_get", in); +} + +void cls_chunk_refcount_put(librados::ObjectWriteOperation& op, const hobject_t& soid) +{ + bufferlist in; + cls_chunk_refcount_put_op call; + call.source = soid; + encode(call, in); + op.exec("refcount", "chunk_put", in); +} + +void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, set& refs) +{ + bufferlist in; + cls_chunk_refcount_set_op call; + call.refs = refs; + encode(call, in); + op.exec("refcount", "chunk_set", in); +} + +int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set *refs) +{ + bufferlist in, out; + int r = io_ctx.exec(oid, "refcount", "chunk_read", in, out); + if (r < 0) + return r; + + cls_chunk_refcount_read_ret ret; + try { + auto iter = out.cbegin(); + decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + + *refs = ret.refs; + + return r; +} diff --git a/src/cls/cas/cls_cas_client.h b/src/cls/cas/cls_cas_client.h new file mode 100644 index 000000000000..4fad0f601a90 --- /dev/null +++ b/src/cls/cas/cls_cas_client.h @@ -0,0 +1,16 @@ +#ifndef CEPH_CLS_CAS_CLIENT_H +#define CEPH_CLS_CAS_CLIENT_H + +#include "include/types.h" +#include "common/hobject.h" + +namespace librados { + class ObjectWriteOperation; + class IoCtx; +} + +void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid); +void cls_chunk_refcount_put(librados::ObjectWriteOperation& op, const hobject_t& soid); +void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, set& refs); +int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set *refs); +#endif diff --git a/src/cls/cas/cls_cas_ops.h b/src/cls/cas/cls_cas_ops.h new file mode 100644 index 000000000000..35bc90dfa4f8 --- /dev/null +++ b/src/cls/cas/cls_cas_ops.h @@ -0,0 +1,142 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_CLS_CAS_OPS_H +#define CEPH_CLS_CAS_OPS_H + +#include "include/types.h" +#include "common/hobject.h" + +#define CHUNK_REFCOUNT_ATTR "chunk_refcount" + +struct cls_chunk_refcount_get_op { + hobject_t source; + + cls_chunk_refcount_get_op() {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(source, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(source, bl); + DECODE_FINISH(bl); + } + void dump(ceph::Formatter *f) const; + static void generate_test_instances(list& ls); +}; +WRITE_CLASS_ENCODER(cls_chunk_refcount_get_op) + +struct cls_chunk_refcount_put_op { + hobject_t source; + + cls_chunk_refcount_put_op() {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(source, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(source, bl); + DECODE_FINISH(bl); + } + + void dump(ceph::Formatter *f) const; + static void generate_test_instances(list& ls); +}; +WRITE_CLASS_ENCODER(cls_chunk_refcount_put_op) + +struct cls_chunk_refcount_set_op { + set refs; + + cls_chunk_refcount_set_op() {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(refs, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(refs, bl); + DECODE_FINISH(bl); + } + + void dump(ceph::Formatter *f) const; + static void generate_test_instances(list& ls); +}; +WRITE_CLASS_ENCODER(cls_chunk_refcount_set_op) + +struct cls_chunk_refcount_read_ret { + set refs; + + cls_chunk_refcount_read_ret() {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(refs, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(refs, bl); + DECODE_FINISH(bl); + } + + void dump(ceph::Formatter *f) const; + static void generate_test_instances(list& ls); +}; +WRITE_CLASS_ENCODER(cls_chunk_refcount_read_ret) + +struct chunk_obj_refcount { + set refs; + + chunk_obj_refcount() {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(refs, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(refs, bl); + DECODE_FINISH(bl); + } +}; +WRITE_CLASS_ENCODER(chunk_obj_refcount) + +struct obj_refcount { + map refs; + set retired_refs; + + obj_refcount() {} + + void encode(bufferlist& bl) const { + ENCODE_START(2, 1, bl); + encode(refs, bl); + encode(retired_refs, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(2, bl); + decode(refs, bl); + if (struct_v >= 2) { + decode(retired_refs, bl); + } + DECODE_FINISH(bl); + } +}; +WRITE_CLASS_ENCODER(obj_refcount) + +#endif diff --git a/src/cls/refcount/cls_refcount.cc b/src/cls/refcount/cls_refcount.cc index 24798342eea1..73cc3b852fdd 100644 --- a/src/cls/refcount/cls_refcount.cc +++ b/src/cls/refcount/cls_refcount.cc @@ -13,50 +13,6 @@ CLS_NAME(refcount) #define REFCOUNT_ATTR "refcount" -#define CHUNK_REFCOUNT_ATTR "chunk_refcount" - -struct chunk_obj_refcount { - set refs; - - chunk_obj_refcount() {} - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - encode(refs, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); - decode(refs, bl); - DECODE_FINISH(bl); - } -}; -WRITE_CLASS_ENCODER(chunk_obj_refcount) - -struct obj_refcount { - map refs; - set retired_refs; - - obj_refcount() {} - - void encode(bufferlist& bl) const { - ENCODE_START(2, 1, bl); - encode(refs, bl); - encode(retired_refs, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::const_iterator& bl) { - DECODE_START(2, bl); - decode(refs, bl); - if (struct_v >= 2) { - decode(retired_refs, bl); - } - DECODE_FINISH(bl); - } -}; -WRITE_CLASS_ENCODER(obj_refcount) static string wildcard_tag; @@ -237,163 +193,6 @@ static int cls_rc_refcount_read(cls_method_context_t hctx, bufferlist *in, buffe return 0; } -static int chunk_read_refcount(cls_method_context_t hctx, chunk_obj_refcount *objr) -{ - bufferlist bl; - objr->refs.clear(); - int ret = cls_cxx_getxattr(hctx, CHUNK_REFCOUNT_ATTR, &bl); - if (ret == -ENODATA) { - return 0; - } - if (ret < 0) - return ret; - - try { - auto iter = bl.cbegin(); - decode(*objr, iter); - } catch (buffer::error& err) { - CLS_LOG(0, "ERROR: chunk_read_refcount(): failed to decode refcount entry\n"); - return -EIO; - } - - return 0; -} - -static int chunk_set_refcount(cls_method_context_t hctx, const struct chunk_obj_refcount& objr) -{ - bufferlist bl; - - encode(objr, bl); - - int ret = cls_cxx_setxattr(hctx, CHUNK_REFCOUNT_ATTR, &bl); - if (ret < 0) - return ret; - - return 0; -} - -static int cls_rc_chunk_refcount_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) -{ - auto in_iter = in->cbegin(); - - cls_chunk_refcount_get_op op; - try { - decode(op, in_iter); - } catch (buffer::error& err) { - CLS_LOG(1, "ERROR: cls_rc_refcount_get(): failed to decode entry\n"); - return -EINVAL; - } - - chunk_obj_refcount objr; - int ret = chunk_read_refcount(hctx, &objr); - if (ret < 0) - return ret; - - CLS_LOG(10, "cls_rc_chunk_refcount_get() oid=%s\n", op.source.oid.name.c_str()); - - objr.refs.insert(op.source); - - ret = chunk_set_refcount(hctx, objr); - if (ret < 0) - return ret; - - return 0; -} - -static int cls_rc_chunk_refcount_put(cls_method_context_t hctx, bufferlist *in, bufferlist *out) -{ - auto in_iter = in->cbegin(); - - cls_chunk_refcount_put_op op; - try { - decode(op, in_iter); - } catch (buffer::error& err) { - CLS_LOG(1, "ERROR: cls_rc_chunk_refcount_put(): failed to decode entry\n"); - return -EINVAL; - } - - chunk_obj_refcount objr; - int ret = chunk_read_refcount(hctx, &objr); - if (ret < 0) - return ret; - - if (objr.refs.empty()) {// shouldn't happen! - CLS_LOG(0, "ERROR: cls_rc_chunk_refcount_put() was called without any references!\n"); - return -EINVAL; - } - - CLS_LOG(10, "cls_rc_chunk_refcount_put() oid=%s\n", op.source.oid.name.c_str()); - - bool found = false; - for (auto &p : objr.refs) { - if (p == op.source) { - found = true; - break; - } - } - - if (!found) { - return 0; - } - - auto p = objr.refs.find(op.source); - objr.refs.erase(p); - - if (objr.refs.empty()) { - return cls_cxx_remove(hctx); - } - - ret = chunk_set_refcount(hctx, objr); - if (ret < 0) - return ret; - - return 0; -} - -static int cls_rc_chunk_refcount_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) -{ - auto in_iter = in->cbegin(); - - cls_chunk_refcount_set_op op; - try { - decode(op, in_iter); - } catch (buffer::error& err) { - CLS_LOG(1, "ERROR: cls_chunk_refcount_set(): failed to decode entry\n"); - return -EINVAL; - } - - if (!op.refs.size()) { - return cls_cxx_remove(hctx); - } - - chunk_obj_refcount objr; - objr.refs = op.refs; - - int ret = chunk_set_refcount(hctx, objr); - if (ret < 0) - return ret; - - return 0; -} - -static int cls_rc_chunk_refcount_read(cls_method_context_t hctx, bufferlist *in, bufferlist *out) -{ - chunk_obj_refcount objr; - - cls_chunk_refcount_read_ret read_ret; - int ret = chunk_read_refcount(hctx, &objr); - if (ret < 0) - return ret; - - for (auto &p : objr.refs) { - read_ret.refs.insert(p); - } - - encode(read_ret, *out); - - return 0; -} - CLS_INIT(refcount) { CLS_LOG(1, "Loaded refcount class!"); @@ -404,11 +203,6 @@ CLS_INIT(refcount) cls_method_handle_t h_refcount_set; cls_method_handle_t h_refcount_read; - cls_method_handle_t h_chunk_refcount_get; - cls_method_handle_t h_chunk_refcount_put; - cls_method_handle_t h_chunk_refcount_set; - cls_method_handle_t h_chunk_refcount_read; - cls_register("refcount", &h_class); /* refcount */ @@ -416,15 +210,6 @@ CLS_INIT(refcount) cls_register_cxx_method(h_class, "put", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_refcount_put, &h_refcount_put); cls_register_cxx_method(h_class, "set", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_refcount_set, &h_refcount_set); cls_register_cxx_method(h_class, "read", CLS_METHOD_RD, cls_rc_refcount_read, &h_refcount_read); - /* chunk refcount */ - cls_register_cxx_method(h_class, "chunk_get", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_get, - &h_chunk_refcount_get); - cls_register_cxx_method(h_class, "chunk_put", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_put, - &h_chunk_refcount_put); - cls_register_cxx_method(h_class, "chunk_set", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_chunk_refcount_set, - &h_chunk_refcount_set); - cls_register_cxx_method(h_class, "chunk_read", CLS_METHOD_RD, cls_rc_chunk_refcount_read, - &h_chunk_refcount_read); return; } diff --git a/src/cls/refcount/cls_refcount_client.cc b/src/cls/refcount/cls_refcount_client.cc index ae2853f73e0b..9d5210c8abc8 100644 --- a/src/cls/refcount/cls_refcount_client.cc +++ b/src/cls/refcount/cls_refcount_client.cc @@ -59,49 +59,3 @@ int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list *refs, return r; } -void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid) -{ - bufferlist in; - cls_chunk_refcount_get_op call; - call.source = soid; - encode(call, in); - op.exec("refcount", "chunk_get", in); -} - -void cls_chunk_refcount_put(librados::ObjectWriteOperation& op, const hobject_t& soid) -{ - bufferlist in; - cls_chunk_refcount_put_op call; - call.source = soid; - encode(call, in); - op.exec("refcount", "chunk_put", in); -} - -void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, set& refs) -{ - bufferlist in; - cls_chunk_refcount_set_op call; - call.refs = refs; - encode(call, in); - op.exec("refcount", "chunk_set", in); -} - -int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set *refs) -{ - bufferlist in, out; - int r = io_ctx.exec(oid, "refcount", "chunk_read", in, out); - if (r < 0) - return r; - - cls_chunk_refcount_read_ret ret; - try { - auto iter = out.cbegin(); - decode(ret, iter); - } catch (buffer::error& err) { - return -EIO; - } - - *refs = ret.refs; - - return r; -} diff --git a/src/cls/refcount/cls_refcount_ops.h b/src/cls/refcount/cls_refcount_ops.h index 6775d82cdaee..3feaedc92d46 100644 --- a/src/cls/refcount/cls_refcount_ops.h +++ b/src/cls/refcount/cls_refcount_ops.h @@ -124,90 +124,28 @@ struct cls_refcount_read_ret { }; WRITE_CLASS_ENCODER(cls_refcount_read_ret) -struct cls_chunk_refcount_get_op { - hobject_t source; +struct obj_refcount { + map refs; + set retired_refs; - cls_chunk_refcount_get_op() {} + obj_refcount() {} void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - encode(source, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); - decode(source, bl); - DECODE_FINISH(bl); - } - void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); -}; -WRITE_CLASS_ENCODER(cls_chunk_refcount_get_op) - -struct cls_chunk_refcount_put_op { - hobject_t source; - - cls_chunk_refcount_put_op() {} - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - encode(source, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); - decode(source, bl); - DECODE_FINISH(bl); - } - - void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); -}; -WRITE_CLASS_ENCODER(cls_chunk_refcount_put_op) - -struct cls_chunk_refcount_set_op { - set refs; - - cls_chunk_refcount_set_op() {} - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); + ENCODE_START(2, 1, bl); encode(refs, bl); + encode(retired_refs, bl); ENCODE_FINISH(bl); } void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); + DECODE_START(2, bl); decode(refs, bl); + if (struct_v >= 2) { + decode(retired_refs, bl); + } DECODE_FINISH(bl); } - - void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); }; -WRITE_CLASS_ENCODER(cls_chunk_refcount_set_op) - -struct cls_chunk_refcount_read_ret { - set refs; - - cls_chunk_refcount_read_ret() {} - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - encode(refs, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); - decode(refs, bl); - DECODE_FINISH(bl); - } +WRITE_CLASS_ENCODER(obj_refcount) - void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); -}; -WRITE_CLASS_ENCODER(cls_chunk_refcount_read_ret) #endif diff --git a/src/common/options.cc b/src/common/options.cc index 68f036ce6bcc..0c1081fd848d 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -3157,11 +3157,11 @@ std::vector