From: Adam C. Emerson Date: Thu, 2 Apr 2020 23:28:22 +0000 (-0400) Subject: cls: Build ceph-osd without using namespace declarations in headers X-Git-Tag: v16.1.0~2665^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=06a6bc8e57153babe286d633dcf200cc4e4703a3;p=ceph.git cls: Build ceph-osd without using namespace declarations in headers This is part of a series of commits to clean up using namespace at top level in headers. Signed-off-by: Adam C. Emerson --- diff --git a/src/cls/2pc_queue/cls_2pc_queue.cc b/src/cls/2pc_queue/cls_2pc_queue.cc index a28fb648edae..41e8166cecf1 100644 --- a/src/cls/2pc_queue/cls_2pc_queue.cc +++ b/src/cls/2pc_queue/cls_2pc_queue.cc @@ -13,6 +13,10 @@ CLS_VER(1,0) CLS_NAME(2pc_queue) +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + constexpr auto CLS_QUEUE_URGENT_DATA_XATTR_NAME = "cls_queue_urgent_data"; static int cls_2pc_queue_init(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { @@ -21,7 +25,7 @@ static int cls_2pc_queue_init(cls_method_context_t hctx, bufferlist *in, bufferl cls_queue_init_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_init: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -44,7 +48,7 @@ static int cls_2pc_queue_reserve(cls_method_context_t hctx, bufferlist *in, buff try { auto in_iter = in->cbegin(); decode(res_op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_reserve: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -69,7 +73,7 @@ static int cls_2pc_queue_reserve(cls_method_context_t hctx, bufferlist *in, buff try { auto in_iter = head.bl_urgent_data.cbegin(); decode(urgent_data, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_reserve: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -126,7 +130,7 @@ static int cls_2pc_queue_reserve(cls_method_context_t hctx, bufferlist *in, buff auto iter = bl_xattrs.cbegin(); try { decode(xattr_reservations, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_reserve: failed to decode xattrs urgent data map"); return -EINVAL; } //end - catch @@ -178,7 +182,7 @@ static int cls_2pc_queue_commit(cls_method_context_t hctx, bufferlist *in, buffe try { auto in_iter = in->cbegin(); decode(commit_op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_commit: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -194,7 +198,7 @@ static int cls_2pc_queue_commit(cls_method_context_t hctx, bufferlist *in, buffe try { auto in_iter = head.bl_urgent_data.cbegin(); decode(urgent_data, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_commit: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -221,7 +225,7 @@ static int cls_2pc_queue_commit(cls_method_context_t hctx, bufferlist *in, buffe auto iter = bl_xattrs.cbegin(); try { decode(xattr_reservations, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_commit: failed to decode xattrs urgent data map"); return -EINVAL; } //end - catch @@ -285,7 +289,7 @@ static int cls_2pc_queue_abort(cls_method_context_t hctx, bufferlist *in, buffer try { auto in_iter = in->cbegin(); decode(abort_op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_abort: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -301,7 +305,7 @@ static int cls_2pc_queue_abort(cls_method_context_t hctx, bufferlist *in, buffer try { auto in_iter = head.bl_urgent_data.cbegin(); decode(urgent_data, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_abort: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -329,7 +333,7 @@ static int cls_2pc_queue_abort(cls_method_context_t hctx, bufferlist *in, buffer cls_2pc_reservations xattr_reservations; try { decode(xattr_reservations, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_abort: failed to decode xattrs urgent data map"); return -EINVAL; } //end - catch @@ -375,7 +379,7 @@ static int cls_2pc_queue_list_reservations(cls_method_context_t hctx, bufferlist try { auto in_iter = head.bl_urgent_data.cbegin(); decode(urgent_data, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_list_reservations: failed to decode entry: %s", err.what()); return -EINVAL; } @@ -396,7 +400,7 @@ static int cls_2pc_queue_list_reservations(cls_method_context_t hctx, bufferlist auto iter = bl_xattrs.cbegin(); try { decode(xattr_reservations, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_2pc_queue_list_reservations: failed to decode xattrs urgent data map"); return -EINVAL; } //end - catch diff --git a/src/cls/2pc_queue/cls_2pc_queue_ops.h b/src/cls/2pc_queue/cls_2pc_queue_ops.h index 5a58dc6c4fa3..24b2be992fd0 100644 --- a/src/cls/2pc_queue/cls_2pc_queue_ops.h +++ b/src/cls/2pc_queue/cls_2pc_queue_ops.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #pragma once #include "include/types.h" @@ -7,14 +10,14 @@ struct cls_2pc_queue_reserve_op { uint64_t size; uint32_t entries; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(size, bl); encode(entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(size, bl); decode(entries, bl); @@ -26,13 +29,13 @@ WRITE_CLASS_ENCODER(cls_2pc_queue_reserve_op) struct cls_2pc_queue_reserve_ret { cls_2pc_reservation::id_t id; // allocated reservation id - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(id, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(id, bl); DECODE_FINISH(bl); @@ -42,16 +45,16 @@ WRITE_CLASS_ENCODER(cls_2pc_queue_reserve_ret) struct cls_2pc_queue_commit_op { cls_2pc_reservation::id_t id; // reservation to commit - std::vector bl_data_vec; // the data to enqueue + std::vector bl_data_vec; // the data to enqueue - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(id, bl); encode(bl_data_vec, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(id, bl); decode(bl_data_vec, bl); @@ -64,13 +67,13 @@ WRITE_CLASS_ENCODER(cls_2pc_queue_commit_op) struct cls_2pc_queue_abort_op { cls_2pc_reservation::id_t id; // reservation to abort - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(id, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(id, bl); DECODE_FINISH(bl); @@ -81,17 +84,16 @@ WRITE_CLASS_ENCODER(cls_2pc_queue_abort_op) struct cls_2pc_queue_reservations_ret { cls_2pc_reservations reservations; // reservation list (keyed by id) - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(reservations, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(reservations, bl); DECODE_FINISH(bl); } }; WRITE_CLASS_ENCODER(cls_2pc_queue_reservations_ret) - diff --git a/src/cls/2pc_queue/cls_2pc_queue_types.h b/src/cls/2pc_queue/cls_2pc_queue_types.h index b0a175cc4721..82dc4e974f98 100644 --- a/src/cls/2pc_queue/cls_2pc_queue_types.h +++ b/src/cls/2pc_queue/cls_2pc_queue_types.h @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #pragma once #include "include/types.h" @@ -14,14 +16,14 @@ struct cls_2pc_reservation cls_2pc_reservation() = default; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(size, bl); encode(timestamp, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(size, bl); decode(timestamp, bl); @@ -39,7 +41,7 @@ struct cls_2pc_urgent_data cls_2pc_reservations reservations; // reservation list (keyed by id) bool has_xattrs{false}; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(reserved_size, bl); encode(last_id, bl); @@ -48,7 +50,7 @@ struct cls_2pc_urgent_data ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(reserved_size, bl); decode(last_id, bl); @@ -58,4 +60,3 @@ struct cls_2pc_urgent_data } }; WRITE_CLASS_ENCODER(cls_2pc_urgent_data) - diff --git a/src/cls/cas/cls_cas.cc b/src/cls/cas/cls_cas.cc index c6a7b9b591ad..d5e5f0e28b85 100644 --- a/src/cls/cas/cls_cas.cc +++ b/src/cls/cas/cls_cas.cc @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include @@ -9,6 +9,9 @@ #include "include/compat.h" #include "osd/osd_types.h" +using ceph::bufferlist; +using ceph::decode; + CLS_VER(1,0) CLS_NAME(cas) @@ -28,7 +31,7 @@ static int chunk_read_refcount(cls_method_context_t hctx, chunk_obj_refcount *ob try { auto iter = bl.cbegin(); decode(*objr, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: chunk_read_refcount(): failed to decode refcount entry\n"); return -EIO; } @@ -56,7 +59,7 @@ static int cls_rc_chunk_refcount_get(cls_method_context_t hctx, bufferlist *in, cls_chunk_refcount_get_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rc_refcount_get(): failed to decode entry\n"); return -EINVAL; } @@ -84,7 +87,7 @@ static int cls_rc_chunk_refcount_put(cls_method_context_t hctx, bufferlist *in, cls_chunk_refcount_put_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rc_chunk_refcount_put(): failed to decode entry\n"); return -EINVAL; } @@ -134,7 +137,7 @@ static int cls_rc_chunk_refcount_set(cls_method_context_t hctx, bufferlist *in, cls_chunk_refcount_set_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_chunk_refcount_set(): failed to decode entry\n"); return -EINVAL; } @@ -182,7 +185,7 @@ static int cls_rc_write_or_get(cls_method_context_t hctx, bufferlist *in, buffer decode(src_obj, in_iter); in_iter.copy(op.extent.length, indata); } - catch (buffer::error& e) { + catch (ceph::buffer::error& e) { return -EINVAL; } @@ -215,12 +218,12 @@ static int cls_rc_write_or_get(cls_method_context_t hctx, bufferlist *in, buffer static int cls_rc_has_chunk(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { auto in_iter = in->cbegin(); - string fp_oid; + std::string fp_oid; bufferlist indata, outdata; try { decode (fp_oid, in_iter); } - catch (buffer::error& e) { + catch (ceph::buffer::error& e) { return -EINVAL; } CLS_LOG(10, " fp_oid: %s \n", fp_oid.c_str()); diff --git a/src/cls/cas/cls_cas_client.cc b/src/cls/cas/cls_cas_client.cc index b041641f6449..8ccc445aff68 100644 --- a/src/cls/cas/cls_cas_client.cc +++ b/src/cls/cas/cls_cas_client.cc @@ -1,10 +1,18 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #include #include "cls/cas/cls_cas_client.h" #include "cls/cas/cls_cas_ops.h" #include "include/rados/librados.hpp" -using namespace librados; +using std::set; +using std::string; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid) { @@ -44,7 +52,7 @@ int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } diff --git a/src/cls/cas/cls_cas_client.h b/src/cls/cas/cls_cas_client.h index 323be9eb98c3..af64f342c015 100644 --- a/src/cls/cas/cls_cas_client.h +++ b/src/cls/cas/cls_cas_client.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_CAS_CLIENT_H #define CEPH_CLS_CAS_CLIENT_H @@ -5,9 +8,9 @@ #include "include/rados/librados_fwd.hpp" #include "common/hobject.h" -void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid); +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); -int cls_chunk_has_chunk(librados::IoCtx& io_ctx, string& oid, string& fp_oid); +void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, std::set& refs); +int cls_chunk_refcount_read(librados::IoCtx& io_ctx, std::string& oid, std::set *refs); +int cls_chunk_has_chunk(librados::IoCtx& io_ctx, std::string& oid, std::string& fp_oid); #endif diff --git a/src/cls/cas/cls_cas_ops.h b/src/cls/cas/cls_cas_ops.h index 35bc90dfa4f8..6632a61a0141 100644 --- a/src/cls/cas/cls_cas_ops.h +++ b/src/cls/cas/cls_cas_ops.h @@ -14,19 +14,19 @@ struct cls_chunk_refcount_get_op { cls_chunk_refcount_get_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(source, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_chunk_refcount_get_op) @@ -35,79 +35,79 @@ struct cls_chunk_refcount_put_op { cls_chunk_refcount_put_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(source, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_chunk_refcount_put_op) struct cls_chunk_refcount_set_op { - set refs; + std::set refs; cls_chunk_refcount_set_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_chunk_refcount_set_op) struct cls_chunk_refcount_read_ret { - set refs; + std::set refs; cls_chunk_refcount_read_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_chunk_refcount_read_ret) struct chunk_obj_refcount { - set refs; + std::set refs; chunk_obj_refcount() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(refs, bl); DECODE_FINISH(bl); @@ -116,19 +116,19 @@ struct chunk_obj_refcount { WRITE_CLASS_ENCODER(chunk_obj_refcount) struct obj_refcount { - map refs; - set retired_refs; + std::map refs; + std::set retired_refs; obj_refcount() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(refs, bl); encode(retired_refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(refs, bl); if (struct_v >= 2) { diff --git a/src/cls/cephfs/cls_cephfs.cc b/src/cls/cephfs/cls_cephfs.cc index 7207a6b4b849..dcd07b4bb5bf 100644 --- a/src/cls/cephfs/cls_cephfs.cc +++ b/src/cls/cephfs/cls_cephfs.cc @@ -24,6 +24,9 @@ CLS_VER(1,0) CLS_NAME(cephfs) +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; std::ostream &operator<<(std::ostream &out, const ObjCeiling &in) { @@ -65,7 +68,7 @@ static int set_if_greater(cls_method_context_t hctx, // Valid existing value, do comparison set_val = input_val > existing_val; } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { // Corrupt or empty existing value, overwrite it set_val = true; } @@ -96,7 +99,7 @@ static int accumulate_inode_metadata(cls_method_context_t hctx, AccumulateArgs args; try { args.decode(q); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -132,7 +135,7 @@ public: InodeTagFilterArgs args; args.decode(params); scrub_tag = args.scrub_tag; - } catch (buffer::error &e) { + } catch (ceph::buffer::error &e) { return -EINVAL; } @@ -173,7 +176,7 @@ bool PGLSCephFSFilter::filter(const hobject_t &obj, decode(tag_ondisk, q); if (tag_ondisk == scrub_tag) return false; - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { } } diff --git a/src/cls/cephfs/cls_cephfs.h b/src/cls/cephfs/cls_cephfs.h index 89f4dab45d3a..37d656f113a3 100644 --- a/src/cls/cephfs/cls_cephfs.h +++ b/src/cls/cephfs/cls_cephfs.h @@ -36,7 +36,7 @@ class ObjCeiling { return id > rhs.id; } - void encode(bufferlist &bl) const + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(id, bl); @@ -44,7 +44,7 @@ class ObjCeiling { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &p) + void decode(ceph::buffer::list::const_iterator &p) { DECODE_START(1, p); decode(id, p); @@ -83,7 +83,7 @@ public: : obj_index(0), obj_size(0), mtime(0) {} - void encode(bufferlist &bl) const + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(obj_xattr_name, bl); @@ -95,7 +95,7 @@ public: ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(obj_xattr_name, bl); @@ -113,14 +113,14 @@ class InodeTagFilterArgs public: std::string scrub_tag; - void encode(bufferlist &bl) const + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(scrub_tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(scrub_tag, bl); diff --git a/src/cls/cephfs/cls_cephfs_client.cc b/src/cls/cephfs/cls_cephfs_client.cc index 988eab41b9a6..d776443fe996 100644 --- a/src/cls/cephfs/cls_cephfs_client.cc +++ b/src/cls/cephfs/cls_cephfs_client.cc @@ -19,6 +19,9 @@ #include "cls_cephfs_client.h" +using ceph::bufferlist; +using ceph::decode; + #define XATTR_CEILING "scan_ceiling" #define XATTR_MAX_MTIME "scan_max_mtime" #define XATTR_MAX_SIZE "scan_max_size" @@ -114,7 +117,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( ceiling.decode(scan_ceiling_bl_iter); result->ceiling_obj_index = ceiling.id; result->ceiling_obj_size = ceiling.size; - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { //dout(4) << "Invalid size attr on '" << oid << "'" << dendl; return -EINVAL; } @@ -123,7 +126,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( try { auto scan_max_size_bl_iter = scan_max_size_bl.cbegin(); decode(result->max_obj_size, scan_max_size_bl_iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { //dout(4) << "Invalid size attr on '" << oid << "'" << dendl; return -EINVAL; } @@ -132,7 +135,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( try { auto scan_max_mtime_bl_iter = scan_max_mtime_bl.cbegin(); decode(result->max_mtime, scan_max_mtime_bl_iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { //dout(4) << "Invalid size attr on '" << oid << "'" << dendl; return -EINVAL; } @@ -142,7 +145,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( try { auto q = parent_bl.cbegin(); backtrace->decode(q); - } catch (buffer::error &e) { + } catch (ceph::buffer::error &e) { //dout(4) << "Corrupt backtrace on '" << oid << "': " << e << dendl; return -EINVAL; } @@ -153,7 +156,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( try { auto q = layout_bl.cbegin(); decode(*layout, q); - } catch (buffer::error &e) { + } catch (ceph::buffer::error &e) { return -EINVAL; } } diff --git a/src/cls/cephfs/cls_cephfs_client.h b/src/cls/cephfs/cls_cephfs_client.h index 744c0aed0f6c..e2b23b4a6f97 100644 --- a/src/cls/cephfs/cls_cephfs_client.h +++ b/src/cls/cephfs/cls_cephfs_client.h @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #include "include/rados/librados_fwd.hpp" #include "mds/mdstypes.h" @@ -28,6 +30,5 @@ class ClsCephFSClient static void build_tag_filter( const std::string &scrub_tag, - bufferlist *out_bl); + ceph::buffer::list *out_bl); }; - diff --git a/src/cls/hello/cls_hello.cc b/src/cls/hello/cls_hello.cc index 9f152ad63738..d7263b431421 100644 --- a/src/cls/hello/cls_hello.cc +++ b/src/cls/hello/cls_hello.cc @@ -37,8 +37,12 @@ #include "objclass/objclass.h" #include "osd/osd_types.h" -using ceph::bufferlist; using std::string; +using std::ostringstream; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; CLS_VER(1,0) CLS_NAME(hello) @@ -278,7 +282,7 @@ public: try { decode(xattr, params); decode(val, params); - } catch (buffer::error &e) { + } catch (ceph::buffer::error &e) { return -EINVAL; } return 0; diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 5102b3ebf2db..fb1267fba10f 100644 --- a/src/cls/journal/cls_journal.cc +++ b/src/cls/journal/cls_journal.cc @@ -15,6 +15,12 @@ CLS_VER(1, 0) CLS_NAME(journal) +using std::string; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + namespace { static const uint64_t MAX_KEYS_READ = 64; @@ -68,7 +74,7 @@ int read_key(cls_method_context_t hctx, const string &key, T *t, try { auto iter = bl.cbegin(); decode(*t, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -127,7 +133,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) { auto iter = val.second.cbegin(); try { decode(client, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding registered client: %s", val.first.c_str()); return -EIO; @@ -176,7 +182,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) { auto iter = val.second.cbegin(); try { decode(tag, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding tag: %s", val.first.c_str()); return -EIO; } @@ -239,7 +245,7 @@ int get_client_list_range(cls_method_context_t hctx, cls::journal::Client client; decode(client, iter); clients->insert(client); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode client '%s': %s", it->first.c_str(), err.what()); return -EIO; @@ -313,7 +319,7 @@ int journal_create(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { decode(order, iter); decode(splay_width, iter); decode(pool_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -459,7 +465,7 @@ int journal_set_minimum_set(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(object_set, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -530,7 +536,7 @@ int journal_set_active_set(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(object_set, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -582,7 +588,7 @@ int journal_get_client(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -614,7 +620,7 @@ int journal_client_register(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(id, iter); decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -664,7 +670,7 @@ int journal_client_update_data(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(id, iter); decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -703,7 +709,7 @@ int journal_client_update_state(cls_method_context_t hctx, bufferlist *in, uint8_t state_raw; decode(state_raw, iter); state = static_cast(state_raw); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -736,7 +742,7 @@ int journal_client_unregister(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -779,7 +785,7 @@ int journal_client_commit(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(id, iter); decode(commit_position, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -830,7 +836,7 @@ int journal_client_list(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -877,7 +883,7 @@ int journal_get_tag(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(tag_tid, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -912,7 +918,7 @@ int journal_tag_create(cls_method_context_t hctx, bufferlist *in, decode(tag_tid, iter); decode(tag_class, iter); decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -1007,7 +1013,7 @@ int journal_tag_list(cls_method_context_t hctx, bufferlist *in, decode(max_return, iter); decode(client_id, iter); decode(tag_class, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -1048,7 +1054,7 @@ int journal_tag_list(cls_method_context_t hctx, bufferlist *in, auto iter = val.second.cbegin(); try { decode(tag, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding tag: %s", val.first.c_str()); return -EIO; } @@ -1102,7 +1108,7 @@ int journal_object_guard_append(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(soft_max_size, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } @@ -1142,7 +1148,7 @@ int journal_object_append(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(soft_max_size, iter); decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode input parameters: %s", err.what()); return -EINVAL; } diff --git a/src/cls/journal/cls_journal_types.cc b/src/cls/journal/cls_journal_types.cc index 6976304d0fe2..6e9dfde87818 100644 --- a/src/cls/journal/cls_journal_types.cc +++ b/src/cls/journal/cls_journal_types.cc @@ -5,6 +5,9 @@ #include "include/stringify.h" #include "common/Formatter.h" +using ceph::bufferlist; +using ceph::Formatter; + namespace cls { namespace journal { diff --git a/src/cls/lock/cls_lock.cc b/src/cls/lock/cls_lock.cc index e9aab96936aa..96d28461db42 100644 --- a/src/cls/lock/cls_lock.cc +++ b/src/cls/lock/cls_lock.cc @@ -26,10 +26,12 @@ #include "include/compat.h" +using std::map; +using std::string; +using ceph::bufferlist; using namespace rados::cls::lock; - CLS_VER(1,0) CLS_NAME(lock) @@ -67,7 +69,7 @@ static int read_lock(cls_method_context_t hctx, try { auto it = bl.cbegin(); decode(*lock, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding %s", key.c_str()); return -EIO; } @@ -76,7 +78,7 @@ static int read_lock(cls_method_context_t hctx, utime_t now = ceph_clock_now(); - map::iterator iter = lock->lockers.begin(); + auto iter = lock->lockers.begin(); while (iter != lock->lockers.end()) { struct locker_info_t& info = iter->second; @@ -167,8 +169,7 @@ static int lock_obj(cls_method_context_t hctx, return r; } - map& lockers = linfo.lockers; - map::iterator iter; + auto& lockers = linfo.lockers; locker_id_t id; id.cookie = cookie; @@ -186,7 +187,7 @@ static int lock_obj(cls_method_context_t hctx, ClsLockType existing_lock_type = linfo.lock_type; CLS_LOG(20, "existing_lock_type=%s", cls_lock_type_str(existing_lock_type)); - iter = lockers.find(id); + auto iter = lockers.find(id); if (iter != lockers.end()) { if (fail_if_exists && !fail_if_does_not_exist) { return -EEXIST; @@ -259,7 +260,7 @@ static int lock_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -291,11 +292,11 @@ static int remove_lock(cls_method_context_t hctx, return r; } - map& lockers = linfo.lockers; + auto& lockers = linfo.lockers; struct locker_id_t id(locker, cookie); // remove named locker from set - map::iterator iter = lockers.find(id); + auto iter = lockers.find(id); if (iter == lockers.end()) { // no such key CLS_LOG(10, "locker %s [name: %s.%ld, cookie: %s] does not exist", name.c_str(), locker.type_str(), locker.num(), cookie.c_str()); @@ -331,7 +332,7 @@ static int unlock_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error& err) { + } catch (const ceph::buffer::error& err) { return -EINVAL; } @@ -359,7 +360,7 @@ static int break_lock(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error& err) { + } catch (const ceph::buffer::error& err) { return -EINVAL; } @@ -385,7 +386,7 @@ static int get_info(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error& err) { + } catch (const ceph::buffer::error& err) { return -EINVAL; } @@ -399,8 +400,7 @@ static int get_info(cls_method_context_t hctx, bufferlist *in, bufferlist *out) struct cls_lock_get_info_reply ret; - map::iterator iter; - for (iter = linfo.lockers.begin(); iter != linfo.lockers.end(); ++iter) { + for (auto iter = linfo.lockers.begin(); iter != linfo.lockers.end(); ++iter) { ret.lockers[iter->first] = iter->second; } ret.lock_type = linfo.lock_type; @@ -435,9 +435,8 @@ static int list_locks(cls_method_context_t hctx, bufferlist *in, bufferlist *out cls_lock_list_locks_reply ret; - map::iterator iter; size_t pos = sizeof(LOCK_PREFIX) - 1; - for (iter = attrs.begin(); iter != attrs.end(); ++iter) { + for (auto iter = attrs.begin(); iter != attrs.end(); ++iter) { const string& attr = iter->first; if (attr.substr(0, pos).compare(LOCK_PREFIX) == 0) { ret.locks.push_back(attr.substr(pos)); @@ -468,7 +467,7 @@ int assert_locked(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error& err) { + } catch (const ceph::buffer::error& err) { return -EINVAL; } @@ -513,7 +512,7 @@ int assert_locked(cls_method_context_t hctx, bufferlist *in, bufferlist *out) id.cookie = op.cookie; id.locker = inst.name; - map::iterator iter = linfo.lockers.find(id); + auto iter = linfo.lockers.find(id); if (iter == linfo.lockers.end()) { CLS_LOG(20, "not locked by assert client"); return -EBUSY; @@ -540,7 +539,7 @@ int set_cookie(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error& err) { + } catch (const ceph::buffer::error& err) { return -EINVAL; } diff --git a/src/cls/lock/cls_lock_client.cc b/src/cls/lock/cls_lock_client.cc index 498d573f20d0..ce979b6cd537 100644 --- a/src/cls/lock/cls_lock_client.cc +++ b/src/cls/lock/cls_lock_client.cc @@ -16,20 +16,23 @@ #include "msg/msg_types.h" #include "include/rados/librados.hpp" #include "include/utime.h" - -using namespace librados; #include "cls/lock/cls_lock_ops.h" #include "cls/lock/cls_lock_client.h" +using std::map; + +using namespace librados; + + namespace rados { namespace cls { namespace lock { void lock(ObjectWriteOperation *rados_op, - const string& name, ClsLockType type, - const string& cookie, const string& tag, - const string& description, + const std::string& name, ClsLockType type, + const std::string& cookie, const std::string& tag, + const std::string& description, const utime_t& duration, uint8_t flags) { cls_lock_lock_op op; @@ -46,10 +49,10 @@ namespace rados { } int lock(IoCtx *ioctx, - const string& oid, - const string& name, ClsLockType type, - const string& cookie, const string& tag, - const string& description, const utime_t& duration, + const std::string& oid, + const std::string& name, ClsLockType type, + const std::string& cookie, const std::string& tag, + const std::string& description, const utime_t& duration, uint8_t flags) { ObjectWriteOperation op; @@ -58,7 +61,7 @@ namespace rados { } void unlock(ObjectWriteOperation *rados_op, - const string& name, const string& cookie) + const std::string& name, const std::string& cookie) { cls_lock_unlock_op op; op.name = name; @@ -69,16 +72,16 @@ namespace rados { rados_op->exec("lock", "unlock", in); } - int unlock(IoCtx *ioctx, const string& oid, - const string& name, const string& cookie) + int unlock(IoCtx *ioctx, const std::string& oid, + const std::string& name, const std::string& cookie) { ObjectWriteOperation op; unlock(&op, name, cookie); return ioctx->operate(oid, &op); } - int aio_unlock(IoCtx *ioctx, const string& oid, - const string& name, const string& cookie, + int aio_unlock(IoCtx *ioctx, const std::string& oid, + const std::string& name, const std::string& cookie, librados::AioCompletion *completion) { ObjectWriteOperation op; @@ -87,7 +90,7 @@ namespace rados { } void break_lock(ObjectWriteOperation *rados_op, - const string& name, const string& cookie, + const std::string& name, const std::string& cookie, const entity_name_t& locker) { cls_lock_break_op op; @@ -99,8 +102,8 @@ namespace rados { rados_op->exec("lock", "break_lock", in); } - int break_lock(IoCtx *ioctx, const string& oid, - const string& name, const string& cookie, + int break_lock(IoCtx *ioctx, const std::string& oid, + const std::string& name, const std::string& cookie, const entity_name_t& locker) { ObjectWriteOperation op; @@ -108,7 +111,7 @@ namespace rados { return ioctx->operate(oid, &op); } - int list_locks(IoCtx *ioctx, const string& oid, list *locks) + int list_locks(IoCtx *ioctx, const std::string& oid, std::list *locks) { bufferlist in, out; int r = ioctx->exec(oid, "lock", "list_locks", in, out); @@ -116,10 +119,10 @@ namespace rados { return r; cls_lock_list_locks_reply ret; - auto iter = cbegin(out); + auto iter = std::cbegin(out); try { decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EBADMSG; } @@ -129,7 +132,7 @@ namespace rados { } void get_lock_info_start(ObjectReadOperation *rados_op, - const string& name) + const std::string& name) { bufferlist in; cls_lock_get_info_op op; @@ -140,12 +143,12 @@ namespace rados { int get_lock_info_finish(bufferlist::const_iterator *iter, map *lockers, - ClsLockType *type, string *tag) + ClsLockType *type, std::string *tag) { cls_lock_get_info_reply ret; try { decode(ret, *iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EBADMSG; } @@ -164,9 +167,9 @@ namespace rados { return 0; } - int get_lock_info(IoCtx *ioctx, const string& oid, const string& name, + int get_lock_info(IoCtx *ioctx, const std::string& oid, const std::string& name, map *lockers, - ClsLockType *type, string *tag) + ClsLockType *type, std::string *tag) { ObjectReadOperation op; get_lock_info_start(&op, name); @@ -229,7 +232,7 @@ namespace rados { cookie, tag, description, duration, flags); } - int Lock::lock_shared(IoCtx *ioctx, const string& oid) + int Lock::lock_shared(IoCtx *ioctx, const std::string& oid) { return lock(ioctx, oid, name, LOCK_SHARED, cookie, tag, description, duration, flags); @@ -241,7 +244,7 @@ namespace rados { cookie, tag, description, duration, flags); } - int Lock::lock_exclusive(IoCtx *ioctx, const string& oid) + int Lock::lock_exclusive(IoCtx *ioctx, const std::string& oid) { return lock(ioctx, oid, name, LOCK_EXCLUSIVE, cookie, tag, description, duration, flags); @@ -253,7 +256,7 @@ namespace rados { cookie, tag, description, duration, flags); } - int Lock::lock_exclusive_ephemeral(IoCtx *ioctx, const string& oid) + int Lock::lock_exclusive_ephemeral(IoCtx *ioctx, const std::string& oid) { return lock(ioctx, oid, name, LOCK_EXCLUSIVE_EPHEMERAL, cookie, tag, description, duration, flags); @@ -264,7 +267,7 @@ namespace rados { rados::cls::lock::unlock(op, name, cookie); } - int Lock::unlock(IoCtx *ioctx, const string& oid) + int Lock::unlock(IoCtx *ioctx, const std::string& oid) { return rados::cls::lock::unlock(ioctx, oid, name, cookie); } @@ -274,11 +277,10 @@ namespace rados { rados::cls::lock::break_lock(op, name, cookie, locker); } - int Lock::break_lock(IoCtx *ioctx, const string& oid, const entity_name_t& locker) + int Lock::break_lock(IoCtx *ioctx, const std::string& oid, const entity_name_t& locker) { return rados::cls::lock::break_lock(ioctx, oid, name, cookie, locker); } } // namespace lock } // namespace cls } // namespace rados - diff --git a/src/cls/lock/cls_lock_client.h b/src/cls/lock/cls_lock_client.h index 11c0e6584374..92e1396bf9d6 100644 --- a/src/cls/lock/cls_lock_client.h +++ b/src/cls/lock/cls_lock_client.h @@ -44,16 +44,16 @@ namespace rados { const entity_name_t& locker); extern int list_locks(librados::IoCtx *ioctx, const std::string& oid, - list *locks); + std::list *locks); extern void get_lock_info_start(librados::ObjectReadOperation *rados_op, const std::string& name); extern int get_lock_info_finish(ceph::bufferlist::const_iterator *out, - map *lockers, + std::map *lockers, ClsLockType *type, std::string *tag); extern int get_lock_info(librados::IoCtx *ioctx, const std::string& oid, const std::string& name, - map *lockers, + std::map *lockers, ClsLockType *type, std::string *tag); extern void assert_locked(librados::ObjectOperation *rados_op, diff --git a/src/cls/lock/cls_lock_ops.h b/src/cls/lock/cls_lock_ops.h index 5d22452b3b25..3df75f22ed1e 100644 --- a/src/cls/lock/cls_lock_ops.h +++ b/src/cls/lock/cls_lock_ops.h @@ -10,17 +10,17 @@ struct cls_lock_lock_op { - string name; + std::string name; ClsLockType type; - string cookie; - string tag; - string description; + std::string cookie; + std::string tag; + std::string description; utime_t duration; uint8_t flags; cls_lock_lock_op() : type(LOCK_NONE), flags(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); uint8_t t = (uint8_t)type; @@ -32,7 +32,7 @@ struct cls_lock_lock_op encode(flags, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); uint8_t t; @@ -45,92 +45,92 @@ struct cls_lock_lock_op decode(flags, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_lock_op) struct cls_lock_unlock_op { - string name; - string cookie; + std::string name; + std::string cookie; cls_lock_unlock_op() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); encode(cookie, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); decode(cookie, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_unlock_op) struct cls_lock_break_op { - string name; + std::string name; entity_name_t locker; - string cookie; + std::string cookie; cls_lock_break_op() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); encode(locker, bl); encode(cookie, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); decode(locker, bl); decode(cookie, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_break_op) struct cls_lock_get_info_op { - string name; + std::string name; cls_lock_get_info_op() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_get_info_op) struct cls_lock_get_info_reply { - map lockers; + std::map lockers; ClsLockType lock_type; - string tag; + std::string tag; cls_lock_get_info_reply() : lock_type(LOCK_NONE) {} - void encode(bufferlist &bl, uint64_t features) const { + void encode(ceph::buffer::list &bl, uint64_t features) const { ENCODE_START(1, 1, bl); encode(lockers, bl, features); uint8_t t = (uint8_t)lock_type; @@ -138,7 +138,7 @@ struct cls_lock_get_info_reply encode(tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(lockers, bl); uint8_t t; @@ -147,42 +147,42 @@ struct cls_lock_get_info_reply decode(tag, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER_FEATURES(cls_lock_get_info_reply) struct cls_lock_list_locks_reply { - list locks; + std::list locks; cls_lock_list_locks_reply() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(locks, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(locks, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_list_locks_reply) struct cls_lock_assert_op { - string name; + std::string name; ClsLockType type; - string cookie; - string tag; + std::string cookie; + std::string tag; cls_lock_assert_op() : type(LOCK_NONE) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); uint8_t t = (uint8_t)type; @@ -191,7 +191,7 @@ struct cls_lock_assert_op encode(tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); uint8_t t; @@ -201,22 +201,22 @@ struct cls_lock_assert_op decode(tag, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_assert_op) struct cls_lock_set_cookie_op { - string name; + std::string name; ClsLockType type; - string cookie; - string tag; - string new_cookie; + std::string cookie; + std::string tag; + std::string new_cookie; cls_lock_set_cookie_op() : type(LOCK_NONE) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); uint8_t t = (uint8_t)type; @@ -226,7 +226,7 @@ struct cls_lock_set_cookie_op encode(new_cookie, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); decode(name, bl); uint8_t t; @@ -237,8 +237,8 @@ struct cls_lock_set_cookie_op decode(new_cookie, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_lock_set_cookie_op) diff --git a/src/cls/lock/cls_lock_types.cc b/src/cls/lock/cls_lock_types.cc index d1aa63342126..9a9a510f3df5 100644 --- a/src/cls/lock/cls_lock_types.cc +++ b/src/cls/lock/cls_lock_types.cc @@ -9,7 +9,7 @@ * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. - * + * */ #include "common/Formatter.h" @@ -18,19 +18,19 @@ using namespace rados::cls::lock; -static void generate_lock_id(locker_id_t& i, int n, const string& cookie) +static void generate_lock_id(locker_id_t& i, int n, const std::string& cookie) { i.locker = entity_name_t::CLIENT(n); i.cookie = cookie; } -void locker_id_t::dump(Formatter *f) const +void locker_id_t::dump(ceph::Formatter *f) const { f->dump_stream("locker") << locker; f->dump_string("cookie", cookie); } -void locker_id_t::generate_test_instances(list& o) +void locker_id_t::generate_test_instances(std::list& o) { locker_id_t *i = new locker_id_t; generate_lock_id(*i, 1, "cookie"); @@ -38,7 +38,7 @@ void locker_id_t::generate_test_instances(list& o) o.push_back(new locker_id_t); } -void locker_info_t::dump(Formatter *f) const +void locker_info_t::dump(ceph::Formatter *f) const { f->dump_stream("expiration") << expiration; f->dump_string("addr", addr.get_legacy_str()); @@ -57,7 +57,7 @@ static void generate_test_addr(entity_addr_t& a, int nonce, int port) a.set_port(port); } -void locker_info_t::generate_test_instances(list& o) +void locker_info_t::generate_test_instances(std::list& o) { locker_info_t *i = new locker_info_t; i->expiration = utime_t(5, 0); @@ -67,7 +67,7 @@ void locker_info_t::generate_test_instances(list& o) o.push_back(new locker_info_t); } -void lock_info_t::dump(Formatter *f) const +void lock_info_t::dump(ceph::Formatter *f) const { f->dump_int("lock_type", lock_type); f->dump_string("tag", tag); @@ -81,7 +81,7 @@ void lock_info_t::dump(Formatter *f) const f->close_section(); } -void lock_info_t::generate_test_instances(list& o) +void lock_info_t::generate_test_instances(std::list& o) { lock_info_t *i = new lock_info_t; locker_id_t id; diff --git a/src/cls/lock/cls_lock_types.h b/src/cls/lock/cls_lock_types.h index e3f15fe628a5..df05c69c24a1 100644 --- a/src/cls/lock/cls_lock_types.h +++ b/src/cls/lock/cls_lock_types.h @@ -84,13 +84,13 @@ namespace rados { return true; return false; } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; friend std::ostream& operator<<(std::ostream& out, const locker_id_t& data) { out << data.locker; return out; } - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(locker_id_t) @@ -118,9 +118,10 @@ namespace rados { decode(description, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; friend std::ostream& operator<<(std::ostream& out, const locker_info_t& data) { + using ceph::operator <<; out << "{addr:" << data.addr << ", exp:"; const auto& exp = data.expiration; @@ -132,12 +133,12 @@ namespace rados { return out; } - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER_FEATURES(locker_info_t) struct lock_info_t { - map lockers; // map of lockers + std::map lockers; // map of lockers ClsLockType lock_type; // lock type (exclusive / shared) std::string tag; // tag: operations on lock can only succeed with this tag // as long as set of non expired lockers @@ -161,8 +162,8 @@ namespace rados { DECODE_FINISH(bl); } lock_info_t() : lock_type(LOCK_NONE) {} - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER_FEATURES(lock_info_t); } diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index ad3de9499fa1..58a8524da341 100644 --- a/src/cls/log/cls_log.cc +++ b/src/cls/log/cls_log.cc @@ -11,6 +11,11 @@ #include "global/global_context.h" #include "include/compat.h" +using std::map; +using std::string; + +using ceph::bufferlist; + CLS_VER(1,0) CLS_NAME(log) @@ -53,7 +58,7 @@ static int read_header(cls_method_context_t hctx, cls_log_header& header) auto iter = header_bl.cbegin(); try { decode(header, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: read_header(): failed to decode header"); } @@ -90,7 +95,7 @@ static int cls_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist *ou cls_log_add_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op"); return -EINVAL; } @@ -101,8 +106,7 @@ static int cls_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist *ou if (ret < 0) return ret; - for (list::iterator iter = op.entries.begin(); - iter != op.entries.end(); ++iter) { + for (auto iter = op.entries.begin(); iter != op.entries.end(); ++iter) { cls_log_entry& entry = *iter; string index; @@ -145,7 +149,7 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o cls_log_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_log_list_op(): failed to decode op"); return -EINVAL; } @@ -176,8 +180,8 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o if (rc < 0) return rc; - list& entries = ret.entries; - map::iterator iter = keys.begin(); + auto& entries = ret.entries; + auto iter = keys.begin(); string marker; @@ -195,7 +199,7 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o cls_log_entry e; decode(e, biter); entries.push_back(e); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: cls_log_list: could not decode entry, index=%s", index.c_str()); } } @@ -215,7 +219,7 @@ static int cls_log_trim(cls_method_context_t hctx, bufferlist *in, bufferlist *o cls_log_trim_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: cls_log_trim(): failed to decode entry"); return -EINVAL; } @@ -280,7 +284,7 @@ static int cls_log_info(cls_method_context_t hctx, bufferlist *in, bufferlist *o cls_log_info_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op"); return -EINVAL; } diff --git a/src/cls/log/cls_log_client.cc b/src/cls/log/cls_log_client.cc index accc9dd14375..418599c8066e 100644 --- a/src/cls/log/cls_log_client.cc +++ b/src/cls/log/cls_log_client.cc @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #include #include "cls/log/cls_log_ops.h" @@ -5,6 +7,11 @@ #include "include/compat.h" +using std::list; +using std::string; + +using ceph::bufferlist; + using namespace librados; @@ -99,7 +106,7 @@ public: *truncated = ret.truncated; if (marker) *marker = std::move(ret.marker); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { // nothing we can do about it atm } } @@ -135,7 +142,7 @@ public: decode(ret, iter); if (header) *header = ret.header; - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { // nothing we can do about it atm } } @@ -151,4 +158,3 @@ void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header) op.exec("log", "info", inbl, new LogInfoCtx(header)); } - diff --git a/src/cls/log/cls_log_client.h b/src/cls/log/cls_log_client.h index b994206bec6d..b049c2cc01bd 100644 --- a/src/cls/log/cls_log_client.h +++ b/src/cls/log/cls_log_client.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_LOG_CLIENT_H #define CEPH_CLS_LOG_CLIENT_H @@ -9,26 +12,26 @@ */ void cls_log_add_prepare_entry(cls_log_entry& entry, const utime_t& timestamp, - const string& section, const string& name, bufferlist& bl); + const std::string& section, const std::string& name, ceph::buffer::list& bl); -void cls_log_add(librados::ObjectWriteOperation& op, list& entries, bool monotonic_inc); +void cls_log_add(librados::ObjectWriteOperation& op, std::list& entries, bool monotonic_inc); void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry); void cls_log_add(librados::ObjectWriteOperation& op, const utime_t& timestamp, - const string& section, const string& name, bufferlist& bl); + const std::string& section, const std::string& name, ceph::buffer::list& bl); void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, utime_t& to, - const string& in_marker, int max_entries, - list& entries, - string *out_marker, bool *truncated); + const std::string& in_marker, int max_entries, + std::list& entries, + std::string *out_marker, bool *truncated); void cls_log_trim(librados::ObjectWriteOperation& op, const utime_t& from_time, const utime_t& to_time, - const string& from_marker, const string& to_marker); + const std::string& from_marker, const std::string& to_marker); // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_log_trim(librados::IoCtx& io_ctx, const string& oid, const utime_t& from_time, const utime_t& to_time, - const string& from_marker, const string& to_marker); +int cls_log_trim(librados::IoCtx& io_ctx, const std::string& oid, const utime_t& from_time, const utime_t& to_time, + const std::string& from_marker, const std::string& to_marker); #endif void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header); diff --git a/src/cls/log/cls_log_ops.h b/src/cls/log/cls_log_ops.h index 2967da6ea687..0cedc8802a5e 100644 --- a/src/cls/log/cls_log_ops.h +++ b/src/cls/log/cls_log_ops.h @@ -7,19 +7,19 @@ #include "cls_log_types.h" struct cls_log_add_op { - list entries; + std::list entries; bool monotonic_inc; cls_log_add_op() : monotonic_inc(true) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(entries, bl); encode(monotonic_inc, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(entries, bl); if (struct_v >= 2) { @@ -32,14 +32,14 @@ WRITE_CLASS_ENCODER(cls_log_add_op) struct cls_log_list_op { utime_t from_time; - string marker; /* if not empty, overrides from_time */ + std::string marker; /* if not empty, overrides from_time */ utime_t to_time; /* not inclusive */ int max_entries; /* upperbound to returned num of entries might return less than that and still be truncated */ cls_log_list_op() : max_entries(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(from_time, bl); encode(marker, bl); @@ -48,7 +48,7 @@ struct cls_log_list_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(from_time, bl); decode(marker, bl); @@ -60,13 +60,13 @@ struct cls_log_list_op { WRITE_CLASS_ENCODER(cls_log_list_op) struct cls_log_list_ret { - list entries; - string marker; + std::list entries; + std::string marker; bool truncated; cls_log_list_ret() : truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(marker, bl); @@ -74,7 +74,7 @@ struct cls_log_list_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(marker, bl); @@ -92,12 +92,12 @@ WRITE_CLASS_ENCODER(cls_log_list_ret) struct cls_log_trim_op { utime_t from_time; utime_t to_time; /* inclusive */ - string from_marker; - string to_marker; + std::string from_marker; + std::string to_marker; cls_log_trim_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(from_time, bl); encode(to_time, bl); @@ -106,7 +106,7 @@ struct cls_log_trim_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(from_time, bl); decode(to_time, bl); @@ -122,13 +122,13 @@ WRITE_CLASS_ENCODER(cls_log_trim_op) struct cls_log_info_op { cls_log_info_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); // currently empty request ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); // currently empty request DECODE_FINISH(bl); @@ -139,13 +139,13 @@ WRITE_CLASS_ENCODER(cls_log_info_op) struct cls_log_info_ret { cls_log_header header; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(header, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(header, bl); DECODE_FINISH(bl); diff --git a/src/cls/log/cls_log_types.h b/src/cls/log/cls_log_types.h index 5ec8628f6ac3..b5ab8f3cb132 100644 --- a/src/cls/log/cls_log_types.h +++ b/src/cls/log/cls_log_types.h @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #ifndef CEPH_CLS_LOG_TYPES_H #define CEPH_CLS_LOG_TYPES_H @@ -10,15 +12,15 @@ class JSONObj; struct cls_log_entry { - string id; - string section; - string name; + std::string id; + std::string section; + std::string name; utime_t timestamp; - bufferlist data; + ceph::buffer::list data; cls_log_entry() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(section, bl); encode(name, bl); @@ -28,7 +30,7 @@ struct cls_log_entry { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(section, bl); decode(name, bl); @@ -42,17 +44,17 @@ struct cls_log_entry { WRITE_CLASS_ENCODER(cls_log_entry) struct cls_log_header { - string max_marker; + std::string max_marker; utime_t max_time; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(max_marker, bl); encode(max_time, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(max_marker, bl); decode(max_time, bl); diff --git a/src/cls/numops/cls_numops.cc b/src/cls/numops/cls_numops.cc index 30a203ef1e32..331eb7dca516 100644 --- a/src/cls/numops/cls_numops.cc +++ b/src/cls/numops/cls_numops.cc @@ -1,3 +1,5 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system * @@ -44,7 +46,7 @@ static int add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { decode(key, iter); decode(diff_str, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "add: invalid decode of input"); return -EINVAL; } @@ -99,7 +101,7 @@ static int mul(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { decode(key, iter); decode(diff_str, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "mul: invalid decode of input"); return -EINVAL; } diff --git a/src/cls/otp/cls_otp.cc b/src/cls/otp/cls_otp.cc index 355e14dab3e0..9143f6241b15 100644 --- a/src/cls/otp/cls_otp.cc +++ b/src/cls/otp/cls_otp.cc @@ -26,6 +26,13 @@ #include "cls/otp/cls_otp_ops.h" #include "cls/otp/cls_otp_types.h" +using std::list; +using std::string; +using std::set; + +using ceph::bufferlist; +using ceph::encode; +using ceph::real_clock; using namespace rados::cls::otp; @@ -147,7 +154,7 @@ bool otp_instance::verify(const ceph::real_time& timestamp, const string& val) void otp_instance::find(const string& token, otp_check_t *result) { - ceph::real_time now = real_clock::now(); + auto now = real_clock::now(); trim_expired(now); for (auto& entry : boost::adaptors::reverse(last_checks)) { @@ -177,7 +184,7 @@ static int get_otp_instance(cls_method_context_t hctx, const string& id, otp_ins try { auto it = bl.cbegin(); decode(*instance, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: failed to decode %s", key.c_str()); return -EIO; } @@ -236,7 +243,7 @@ static int read_header(cls_method_context_t hctx, otp_header *h) auto iter = bl.cbegin(); try { decode(*h, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_ERR("failed to decode otp_header"); return -EIO; } @@ -299,7 +306,7 @@ static int otp_set_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -348,7 +355,7 @@ static int otp_remove_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -394,7 +401,7 @@ static int otp_get_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -445,7 +452,7 @@ static int otp_check_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -481,7 +488,7 @@ static int otp_get_result(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -511,7 +518,7 @@ static int otp_get_current_time_op(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(op, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("ERROR: %s(): failed to decode request", __func__); return -EINVAL; } diff --git a/src/cls/otp/cls_otp_client.cc b/src/cls/otp/cls_otp_client.cc index dc1efab4132a..0ba55571f8d1 100644 --- a/src/cls/otp/cls_otp_client.cc +++ b/src/cls/otp/cls_otp_client.cc @@ -16,7 +16,9 @@ #include "msg/msg_types.h" #include "include/rados/librados.hpp" #include "include/utime.h" - + +using std::list; +using std::string; using namespace librados; #include "cls/otp/cls_otp_ops.h" @@ -85,7 +87,7 @@ namespace rados { cls_otp_get_result_reply ret; try { decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EBADMSG; } @@ -123,7 +125,7 @@ namespace rados { auto iter = out.cbegin(); try { decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EBADMSG; } @@ -176,7 +178,7 @@ namespace rados { auto iter = out.cbegin(); try { decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EBADMSG; } @@ -187,4 +189,3 @@ namespace rados { } // namespace otp } // namespace cls } // namespace rados - diff --git a/src/cls/otp/cls_otp_client.h b/src/cls/otp/cls_otp_client.h index f1dec9f5681f..a921e4e383f4 100644 --- a/src/cls/otp/cls_otp_client.h +++ b/src/cls/otp/cls_otp_client.h @@ -14,23 +14,23 @@ namespace rados { class OTP { public: static void create(librados::ObjectWriteOperation *op, const otp_info_t& config); - static void set(librados::ObjectWriteOperation *op, const list& entries); - static void remove(librados::ObjectWriteOperation *op, const string& id); + static void set(librados::ObjectWriteOperation *op, const std::list& entries); + static void remove(librados::ObjectWriteOperation *op, const std::string& id); static int get(librados::ObjectReadOperation *op, - librados::IoCtx& ioctx, const string& oid, - const string& id, otp_info_t *result); + librados::IoCtx& ioctx, const std::string& oid, + const std::string& id, otp_info_t *result); static int get_all(librados::ObjectReadOperation *op, - librados::IoCtx& ioctx, const string& oid, - list *result); + librados::IoCtx& ioctx, const std::string& oid, + std::list *result); // these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec() #ifndef CLS_CLIENT_HIDE_IOCTX static int get(librados::ObjectReadOperation *op, - librados::IoCtx& ioctx, const string& oid, - const list *ids, bool get_all, list *result); - static int check(CephContext *cct, librados::IoCtx& ioctx, const string& oid, - const string& id, const string& val, otp_check_t *result); - static int get_current_time(librados::IoCtx& ioctx, const string& oid, + librados::IoCtx& ioctx, const std::string& oid, + const std::list *ids, bool get_all, std::list *result); + static int check(CephContext *cct, librados::IoCtx& ioctx, const std::string& oid, + const std::string& id, const std::string& val, otp_check_t *result); + static int get_current_time(librados::IoCtx& ioctx, const std::string& oid, ceph::real_time *result); #endif }; @@ -38,7 +38,7 @@ namespace rados { class TOTPConfig { otp_info_t config; public: - TOTPConfig(const string& id, const string& seed) { + TOTPConfig(const std::string& id, const std::string& seed) { config.type = OTP_TOTP; config.id = id; config.seed = seed; diff --git a/src/cls/otp/cls_otp_ops.h b/src/cls/otp/cls_otp_ops.h index 51cec3eb37bc..970bd3a7809f 100644 --- a/src/cls/otp/cls_otp_ops.h +++ b/src/cls/otp/cls_otp_ops.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_OTP_OPS_H #define CEPH_CLS_OTP_OPS_H @@ -7,14 +10,14 @@ struct cls_otp_set_otp_op { - list entries; + std::list entries; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(entries, bl); DECODE_FINISH(bl); @@ -24,18 +27,18 @@ WRITE_CLASS_ENCODER(cls_otp_set_otp_op) struct cls_otp_check_otp_op { - string id; - string val; - string token; + std::string id; + std::string val; + std::string token; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(id, bl); encode(val, bl); encode(token, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(id, bl); decode(val, bl); @@ -47,14 +50,14 @@ WRITE_CLASS_ENCODER(cls_otp_check_otp_op) struct cls_otp_get_result_op { - string token; + std::string token; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(token, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(token, bl); DECODE_FINISH(bl); @@ -66,12 +69,12 @@ struct cls_otp_get_result_reply { rados::cls::otp::otp_check_t result; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(result, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(result, bl); DECODE_FINISH(bl); @@ -81,14 +84,14 @@ WRITE_CLASS_ENCODER(cls_otp_get_result_reply) struct cls_otp_remove_otp_op { - list ids; + std::list ids; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(ids, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(ids, bl); DECODE_FINISH(bl); @@ -99,15 +102,15 @@ WRITE_CLASS_ENCODER(cls_otp_remove_otp_op) struct cls_otp_get_otp_op { bool get_all{false}; - list ids; + std::list ids; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(get_all, bl); encode(ids, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(get_all, bl); decode(ids, bl); @@ -118,14 +121,14 @@ WRITE_CLASS_ENCODER(cls_otp_get_otp_op) struct cls_otp_get_otp_reply { - list found_entries; + std::list found_entries; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(found_entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(found_entries, bl); DECODE_FINISH(bl); @@ -135,11 +138,11 @@ WRITE_CLASS_ENCODER(cls_otp_get_otp_reply) struct cls_otp_get_current_time_op { - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); DECODE_FINISH(bl); } @@ -150,12 +153,12 @@ struct cls_otp_get_current_time_reply { ceph::real_time time; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(time, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(time, bl); DECODE_FINISH(bl); diff --git a/src/cls/otp/cls_otp_types.cc b/src/cls/otp/cls_otp_types.cc index b8a6e0125e4b..1f95749ed1af 100644 --- a/src/cls/otp/cls_otp_types.cc +++ b/src/cls/otp/cls_otp_types.cc @@ -1,4 +1,4 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system @@ -7,9 +7,9 @@ * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software + * License version 2.1, as published by the Free Software * Foundation. See file COPYING. - * + * */ #include "objclass/objclass.h" @@ -21,6 +21,10 @@ #include "cls/otp/cls_otp_types.h" +using std::string; + +using ceph::Formatter; + using namespace rados::cls::otp; void otp_info_t::dump(Formatter *f) const diff --git a/src/cls/otp/cls_otp_types.h b/src/cls/otp/cls_otp_types.h index b542b5cbd878..6e431b330c74 100644 --- a/src/cls/otp/cls_otp_types.h +++ b/src/cls/otp/cls_otp_types.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_OTP_TYPES_H #define CEPH_CLS_OTP_TYPES_H @@ -27,10 +30,10 @@ namespace rados { struct otp_info_t { OTPType type{OTP_TOTP}; - string id; - string seed; + std::string id; + std::string seed; SeedType seed_type{OTP_SEED_UNKNOWN}; - bufferlist seed_bin; /* parsed seed, built automatically by otp_set_op, + ceph::buffer::list seed_bin; /* parsed seed, built automatically by otp_set_op, * not being json encoded/decoded on purpose */ int32_t time_ofs{0}; @@ -39,7 +42,7 @@ namespace rados { otp_info_t() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode((uint8_t)type, bl); /* if we ever implement anything other than TOTP @@ -53,7 +56,7 @@ namespace rados { encode(window, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); uint8_t t; decode(t, bl); @@ -69,7 +72,7 @@ namespace rados { decode(window, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rados::cls::otp::otp_info_t) @@ -81,18 +84,18 @@ namespace rados { }; struct otp_check_t { - string token; + std::string token; ceph::real_time timestamp; OTPCheckResult result{OTP_CHECK_UNKNOWN}; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(token, bl); encode(timestamp, bl); encode((char)result, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(token, bl); decode(timestamp, bl); @@ -105,16 +108,16 @@ namespace rados { WRITE_CLASS_ENCODER(rados::cls::otp::otp_check_t) struct otp_repo_t { - map entries; + std::map entries; otp_repo_t() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(entries, bl); DECODE_FINISH(bl); diff --git a/src/cls/queue/cls_queue.cc b/src/cls/queue/cls_queue.cc index 54bddb25498f..cf4daaac8b64 100644 --- a/src/cls/queue/cls_queue.cc +++ b/src/cls/queue/cls_queue.cc @@ -11,6 +11,10 @@ #include "cls/queue/cls_queue_const.h" #include "cls/queue/cls_queue_src.h" +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + CLS_VER(1,0) CLS_NAME(queue) @@ -20,7 +24,7 @@ static int cls_queue_init(cls_method_context_t hctx, bufferlist *in, bufferlist cls_queue_init_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_queue_init_op(): failed to decode entry\n"); return -EINVAL; } @@ -46,7 +50,7 @@ static int cls_queue_enqueue(cls_method_context_t hctx, bufferlist *in, bufferli cls_queue_enqueue_op op; try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_queue_enqueue: failed to decode input data \n"); return -EINVAL; } @@ -72,7 +76,7 @@ static int cls_queue_list_entries(cls_method_context_t hctx, bufferlist *in, buf cls_queue_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_queue_list_entries(): failed to decode input data\n"); return -EINVAL; } @@ -99,7 +103,7 @@ static int cls_queue_remove_entries(cls_method_context_t hctx, bufferlist *in, b cls_queue_remove_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_queue_remove_entries: failed to decode input data\n"); return -EINVAL; } diff --git a/src/cls/queue/cls_queue_ops.h b/src/cls/queue/cls_queue_ops.h index e48b03dd20fc..64891cffb390 100644 --- a/src/cls/queue/cls_queue_ops.h +++ b/src/cls/queue/cls_queue_ops.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_QUEUE_OPS_H #define CEPH_CLS_QUEUE_OPS_H @@ -6,11 +9,11 @@ struct cls_queue_init_op { uint64_t queue_size{0}; uint64_t max_urgent_data_size{0}; - bufferlist bl_urgent_data; + ceph::buffer::list bl_urgent_data; cls_queue_init_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(queue_size, bl); encode(max_urgent_data_size, bl); @@ -18,7 +21,7 @@ struct cls_queue_init_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(queue_size, bl); decode(max_urgent_data_size, bl); @@ -30,17 +33,17 @@ struct cls_queue_init_op { WRITE_CLASS_ENCODER(cls_queue_init_op) struct cls_queue_enqueue_op { - vector bl_data_vec; + std::vector bl_data_vec; cls_queue_enqueue_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(bl_data_vec, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(bl_data_vec, bl); DECODE_FINISH(bl); @@ -50,18 +53,18 @@ WRITE_CLASS_ENCODER(cls_queue_enqueue_op) struct cls_queue_list_op { uint64_t max; - string start_marker; + std::string start_marker; cls_queue_list_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(max, bl); encode(start_marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(max, bl); decode(start_marker, bl); @@ -72,12 +75,12 @@ WRITE_CLASS_ENCODER(cls_queue_list_op) struct cls_queue_list_ret { bool is_truncated; - string next_marker; - vector entries; + std::string next_marker; + std::vector entries; cls_queue_list_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(is_truncated, bl); encode(next_marker, bl); @@ -85,7 +88,7 @@ struct cls_queue_list_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(is_truncated, bl); decode(next_marker, bl); @@ -96,17 +99,17 @@ struct cls_queue_list_ret { WRITE_CLASS_ENCODER(cls_queue_list_ret) struct cls_queue_remove_op { - string end_marker; + std::string end_marker; cls_queue_remove_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(end_marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(end_marker, bl); DECODE_FINISH(bl); @@ -119,13 +122,13 @@ struct cls_queue_get_capacity_ret { cls_queue_get_capacity_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(queue_capacity, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(queue_capacity, bl); DECODE_FINISH(bl); @@ -133,4 +136,4 @@ struct cls_queue_get_capacity_ret { }; WRITE_CLASS_ENCODER(cls_queue_get_capacity_ret) -#endif /* CEPH_CLS_QUEUE_OPS_H */ \ No newline at end of file +#endif /* CEPH_CLS_QUEUE_OPS_H */ diff --git a/src/cls/queue/cls_queue_src.cc b/src/cls/queue/cls_queue_src.cc index ed5fe6df5b28..8900482d2df4 100644 --- a/src/cls/queue/cls_queue_src.cc +++ b/src/cls/queue/cls_queue_src.cc @@ -9,6 +9,10 @@ #include "cls/queue/cls_queue_const.h" #include "cls/queue/cls_queue_src.h" +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + int queue_write_head(cls_method_context_t hctx, cls_queue_head& head) { bufferlist bl; @@ -52,7 +56,7 @@ int queue_read_head(cls_method_context_t hctx, cls_queue_head& head) uint16_t queue_head_start; try { decode(queue_head_start, it); - } catch (buffer::error& err) { + } catch (const ceph::buffer::error& err) { CLS_LOG(0, "ERROR: queue_read_head: failed to decode queue start: %s", err.what()); return -EINVAL; } @@ -64,7 +68,7 @@ int queue_read_head(cls_method_context_t hctx, cls_queue_head& head) uint64_t encoded_len; try { decode(encoded_len, it); - } catch (buffer::error& err) { + } catch (const ceph::buffer::error& err) { CLS_LOG(0, "ERROR: queue_read_head: failed to decode encoded head size: %s", err.what()); return -EINVAL; } @@ -83,7 +87,7 @@ int queue_read_head(cls_method_context_t hctx, cls_queue_head& head) try { decode(head, it); - } catch (buffer::error& err) { + } catch (const ceph::buffer::error& err) { CLS_LOG(0, "ERROR: queue_read_head: failed to decode head: %s", err.what()); return -EINVAL; } @@ -345,7 +349,7 @@ int queue_list_entries(cls_method_context_t hctx, const cls_queue_list_op& op, c // Decode magic number at start try { decode(entry_start, it); - } catch (buffer::error& err) { + } catch (const ceph::buffer::error& err) { CLS_LOG(10, "ERROR: queue_list_entries: failed to decode entry start: %s", err.what()); return -EINVAL; } @@ -358,7 +362,7 @@ int queue_list_entries(cls_method_context_t hctx, const cls_queue_list_op& op, c // Decode data size try { decode(data_size, it); - } catch (buffer::error& err) { + } catch (const ceph::buffer::error& err) { CLS_LOG(10, "ERROR: queue_list_entries: failed to decode data size: %s", err.what()); return -EINVAL; } diff --git a/src/cls/queue/cls_queue_types.h b/src/cls/queue/cls_queue_types.h index 0a253bdfefb8..cc46df405052 100644 --- a/src/cls/queue/cls_queue_types.h +++ b/src/cls/queue/cls_queue_types.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_QUEUE_TYPES_H #define CEPH_CLS_QUEUE_TYPES_H @@ -15,17 +18,17 @@ constexpr unsigned int QUEUE_ENTRY_OVERHEAD = sizeof(uint16_t) + sizeof(uint64_t struct cls_queue_entry { - bufferlist data; + ceph::buffer::list data; std::string marker; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(data, bl); encode(marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(data, bl); decode(marker, bl); @@ -39,23 +42,22 @@ struct cls_queue_marker uint64_t offset{0}; uint64_t gen{0}; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(gen, bl); encode(offset, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(gen, bl); decode(offset, bl); DECODE_FINISH(bl); } - string to_str() { - string marker = std::to_string(gen) + '/' + std::to_string(offset); - return marker; + std::string to_str() { + return std::to_string(gen) + '/' + std::to_string(offset); } int from_str(const char* str) { @@ -89,9 +91,9 @@ struct cls_queue_head cls_queue_marker tail{QUEUE_START_OFFSET_1K, 0}; uint64_t queue_size{0}; // size of queue requested by user, with head size added to it uint64_t max_urgent_data_size{0}; - bufferlist bl_urgent_data; // special data known to application using queue + ceph::buffer::list bl_urgent_data; // special data known to application using queue - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(max_head_size, bl); encode(front, bl); @@ -102,7 +104,7 @@ struct cls_queue_head ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(max_head_size, bl); decode(front, bl); diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index 6c8dfc61a3d3..33910b7df518 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -44,6 +44,19 @@ #include +using std::istringstream; +using std::ostringstream; +using std::map; +using std::set; +using std::string; +using std::vector; + +using ceph::BitVector; +using ceph::bufferlist; +using ceph::bufferptr; +using ceph::encode; +using ceph::decode; + /* * Object keys: * @@ -173,7 +186,7 @@ static int read_key(cls_method_context_t hctx, const string &key, T *out) try { auto it = bl.cbegin(); decode(*out, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding %s", key.c_str()); return -EIO; } @@ -528,7 +541,7 @@ int iterate(cls_method_context_t hctx, L& lambda) { auto iter = val.second.cbegin(); try { decode(snap_meta, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding snapshot metadata for snap : %s", val.first.c_str()); return -EIO; @@ -767,7 +780,7 @@ int create(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (!iter.end()) { decode(data_pool_id, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -862,7 +875,7 @@ int get_features(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (!iter.end()) { decode(read_only, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -902,7 +915,7 @@ int set_features(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { decode(features, iter); decode(mask, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -971,7 +984,7 @@ int get_size(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1020,7 +1033,7 @@ int set_size(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(size, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1086,7 +1099,7 @@ int get_protection_status(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "get_protection_status: invalid decode"); return -EINVAL; } @@ -1141,7 +1154,7 @@ int set_protection_status(cls_method_context_t hctx, bufferlist *in, try { decode(snap_id, iter); decode(status, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "set_protection_status: invalid decode"); return -EINVAL; } @@ -1255,7 +1268,7 @@ int set_stripe_unit_count(cls_method_context_t hctx, bufferlist *in, bufferlist try { decode(stripe_unit, iter); decode(stripe_count, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "set_stripe_unit_count: invalid decode"); return -EINVAL; } @@ -1319,7 +1332,7 @@ int get_create_timestamp(cls_method_context_t hctx, bufferlist *in, bufferlist * try { auto it = bl.cbegin(); decode(timestamp, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode create_timestamp"); return -EIO; } @@ -1356,7 +1369,7 @@ int get_access_timestamp(cls_method_context_t hctx, bufferlist *in, bufferlist * try { auto it = bl.cbegin(); decode(timestamp, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode access_timestamp"); return -EIO; } @@ -1393,7 +1406,7 @@ int get_modify_timestamp(cls_method_context_t hctx, bufferlist *in, bufferlist * try { auto it = bl.cbegin(); decode(timestamp, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode modify_timestamp"); return -EIO; } @@ -1421,7 +1434,7 @@ int get_flags(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1474,7 +1487,7 @@ int set_flags(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (!iter.end()) { decode(snap_id, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1564,7 +1577,7 @@ int op_features_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { decode(op_features, iter); decode(mask, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1598,7 +1611,7 @@ int get_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1677,7 +1690,7 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out) uint64_t overlap; decode(overlap, iter); parent.head_overlap = overlap; - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "cls_rbd::set_parent: invalid decode"); return -EINVAL; } @@ -1767,7 +1780,7 @@ int parent_overlap_get(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -1828,7 +1841,7 @@ int parent_attach(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { if (!iter.end()) { decode(reattach, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "cls_rbd::parent_attach: invalid decode"); return -EINVAL; } @@ -1870,7 +1883,7 @@ static int decode_parent_common(bufferlist::const_iterator& it, uint64_t *pool_i decode(*pool_id, it); decode(*image_id, it); decode(*snap_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding parent spec"); return -EINVAL; } @@ -1894,7 +1907,7 @@ static int decode_parent_and_child(bufferlist *in, uint64_t *pool_id, return r; try { decode(*c_image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding child image id"); return -EINVAL; } @@ -2096,8 +2109,7 @@ int get_snapcontext(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (r < 0) return r; - for (set::const_iterator it = keys.begin(); - it != keys.end(); ++it) { + for (auto it = keys.begin(); it != keys.end(); ++it) { if ((*it).find(RBD_SNAP_KEY_PREFIX) != 0) break; snapid_t snap_id = snap_id_from_key(*it); @@ -2185,7 +2197,7 @@ int get_snapshot_name(cls_method_context_t hctx, bufferlist *in, bufferlist *out auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2223,7 +2235,7 @@ int get_snapshot_timestamp(cls_method_context_t hctx, bufferlist *in, bufferlist auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2260,7 +2272,7 @@ int snapshot_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2310,7 +2322,7 @@ int snapshot_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (!iter.end()) { decode(snap_meta.snapshot_namespace, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2443,7 +2455,7 @@ int snapshot_rename(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(src_snap_id, iter); decode(dst_snap_name, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2505,7 +2517,7 @@ int snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2614,7 +2626,7 @@ int snapshot_trash_add(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -2714,7 +2726,7 @@ int sparse_copyup(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(extent_map, iter); decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "sparse_copyup: invalid decode"); return -EINVAL; } @@ -2738,7 +2750,7 @@ int sparse_copyup(cls_method_context_t hctx, bufferlist *in, bufferlist *out) bufferlist tmpbl; try { tmpbl.substr_of(data, data_offset, len); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_LOG(20, "sparse_copyup: invalid data"); return -EINVAL; } @@ -2788,7 +2800,7 @@ int get_id(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = read_bl.cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EIO; } @@ -2816,7 +2828,7 @@ int set_id(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3011,7 +3023,7 @@ int dir_rename_image(cls_method_context_t hctx, bufferlist *in, bufferlist *out) decode(src, iter); decode(dest, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3040,7 +3052,7 @@ int dir_get_id(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(name, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3074,7 +3086,7 @@ int dir_get_name(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3115,7 +3127,7 @@ int dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3136,13 +3148,12 @@ int dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return r; } - for (map::iterator it = vals.begin(); - it != vals.end(); ++it) { + for (auto it = vals.begin(); it != vals.end(); ++it) { string id; auto iter = it->second.cbegin(); try { decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode id of image '%s'", it->first.c_str()); return -EIO; } @@ -3187,7 +3198,7 @@ int dir_add_image(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(name, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3212,7 +3223,7 @@ int dir_remove_image(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(name, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3235,7 +3246,7 @@ int dir_state_assert(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(directory_state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3267,7 +3278,7 @@ int dir_state_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(directory_state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3329,7 +3340,7 @@ int object_map_read(cls_method_context_t hctx, BitVector<2> &object_map) try { auto iter = bl.cbegin(); decode(object_map, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode object map: %s", err.what()); return -EINVAL; } @@ -3374,7 +3385,7 @@ int object_map_save(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(object_map, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3405,7 +3416,7 @@ int object_map_resize(cls_method_context_t hctx, bufferlist *in, bufferlist *out auto iter = in->cbegin(); decode(object_count, iter); decode(default_state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3473,7 +3484,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out decode(end_object_no, iter); decode(new_object_state, iter); decode(current_object_state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode message"); return -EINVAL; } @@ -3496,7 +3507,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out try { auto it = header_bl.cbegin(); object_map.decode_header(it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode object map header: %s", err.what()); return -EINVAL; } @@ -3516,7 +3527,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out try { auto it = footer_bl.cbegin(); object_map.decode_header_crc(it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode object map header CRC: %s", err.what()); } @@ -3540,7 +3551,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out try { auto it = footer_bl.cbegin(); object_map.decode_data_crcs(it, start_object_no); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode object map data CRCs: %s", err.what()); } @@ -3560,7 +3571,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out try { auto it = data_bl.cbegin(); object_map.decode_data(it, data_byte_offset); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("failed to decode data chunk [%" PRIu64 "]: %s", data_byte_offset, err.what()); return -EINVAL; @@ -3661,7 +3672,7 @@ int object_map_snap_remove(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(src_object_map, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3724,7 +3735,7 @@ int metadata_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3777,12 +3788,11 @@ int metadata_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(data, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } - for (map::iterator it = data.begin(); - it != data.end(); ++it) { + for (auto it = data.begin(); it != data.end(); ++it) { CLS_LOG(20, "metadata_set key=%s value=%.*s", it->first.c_str(), it->second.length(), it->second.c_str()); raw_data[metadata_key_for_name(it->first)].swap(it->second); @@ -3810,7 +3820,7 @@ int metadata_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(key, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3841,7 +3851,7 @@ int metadata_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); try { decode(key, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3887,7 +3897,7 @@ int snapshot_set_limit(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(new_limit, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -3961,7 +3971,7 @@ int child_attach(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto it = in->cbegin(); decode(snap_id, it); decode(child_image, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4034,7 +4044,7 @@ int child_detach(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto it = in->cbegin(); decode(snap_id, it); decode(child_image, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4124,7 +4134,7 @@ int children_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto it = in->cbegin(); decode(snap_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4167,7 +4177,7 @@ int migration_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { try { auto it = in->cbegin(); decode(migration_spec, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4198,7 +4208,7 @@ int migration_set_state(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(state, it); decode(description, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4280,7 +4290,7 @@ int assert_snapc_seq(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(snapc_seq, it); decode(state, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -4362,7 +4372,7 @@ int old_snapshot_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { decode(s, iter); decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } snap_name = s.c_str(); @@ -4450,7 +4460,7 @@ int old_snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *o try { decode(s, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } snap_name = s.c_str(); @@ -4544,7 +4554,7 @@ int old_snapshot_rename(cls_method_context_t hctx, bufferlist *in, bufferlist *o try { decode(src_snap_id, iter); decode(dst, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } dst_snap_name = dst.c_str(); @@ -4704,7 +4714,7 @@ int read_peers(cls_method_context_t hctx, cls::rbd::MirrorPeer peer; decode(peer, bl_it); peers->push_back(peer); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode peer '%s'", it.first.c_str()); return -EIO; } @@ -4730,7 +4740,7 @@ int read_peer(cls_method_context_t hctx, const std::string &id, try { auto bl_it = bl.cbegin(); decode(*peer, bl_it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode peer '%s'", id.c_str()); return -EIO; } @@ -4939,7 +4949,7 @@ int image_get(cls_method_context_t hctx, const string &image_id, try { auto it = bl.cbegin(); decode(*mirror_image, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode mirrored image '%s'", image_id.c_str()); return -EIO; } @@ -5133,7 +5143,7 @@ int image_status_get(cls_method_context_t hctx, const string &global_image_id, try { auto it = bl.cbegin(); decode(ondisk_status, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode status for mirrored image, global id '%s', " "site '%s'", global_image_id.c_str(), mirror_uuid.c_str()); @@ -5269,7 +5279,7 @@ int image_status_list(cls_method_context_t hctx, auto iter = it->second.cbegin(); try { decode(mirror_image, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode mirror image payload of image '%s'", image_id.c_str()); return -EIO; @@ -5390,7 +5400,7 @@ int image_status_get_summary( auto iter = list_it.second.cbegin(); try { decode(mirror_image, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode mirror image payload for key '%s'", key.c_str()); return -EIO; @@ -5450,7 +5460,7 @@ int image_status_remove_down(cls_method_context_t hctx) { try { auto it = list_it.second.cbegin(); status.decode_meta(it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode status metadata for mirrored image '%s'", key.c_str()); return -EIO; @@ -5499,7 +5509,7 @@ int image_instance_get(cls_method_context_t hctx, try { auto it = bl.cbegin(); decode(ondisk_status, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode status for mirrored image, global id '%s'", global_image_id.c_str()); return -EIO; @@ -5547,7 +5557,7 @@ int image_instance_list(cls_method_context_t hctx, auto iter = it->second.cbegin(); try { decode(mirror_image, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode mirror image payload of image '%s'", image_id.c_str()); return -EIO; @@ -5651,7 +5661,7 @@ int mirror_image_map_list(cls_method_context_t hctx, auto iter = it->second.cbegin(); try { decode(mirror_image_map, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode image map payload: %s", cpp_strerror(r).c_str()); return -EINVAL; @@ -5795,7 +5805,7 @@ int mirror_uuid_set(cls_method_context_t hctx, bufferlist *in, try { auto bl_it = in->cbegin(); decode(mirror_uuid, bl_it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -5856,7 +5866,7 @@ int mirror_mode_set(cls_method_context_t hctx, bufferlist *in, try { auto bl_it = in->cbegin(); decode(mirror_mode_decode, bl_it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -5940,7 +5950,7 @@ int mirror_peer_ping(cls_method_context_t hctx, bufferlist *in, decode(direction, it); mirror_peer_direction = static_cast( direction); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -5989,7 +5999,7 @@ int mirror_peer_add(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(mirror_peer, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6014,7 +6024,7 @@ int mirror_peer_remove(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(uuid, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6041,7 +6051,7 @@ int mirror_peer_set_client(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(uuid, it); decode(client_name, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6075,7 +6085,7 @@ int mirror_peer_set_cluster(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(uuid, it); decode(site_name, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6125,7 +6135,7 @@ int mirror_peer_set_direction(cls_method_context_t hctx, bufferlist *in, decode(direction, it); mirror_peer_direction = static_cast( direction); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6161,7 +6171,7 @@ int mirror_image_list(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6190,7 +6200,7 @@ int mirror_image_list(cls_method_context_t hctx, bufferlist *in, auto iter = it->second.cbegin(); try { decode(mirror_image, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode mirror image payload of image '%s'", image_id.c_str()); return -EIO; @@ -6224,7 +6234,7 @@ int mirror_image_get_image_id(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(global_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6256,7 +6266,7 @@ int mirror_image_get(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6287,7 +6297,7 @@ int mirror_image_set(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(image_id, it); decode(mirror_image, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6311,7 +6321,7 @@ int mirror_image_remove(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6338,7 +6348,7 @@ int mirror_image_status_set(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(global_image_id, it); decode(status, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6364,7 +6374,7 @@ int mirror_image_status_remove(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(global_image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6389,7 +6399,7 @@ int mirror_image_status_get(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(global_image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6428,7 +6438,7 @@ int mirror_image_status_list(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6461,7 +6471,7 @@ int mirror_image_status_get_summary(cls_method_context_t hctx, bufferlist *in, if (!iter.end()) { decode(peers, iter); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6524,7 +6534,7 @@ int mirror_image_instance_get(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(global_image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6562,7 +6572,7 @@ int mirror_image_instance_list(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6611,7 +6621,7 @@ int mirror_instances_add(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(instance_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6635,7 +6645,7 @@ int mirror_instances_remove(cls_method_context_t hctx, bufferlist *in, try { auto iter = in->cbegin(); decode(instance_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6663,7 +6673,7 @@ int mirror_image_map_list(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(start_after, it); decode(max_return, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6694,7 +6704,7 @@ int mirror_image_map_update(cls_method_context_t hctx, bufferlist *in, auto it = in->cbegin(); decode(global_image_id, it); decode(image_map, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6726,7 +6736,7 @@ int mirror_image_map_remove(cls_method_context_t hctx, bufferlist *in, try { auto it = in->cbegin(); decode(global_image_id, it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6758,7 +6768,7 @@ int mirror_image_snapshot_unlink_peer(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); decode(snap_id, iter); decode(mirror_peer_uuid, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6793,7 +6803,7 @@ int mirror_image_snapshot_set_copy_progress(cls_method_context_t hctx, decode(snap_id, iter); decode(complete, iter); decode(last_copied_object_number, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -6917,14 +6927,13 @@ int snap_list(cls_method_context_t hctx, cls::rbd::GroupSnapshot start_after, if (r < 0) return r; - for (map::iterator it = vals.begin(); - it != vals.end() && group_snaps->size() < max_return; ++it) { + for (auto it = vals.begin(); it != vals.end() && group_snaps->size() < max_return; ++it) { auto iter = it->second.cbegin(); cls::rbd::GroupSnapshot snap; try { decode(snap, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding snapshot: %s", it->first.c_str()); return -EIO; } @@ -6990,7 +6999,7 @@ int group_dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7011,12 +7020,12 @@ int group_dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return r; } - for (pair val: vals) { + for (auto val : vals) { string id; auto iter = val.second.cbegin(); try { decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("could not decode id of group '%s'", val.first.c_str()); return -EIO; } @@ -7060,7 +7069,7 @@ int group_dir_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(name, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7086,7 +7095,7 @@ int group_dir_rename(cls_method_context_t hctx, bufferlist *in, bufferlist *out) decode(src, iter); decode(dest, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7114,7 +7123,7 @@ int group_dir_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(name, iter); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7138,7 +7147,7 @@ int group_image_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(st, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7171,7 +7180,7 @@ int group_image_remove(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(spec, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7208,7 +7217,7 @@ int group_image_list(cls_method_context_t hctx, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7224,14 +7233,13 @@ int group_image_list(cls_method_context_t hctx, if (r < 0) return r; - for (map::iterator it = vals.begin(); - it != vals.end() && res.size() < max_return; ++it) { + for (auto it = vals.begin(); it != vals.end() && res.size() < max_return; ++it) { auto iter = it->second.cbegin(); cls::rbd::GroupImageLinkState state; try { decode(state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding state for image: %s", it->first.c_str()); return -EIO; } @@ -7273,7 +7281,7 @@ int image_group_add(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(new_group, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7287,7 +7295,7 @@ int image_group_add(cls_method_context_t hctx, try { auto iter = existing_refbl.cbegin(); decode(old_group, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7337,7 +7345,7 @@ int image_group_remove(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(spec, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7351,7 +7359,7 @@ int image_group_remove(cls_method_context_t hctx, auto iter = refbl.cbegin(); try { decode(ref_spec, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7398,7 +7406,7 @@ int image_group_get(cls_method_context_t hctx, auto iter = refbl.cbegin(); try { decode(spec, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } } @@ -7424,7 +7432,7 @@ int group_snap_set(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(group_snap, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7477,7 +7485,7 @@ int group_snap_remove(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7507,7 +7515,7 @@ int group_snap_get_by_id(cls_method_context_t hctx, try { auto iter = in->cbegin(); decode(snap_id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7522,7 +7530,7 @@ int group_snap_get_by_id(cls_method_context_t hctx, auto iter = snapbl.cbegin(); try { decode(group_snap, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { CLS_ERR("error decoding snapshot: %s", snap_id.c_str()); return -EIO; } @@ -7555,7 +7563,7 @@ int group_snap_list(cls_method_context_t hctx, auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } std::vector group_snaps; @@ -7606,7 +7614,7 @@ int trash_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(id, iter); decode(trash_spec, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7651,7 +7659,7 @@ int trash_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7699,7 +7707,7 @@ int trash_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7725,8 +7733,7 @@ int trash_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) break; } - map::iterator it = raw_data.begin(); - for (; it != raw_data.end(); ++it) { + for (auto it = raw_data.begin(); it != raw_data.end(); ++it) { decode(data[trash::image_id_from_key(it->first)], it->second); } @@ -7759,7 +7766,7 @@ int trash_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(id, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7793,11 +7800,11 @@ int trash_state_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out) cls::rbd::TrashImageState trash_state; cls::rbd::TrashImageState expect_state; try { - bufferlist::const_iterator iter = in->begin(); + auto iter = in->cbegin(); decode(id, iter); decode(trash_state, iter); decode(expect_state, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7862,7 +7869,7 @@ int namespace_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(name, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7899,7 +7906,7 @@ int namespace_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out) try { auto iter = in->cbegin(); decode(name, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7938,7 +7945,7 @@ int namespace_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(start_after, iter); decode(max_return, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -7995,7 +8002,7 @@ int sparsify(cls_method_context_t hctx, bufferlist *in, bufferlist *out) auto iter = in->cbegin(); decode(sparse_size, iter); decode(remove_empty, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EINVAL; } @@ -8033,7 +8040,7 @@ int sparsify(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return 0; } - bl.rebuild(buffer::ptr_node::create(bl.length())); + bl.rebuild(ceph::buffer::ptr_node::create(bl.length())); size_t write_offset = 0; size_t write_length = 0; size_t offset = 0; @@ -8050,10 +8057,10 @@ int sparsify(cls_method_context_t hctx, bufferlist *in, bufferlist *out) CLS_LOG(20, "write%s %" PRIu64 "~%" PRIu64, (replace ? "(replace)" : ""), write_offset, write_length); bufferlist write_bl; - write_bl.push_back(buffer::ptr_node::create(ptr, write_offset, - write_length)); + write_bl.push_back(ceph::buffer::ptr_node::create(ptr, write_offset, + write_length)); if (replace) { - r = cls_cxx_replace(hctx, write_offset, write_length, &write_bl); + r = cls_cxx_replace(hctx, write_offset, write_length, &write_bl); replace = false; } else { r = cls_cxx_write(hctx, write_offset, write_length, &write_bl); diff --git a/src/cls/rbd/cls_rbd.h b/src/cls/rbd/cls_rbd.h index 0dc0a9b94f15..566bcdf6ca0d 100644 --- a/src/cls/rbd/cls_rbd.h +++ b/src/cls/rbd/cls_rbd.h @@ -42,7 +42,7 @@ struct cls_rbd_parent { return !(*this == rhs); } - void encode(bufferlist& bl, uint64_t features) const { + void encode(ceph::buffer::list& bl, uint64_t features) const { // NOTE: remove support for version 1 after Nautilus EOLed uint8_t version = 1; if ((features & CEPH_FEATURE_SERVER_NAUTILUS) != 0ULL) { @@ -65,7 +65,7 @@ struct cls_rbd_parent { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(pool_id, bl); if (struct_v >= 2) { @@ -83,7 +83,7 @@ struct cls_rbd_parent { DECODE_FINISH(bl); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_int("pool_id", pool_id); f->dump_string("pool_namespace", pool_namespace); f->dump_string("image_id", image_id); @@ -93,7 +93,7 @@ struct cls_rbd_parent { } } - static void generate_test_instances(list& o) { + static void generate_test_instances(std::list& o) { o.push_back(new cls_rbd_parent{}); o.push_back(new cls_rbd_parent{{1, "", "image id", 234}, {}}); o.push_back(new cls_rbd_parent{{1, "", "image id", 234}, {123}}); @@ -134,7 +134,7 @@ struct cls_rbd_snap { (parent.exists())); } - void encode(bufferlist& bl, uint64_t features) const { + void encode(ceph::buffer::list& bl, uint64_t features) const { // NOTE: remove support for versions < 8 after Nautilus EOLed uint8_t min_version = 1; if ((features & CEPH_FEATURE_SERVER_NAUTILUS) != 0ULL) { @@ -160,7 +160,7 @@ struct cls_rbd_snap { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { DECODE_START(8, p); decode(id, p); decode(name, p); @@ -193,7 +193,7 @@ struct cls_rbd_snap { DECODE_FINISH(p); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_unsigned("id", id); f->dump_string("name", name); f->dump_unsigned("image_size", image_size); @@ -221,7 +221,7 @@ struct cls_rbd_snap { } } - static void generate_test_instances(list& o) { + static void generate_test_instances(std::list& o) { o.push_back(new cls_rbd_snap{}); o.push_back(new cls_rbd_snap{1, "snap", 123456, RBD_PROTECTION_STATUS_PROTECTED, diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index 1de9306a682c..f9ba2419a680 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -14,6 +14,14 @@ namespace librbd { namespace cls_client { +using std::map; +using std::set; +using std::string; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + void create_image(librados::ObjectWriteOperation *op, uint64_t size, uint8_t order, uint64_t features, const std::string &object_prefix, int64_t data_pool_id) @@ -52,7 +60,7 @@ int get_features_finish(bufferlist::const_iterator *it, uint64_t *features, try { decode(*features, *it); decode(*incompatible_features, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -106,7 +114,7 @@ int get_object_prefix_finish(bufferlist::const_iterator *it, { try { decode(*object_prefix, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -136,7 +144,7 @@ void get_data_pool_start(librados::ObjectReadOperation *op) { int get_data_pool_finish(bufferlist::const_iterator *it, int64_t *data_pool_id) { try { decode(*data_pool_id, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -170,7 +178,7 @@ int get_size_finish(bufferlist::const_iterator *it, uint64_t *size, try { decode(*order, *it); decode(*size, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -216,7 +224,7 @@ void get_flags_start(librados::ObjectReadOperation *op, snapid_t snap_id) { int get_flags_finish(bufferlist::const_iterator *it, uint64_t *flags) { try { decode(*flags, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -258,7 +266,7 @@ int op_features_get_finish(bufferlist::const_iterator *it, uint64_t *op_features { try { decode(*op_features, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -315,7 +323,7 @@ int get_parent_finish(bufferlist::const_iterator *it, decode(pspec->image_id, *it); decode(pspec->snap_id, *it); decode(*parent_overlap, *it); - } catch (const buffer::error &) { + } catch (const ceph::buffer::error &) { return -EBADMSG; } return 0; @@ -382,7 +390,7 @@ int parent_get_finish(bufferlist::const_iterator* it, cls::rbd::ParentImageSpec* parent_image_spec) { try { decode(*parent_image_spec, *it); - } catch (const buffer::error &) { + } catch (const ceph::buffer::error &) { return -EBADMSG; } return 0; @@ -418,7 +426,7 @@ int parent_overlap_get_finish(bufferlist::const_iterator* it, std::optional* parent_overlap) { try { decode(*parent_overlap, *it); - } catch (const buffer::error &) { + } catch (const ceph::buffer::error &) { return -EBADMSG; } return 0; @@ -533,7 +541,7 @@ int get_children_finish(bufferlist::const_iterator *it, std::set* children) { try { decode(*children, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -567,7 +575,7 @@ int snapshot_get_finish(bufferlist::const_iterator* it, { try { decode(*snap_info, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -636,7 +644,7 @@ int get_snapcontext_finish(bufferlist::const_iterator *it, { try { decode(*snapc, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } if (!snapc->is_valid()) { @@ -674,7 +682,7 @@ int get_snapshot_name_finish(bufferlist::const_iterator *it, { try { decode(*name, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -709,7 +717,7 @@ int get_snapshot_timestamp_finish(bufferlist::const_iterator *it, { try { decode(*timestamp, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -779,7 +787,7 @@ int old_snapshot_list_finish(bufferlist::const_iterator *it, decode((*sizes)[i], *it); decode((*names)[i], *it); } - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -812,7 +820,7 @@ int get_all_features_finish(bufferlist::const_iterator *it, uint64_t *all_features) { try { decode(*all_features, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -876,7 +884,7 @@ int get_protection_status_finish(bufferlist::const_iterator *it, { try { decode(*protection_status, *it); - } catch (const buffer::error &) { + } catch (const ceph::buffer::error &) { return -EBADMSG; } return 0; @@ -926,7 +934,7 @@ int snapshot_get_limit_finish(bufferlist::const_iterator *it, uint64_t *limit) { try { decode(*limit, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -969,7 +977,7 @@ int get_stripe_unit_count_finish(bufferlist::const_iterator *it, try { decode(*stripe_unit, *it); decode(*stripe_count, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1021,7 +1029,7 @@ int get_create_timestamp_finish(bufferlist::const_iterator *it, try { decode(*timestamp, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1054,7 +1062,7 @@ int get_access_timestamp_finish(bufferlist::const_iterator *it, try { decode(*timestamp, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1100,7 +1108,7 @@ int get_modify_timestamp_finish(bufferlist::const_iterator *it, try { decode(*timestamp, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1146,7 +1154,7 @@ void get_id_start(librados::ObjectReadOperation *op) { int get_id_finish(bufferlist::const_iterator *it, std::string *id) { try { decode(*id, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1195,7 +1203,7 @@ void dir_get_id_start(librados::ObjectReadOperation *op, int dir_get_id_finish(bufferlist::const_iterator *iter, std::string *image_id) { try { decode(*image_id, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -1227,7 +1235,7 @@ void dir_get_name_start(librados::ObjectReadOperation *op, int dir_get_name_finish(bufferlist::const_iterator *it, std::string *name) { try { decode(*name, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1262,7 +1270,7 @@ int dir_list_finish(bufferlist::const_iterator *it, map *images) { try { decode(*images, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1376,7 +1384,7 @@ int object_map_load_finish(bufferlist::const_iterator *it, ceph::BitVector<2> *object_map) { try { decode(*object_map, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1516,7 +1524,7 @@ int metadata_list_finish(bufferlist::const_iterator *it, ceph_assert(pairs); try { decode(*pairs, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1534,7 +1542,7 @@ int metadata_get_finish(bufferlist::const_iterator *it, std::string* value) { try { decode(*value, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1621,7 +1629,7 @@ int children_list_finish(bufferlist::const_iterator *it, child_images->clear(); try { decode(*child_images, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1688,7 +1696,7 @@ int migration_get_finish(bufferlist::const_iterator *it, cls::rbd::MigrationSpec *migration_spec) { try { decode(*migration_spec, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1750,7 +1758,7 @@ int mirror_uuid_get_finish(bufferlist::const_iterator *it, std::string *uuid) { try { decode(*uuid, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1798,7 +1806,7 @@ int mirror_mode_get_finish(bufferlist::const_iterator *it, uint32_t mirror_mode_decode; decode(mirror_mode_decode, *it); *mirror_mode = static_cast(mirror_mode_decode); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -1851,7 +1859,7 @@ int mirror_peer_list_finish(bufferlist::const_iterator *it, peers->clear(); try { decode(*peers, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -1998,7 +2006,7 @@ int mirror_image_list_finish(bufferlist::const_iterator *it, { try { decode(*mirror_image_ids, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2031,7 +2039,7 @@ int mirror_image_get_image_id_finish(bufferlist::const_iterator *it, std::string *image_id) { try { decode(*image_id, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2084,7 +2092,7 @@ int mirror_image_get_finish(bufferlist::const_iterator *iter, cls::rbd::MirrorImage *mirror_image) { try { decode(*mirror_image, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2179,7 +2187,7 @@ int mirror_image_status_get_finish(bufferlist::const_iterator *iter, cls::rbd::MirrorImageStatus *status) { try { decode(*status, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2223,7 +2231,7 @@ int mirror_image_status_list_finish(bufferlist::const_iterator *iter, try { decode(*images, *iter); decode(*statuses, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2263,7 +2271,7 @@ int mirror_image_status_get_summary_finish( std::map *states) { try { decode(*states, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2311,7 +2319,7 @@ int mirror_image_instance_get_finish(bufferlist::const_iterator *iter, entity_inst_t *instance) { try { decode(*instance, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2352,7 +2360,7 @@ int mirror_image_instance_list_finish( instances->clear(); try { decode(*instances, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2368,7 +2376,7 @@ int mirror_instances_list_finish(bufferlist::const_iterator *iter, instance_ids->clear(); try { decode(*instance_ids, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2435,7 +2443,7 @@ int mirror_image_map_list_finish(bufferlist::const_iterator *iter, std::map *image_mapping) { try { decode(*image_mapping, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2531,7 +2539,7 @@ int group_dir_list(librados::IoCtx *ioctx, const std::string &oid, auto iter = out.cbegin(); try { decode(*cgs, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2593,7 +2601,7 @@ int group_image_list(librados::IoCtx *ioctx, auto iter = bl2.cbegin(); try { decode(*images, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2638,7 +2646,7 @@ int image_group_get_finish(bufferlist::const_iterator *iter, { try { decode(*group_spec, *iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } return 0; @@ -2696,7 +2704,7 @@ int group_snap_get_by_id(librados::IoCtx *ioctx, const std::string &oid, auto iter = outbl.cbegin(); try { decode(*snapshot, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2720,7 +2728,7 @@ int group_snap_list(librados::IoCtx *ioctx, const std::string &oid, auto iter = outbl.cbegin(); try { decode(*snapshots, iter); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2779,7 +2787,7 @@ int trash_list_finish(bufferlist::const_iterator *it, try { decode(*entries, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2816,7 +2824,7 @@ int trash_get_finish(bufferlist::const_iterator *it, ceph_assert(trash_spec); try { decode(*trash_spec, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } @@ -2909,7 +2917,7 @@ int namespace_list_finish(bufferlist::const_iterator *it, try { decode(*entries, *it); - } catch (const buffer::error &err) { + } catch (const ceph::buffer::error &err) { return -EBADMSG; } diff --git a/src/cls/rbd/cls_rbd_client.h b/src/cls/rbd/cls_rbd_client.h index 23917b91b33c..aa9bb2b09e09 100644 --- a/src/cls/rbd/cls_rbd_client.h +++ b/src/cls/rbd/cls_rbd_client.h @@ -25,7 +25,7 @@ int create_image(librados::IoCtx *ioctx, const std::string &oid, const std::string &object_prefix, int64_t data_pool_id); void get_features_start(librados::ObjectReadOperation *op, bool read_only); -int get_features_finish(bufferlist::const_iterator *it, uint64_t *features, +int get_features_finish(ceph::buffer::list::const_iterator *it, uint64_t *features, uint64_t *incompatible_features); int get_features(librados::IoCtx *ioctx, const std::string &oid, bool read_only, uint64_t *features, @@ -36,18 +36,18 @@ int set_features(librados::IoCtx *ioctx, const std::string &oid, uint64_t features, uint64_t mask); void get_object_prefix_start(librados::ObjectReadOperation *op); -int get_object_prefix_finish(bufferlist::const_iterator *it, +int get_object_prefix_finish(ceph::buffer::list::const_iterator *it, std::string *object_prefix); int get_object_prefix(librados::IoCtx *ioctx, const std::string &oid, std::string *object_prefix); void get_data_pool_start(librados::ObjectReadOperation *op); -int get_data_pool_finish(bufferlist::const_iterator *it, int64_t *data_pool_id); +int get_data_pool_finish(ceph::buffer::list::const_iterator *it, int64_t *data_pool_id); int get_data_pool(librados::IoCtx *ioctx, const std::string &oid, int64_t *data_pool_id); void get_size_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_size_finish(bufferlist::const_iterator *it, uint64_t *size, +int get_size_finish(ceph::buffer::list::const_iterator *it, uint64_t *size, uint8_t *order); int get_size(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, uint64_t *size, uint8_t *order); @@ -56,7 +56,7 @@ int set_size(librados::IoCtx *ioctx, const std::string &oid, void set_size(librados::ObjectWriteOperation *op, uint64_t size); void get_flags_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_flags_finish(bufferlist::const_iterator *it, uint64_t *flags); +int get_flags_finish(ceph::buffer::list::const_iterator *it, uint64_t *flags); int get_flags(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, uint64_t *flags); @@ -64,7 +64,7 @@ void set_flags(librados::ObjectWriteOperation *op, snapid_t snap_id, uint64_t flags, uint64_t mask); void op_features_get_start(librados::ObjectReadOperation *op); -int op_features_get_finish(bufferlist::const_iterator *it, +int op_features_get_finish(ceph::buffer::list::const_iterator *it, uint64_t *op_features); int op_features_get(librados::IoCtx *ioctx, const std::string &oid, uint64_t *op_features); @@ -75,7 +75,7 @@ int op_features_set(librados::IoCtx *ioctx, const std::string &oid, // NOTE: deprecate v1 parent APIs after mimic EOLed void get_parent_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_parent_finish(bufferlist::const_iterator *it, +int get_parent_finish(ceph::buffer::list::const_iterator *it, cls::rbd::ParentImageSpec *pspec, uint64_t *parent_overlap); int get_parent(librados::IoCtx *ioctx, const std::string &oid, @@ -91,14 +91,14 @@ void remove_parent(librados::ObjectWriteOperation *op); // v2 parent APIs void parent_get_start(librados::ObjectReadOperation* op); -int parent_get_finish(bufferlist::const_iterator* it, +int parent_get_finish(ceph::buffer::list::const_iterator* it, cls::rbd::ParentImageSpec* parent_image_spec); int parent_get(librados::IoCtx* ioctx, const std::string &oid, cls::rbd::ParentImageSpec* parent_image_spec); void parent_overlap_get_start(librados::ObjectReadOperation* op, snapid_t snap_id); -int parent_overlap_get_finish(bufferlist::const_iterator* it, +int parent_overlap_get_finish(ceph::buffer::list::const_iterator* it, std::optional* parent_overlap); int parent_overlap_get(librados::IoCtx* ioctx, const std::string &oid, snapid_t snap_id, @@ -128,14 +128,14 @@ int remove_child(librados::IoCtx *ioctx, const std::string &oid, const std::string &c_imageid); void get_children_start(librados::ObjectReadOperation *op, const cls::rbd::ParentImageSpec &pspec); -int get_children_finish(bufferlist::const_iterator *it, - std::set *children); +int get_children_finish(ceph::buffer::list::const_iterator *it, + std::set *children); int get_children(librados::IoCtx *ioctx, const std::string &oid, - const cls::rbd::ParentImageSpec& pspec, set& children); + const cls::rbd::ParentImageSpec& pspec, std::set& children); void snapshot_get_start(librados::ObjectReadOperation* op, snapid_t snap_id); -int snapshot_get_finish(bufferlist::const_iterator* it, +int snapshot_get_finish(ceph::buffer::list::const_iterator* it, cls::rbd::SnapshotInfo* snap_info); int snapshot_get(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, cls::rbd::SnapshotInfo* snap_info); @@ -151,7 +151,7 @@ void snapshot_trash_add(librados::ObjectWriteOperation *op, snapid_t snap_id); void get_snapcontext_start(librados::ObjectReadOperation *op); -int get_snapcontext_finish(bufferlist::const_iterator *it, +int get_snapcontext_finish(ceph::buffer::list::const_iterator *it, ::SnapContext *snapc); int get_snapcontext(librados::IoCtx *ioctx, const std::string &oid, ::SnapContext *snapc); @@ -159,7 +159,7 @@ int get_snapcontext(librados::IoCtx *ioctx, const std::string &oid, /// NOTE: remove after Luminous is retired void get_snapshot_name_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_snapshot_name_finish(bufferlist::const_iterator *it, +int get_snapshot_name_finish(ceph::buffer::list::const_iterator *it, std::string *name); int get_snapshot_name(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, std::string *name); @@ -167,13 +167,13 @@ int get_snapshot_name(librados::IoCtx *ioctx, const std::string &oid, /// NOTE: remove after Luminous is retired void get_snapshot_timestamp_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_snapshot_timestamp_finish(bufferlist::const_iterator *it, +int get_snapshot_timestamp_finish(ceph::buffer::list::const_iterator *it, utime_t *timestamp); int get_snapshot_timestamp(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, utime_t *timestamp); void get_all_features_start(librados::ObjectReadOperation *op); -int get_all_features_finish(bufferlist::const_iterator *it, +int get_all_features_finish(ceph::buffer::list::const_iterator *it, uint64_t *all_features); int get_all_features(librados::IoCtx *ioctx, const std::string &oid, uint64_t *all_features); @@ -181,7 +181,7 @@ int get_all_features(librados::IoCtx *ioctx, const std::string &oid, /// NOTE: remove protection after clone v1 is retired void get_protection_status_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_protection_status_finish(bufferlist::const_iterator *it, +int get_protection_status_finish(ceph::buffer::list::const_iterator *it, uint8_t *protection_status); int get_protection_status(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, uint8_t *protection_status); @@ -192,14 +192,14 @@ void set_protection_status(librados::ObjectWriteOperation *op, snapid_t snap_id, uint8_t protection_status); void snapshot_get_limit_start(librados::ObjectReadOperation *op); -int snapshot_get_limit_finish(bufferlist::const_iterator *it, uint64_t *limit); +int snapshot_get_limit_finish(ceph::buffer::list::const_iterator *it, uint64_t *limit); int snapshot_get_limit(librados::IoCtx *ioctx, const std::string &oid, uint64_t *limit); void snapshot_set_limit(librados::ObjectWriteOperation *op, uint64_t limit); void get_stripe_unit_count_start(librados::ObjectReadOperation *op); -int get_stripe_unit_count_finish(bufferlist::const_iterator *it, +int get_stripe_unit_count_finish(ceph::buffer::list::const_iterator *it, uint64_t *stripe_unit, uint64_t *stripe_count); int get_stripe_unit_count(librados::IoCtx *ioctx, const std::string &oid, @@ -211,13 +211,13 @@ int set_stripe_unit_count(librados::IoCtx *ioctx, const std::string &oid, uint64_t stripe_unit, uint64_t stripe_count); void get_create_timestamp_start(librados::ObjectReadOperation *op); -int get_create_timestamp_finish(bufferlist::const_iterator *it, +int get_create_timestamp_finish(ceph::buffer::list::const_iterator *it, utime_t *timestamp); int get_create_timestamp(librados::IoCtx *ioctx, const std::string &oid, utime_t *timestamp); void get_access_timestamp_start(librados::ObjectReadOperation *op); -int get_access_timestamp_finish(bufferlist::const_iterator *it, +int get_access_timestamp_finish(ceph::buffer::list::const_iterator *it, utime_t *timestamp); int get_access_timestamp(librados::IoCtx *ioctx, const std::string &oid, utime_t *timestamp); @@ -226,7 +226,7 @@ void set_access_timestamp(librados::ObjectWriteOperation *op); int set_access_timestamp(librados::IoCtx *ioctx, const std::string &oid); void get_modify_timestamp_start(librados::ObjectReadOperation *op); -int get_modify_timestamp_finish(bufferlist::const_iterator *it, +int get_modify_timestamp_finish(ceph::buffer::list::const_iterator *it, utime_t *timestamp); int get_modify_timestamp(librados::IoCtx *ioctx, const std::string &oid, utime_t *timestamp); @@ -236,25 +236,25 @@ int set_modify_timestamp(librados::IoCtx *ioctx, const std::string &oid); int metadata_list(librados::IoCtx *ioctx, const std::string &oid, const std::string &start, uint64_t max_return, - map *pairs); + std::map *pairs); void metadata_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int metadata_list_finish(bufferlist::const_iterator *it, - std::map *pairs); +int metadata_list_finish(ceph::buffer::list::const_iterator *it, + std::map *pairs); void metadata_set(librados::ObjectWriteOperation *op, - const map &data); + const std::map &data); int metadata_set(librados::IoCtx *ioctx, const std::string &oid, - const map &data); + const std::map &data); void metadata_remove(librados::ObjectWriteOperation *op, const std::string &key); int metadata_remove(librados::IoCtx *ioctx, const std::string &oid, const std::string &key); void metadata_get_start(librados::ObjectReadOperation* op, const std::string &key); -int metadata_get_finish(bufferlist::const_iterator *it, +int metadata_get_finish(ceph::buffer::list::const_iterator *it, std::string* value); int metadata_get(librados::IoCtx *ioctx, const std::string &oid, - const std::string &key, string *v); + const std::string &key, std::string *v); void child_attach(librados::ObjectWriteOperation *op, snapid_t snap_id, const cls::rbd::ChildImageSpec& child_image); @@ -268,7 +268,7 @@ int child_detach(librados::IoCtx *ioctx, const std::string &oid, const cls::rbd::ChildImageSpec& child_image); void children_list_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int children_list_finish(bufferlist::const_iterator *it, +int children_list_finish(ceph::buffer::list::const_iterator *it, cls::rbd::ChildImageSpecs *child_images); int children_list(librados::IoCtx *ioctx, const std::string &oid, snapid_t snap_id, @@ -284,7 +284,7 @@ void migration_set_state(librados::ObjectWriteOperation *op, cls::rbd::MigrationState state, const std::string &description); void migration_get_start(librados::ObjectReadOperation *op); -int migration_get_finish(bufferlist::const_iterator *it, +int migration_get_finish(ceph::buffer::list::const_iterator *it, cls::rbd::MigrationSpec *migration_spec); int migration_get(librados::IoCtx *ioctx, const std::string &oid, cls::rbd::MigrationSpec *migration_spec); @@ -293,7 +293,7 @@ void migration_remove(librados::ObjectWriteOperation *op); // operations on rbd_id objects void get_id_start(librados::ObjectReadOperation *op); -int get_id_finish(bufferlist::const_iterator *it, std::string *id); +int get_id_finish(ceph::buffer::list::const_iterator *it, std::string *id); int get_id(librados::IoCtx *ioctx, const std::string &oid, std::string *id); void set_id(librados::ObjectWriteOperation *op, const std::string &id); @@ -304,18 +304,18 @@ int dir_get_id(librados::IoCtx *ioctx, const std::string &oid, const std::string &name, std::string *id); void dir_get_id_start(librados::ObjectReadOperation *op, const std::string &image_name); -int dir_get_id_finish(bufferlist::const_iterator *iter, std::string *image_id); +int dir_get_id_finish(ceph::buffer::list::const_iterator *iter, std::string *image_id); void dir_get_name_start(librados::ObjectReadOperation *op, const std::string &id); -int dir_get_name_finish(bufferlist::const_iterator *it, std::string *name); +int dir_get_name_finish(ceph::buffer::list::const_iterator *it, std::string *name); int dir_get_name(librados::IoCtx *ioctx, const std::string &oid, const std::string &id, std::string *name); void dir_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int dir_list_finish(bufferlist::const_iterator *it, map *images); +int dir_list_finish(ceph::buffer::list::const_iterator *it, std::map *images); int dir_list(librados::IoCtx *ioctx, const std::string &oid, const std::string &start, uint64_t max_return, - map *images); + std::map *images); void dir_add_image(librados::ObjectWriteOperation *op, const std::string &name, const std::string &id); int dir_add_image(librados::IoCtx *ioctx, const std::string &oid, @@ -339,7 +339,7 @@ int dir_state_set(librados::IoCtx *ioctx, const std::string &oid, // operations on the rbd_object_map.$image_id object void object_map_load_start(librados::ObjectReadOperation *op); -int object_map_load_finish(bufferlist::const_iterator *it, +int object_map_load_finish(ceph::buffer::list::const_iterator *it, ceph::BitVector<2> *object_map); int object_map_load(librados::IoCtx *ioctx, const std::string &oid, ceph::BitVector<2> *object_map); @@ -365,23 +365,23 @@ void old_snapshot_rename(librados::ObjectWriteOperation *rados_op, snapid_t src_snap_id, const std::string &dst_name); void old_snapshot_list_start(librados::ObjectReadOperation *op); -int old_snapshot_list_finish(bufferlist::const_iterator *it, - std::vector *names, +int old_snapshot_list_finish(ceph::buffer::list::const_iterator *it, + std::vector *names, std::vector *sizes, ::SnapContext *snapc); int old_snapshot_list(librados::IoCtx *ioctx, const std::string &oid, - std::vector *names, + std::vector *names, std::vector *sizes, ::SnapContext *snapc); // operations on the rbd_mirroring object void mirror_uuid_get_start(librados::ObjectReadOperation *op); -int mirror_uuid_get_finish(bufferlist::const_iterator *it, +int mirror_uuid_get_finish(ceph::buffer::list::const_iterator *it, std::string *uuid); int mirror_uuid_get(librados::IoCtx *ioctx, std::string *uuid); int mirror_uuid_set(librados::IoCtx *ioctx, const std::string &uuid); void mirror_mode_get_start(librados::ObjectReadOperation *op); -int mirror_mode_get_finish(bufferlist::const_iterator *it, +int mirror_mode_get_finish(ceph::buffer::list::const_iterator *it, cls::rbd::MirrorMode *mirror_mode); int mirror_mode_get(librados::IoCtx *ioctx, cls::rbd::MirrorMode *mirror_mode); @@ -395,7 +395,7 @@ void mirror_peer_ping(librados::ObjectWriteOperation *op, const std::string& site_name, const std::string& fsid); void mirror_peer_list_start(librados::ObjectReadOperation *op); -int mirror_peer_list_finish(bufferlist::const_iterator *it, +int mirror_peer_list_finish(ceph::buffer::list::const_iterator *it, std::vector *peers); int mirror_peer_list(librados::IoCtx *ioctx, std::vector *peers); @@ -417,14 +417,14 @@ int mirror_peer_set_direction( void mirror_image_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int mirror_image_list_finish(bufferlist::const_iterator *it, - std::map *mirror_image_ids); +int mirror_image_list_finish(ceph::buffer::list::const_iterator *it, + std::map *mirror_image_ids); int mirror_image_list(librados::IoCtx *ioctx, const std::string &start, uint64_t max_return, std::map *mirror_image_ids); void mirror_image_get_image_id_start(librados::ObjectReadOperation *op, const std::string &global_image_id); -int mirror_image_get_image_id_finish(bufferlist::const_iterator *it, +int mirror_image_get_image_id_finish(ceph::buffer::list::const_iterator *it, std::string *image_id); int mirror_image_get_image_id(librados::IoCtx *ioctx, const std::string &global_image_id, @@ -433,7 +433,7 @@ int mirror_image_get(librados::IoCtx *ioctx, const std::string &image_id, cls::rbd::MirrorImage *mirror_image); void mirror_image_get_start(librados::ObjectReadOperation *op, const std::string &image_id); -int mirror_image_get_finish(bufferlist::const_iterator *iter, +int mirror_image_get_finish(ceph::buffer::list::const_iterator *iter, cls::rbd::MirrorImage *mirror_image); void mirror_image_set(librados::ObjectWriteOperation *op, const std::string &image_id, @@ -455,7 +455,7 @@ int mirror_image_status_get(librados::IoCtx *ioctx, cls::rbd::MirrorImageStatus *status); void mirror_image_status_get_start(librados::ObjectReadOperation *op, const std::string &global_image_id); -int mirror_image_status_get_finish(bufferlist::const_iterator *iter, +int mirror_image_status_get_finish(ceph::buffer::list::const_iterator *iter, cls::rbd::MirrorImageStatus *status); int mirror_image_status_list(librados::IoCtx *ioctx, const std::string &start, uint64_t max_return, @@ -464,7 +464,7 @@ int mirror_image_status_list(librados::IoCtx *ioctx, void mirror_image_status_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int mirror_image_status_list_finish(bufferlist::const_iterator *iter, +int mirror_image_status_list_finish(ceph::buffer::list::const_iterator *iter, std::map *images, std::map *statuses); int mirror_image_status_get_summary( @@ -475,7 +475,7 @@ void mirror_image_status_get_summary_start( librados::ObjectReadOperation *op, const std::vector& mirror_peer_sites); int mirror_image_status_get_summary_finish( - bufferlist::const_iterator *iter, + ceph::buffer::list::const_iterator *iter, std::map *states); int mirror_image_status_remove_down(librados::IoCtx *ioctx); void mirror_image_status_remove_down(librados::ObjectWriteOperation *op); @@ -485,7 +485,7 @@ int mirror_image_instance_get(librados::IoCtx *ioctx, entity_inst_t *instance); void mirror_image_instance_get_start(librados::ObjectReadOperation *op, const std::string &global_image_id); -int mirror_image_instance_get_finish(bufferlist::const_iterator *iter, +int mirror_image_instance_get_finish(ceph::buffer::list::const_iterator *iter, entity_inst_t *instance); int mirror_image_instance_list(librados::IoCtx *ioctx, const std::string &start, uint64_t max_return, @@ -493,11 +493,11 @@ int mirror_image_instance_list(librados::IoCtx *ioctx, void mirror_image_instance_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int mirror_image_instance_list_finish(bufferlist::const_iterator *iter, +int mirror_image_instance_list_finish(ceph::buffer::list::const_iterator *iter, std::map *instances); void mirror_instances_list_start(librados::ObjectReadOperation *op); -int mirror_instances_list_finish(bufferlist::const_iterator *iter, +int mirror_instances_list_finish(ceph::buffer::list::const_iterator *iter, std::vector *instance_ids); int mirror_instances_list(librados::IoCtx *ioctx, std::vector *instance_ids); @@ -514,7 +514,7 @@ int mirror_instances_remove(librados::IoCtx *ioctx, void mirror_image_map_list_start(librados::ObjectReadOperation *op, const std::string &start_after, uint64_t max_read); -int mirror_image_map_list_finish(bufferlist::const_iterator *iter, +int mirror_image_map_list_finish(ceph::buffer::list::const_iterator *iter, std::map *image_mapping); int mirror_image_map_list(librados::IoCtx *ioctx, const std::string &start_after, uint64_t max_read, @@ -543,7 +543,7 @@ int mirror_image_snapshot_set_copy_progress(librados::IoCtx *ioctx, // Groups functions int group_dir_list(librados::IoCtx *ioctx, const std::string &oid, const std::string &start, uint64_t max_return, - map *groups); + std::map *groups); int group_dir_add(librados::IoCtx *ioctx, const std::string &oid, const std::string &name, const std::string &id); int group_dir_rename(librados::IoCtx *ioctx, const std::string &oid, @@ -564,7 +564,7 @@ int image_group_add(librados::IoCtx *ioctx, const std::string &oid, int image_group_remove(librados::IoCtx *ioctx, const std::string &oid, const cls::rbd::GroupSpec &group_spec); void image_group_get_start(librados::ObjectReadOperation *op); -int image_group_get_finish(bufferlist::const_iterator *iter, +int image_group_get_finish(ceph::buffer::list::const_iterator *iter, cls::rbd::GroupSpec *group_spec); int image_group_get(librados::IoCtx *ioctx, const std::string &oid, cls::rbd::GroupSpec *group_spec); @@ -591,14 +591,14 @@ void trash_remove(librados::ObjectWriteOperation *op, int trash_remove(librados::IoCtx *ioctx, const std::string &id); void trash_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int trash_list_finish(bufferlist::const_iterator *it, - map *entries); +int trash_list_finish(ceph::buffer::list::const_iterator *it, + std::map *entries); int trash_list(librados::IoCtx *ioctx, const std::string &start, uint64_t max_return, - map *entries); + std::map *entries); void trash_get_start(librados::ObjectReadOperation *op, const std::string &id); -int trash_get_finish(bufferlist::const_iterator *it, +int trash_get_finish(ceph::buffer::list::const_iterator *it, cls::rbd::TrashImageSpec *trash_spec); int trash_get(librados::IoCtx *ioctx, const std::string &id, cls::rbd::TrashImageSpec *trash_spec); @@ -619,7 +619,7 @@ void namespace_remove(librados::ObjectWriteOperation *op, int namespace_remove(librados::IoCtx *ioctx, const std::string &name); void namespace_list_start(librados::ObjectReadOperation *op, const std::string &start, uint64_t max_return); -int namespace_list_finish(bufferlist::const_iterator *it, +int namespace_list_finish(ceph::buffer::list::const_iterator *it, std::list *entries); int namespace_list(librados::IoCtx *ioctx, const std::string &start, uint64_t max_return, @@ -633,16 +633,16 @@ void assert_snapc_seq(librados::ObjectWriteOperation *op, uint64_t snapc_seq, cls::rbd::AssertSnapcSeqState state); -void copyup(librados::ObjectWriteOperation *op, bufferlist data); +void copyup(librados::ObjectWriteOperation *op, ceph::buffer::list data); int copyup(librados::IoCtx *ioctx, const std::string &oid, - bufferlist data); + ceph::buffer::list data); void sparse_copyup(librados::ObjectWriteOperation *op, const std::map &extent_map, - bufferlist data); + ceph::buffer::list data); int sparse_copyup(librados::IoCtx *ioctx, const std::string &oid, const std::map &extent_map, - bufferlist data); + ceph::buffer::list data); void sparsify(librados::ObjectWriteOperation *op, size_t sparse_size, bool remove_empty); diff --git a/src/cls/rbd/cls_rbd_types.cc b/src/cls/rbd/cls_rbd_types.cc index 9071f3457fe5..4da8a28246a2 100644 --- a/src/cls/rbd/cls_rbd_types.cc +++ b/src/cls/rbd/cls_rbd_types.cc @@ -8,6 +8,13 @@ namespace cls { namespace rbd { +using std::istringstream; +using std::ostringstream; +using std::string; + +using ceph::bufferlist; +using ceph::Formatter; + std::ostream& operator<<(std::ostream& os, MirrorPeerDirection mirror_peer_direction) { switch (mirror_peer_direction) { diff --git a/src/cls/rbd/cls_rbd_types.h b/src/cls/rbd/cls_rbd_types.h index b2c155eb864a..f5abbc9eb669 100644 --- a/src/cls/rbd/cls_rbd_types.h +++ b/src/cls/rbd/cls_rbd_types.h @@ -23,20 +23,20 @@ namespace cls { namespace rbd { static const uint32_t MAX_OBJECT_MAP_OBJECT_COUNT = 256000000; -static const string RBD_GROUP_IMAGE_KEY_PREFIX = "image_"; +static const std::string RBD_GROUP_IMAGE_KEY_PREFIX = "image_"; enum DirectoryState { DIRECTORY_STATE_READY = 0, DIRECTORY_STATE_ADD_DISABLED = 1 }; -inline void encode(DirectoryState state, bufferlist& bl, +inline void encode(DirectoryState state, ceph::buffer::list& bl, uint64_t features=0) { ceph::encode(static_cast(state), bl); } -inline void decode(DirectoryState &state, bufferlist::const_iterator& it) +inline void decode(DirectoryState &state, ceph::buffer::list::const_iterator& it) { uint8_t int_state; ceph::decode(int_state, it); @@ -54,14 +54,14 @@ enum GroupImageLinkState { GROUP_IMAGE_LINK_STATE_INCOMPLETE }; -inline void encode(const GroupImageLinkState &state, bufferlist& bl, +inline void encode(const GroupImageLinkState &state, ceph::buffer::list& bl, uint64_t features=0) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(GroupImageLinkState &state, bufferlist::const_iterator& it) +inline void decode(GroupImageLinkState &state, ceph::buffer::list::const_iterator& it) { uint8_t int_state; using ceph::decode; @@ -115,9 +115,9 @@ struct MirrorPeer { return (!uuid.empty() && !site_name.empty()); } - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -156,9 +156,9 @@ struct MirrorImage { std::string global_image_id; MirrorImageState state = MIRROR_IMAGE_STATE_DISABLING; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -182,7 +182,7 @@ enum MirrorImageStatusState { MIRROR_IMAGE_STATUS_STATE_STOPPED = 6, }; -inline void encode(const MirrorImageStatusState &state, bufferlist& bl, +inline void encode(const MirrorImageStatusState &state, ceph::buffer::list& bl, uint64_t features=0) { using ceph::encode; @@ -190,7 +190,7 @@ inline void encode(const MirrorImageStatusState &state, bufferlist& bl, } inline void decode(MirrorImageStatusState &state, - bufferlist::const_iterator& it) + ceph::buffer::list::const_iterator& it) { uint8_t int_state; using ceph::decode; @@ -216,12 +216,12 @@ struct MirrorImageSiteStatus { utime_t last_update; bool up = false; - void encode_meta(uint8_t version, bufferlist &bl) const; - void decode_meta(uint8_t version, bufferlist::const_iterator &it); + void encode_meta(uint8_t version, ceph::buffer::list &bl) const; + void decode_meta(uint8_t version, ceph::buffer::list::const_iterator &it); - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; std::string state_to_string() const; @@ -242,11 +242,11 @@ struct MirrorImageSiteStatusOnDisk : cls::rbd::MirrorImageSiteStatus { cls::rbd::MirrorImageSiteStatus(status) { } - void encode_meta(bufferlist &bl, uint64_t features) const; - void decode_meta(bufferlist::const_iterator &it); + void encode_meta(ceph::buffer::list &bl, uint64_t features) const; + void decode_meta(ceph::buffer::list::const_iterator &it); - void encode(bufferlist &bl, uint64_t features) const; - void decode(bufferlist::const_iterator &it); + void encode(ceph::buffer::list &bl, uint64_t features) const; + void decode(ceph::buffer::list::const_iterator &it); static void generate_test_instances( std::list &o); @@ -265,9 +265,9 @@ struct MirrorImageStatus { int get_local_mirror_image_site_status(MirrorImageSiteStatus* status) const; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; bool operator==(const MirrorImageStatus& rhs) const; @@ -306,9 +306,9 @@ struct ParentImageSpec { return !(*this == rhs); } - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); }; @@ -328,9 +328,9 @@ struct ChildImageSpec { : pool_id(pool_id), pool_namespace(pool_namespace), image_id(image_id) { } - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -366,9 +366,9 @@ struct GroupImageSpec { std::string image_id; int64_t pool_id = -1; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -391,9 +391,9 @@ struct GroupImageStatus { GroupImageSpec spec; GroupImageLinkState state = GROUP_IMAGE_LINK_STATE_INCOMPLETE; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -410,9 +410,9 @@ struct GroupSpec { std::string group_id; int64_t pool_id = -1; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; bool is_valid() const; static void generate_test_instances(std::list &o); @@ -433,10 +433,10 @@ struct UserSnapshotNamespace { UserSnapshotNamespace() {} - void encode(bufferlist& bl) const {} - void decode(bufferlist::const_iterator& it) {} + void encode(ceph::buffer::list& bl) const {} + void decode(ceph::buffer::list::const_iterator& it) {} - void dump(Formatter *f) const {} + void dump(ceph::Formatter *f) const {} inline bool operator==(const UserSnapshotNamespace& usn) const { return true; @@ -454,19 +454,19 @@ struct GroupSnapshotNamespace { GroupSnapshotNamespace() {} GroupSnapshotNamespace(int64_t _group_pool, - const string &_group_id, - const string &_group_snapshot_id) + const std::string &_group_id, + const std::string &_group_snapshot_id) : group_id(_group_id), group_pool(_group_pool), group_snapshot_id(_group_snapshot_id) {} - string group_id; + std::string group_id; int64_t group_pool = 0; - string group_snapshot_id; + std::string group_snapshot_id; - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; inline bool operator==(const GroupSnapshotNamespace& gsn) const { return group_pool == gsn.group_pool && @@ -500,9 +500,9 @@ struct TrashSnapshotNamespace { : original_name(original_name), original_snapshot_namespace_type(original_snapshot_namespace_type) {} - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; inline bool operator==(const TrashSnapshotNamespace& usn) const { return true; @@ -519,13 +519,13 @@ enum MirrorSnapshotState { MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED = 3, }; -inline void encode(const MirrorSnapshotState &state, bufferlist& bl, +inline void encode(const MirrorSnapshotState &state, ceph::buffer::list& bl, uint64_t features=0) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(MirrorSnapshotState &state, bufferlist::const_iterator& it) { +inline void decode(MirrorSnapshotState &state, ceph::buffer::list::const_iterator& it) { using ceph::decode; uint8_t int_state; decode(int_state, it); @@ -594,10 +594,10 @@ struct MirrorSnapshotNamespace { primary_snap_id == CEPH_NOSNAP); } - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; inline bool operator==(const MirrorSnapshotNamespace& rhs) const { return state == rhs.state && @@ -634,9 +634,9 @@ struct UnknownSnapshotNamespace { UnknownSnapshotNamespace() {} - void encode(bufferlist& bl) const {} - void decode(bufferlist::const_iterator& it) {} - void dump(Formatter *f) const {} + void encode(ceph::buffer::list& bl) const {} + void decode(ceph::buffer::list::const_iterator& it) {} + void dump(ceph::Formatter *f) const {} inline bool operator==(const UnknownSnapshotNamespace& gsn) const { return true; @@ -668,9 +668,9 @@ struct SnapshotNamespace : public SnapshotNamespaceVariant { SnapshotNamespace(T&& t) : SnapshotNamespaceVariant(std::forward(t)) { } - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -708,9 +708,9 @@ struct SnapshotInfo { child_count(child_count) { } - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); }; @@ -721,13 +721,13 @@ enum GroupSnapshotState { GROUP_SNAPSHOT_STATE_COMPLETE = 1, }; -inline void encode(const GroupSnapshotState &state, bufferlist& bl, uint64_t features=0) +inline void encode(const GroupSnapshotState &state, ceph::buffer::list& bl, uint64_t features=0) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(GroupSnapshotState &state, bufferlist::const_iterator& it) +inline void decode(GroupSnapshotState &state, ceph::buffer::list::const_iterator& it) { using ceph::decode; uint8_t int_state; @@ -737,20 +737,20 @@ inline void decode(GroupSnapshotState &state, bufferlist::const_iterator& it) struct ImageSnapshotSpec { int64_t pool; - string image_id; + std::string image_id; snapid_t snap_id; ImageSnapshotSpec() {} ImageSnapshotSpec(int64_t _pool, - string _image_id, + std::string _image_id, snapid_t _snap_id) : pool(_pool), image_id(_image_id), snap_id(_snap_id) {} - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); }; @@ -768,11 +768,11 @@ struct GroupSnapshot { name(_name), state(_state) {} - vector snaps; + std::vector snaps; - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); }; @@ -807,14 +807,14 @@ inline std::ostream& operator<<(std::ostream& os, return os; } -inline void encode(const TrashImageSource &source, bufferlist& bl, +inline void encode(const TrashImageSource &source, ceph::buffer::list& bl, uint64_t features=0) { using ceph::encode; encode(static_cast(source), bl); } -inline void decode(TrashImageSource &source, bufferlist::const_iterator& it) +inline void decode(TrashImageSource &source, ceph::buffer::list::const_iterator& it) { uint8_t int_source; using ceph::decode; @@ -829,13 +829,13 @@ enum TrashImageState { TRASH_IMAGE_STATE_RESTORING = 3 }; -inline void encode(const TrashImageState &state, bufferlist &bl) +inline void encode(const TrashImageState &state, ceph::buffer::list &bl) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(TrashImageState &state, bufferlist::const_iterator &it) +inline void decode(TrashImageState &state, ceph::buffer::list::const_iterator &it) { uint8_t int_state; using ceph::decode; @@ -858,9 +858,9 @@ struct TrashImageSpec { deferment_end_time(deferment_end_time) { } - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; inline bool operator==(const TrashImageSpec& rhs) const { return (source == rhs.source && @@ -876,7 +876,7 @@ struct MirrorImageMap { } MirrorImageMap(const std::string &instance_id, utime_t mapped_time, - const bufferlist &data) + const ceph::buffer::list &data) : instance_id(instance_id), mapped_time(mapped_time), data(data) { @@ -884,11 +884,11 @@ struct MirrorImageMap { std::string instance_id; utime_t mapped_time; - bufferlist data; + ceph::buffer::list data; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -905,12 +905,12 @@ enum MigrationHeaderType { MIGRATION_HEADER_TYPE_DST = 2, }; -inline void encode(const MigrationHeaderType &type, bufferlist& bl) { +inline void encode(const MigrationHeaderType &type, ceph::buffer::list& bl) { using ceph::encode; encode(static_cast(type), bl); } -inline void decode(MigrationHeaderType &type, bufferlist::const_iterator& it) { +inline void decode(MigrationHeaderType &type, ceph::buffer::list::const_iterator& it) { uint8_t int_type; using ceph::decode; decode(int_type, it); @@ -925,12 +925,12 @@ enum MigrationState { MIGRATION_STATE_EXECUTED = 4, }; -inline void encode(const MigrationState &state, bufferlist& bl) { +inline void encode(const MigrationState &state, ceph::buffer::list& bl) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(MigrationState &state, bufferlist::const_iterator& it) { +inline void decode(MigrationState &state, ceph::buffer::list::const_iterator& it) { uint8_t int_state; using ceph::decode; decode(int_state, it); @@ -970,9 +970,9 @@ struct MigrationSpec { state_description(state_description) { } - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator& it); - void dump(Formatter *f) const; + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator& it); + void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list &o); @@ -995,12 +995,12 @@ enum AssertSnapcSeqState { ASSERT_SNAPC_SEQ_LE_SNAPSET_SEQ = 1, }; -inline void encode(const AssertSnapcSeqState &state, bufferlist& bl) { +inline void encode(const AssertSnapcSeqState &state, ceph::buffer::list& bl) { using ceph::encode; encode(static_cast(state), bl); } -inline void decode(AssertSnapcSeqState &state, bufferlist::const_iterator& it) { +inline void decode(AssertSnapcSeqState &state, ceph::buffer::list::const_iterator& it) { uint8_t int_state; using ceph::decode; decode(int_state, it); diff --git a/src/cls/refcount/cls_refcount.cc b/src/cls/refcount/cls_refcount.cc index 73cc3b852fdd..781d967f979b 100644 --- a/src/cls/refcount/cls_refcount.cc +++ b/src/cls/refcount/cls_refcount.cc @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include @@ -8,10 +8,13 @@ #include "include/compat.h" +using std::string; + +using ceph::bufferlist; + CLS_VER(1,0) CLS_NAME(refcount) - #define REFCOUNT_ATTR "refcount" static string wildcard_tag; @@ -33,7 +36,7 @@ static int read_refcount(cls_method_context_t hctx, bool implicit_ref, obj_refco try { auto iter = bl.cbegin(); decode(*objr, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: read_refcount(): failed to decode refcount entry\n"); return -EIO; } @@ -61,7 +64,7 @@ static int cls_rc_refcount_get(cls_method_context_t hctx, bufferlist *in, buffer cls_refcount_get_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rc_refcount_get(): failed to decode entry\n"); return -EINVAL; } @@ -89,7 +92,7 @@ static int cls_rc_refcount_put(cls_method_context_t hctx, bufferlist *in, buffer cls_refcount_put_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rc_refcount_put(): failed to decode entry\n"); return -EINVAL; } @@ -107,7 +110,7 @@ static int cls_rc_refcount_put(cls_method_context_t hctx, bufferlist *in, buffer CLS_LOG(10, "cls_rc_refcount_put() tag=%s\n", op.tag.c_str()); bool found = false; - map::iterator iter = objr.refs.find(op.tag); + auto iter = objr.refs.find(op.tag); if (iter != objr.refs.end()) { found = true; } else if (op.implicit_ref) { @@ -142,7 +145,7 @@ static int cls_rc_refcount_set(cls_method_context_t hctx, bufferlist *in, buffer cls_refcount_set_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_refcount_set(): failed to decode entry\n"); return -EINVAL; } @@ -152,8 +155,7 @@ static int cls_rc_refcount_set(cls_method_context_t hctx, bufferlist *in, buffer } obj_refcount objr; - list::iterator iter; - for (iter = op.refs.begin(); iter != op.refs.end(); ++iter) { + for (auto iter = op.refs.begin(); iter != op.refs.end(); ++iter) { objr.refs[*iter] = true; } @@ -171,7 +173,7 @@ static int cls_rc_refcount_read(cls_method_context_t hctx, bufferlist *in, buffe cls_refcount_read_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rc_refcount_read(): failed to decode entry\n"); return -EINVAL; } @@ -183,8 +185,7 @@ static int cls_rc_refcount_read(cls_method_context_t hctx, bufferlist *in, buffe if (ret < 0) return ret; - map::iterator iter; - for (iter = objr.refs.begin(); iter != objr.refs.end(); ++iter) { + for (auto iter = objr.refs.begin(); iter != objr.refs.end(); ++iter) { read_ret.refs.push_back(iter->first); } diff --git a/src/cls/refcount/cls_refcount_client.cc b/src/cls/refcount/cls_refcount_client.cc index 9d5210c8abc8..f65a0fe32d0f 100644 --- a/src/cls/refcount/cls_refcount_client.cc +++ b/src/cls/refcount/cls_refcount_client.cc @@ -1,11 +1,16 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #include #include "cls/refcount/cls_refcount_client.h" #include "cls/refcount/cls_refcount_ops.h" #include "include/rados/librados.hpp" -using namespace librados; +using std::list; +using std::string; +using ceph::bufferlist; void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref) { @@ -50,7 +55,7 @@ int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list *refs, try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -58,4 +63,3 @@ int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list *refs, return r; } - diff --git a/src/cls/refcount/cls_refcount_client.h b/src/cls/refcount/cls_refcount_client.h index 756a971a328c..73a23a7ee28d 100644 --- a/src/cls/refcount/cls_refcount_client.h +++ b/src/cls/refcount/cls_refcount_client.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_REFCOUNT_CLIENT_H #define CEPH_CLS_REFCOUNT_CLIENT_H @@ -26,13 +29,13 @@ * as the relevant tag, and the refcount will be decreased. */ -void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref = false); -void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref = false); -void cls_refcount_set(librados::ObjectWriteOperation& op, list& refs); +void cls_refcount_get(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false); +void cls_refcount_put(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false); +void cls_refcount_set(librados::ObjectWriteOperation& op, std::list& refs); // these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list *refs, bool implicit_ref = false); +int cls_refcount_read(librados::IoCtx& io_ctx, std::string& oid, std::list *refs, bool implicit_ref = false); #endif #endif diff --git a/src/cls/refcount/cls_refcount_ops.cc b/src/cls/refcount/cls_refcount_ops.cc index ca7f93ed8089..3731269a9be1 100644 --- a/src/cls/refcount/cls_refcount_ops.cc +++ b/src/cls/refcount/cls_refcount_ops.cc @@ -5,6 +5,8 @@ #include "common/Formatter.h" #include "common/ceph_json.h" +using std::list; + void cls_refcount_get_op::dump(ceph::Formatter *f) const { f->dump_string("tag", tag); @@ -66,7 +68,7 @@ void cls_refcount_read_op::generate_test_instances(list& void cls_refcount_read_ret::dump(ceph::Formatter *f) const { f->open_array_section("refs"); - for (list::const_iterator p = refs.begin(); p != refs.end(); ++p) + for (auto p = refs.begin(); p != refs.end(); ++p) f->dump_string("ref", *p); f->close_section(); } diff --git a/src/cls/refcount/cls_refcount_ops.h b/src/cls/refcount/cls_refcount_ops.h index 946c11aa30bb..5d60b161fd5a 100644 --- a/src/cls/refcount/cls_refcount_ops.h +++ b/src/cls/refcount/cls_refcount_ops.h @@ -8,44 +8,44 @@ #include "common/hobject.h" struct cls_refcount_get_op { - string tag; + std::string tag; bool implicit_ref; cls_refcount_get_op() : implicit_ref(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(tag, bl); encode(implicit_ref, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(tag, bl); decode(implicit_ref, bl); DECODE_FINISH(bl); } void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_refcount_get_op) struct cls_refcount_put_op { - string tag; + std::string tag; bool implicit_ref; // assume wildcard reference for - // objects without a set ref + // objects without a std::set ref cls_refcount_put_op() : implicit_ref(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(tag, bl); encode(implicit_ref, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(tag, bl); decode(implicit_ref, bl); @@ -53,91 +53,91 @@ struct cls_refcount_put_op { } void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_refcount_put_op) struct cls_refcount_set_op { - list refs; + std::list refs; cls_refcount_set_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_refcount_set_op) struct cls_refcount_read_op { bool implicit_ref; // assume wildcard reference for - // objects without a set ref + // objects without a std::set ref cls_refcount_read_op() : implicit_ref(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(implicit_ref, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(implicit_ref, bl); DECODE_FINISH(bl); } void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_refcount_read_op) struct cls_refcount_read_ret { - list refs; + std::list refs; cls_refcount_read_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::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); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_refcount_read_ret) struct obj_refcount { - map refs; - set retired_refs; + std::map refs; + std::set retired_refs; obj_refcount() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(refs, bl); encode(retired_refs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(refs, bl); if (struct_v >= 2) { @@ -147,7 +147,7 @@ struct obj_refcount { } void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(obj_refcount) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index bdc3f7843324..98f4cc31aa53 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -17,6 +17,20 @@ #include "include/compat.h" #include +using std::pair; +using std::list; +using std::map; +using std::string; +using std::vector; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; +using ceph::make_timespan; +using ceph::real_clock; +using ceph::real_time; +using ceph::timespan; + CLS_VER(1,0) CLS_NAME(rgw) @@ -389,7 +403,7 @@ static int decode_list_index_key(const string& index_key, cls_rgw_obj_key *key, return -EIO; } - list::iterator iter = vals.begin(); + auto iter = vals.begin(); key->name = *iter; ++iter; @@ -431,7 +445,7 @@ static int read_bucket_header(cls_method_context_t hctx, auto iter = bl.cbegin(); try { decode(*header, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: read_bucket_header(): failed to decode header\n"); return -EIO; } @@ -451,7 +465,7 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) rgw_cls_list_op op; try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s: failed to decode request\n", __func__); return -EINVAL; } @@ -519,7 +533,7 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) const bufferlist& entrybl = kiter->second; auto eiter = entrybl.cbegin(); decode(entry, eiter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s: failed to decode entry, key=%s\n", __func__, kiter->first.c_str()); return -EINVAL; @@ -637,8 +651,7 @@ static int check_index(cls_method_context_t hctx, if (rc < 0) return rc; - std::map::iterator kiter = keys.begin(); - for (; kiter != keys.end(); ++kiter) { + for (auto kiter = keys.begin(); kiter != keys.end(); ++kiter) { if (!bi_is_objs_index(kiter->first)) { done = true; break; @@ -648,7 +661,7 @@ static int check_index(cls_method_context_t hctx, auto eiter = kiter->second.cbegin(); try { decode(entry, eiter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bucket_list(): failed to decode entry, key=%s\n", kiter->first.c_str()); return -EIO; } @@ -706,7 +719,7 @@ int rgw_bucket_update_stats(cls_method_context_t hctx, bufferlist *in, bufferlis auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s(): failed to decode request\n", __func__); return -EINVAL; } @@ -764,7 +777,7 @@ int rgw_bucket_set_tag_timeout(cls_method_context_t hctx, bufferlist *in, buffer auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bucket_set_tag_timeout(): failed to decode request\n"); return -EINVAL; } @@ -792,7 +805,7 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bucket_prepare_op(): failed to decode request\n"); return -EINVAL; } @@ -874,7 +887,7 @@ static int read_omap_entry(cls_method_context_t hctx, const std::string& name, auto cur_iter = current_entry.cbegin(); try { decode(*entry, cur_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s(): failed to decode entry\n", __func__); return -EIO; } @@ -934,7 +947,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bucket_complete_op(): failed to decode request\n"); return -EINVAL; } @@ -973,7 +986,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist rgw_bucket_dir_entry::FLAG_VER); if (op.tag.size()) { - map::iterator pinter = entry.pending_map.find(op.tag); + auto pinter = entry.pending_map.find(op.tag); if (pinter == entry.pending_map.end()) { CLS_LOG(1, "ERROR: couldn't find tag for pending operation\n"); return -EINVAL; @@ -1056,9 +1069,8 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist return rc; } - list::iterator remove_iter; CLS_LOG(20, "rgw_bucket_complete_op(): remove_objs.size()=%d\n", (int)op.remove_objs.size()); - for (remove_iter = op.remove_objs.begin(); remove_iter != op.remove_objs.end(); ++remove_iter) { + for (auto remove_iter = op.remove_objs.begin(); remove_iter != op.remove_objs.end(); ++remove_iter) { cls_rgw_obj_key& remove_key = *remove_iter; CLS_LOG(1, "rgw_bucket_complete_op(): removing entries, read_index_entry name=%s instance=%s\n", remove_key.name.c_str(), remove_key.instance.c_str()); @@ -1309,11 +1321,11 @@ public: rgw_bucket_dir_entry next_entry; - map::reverse_iterator last = keys.rbegin(); + auto last = keys.rbegin(); try { auto iter = last->second.cbegin(); decode(next_entry, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR; failed to decode entry: %s", last->first.c_str()); return -EIO; } @@ -1513,7 +1525,7 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_bucket_link_olh_op(): failed to decode request\n"); return -EINVAL; } @@ -1710,7 +1722,7 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_bucket_rm_obj_instance_op(): failed to decode request\n"); return -EINVAL; } @@ -1857,7 +1869,7 @@ static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bu auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_bucket_read_olh_log(): failed to decode request\n"); return -EINVAL; } @@ -1890,7 +1902,7 @@ static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bu op_ret.log = log; op_ret.is_truncated = false; } else { - map >::iterator iter = log.upper_bound(op.ver_marker); + auto iter = log.upper_bound(op.ver_marker); for (int i = 0; i < MAX_OLH_LOG_ENTRIES && iter != log.end(); ++i, ++iter) { op_ret.log[iter->first] = iter->second; @@ -1910,7 +1922,7 @@ static int rgw_bucket_trim_olh_log(cls_method_context_t hctx, bufferlist *in, bu auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_bucket_trim_olh_log(): failed to decode request\n"); return -EINVAL; } @@ -1936,10 +1948,10 @@ static int rgw_bucket_trim_olh_log(cls_method_context_t hctx, bufferlist *in, bu } /* remove all versions up to and including ver from the pending map */ - map >& log = olh_data_entry.pending_log; - map >::iterator liter = log.begin(); + auto& log = olh_data_entry.pending_log; + auto liter = log.begin(); while (liter != log.end() && liter->first <= op.ver) { - map >::iterator rm_iter = liter; + auto rm_iter = liter; ++liter; log.erase(rm_iter); } @@ -1961,7 +1973,7 @@ static int rgw_bucket_clear_olh(cls_method_context_t hctx, bufferlist *in, buffe auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_bucket_clear_olh(): failed to decode request\n"); return -EINVAL; } @@ -2047,7 +2059,7 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, try { decode(op, in_iter); decode(cur_change, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_dir_suggest_changes(): failed to decode request\n"); return -EINVAL; } @@ -2067,16 +2079,15 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, auto cur_disk_iter = cur_disk_bl.cbegin(); try { decode(cur_disk, cur_disk_iter); - } catch (buffer::error& error) { + } catch (ceph::buffer::error& error) { CLS_LOG(1, "ERROR: rgw_dir_suggest_changes(): failed to decode cur_disk\n"); return -EINVAL; } real_time cur_time = real_clock::now(); - map::iterator iter = - cur_disk.pending_map.begin(); + auto iter = cur_disk.pending_map.begin(); while(iter != cur_disk.pending_map.end()) { - map::iterator cur_iter=iter++; + auto cur_iter = iter++; if (cur_time > (cur_iter->second.timestamp + timespan(tag_timeout))) { cur_disk.pending_map.erase(cur_iter); } @@ -2156,7 +2167,7 @@ static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2173,11 +2184,11 @@ static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist } map new_attrs; - for (list::iterator iter = op.keep_attr_prefixes.begin(); + for (auto iter = op.keep_attr_prefixes.begin(); iter != op.keep_attr_prefixes.end(); ++iter) { - string& check_prefix = *iter; + auto& check_prefix = *iter; - for (map::iterator aiter = attrset.lower_bound(check_prefix); + for (auto aiter = attrset.lower_bound(check_prefix); aiter != attrset.end(); ++aiter) { const string& attr = aiter->first; @@ -2207,9 +2218,9 @@ static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist return ret; } - for (map::iterator aiter = new_attrs.begin(); + for (auto aiter = new_attrs.begin(); aiter != new_attrs.end(); ++aiter) { - const string& attr = aiter->first; + const auto& attr = aiter->first; ret = cls_cxx_setxattr(hctx, attr.c_str(), &aiter->second); CLS_LOG(20, "%s(): setting attr: %s", __func__, attr.c_str()); @@ -2229,7 +2240,7 @@ static int rgw_obj_store_pg_ver(cls_method_context_t hctx, bufferlist *in, buffe auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2253,7 +2264,7 @@ static int rgw_obj_check_attrs_prefix(cls_method_context_t hctx, bufferlist *in, auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2271,9 +2282,9 @@ static int rgw_obj_check_attrs_prefix(cls_method_context_t hctx, bufferlist *in, bool exist = false; - for (map::iterator aiter = attrset.lower_bound(op.check_prefix); + for (auto aiter = attrset.lower_bound(op.check_prefix); aiter != attrset.end(); ++aiter) { - const string& attr = aiter->first; + const auto& attr = aiter->first; if (attr.substr(0, op.check_prefix.size()) > op.check_prefix) { break; @@ -2296,7 +2307,7 @@ static int rgw_obj_check_mtime(cls_method_context_t hctx, bufferlist *in, buffer auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2359,7 +2370,7 @@ static int rgw_bi_get_op(cls_method_context_t hctx, bufferlist *in, bufferlist * auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2407,7 +2418,7 @@ static int rgw_bi_put_op(cls_method_context_t hctx, bufferlist *in, bufferlist * auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2443,8 +2454,7 @@ static int list_plain_entries(cls_method_context_t hctx, return ret; } - map::iterator iter; - for (iter = keys.begin(); iter != keys.end(); ++iter) { + for (auto iter = keys.begin(); iter != keys.end(); ++iter) { if (iter->first >= end_key) { /* past the end of plain namespace */ if (pmore) { @@ -2463,7 +2473,7 @@ static int list_plain_entries(cls_method_context_t hctx, rgw_bucket_dir_entry e; try { decode(e, biter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode buffer", __func__); return -EIO; } @@ -2536,8 +2546,7 @@ static int list_instance_entries(cls_method_context_t hctx, keys[start_after_key].claim(k); } - map::iterator iter; - for (iter = keys.begin(); iter != keys.end(); ++iter) { + for (auto iter = keys.begin(); iter != keys.end(); ++iter) { rgw_cls_bi_entry entry; entry.type = BIIndexType::Instance; entry.idx = iter->first; @@ -2558,7 +2567,7 @@ static int list_instance_entries(cls_method_context_t hctx, rgw_bucket_dir_entry e; try { decode(e, biter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode buffer (size=%d)", __func__, entry.data.length()); return -EIO; } @@ -2628,8 +2637,7 @@ static int list_olh_entries(cls_method_context_t hctx, keys[start_after_key].claim(k); } - map::iterator iter; - for (iter = keys.begin(); iter != keys.end(); ++iter) { + for (auto iter = keys.begin(); iter != keys.end(); ++iter) { rgw_cls_bi_entry entry; entry.type = BIIndexType::OLH; entry.idx = iter->first; @@ -2650,7 +2658,7 @@ static int list_olh_entries(cls_method_context_t hctx, rgw_bucket_olh_entry e; try { decode(e, biter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode buffer (size=%d)", __func__, entry.data.length()); return -EIO; } @@ -2680,7 +2688,7 @@ static int rgw_bi_list_op(cls_method_context_t hctx, auto iter = in->cbegin(); try { decode(op, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s(): failed to decode request", __func__); return -EINVAL; } @@ -2737,7 +2745,7 @@ int bi_log_record_decode(bufferlist& bl, rgw_bi_log_entry& e) auto iter = bl.cbegin(); try { decode(e, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: failed to decode rgw_bi_log_entry"); return -EIO; } @@ -2793,7 +2801,7 @@ static int bi_log_iterate_entries(cls_method_context_t hctx, if (ret < 0) return ret; - map::iterator iter = keys.begin(); + auto iter = keys.begin(); if (iter == keys.end()) return 0; @@ -2854,7 +2862,7 @@ static int rgw_bi_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist cls_rgw_bi_log_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bi_log_list(): failed to decode entry\n"); return -EINVAL; } @@ -2876,7 +2884,7 @@ static int rgw_bi_log_trim(cls_method_context_t hctx, bufferlist *in, bufferlist cls_rgw_bi_log_trim_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_bi_log_list(): failed to decode entry\n"); return -EINVAL; } @@ -3031,7 +3039,7 @@ static int usage_record_decode(bufferlist& record_bl, rgw_usage_log_entry& e) auto kiter = record_bl.cbegin(); try { decode(e, kiter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: usage_record_decode(): failed to decode record_bl\n"); return -EINVAL; } @@ -3048,15 +3056,14 @@ int rgw_user_usage_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_user_usage_log_add(): failed to decode request\n"); return -EINVAL; } rgw_usage_log_info& info = op.info; - vector::iterator iter; - for (iter = info.entries.begin(); iter != info.entries.end(); ++iter) { + for (auto iter = info.entries.begin(); iter != info.entries.end(); ++iter) { rgw_usage_log_entry& entry = *iter; string key_by_time; @@ -3136,8 +3143,8 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64 return ret; *truncated = truncated_status; - - map::iterator iter = keys.begin(); + + auto iter = keys.begin(); if (iter == keys.end()) return 0; @@ -3208,7 +3215,7 @@ int rgw_user_usage_log_read(cls_method_context_t hctx, bufferlist *in, bufferlis try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_user_usage_log_read(): failed to decode request\n"); return -EINVAL; } @@ -3263,7 +3270,7 @@ int rgw_user_usage_log_trim(cls_method_context_t hctx, bufferlist *in, bufferlis try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_user_log_usage_log_trim(): failed to decode request\n"); return -EINVAL; } @@ -3434,7 +3441,7 @@ int gc_record_decode(bufferlist& bl, cls_rgw_gc_obj_info& e) auto iter = bl.cbegin(); try { decode(e, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: failed to decode cls_rgw_gc_obj_info"); return -EIO; } @@ -3448,7 +3455,7 @@ static int rgw_cls_gc_set_entry(cls_method_context_t hctx, bufferlist *in, buffe cls_rgw_gc_set_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_gc_set_entry(): failed to decode entry\n"); return -EINVAL; } @@ -3463,7 +3470,7 @@ static int rgw_cls_gc_defer_entry(cls_method_context_t hctx, bufferlist *in, buf cls_rgw_gc_defer_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_gc_defer_entry(): failed to decode entry\n"); return -EINVAL; } @@ -3515,7 +3522,7 @@ static int gc_iterate_entries(cls_method_context_t hctx, if (ret < 0) return ret; - map::iterator iter = keys.begin(); + auto iter = keys.begin(); if (iter == keys.end()) { // if keys empty must not come back as truncated ceph_assert(!truncated || !(*truncated)); @@ -3585,7 +3592,7 @@ static int rgw_cls_gc_list(cls_method_context_t hctx, bufferlist *in, bufferlist cls_rgw_gc_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_gc_list(): failed to decode entry\n"); return -EINVAL; } @@ -3640,7 +3647,7 @@ static int rgw_cls_gc_remove(cls_method_context_t hctx, bufferlist *in, bufferli cls_rgw_gc_remove_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_gc_remove(): failed to decode entry\n"); return -EINVAL; } @@ -3655,7 +3662,7 @@ static int rgw_cls_lc_get_entry(cls_method_context_t hctx, bufferlist *in, buffe cls_rgw_lc_get_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_set_entry(): failed to decode entry\n"); return -EINVAL; } @@ -3678,7 +3685,7 @@ static int rgw_cls_lc_set_entry(cls_method_context_t hctx, bufferlist *in, buffe cls_rgw_lc_set_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_set_entry(): failed to decode entry\n"); return -EINVAL; } @@ -3697,7 +3704,7 @@ static int rgw_cls_lc_rm_entry(cls_method_context_t hctx, bufferlist *in, buffer cls_rgw_lc_rm_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_rm_entry(): failed to decode entry\n"); return -EINVAL; } @@ -3713,7 +3720,7 @@ static int rgw_cls_lc_get_next_entry(cls_method_context_t hctx, bufferlist *in, cls_rgw_lc_get_next_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_get_next_entry: failed to decode op\n"); return -EINVAL; } @@ -3724,14 +3731,13 @@ static int rgw_cls_lc_get_next_entry(cls_method_context_t hctx, bufferlist *in, int ret = cls_cxx_map_get_vals(hctx, op.marker, filter_prefix, 1, &vals, &more); if (ret < 0) return ret; - map::iterator it; pair entry; if (!vals.empty()) { - it=vals.begin(); + auto it = vals.begin(); in_iter = it->second.begin(); try { decode(entry, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_get_next_entry(): failed to decode entry\n"); return -EIO; } @@ -3747,25 +3753,23 @@ static int rgw_cls_lc_list_entries(cls_method_context_t hctx, bufferlist *in, bu auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_list_entries(): failed to decode op\n"); return -EINVAL; } cls_rgw_lc_list_entries_ret op_ret; - bufferlist::const_iterator iter; map vals; string filter_prefix; int ret = cls_cxx_map_get_vals(hctx, op.marker, filter_prefix, op.max_entries, &vals, &op_ret.is_truncated); if (ret < 0) return ret; - map::iterator it; pair entry; - for (it = vals.begin(); it != vals.end(); ++it) { - iter = it->second.cbegin(); + for (auto it = vals.begin(); it != vals.end(); ++it) { + auto iter = it->second.cbegin(); try { - decode(entry, iter); - } catch (buffer::error& err) { + decode(entry, iter); + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_list_entries(): failed to decode entry\n"); return -EIO; } @@ -3782,7 +3786,7 @@ static int rgw_cls_lc_put_head(cls_method_context_t hctx, bufferlist *in, buffer cls_rgw_lc_put_head_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_lc_put_head(): failed to decode entry\n"); return -EINVAL; } @@ -3804,7 +3808,7 @@ static int rgw_cls_lc_get_head(cls_method_context_t hctx, bufferlist *in, buffe auto iter = bl.cbegin(); try { decode(head, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: rgw_cls_lc_get_head(): failed to decode entry %s\n",err.what()); return -EINVAL; } @@ -3825,7 +3829,7 @@ static int rgw_reshard_add(cls_method_context_t hctx, bufferlist *in, bufferlist cls_rgw_reshard_add_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_reshard_add: failed to decode entry\n"); return -EINVAL; } @@ -3851,12 +3855,11 @@ static int rgw_reshard_list(cls_method_context_t hctx, bufferlist *in, bufferlis auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_rehard_list(): failed to decode entry\n"); return -EINVAL; } cls_rgw_reshard_list_ret op_ret; - bufferlist::const_iterator iter; map vals; string filter_prefix; #define MAX_RESHARD_LIST_ENTRIES 1000 @@ -3865,14 +3868,13 @@ static int rgw_reshard_list(cls_method_context_t hctx, bufferlist *in, bufferlis int ret = cls_cxx_map_get_vals(hctx, op.marker, filter_prefix, max, &vals, &op_ret.is_truncated); if (ret < 0) return ret; - map::iterator it; cls_rgw_reshard_entry entry; int i = 0; - for (it = vals.begin(); i < (int)op.max && it != vals.end(); ++it, ++i) { - iter = it->second.cbegin(); + for (auto it = vals.begin(); i < (int)op.max && it != vals.end(); ++it, ++i) { + auto iter = it->second.cbegin(); try { decode(entry, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_rehard_list(): failed to decode entry\n"); return -EIO; } @@ -3889,7 +3891,7 @@ static int rgw_reshard_get(cls_method_context_t hctx, bufferlist *in, bufferlis cls_rgw_reshard_get_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_reshard_get: failed to decode entry\n"); return -EINVAL; } @@ -3915,7 +3917,7 @@ static int rgw_reshard_remove(cls_method_context_t hctx, bufferlist *in, bufferl cls_rgw_reshard_remove_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: rgw_cls_rehard_remove: failed to decode entry\n"); return -EINVAL; } @@ -3948,7 +3950,7 @@ static int rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in, auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_set_bucket_resharding: failed to decode entry\n"); return -EINVAL; } @@ -3972,7 +3974,7 @@ static int rgw_clear_bucket_resharding(cls_method_context_t hctx, bufferlist *in auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_clear_bucket_resharding: failed to decode entry\n"); return -EINVAL; } @@ -3995,7 +3997,7 @@ static int rgw_guard_bucket_resharding(cls_method_context_t hctx, bufferlist *in auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s(): failed to decode entry\n", __func__); return -EINVAL; } @@ -4022,7 +4024,7 @@ static int rgw_get_bucket_resharding(cls_method_context_t hctx, auto in_iter = in->cbegin(); try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: %s(): failed to decode entry\n", __func__); return -EINVAL; } diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 65e59047ebad..09ce9749a00a 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -8,6 +8,14 @@ #include "common/debug.h" +using std::list; +using std::map; +using std::pair; +using std::string; +using std::vector; + +using ceph::real_time; + using namespace librados; const string BucketIndexShardsManager::KEY_VALUE_SEPARATOR = "#"; @@ -29,7 +37,7 @@ public: try { auto iter = outbl.cbegin(); decode((*data), iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { r = -EIO; } } @@ -42,14 +50,14 @@ public: void BucketIndexAioManager::do_completion(int id) { std::lock_guard l{lock}; - map::iterator iter = pendings.find(id); + auto iter = pendings.find(id); ceph_assert(iter != pendings.end()); completions[id] = iter->second; pendings.erase(iter); // If the caller needs a list of finished objects, store them // for further processing - map::iterator miter = pending_objs.find(id); + auto miter = pending_objs.find(id); if (miter != pending_objs.end()) { completion_objs[id] = miter->second; pending_objs.erase(miter); @@ -71,11 +79,11 @@ bool BucketIndexAioManager::wait_for_completions(int valid_ret_code, } // Clear the completed AIOs - map::iterator iter = completions.begin(); + auto iter = completions.begin(); for (; iter != completions.end(); ++iter) { int r = iter->second->get_return_value(); if (objs && r == 0) { /* update list of successfully completed objs */ - map::iterator liter = completion_objs.find(iter->first); + auto liter = completion_objs.find(iter->first); if (liter != completion_objs.end()) { (*objs)[liter->first] = liter->second; } @@ -309,7 +317,7 @@ int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid, auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -358,7 +366,7 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid, auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -634,7 +642,7 @@ public: try { auto iter = outbl.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { r = -EIO; } @@ -690,7 +698,7 @@ int cls_rgw_usage_log_read(IoCtx& io_ctx, const string& oid, const string& user, *is_truncated = result.truncated; usage = result.usage; - } catch (buffer::error& e) { + } catch (ceph::buffer::error& e) { return -EINVAL; } @@ -789,7 +797,7 @@ int cls_rgw_gc_list(IoCtx& io_ctx, string& oid, string& marker, uint32_t max, bo try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -821,7 +829,7 @@ int cls_rgw_lc_get_head(IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& h try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } head = ret.head; @@ -853,7 +861,7 @@ int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, string& marker, try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } entry = ret.entry; @@ -896,7 +904,7 @@ int cls_rgw_lc_get_entry(IoCtx& io_ctx, const string& oid, const std::string& ma try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -927,7 +935,7 @@ int cls_rgw_lc_list(IoCtx& io_ctx, const string& oid, try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } entries.insert(ret.entries.begin(),ret.entries.end()); @@ -960,7 +968,7 @@ int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& mar auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -984,7 +992,7 @@ int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_resh auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -1036,7 +1044,7 @@ int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid, auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index bd13710e8668..a8fd6dd51bbc 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #ifndef CEPH_CLS_RGW_CLIENT_H @@ -34,10 +34,10 @@ struct BucketIndexAioArg : public RefCountedObject { */ class BucketIndexAioManager { private: - map pendings; - map completions; - map pending_objs; - map completion_objs; + std::map pendings; + std::map completions; + std::map pending_objs; + std::map completion_objs; int next = 0; ceph::mutex lock = ceph::make_mutex("BucketIndexAioManager::lock"); ceph::condition_variable cond; @@ -65,7 +65,7 @@ private: * @param oid - the object id associated with the object, if it is NULL, we don't * track the object id per callback. */ - void add_pending(int id, librados::AioCompletion* completion, const string& oid) { + void add_pending(int id, librados::AioCompletion* completion, const std::string& oid) { pendings[id] = completion; pending_objs[id] = oid; } @@ -86,17 +86,17 @@ public: * valid_ret_code - valid AIO return code. * num_completions - number of completions. * ret_code - return code of failed AIO. - * objs - a list of objects that has been finished the AIO. + * objs - a std::list of objects that has been finished the AIO. * * Return false if there is no pending AIO, true otherwise. */ bool wait_for_completions(int valid_ret_code, int *num_completions, int *ret_code, - map *objs); + std::map *objs); /** * Do aio read operation. */ - bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectReadOperation *op) { + bool aio_operate(librados::IoCtx& io_ctx, const std::string& oid, librados::ObjectReadOperation *op) { std::lock_guard l{lock}; BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, bucket_index_op_completion_cb); @@ -113,7 +113,7 @@ public: /** * Do aio write operation. */ - bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectWriteOperation *op) { + bool aio_operate(librados::IoCtx& io_ctx, const std::string& oid, librados::ObjectWriteOperation *op) { std::lock_guard l{lock}; BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, bucket_index_op_completion_cb); @@ -137,21 +137,21 @@ public: class BucketIndexShardsManager { private: // Per shard setting manager, for example, marker. - map value_by_shards; + std::map value_by_shards; public: - const static string KEY_VALUE_SEPARATOR; - const static string SHARDS_SEPARATOR; + const static std::string KEY_VALUE_SEPARATOR; + const static std::string SHARDS_SEPARATOR; - void add(int shard, const string& value) { + void add(int shard, const std::string& value) { value_by_shards[shard] = value; } - const string& get(int shard, const string& default_value) { - map::iterator iter = value_by_shards.find(shard); + const std::string& get(int shard, const std::string& default_value) { + auto iter = value_by_shards.find(shard); return (iter == value_by_shards.end() ? default_value : iter->second); } - map& get() { + std::map& get() { return value_by_shards; } @@ -159,13 +159,13 @@ public: return value_by_shards.empty(); } - void to_string(string *out) const { + void to_string(std::string *out) const { if (!out) { return; } out->clear(); - map::const_iterator iter = value_by_shards.begin(); - for (; iter != value_by_shards.end(); ++iter) { + for (auto iter = value_by_shards.begin(); + iter != value_by_shards.end(); ++iter) { if (out->length()) { // Not the first item, append a separator first out->append(SHARDS_SEPARATOR); @@ -178,12 +178,12 @@ public: } } - static bool is_shards_marker(const string& marker) { - return marker.find(KEY_VALUE_SEPARATOR) != string::npos; + static bool is_shards_marker(const std::string& marker) { + return marker.find(KEY_VALUE_SEPARATOR) != std::string::npos; } /* - * convert from string. There are two options of how the string looks like: + * convert from std::string. There are two options of how the std::string looks like: * * 1. Single shard, no shard id specified, e.g. 000001.23.1 * @@ -193,17 +193,16 @@ public: * 2. One or more shards, shard id specified for each shard, e.g., 0#00002.12,1#00003.23.2 * */ - int from_string(const string& composed_marker, int shard_id) { + int from_string(const std::string& composed_marker, int shard_id) { value_by_shards.clear(); - vector shards; + std::vector shards; get_str_vec(composed_marker, SHARDS_SEPARATOR.c_str(), shards); if (shards.size() > 1 && shard_id >= 0) { return -EINVAL; } - vector::const_iterator iter = shards.begin(); - for (; iter != shards.end(); ++iter) { + for (auto iter = shards.begin(); iter != shards.end(); ++iter) { size_t pos = iter->find(KEY_VALUE_SEPARATOR); - if (pos == string::npos) { + if (pos == std::string::npos) { if (!value_by_shards.empty()) { return -EINVAL; } @@ -214,8 +213,8 @@ public: } return 0; } - string shard_str = iter->substr(0, pos); - string err; + std::string shard_str = iter->substr(0, pos); + std::string err; int shard = (int)strict_strtol(shard_str.c_str(), 10, &err); if (!err.empty()) { return -EINVAL; @@ -241,12 +240,12 @@ void cls_rgw_bucket_init_index(librados::ObjectWriteOperation& o); class CLSRGWConcurrentIO { protected: librados::IoCtx& io_ctx; - map& objs_container; - map::iterator iter; + std::map& objs_container; + std::map::iterator iter; uint32_t max_aio; BucketIndexAioManager manager; - virtual int issue_op(int shard_id, const string& oid) = 0; + virtual int issue_op(int shard_id, const std::string& oid) = 0; virtual void cleanup() {} virtual int valid_ret_code() { return 0; } @@ -254,13 +253,13 @@ protected: // OP needs to be re-send until a certain code is returned. virtual bool need_multiple_rounds() { return false; } // Add a new object to the end of the container. - virtual void add_object(int shard, const string& oid) {} - virtual void reset_container(map& objs) {} + virtual void add_object(int shard, const std::string& oid) {} + virtual void reset_container(std::map& objs) {} public: CLSRGWConcurrentIO(librados::IoCtx& ioc, - map& _objs_container, + std::map& _objs_container, uint32_t _max_aio) : io_ctx(ioc), objs_container(_objs_container), max_aio(_max_aio) {} @@ -278,8 +277,8 @@ public: } int num_completions = 0, r = 0; - map objs; - map *pobjs = (need_multiple_rounds() ? &objs : NULL); + std::map objs; + std::map *pobjs = (need_multiple_rounds() ? &objs : NULL); while (manager.wait_for_completions(valid_ret_code(), &num_completions, &r, pobjs)) { if (r >= 0 && ret >= 0) { for (; num_completions && iter != objs_container.end(); --num_completions, ++iter) { @@ -316,11 +315,11 @@ public: class CLSRGWIssueBucketIndexInit : public CLSRGWConcurrentIO { protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; int valid_ret_code() override { return -EEXIST; } void cleanup() override; public: - CLSRGWIssueBucketIndexInit(librados::IoCtx& ioc, map& _bucket_objs, + CLSRGWIssueBucketIndexInit(librados::IoCtx& ioc, std::map& _bucket_objs, uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio) {} }; @@ -328,14 +327,14 @@ public: class CLSRGWIssueBucketIndexClean : public CLSRGWConcurrentIO { protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; int valid_ret_code() override { return -ENOENT; } public: CLSRGWIssueBucketIndexClean(librados::IoCtx& ioc, - map& _bucket_objs, + std::map& _bucket_objs, uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio) {} @@ -345,76 +344,76 @@ public: class CLSRGWIssueSetTagTimeout : public CLSRGWConcurrentIO { uint64_t tag_timeout; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: - CLSRGWIssueSetTagTimeout(librados::IoCtx& ioc, map& _bucket_objs, + CLSRGWIssueSetTagTimeout(librados::IoCtx& ioc, std::map& _bucket_objs, uint32_t _max_aio, uint64_t _tag_timeout) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), tag_timeout(_tag_timeout) {} }; void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, bool absolute, - const map& stats); + const std::map& stats); -void cls_rgw_bucket_prepare_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag, - const cls_rgw_obj_key& key, const string& locator, bool log_op, +void cls_rgw_bucket_prepare_op(librados::ObjectWriteOperation& o, RGWModifyOp op, std::string& tag, + const cls_rgw_obj_key& key, const std::string& locator, bool log_op, uint16_t bilog_op, rgw_zone_set& zones_trace); -void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag, +void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp op, std::string& tag, rgw_bucket_entry_ver& ver, const cls_rgw_obj_key& key, rgw_bucket_dir_entry_meta& dir_meta, - list *remove_objs, bool log_op, + std::list *remove_objs, bool log_op, uint16_t bilog_op, rgw_zone_set *zones_trace); -void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list& keep_attr_prefixes); -void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr); -void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist); +void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, std::list& keep_attr_prefixes); +void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const std::string& attr); +void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const std::string& prefix, bool fail_if_exist); void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const ceph::real_time& mtime, bool high_precision_time, RGWCheckMTimeType type); -int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid, +int cls_rgw_bi_get(librados::IoCtx& io_ctx, const std::string oid, BIIndexType index_type, cls_rgw_obj_key& key, rgw_cls_bi_entry *entry); -int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, rgw_cls_bi_entry& entry); -void cls_rgw_bi_put(librados::ObjectWriteOperation& op, const string oid, rgw_cls_bi_entry& entry); -int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid, - const string& name, const string& marker, uint32_t max, - list *entries, bool *is_truncated); +int cls_rgw_bi_put(librados::IoCtx& io_ctx, const std::string oid, rgw_cls_bi_entry& entry); +void cls_rgw_bi_put(librados::ObjectWriteOperation& op, const std::string oid, rgw_cls_bi_entry& entry); +int cls_rgw_bi_list(librados::IoCtx& io_ctx, const std::string oid, + const std::string& name, const std::string& marker, uint32_t max, + std::list *entries, bool *is_truncated); void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op, - const cls_rgw_obj_key& key, bufferlist& olh_tag, - bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta, + const cls_rgw_obj_key& key, ceph::buffer::list& olh_tag, + bool delete_marker, const std::string& op_tag, rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace); void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op, - const cls_rgw_obj_key& key, const string& op_tag, - const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace); -void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret); -void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const string& olh_tag); -void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const string& olh_tag); + const cls_rgw_obj_key& key, const std::string& op_tag, + const std::string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace); +void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const std::string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret); +void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const std::string& olh_tag); +void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const std::string& olh_tag); // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, - const cls_rgw_obj_key& key, bufferlist& olh_tag, - bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta, +int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const std::string& oid, + const cls_rgw_obj_key& key, ceph::buffer::list& olh_tag, + bool delete_marker, const std::string& op_tag, rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace); -int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid, - const cls_rgw_obj_key& key, const string& op_tag, - const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace); -int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker, - const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret); -int cls_rgw_clear_olh(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag); -int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket, +int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const std::string& oid, + const cls_rgw_obj_key& key, const std::string& op_tag, + const std::string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace); +int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, std::string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker, + const std::string& olh_tag, rgw_cls_read_olh_log_ret& log_ret); +int cls_rgw_clear_olh(librados::IoCtx& io_ctx, std::string& oid, const cls_rgw_obj_key& olh, const std::string& olh_tag); +int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const std::string& oid, const std::string& user, const std::string& bucket, uint64_t start_epoch, uint64_t end_epoch); #endif /** - * List the bucket with the starting object and filter prefix. + * Std::list the bucket with the starting object and filter prefix. * NOTE: this method do listing requests for each bucket index shards identified by - * the keys of the *list_results* map, which means the map should be popludated + * the keys of the *list_results* std::map, which means the std::map should be popludated * by the caller to fill with each bucket index object id. * * io_ctx - IO context for rados. @@ -422,7 +421,7 @@ int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const string& oid, const str * filter_prefix - filter prefix. * num_entries - number of entries to request for each object (note the total * amount of entries returned depends on the number of shardings). - * list_results - the list results keyed by bucket index object id. + * list_results - the std::list results keyed by bucket index object id. * max_aio - the maximum number of AIO (for throttling). * * Return 0 on success, a failure code otherwise. @@ -430,22 +429,22 @@ int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const string& oid, const str class CLSRGWIssueBucketList : public CLSRGWConcurrentIO { cls_rgw_obj_key start_obj; - string filter_prefix; - string delimiter; + std::string filter_prefix; + std::string delimiter; uint32_t num_entries; bool list_versions; - map& result; + std::map& result; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: CLSRGWIssueBucketList(librados::IoCtx& io_ctx, const cls_rgw_obj_key& _start_obj, - const string& _filter_prefix, - const string& _delimiter, + const std::string& _filter_prefix, + const std::string& _delimiter, uint32_t _num_entries, bool _list_versions, - map& oids, - map& list_results, + std::map& oids, + std::map& list_results, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, oids, max_aio), start_obj(_start_obj), filter_prefix(_filter_prefix), delimiter(_delimiter), @@ -467,15 +466,15 @@ void cls_rgw_bilog_list(librados::ObjectReadOperation& op, cls_rgw_bi_log_list_ret *pdata, int *ret = nullptr); class CLSRGWIssueBILogList : public CLSRGWConcurrentIO { - map& result; + std::map& result; BucketIndexShardsManager& marker_mgr; uint32_t max; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: CLSRGWIssueBILogList(librados::IoCtx& io_ctx, BucketIndexShardsManager& _marker_mgr, uint32_t _max, - map& oids, - map& bi_log_lists, uint32_t max_aio) : + std::map& oids, + std::map& bi_log_lists, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, oids, max_aio), result(bi_log_lists), marker_mgr(_marker_mgr), max(_max) {} }; @@ -488,19 +487,19 @@ class CLSRGWIssueBILogTrim : public CLSRGWConcurrentIO { BucketIndexShardsManager& start_marker_mgr; BucketIndexShardsManager& end_marker_mgr; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; // Trim until -ENODATA is returned. int valid_ret_code() override { return -ENODATA; } bool need_multiple_rounds() override { return true; } - void add_object(int shard, const string& oid) override { objs_container[shard] = oid; } - void reset_container(map& objs) override { + void add_object(int shard, const std::string& oid) override { objs_container[shard] = oid; } + void reset_container(std::map& objs) override { objs_container.swap(objs); iter = objs_container.begin(); objs.clear(); } public: CLSRGWIssueBILogTrim(librados::IoCtx& io_ctx, BucketIndexShardsManager& _start_marker_mgr, - BucketIndexShardsManager& _end_marker_mgr, map& _bucket_objs, uint32_t max_aio) : + BucketIndexShardsManager& _end_marker_mgr, std::map& _bucket_objs, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio), start_marker_mgr(_start_marker_mgr), end_marker_mgr(_end_marker_mgr) {} }; @@ -514,31 +513,31 @@ public: * * Return 0 on success, a failure code otherwise. */ -class CLSRGWIssueBucketCheck : public CLSRGWConcurrentIO /* >*/ { - map& result; +class CLSRGWIssueBucketCheck : public CLSRGWConcurrentIO /* >*/ { + std::map& result; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: - CLSRGWIssueBucketCheck(librados::IoCtx& ioc, map& oids, - map& bucket_objs_ret, + CLSRGWIssueBucketCheck(librados::IoCtx& ioc, std::map& oids, + std::map& bucket_objs_ret, uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, oids, _max_aio), result(bucket_objs_ret) {} }; class CLSRGWIssueBucketRebuild : public CLSRGWConcurrentIO { protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: - CLSRGWIssueBucketRebuild(librados::IoCtx& io_ctx, map& bucket_objs, + CLSRGWIssueBucketRebuild(librados::IoCtx& io_ctx, std::map& bucket_objs, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, bucket_objs, max_aio) {} }; class CLSRGWIssueGetDirHeader : public CLSRGWConcurrentIO { - map& result; + std::map& result; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: - CLSRGWIssueGetDirHeader(librados::IoCtx& io_ctx, map& oids, map& dir_headers, + CLSRGWIssueGetDirHeader(librados::IoCtx& io_ctx, std::map& oids, std::map& dir_headers, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, oids, max_aio), result(dir_headers) {} }; @@ -546,75 +545,75 @@ public: class CLSRGWIssueSetBucketResharding : public CLSRGWConcurrentIO { cls_rgw_bucket_instance_entry entry; protected: - int issue_op(int shard_id, const string& oid) override; + int issue_op(int shard_id, const std::string& oid) override; public: - CLSRGWIssueSetBucketResharding(librados::IoCtx& ioc, map& _bucket_objs, + CLSRGWIssueSetBucketResharding(librados::IoCtx& ioc, std::map& _bucket_objs, const cls_rgw_bucket_instance_entry& _entry, uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), entry(_entry) {} }; class CLSRGWIssueResyncBucketBILog : public CLSRGWConcurrentIO { protected: - int issue_op(int shard_id, const string& oid); + int issue_op(int shard_id, const std::string& oid); public: - CLSRGWIssueResyncBucketBILog(librados::IoCtx& io_ctx, map& _bucket_objs, uint32_t max_aio) : + CLSRGWIssueResyncBucketBILog(librados::IoCtx& io_ctx, std::map& _bucket_objs, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio) {} }; class CLSRGWIssueBucketBILogStop : public CLSRGWConcurrentIO { protected: - int issue_op(int shard_id, const string& oid); + int issue_op(int shard_id, const std::string& oid); public: - CLSRGWIssueBucketBILogStop(librados::IoCtx& io_ctx, map& _bucket_objs, uint32_t max_aio) : + CLSRGWIssueBucketBILogStop(librados::IoCtx& io_ctx, std::map& _bucket_objs, uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio) {} }; -int cls_rgw_get_dir_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetDirHeader_CB *ctx); +int cls_rgw_get_dir_header_async(librados::IoCtx& io_ctx, std::string& oid, RGWGetDirHeader_CB *ctx); -void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates); +void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, ceph::buffer::list& updates); -void cls_rgw_suggest_changes(librados::ObjectWriteOperation& o, bufferlist& updates); +void cls_rgw_suggest_changes(librados::ObjectWriteOperation& o, ceph::buffer::list& updates); /* usage logging */ // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_usage_log_read(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket, - uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, string& read_iter, - map& usage, bool *is_truncated); +int cls_rgw_usage_log_read(librados::IoCtx& io_ctx, const std::string& oid, const std::string& user, const std::string& bucket, + uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, std::string& read_iter, + std::map& usage, bool *is_truncated); #endif -void cls_rgw_usage_log_trim(librados::ObjectWriteOperation& op, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch); +void cls_rgw_usage_log_trim(librados::ObjectWriteOperation& op, const std::string& user, const std::string& bucket, uint64_t start_epoch, uint64_t end_epoch); void cls_rgw_usage_log_clear(librados::ObjectWriteOperation& op); void cls_rgw_usage_log_add(librados::ObjectWriteOperation& op, rgw_usage_log_info& info); /* garbage collection */ void cls_rgw_gc_set_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, cls_rgw_gc_obj_info& info); -void cls_rgw_gc_defer_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const string& tag); -void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector& tags); +void cls_rgw_gc_defer_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const std::string& tag); +void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const std::vector& tags); // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_gc_list(librados::IoCtx& io_ctx, string& oid, string& marker, uint32_t max, bool expired_only, - list& entries, bool *truncated, string& next_marker); +int cls_rgw_gc_list(librados::IoCtx& io_ctx, std::string& oid, std::string& marker, uint32_t max, bool expired_only, + std::list& entries, bool *truncated, std::string& next_marker); #endif /* lifecycle */ // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head); -int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head); -int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const string& oid, string& marker, pair& entry); -int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const string& oid, const pair& entry); -int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const string& oid, const pair& entry); -int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const string& oid, const std::string& marker, rgw_lc_entry_t& entry); -int cls_rgw_lc_list(librados::IoCtx& io_ctx, const string& oid, - const string& marker, +int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head); +int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head); +int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, std::string& marker, std::pair& entry); +int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::pair& entry); +int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::pair& entry); +int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, rgw_lc_entry_t& entry); +int cls_rgw_lc_list(librados::IoCtx& io_ctx, const std::string& oid, + const std::string& marker, uint32_t max_entries, - map& entries); + std::map& entries); #endif /* resharding */ @@ -623,9 +622,9 @@ void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_re // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& marker, uint32_t max, - list& entries, bool* is_truncated); -int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry); +int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const std::string& oid, std::string& marker, uint32_t max, + std::list& entries, bool* is_truncated); +int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_reshard_entry& entry); #endif /* resharding attribute on bucket index shard headers */ @@ -633,10 +632,10 @@ void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err) // these overloads which call io_ctx.operate() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid, +int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_bucket_instance_entry& entry); -int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid); -int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid, +int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const std::string& oid); +int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_bucket_instance_entry *entry); #endif diff --git a/src/cls/rgw/cls_rgw_const.h b/src/cls/rgw/cls_rgw_const.h index 5957d2ffbfd7..f39919d24b60 100644 --- a/src/cls/rgw/cls_rgw_const.h +++ b/src/cls/rgw/cls_rgw_const.h @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #ifndef CEPH_CLS_RGW_CONST_H diff --git a/src/cls/rgw/cls_rgw_ops.cc b/src/cls/rgw/cls_rgw_ops.cc index afca9a281696..d779ea567e17 100644 --- a/src/cls/rgw/cls_rgw_ops.cc +++ b/src/cls/rgw/cls_rgw_ops.cc @@ -7,6 +7,11 @@ #include "common/ceph_json.h" #include "include/utime.h" +using std::list; +using std::map; + +using ceph::Formatter; + void rgw_cls_tag_timeout_op::dump(Formatter *f) const { f->dump_int("tag_timeout", tag_timeout); @@ -111,7 +116,7 @@ void rgw_cls_obj_prepare_op::dump(Formatter *f) const f->dump_string("locator", locator); f->dump_bool("log_op", log_op); f->dump_int("bilog_flags", bilog_flags); - ::encode_json("zones_trace", zones_trace, f); + encode_json("zones_trace", zones_trace, f); } void rgw_cls_obj_complete_op::generate_test_instances(list& o) @@ -126,7 +131,7 @@ void rgw_cls_obj_complete_op::generate_test_instances(list l; rgw_bucket_dir_entry_meta::generate_test_instances(l); - list::iterator iter = l.begin(); + auto iter = l.begin(); op->meta = *(*iter); o.push_back(op); @@ -149,7 +154,7 @@ void rgw_cls_obj_complete_op::dump(Formatter *f) const f->dump_string("tag", tag); f->dump_bool("log_op", log_op); f->dump_int("bilog_flags", bilog_flags); - ::encode_json("zones_trace", zones_trace, f); + encode_json("zones_trace", zones_trace, f); } void rgw_cls_link_olh_op::generate_test_instances(list& o) @@ -162,7 +167,7 @@ void rgw_cls_link_olh_op::generate_test_instances(list& o) op->olh_epoch = 123; list l; rgw_bucket_dir_entry_meta::generate_test_instances(l); - list::iterator iter = l.begin(); + auto iter = l.begin(); op->meta = *(*iter); op->log_op = true; @@ -173,18 +178,18 @@ void rgw_cls_link_olh_op::generate_test_instances(list& o) void rgw_cls_link_olh_op::dump(Formatter *f) const { - ::encode_json("key", key, f); - ::encode_json("olh_tag", olh_tag, f); - ::encode_json("delete_marker", delete_marker, f); - ::encode_json("op_tag", op_tag, f); - ::encode_json("meta", meta, f); - ::encode_json("olh_epoch", olh_epoch, f); - ::encode_json("log_op", log_op, f); - ::encode_json("bilog_flags", (uint32_t)bilog_flags, f); + encode_json("key", key, f); + encode_json("olh_tag", olh_tag, f); + encode_json("delete_marker", delete_marker, f); + encode_json("op_tag", op_tag, f); + encode_json("meta", meta, f); + encode_json("olh_epoch", olh_epoch, f); + encode_json("log_op", log_op, f); + encode_json("bilog_flags", (uint32_t)bilog_flags, f); utime_t ut(unmod_since); - ::encode_json("unmod_since", ut, f); - ::encode_json("high_precision_time", high_precision_time, f); - ::encode_json("zones_trace", zones_trace, f); + encode_json("unmod_since", ut, f); + encode_json("high_precision_time", high_precision_time, f); + encode_json("zones_trace", zones_trace, f); } void rgw_cls_unlink_instance_op::generate_test_instances(list& o) @@ -202,12 +207,12 @@ void rgw_cls_unlink_instance_op::generate_test_instances(list& o) @@ -224,9 +229,9 @@ void rgw_cls_read_olh_log_op::generate_test_instances(list& o) @@ -235,7 +240,7 @@ void rgw_cls_read_olh_log_ret::generate_test_instances(listis_truncated = true; list l; rgw_bucket_olh_log_entry::generate_test_instances(l); - list::iterator iter = l.begin(); + auto iter = l.begin(); r->log[1].push_back(*(*iter)); o.push_back(r); @@ -245,8 +250,8 @@ void rgw_cls_read_olh_log_ret::generate_test_instances(list& o) @@ -263,9 +268,9 @@ void rgw_cls_trim_olh_log_op::generate_test_instances(list& o) @@ -281,8 +286,8 @@ void rgw_cls_bucket_clear_olh_op::generate_test_instances(list& o) @@ -305,8 +310,7 @@ void rgw_cls_list_ret::generate_test_instances(list& o) { list l; rgw_bucket_dir::generate_test_instances(l); - list::iterator iter; - for (iter = l.begin(); iter != l.end(); ++iter) { + for (auto iter = l.begin(); iter != l.end(); ++iter) { rgw_bucket_dir *d = *iter; rgw_cls_list_ret *ret = new rgw_cls_list_ret; @@ -338,7 +342,7 @@ void rgw_cls_check_index_ret::generate_test_instances(listcalculated_header = *(h.front()); o.push_back(r); - for (list::iterator iter = h.begin(); iter != h.end(); ++iter) { + for (auto iter = h.begin(); iter != h.end(); ++iter) { delete *iter; } o.push_back(new rgw_cls_check_index_ret); @@ -346,8 +350,8 @@ void rgw_cls_check_index_ret::generate_test_instances(list& o) @@ -365,12 +369,12 @@ void rgw_cls_bucket_update_stats_op::generate_test_instances(list s; for (auto& entry : stats) { s[(int)entry.first] = entry.second; } - ::encode_json("stats", s, f); + encode_json("stats", s, f); } void cls_rgw_bi_log_list_op::dump(Formatter *f) const @@ -421,13 +425,13 @@ void cls_rgw_reshard_add_op::generate_test_instances(list l; cls_rgw_reshard_entry::generate_test_instances(l); - list::iterator iter = l.begin(); + auto iter = l.begin(); ls.back()->entry = *(*iter); } void cls_rgw_reshard_add_op::dump(Formatter *f) const { - ::encode_json("entry", entry, f); + encode_json("entry", entry, f); } void cls_rgw_reshard_list_op::generate_test_instances(list& ls) @@ -440,8 +444,8 @@ void cls_rgw_reshard_list_op::generate_test_instances(list& ls) @@ -454,8 +458,8 @@ void cls_rgw_reshard_list_ret::generate_test_instances(list& ls) @@ -466,7 +470,7 @@ void cls_rgw_reshard_get_op::generate_test_instances(list& ls) @@ -477,7 +481,7 @@ void cls_rgw_reshard_get_ret::generate_test_instances(list& ls) @@ -490,8 +494,8 @@ void cls_rgw_reshard_remove_op::generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(rgw_cls_tag_timeout_op) @@ -31,15 +31,15 @@ struct rgw_cls_obj_prepare_op { RGWModifyOp op; cls_rgw_obj_key key; - string tag; - string locator; + std::string tag; + std::string locator; bool log_op; uint16_t bilog_flags; rgw_zone_set zones_trace; rgw_cls_obj_prepare_op() : op(CLS_RGW_OP_UNKNOWN), log_op(false), bilog_flags(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(7, 5, bl); uint8_t c = (uint8_t)op; encode(c, bl); @@ -51,7 +51,7 @@ struct rgw_cls_obj_prepare_op encode(zones_trace, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(7, 3, 3, bl); uint8_t c; decode(c, bl); @@ -77,8 +77,8 @@ struct rgw_cls_obj_prepare_op } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_obj_prepare_op) @@ -86,19 +86,19 @@ struct rgw_cls_obj_complete_op { RGWModifyOp op; cls_rgw_obj_key key; - string locator; + std::string locator; rgw_bucket_entry_ver ver; rgw_bucket_dir_entry_meta meta; - string tag; + std::string tag; bool log_op; uint16_t bilog_flags; - list remove_objs; + std::list remove_objs; rgw_zone_set zones_trace; rgw_cls_obj_complete_op() : op(CLS_RGW_OP_ADD), log_op(false), bilog_flags(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(9, 7, bl); uint8_t c = (uint8_t)op; encode(c, bl); @@ -114,7 +114,7 @@ struct rgw_cls_obj_complete_op encode(zones_trace, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(9, 3, 3, bl); uint8_t c; decode(c, bl); @@ -129,10 +129,10 @@ struct rgw_cls_obj_complete_op decode(locator, bl); } if (struct_v >= 4 && struct_v < 7) { - list old_remove_objs; + std::list old_remove_objs; decode(old_remove_objs, bl); - for (list::iterator iter = old_remove_objs.begin(); + for (auto iter = old_remove_objs.begin(); iter != old_remove_objs.end(); ++iter) { cls_rgw_obj_key k; k.name = *iter; @@ -160,27 +160,27 @@ struct rgw_cls_obj_complete_op } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_obj_complete_op) struct rgw_cls_link_olh_op { cls_rgw_obj_key key; - string olh_tag; + std::string olh_tag; bool delete_marker; - string op_tag; + std::string op_tag; rgw_bucket_dir_entry_meta meta; uint64_t olh_epoch; bool log_op; uint16_t bilog_flags; - real_time unmod_since; /* only create delete marker if newer then this */ + ceph::real_time unmod_since; /* only create delete marker if newer then this */ bool high_precision_time; rgw_zone_set zones_trace; rgw_cls_link_olh_op() : delete_marker(false), olh_epoch(0), log_op(false), bilog_flags(0), high_precision_time(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(5, 1, bl); encode(key, bl); encode(olh_tag, bl); @@ -198,7 +198,7 @@ struct rgw_cls_link_olh_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(5, bl); decode(key, bl); decode(olh_tag, bl); @@ -227,23 +227,23 @@ struct rgw_cls_link_olh_op { DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_link_olh_op) struct rgw_cls_unlink_instance_op { cls_rgw_obj_key key; - string op_tag; + std::string op_tag; uint64_t olh_epoch; bool log_op; uint16_t bilog_flags; - string olh_tag; + std::string olh_tag; rgw_zone_set zones_trace; rgw_cls_unlink_instance_op() : olh_epoch(0), log_op(false), bilog_flags(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(3, 1, bl); encode(key, bl); encode(op_tag, bl); @@ -255,7 +255,7 @@ struct rgw_cls_unlink_instance_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(3, bl); decode(key, bl); decode(op_tag, bl); @@ -271,8 +271,8 @@ struct rgw_cls_unlink_instance_op { DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_unlink_instance_op) @@ -280,51 +280,51 @@ struct rgw_cls_read_olh_log_op { cls_rgw_obj_key olh; uint64_t ver_marker; - string olh_tag; + std::string olh_tag; rgw_cls_read_olh_log_op() : ver_marker(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(olh, bl); encode(ver_marker, bl); encode(olh_tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(olh, bl); decode(ver_marker, bl); decode(olh_tag, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_read_olh_log_op) struct rgw_cls_read_olh_log_ret { - map > log; + std::map > log; bool is_truncated; rgw_cls_read_olh_log_ret() : is_truncated(false) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(log, bl); encode(is_truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(log, bl); decode(is_truncated, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_read_olh_log_ret) @@ -332,51 +332,51 @@ struct rgw_cls_trim_olh_log_op { cls_rgw_obj_key olh; uint64_t ver; - string olh_tag; + std::string olh_tag; rgw_cls_trim_olh_log_op() : ver(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(olh, bl); encode(ver, bl); encode(olh_tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(olh, bl); decode(ver, bl); decode(olh_tag, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_trim_olh_log_op) struct rgw_cls_bucket_clear_olh_op { cls_rgw_obj_key key; - string olh_tag; + std::string olh_tag; rgw_cls_bucket_clear_olh_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(key, bl); encode(olh_tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(key, bl); decode(olh_tag, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(rgw_cls_bucket_clear_olh_op) @@ -384,13 +384,13 @@ struct rgw_cls_list_op { cls_rgw_obj_key start_obj; uint32_t num_entries; - string filter_prefix; + std::string filter_prefix; bool list_versions; - string delimiter; + std::string delimiter; rgw_cls_list_op() : num_entries(0), list_versions(false) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(6, 4, bl); encode(num_entries, bl); encode(filter_prefix, bl); @@ -399,7 +399,7 @@ struct rgw_cls_list_op encode(delimiter, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl); if (struct_v < 4) { decode(start_obj.name, bl); @@ -419,8 +419,8 @@ struct rgw_cls_list_op } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_list_op) @@ -438,21 +438,21 @@ struct rgw_cls_list_ret { cls_filtered(true) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(3, 2, bl); encode(dir, bl); encode(is_truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); decode(dir, bl); decode(is_truncated, bl); cls_filtered = struct_v >= 3; DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_list_ret) @@ -463,57 +463,57 @@ struct rgw_cls_check_index_ret rgw_cls_check_index_ret() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(existing_header, bl); encode(calculated_header, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(existing_header, bl); decode(calculated_header, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_check_index_ret) struct rgw_cls_bucket_update_stats_op { bool absolute{false}; - map stats; + std::map stats; rgw_cls_bucket_update_stats_op() {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(absolute, bl); encode(stats, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(absolute, bl); decode(stats, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_cls_bucket_update_stats_op) struct rgw_cls_obj_remove_op { - list keep_attr_prefixes; + std::list keep_attr_prefixes; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(keep_attr_prefixes, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(keep_attr_prefixes, bl); DECODE_FINISH(bl); @@ -522,15 +522,15 @@ struct rgw_cls_obj_remove_op { WRITE_CLASS_ENCODER(rgw_cls_obj_remove_op) struct rgw_cls_obj_store_pg_ver_op { - string attr; + std::string attr; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(attr, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(attr, bl); DECODE_FINISH(bl); @@ -539,19 +539,19 @@ struct rgw_cls_obj_store_pg_ver_op { WRITE_CLASS_ENCODER(rgw_cls_obj_store_pg_ver_op) struct rgw_cls_obj_check_attrs_prefix { - string check_prefix; + std::string check_prefix; bool fail_if_exist; rgw_cls_obj_check_attrs_prefix() : fail_if_exist(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(check_prefix, bl); encode(fail_if_exist, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(check_prefix, bl); decode(fail_if_exist, bl); @@ -567,7 +567,7 @@ struct rgw_cls_obj_check_mtime { rgw_cls_obj_check_mtime() : type(CLS_RGW_CHECK_TIME_MTIME_EQ), high_precision_time(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(mtime, bl); encode((uint8_t)type, bl); @@ -575,7 +575,7 @@ struct rgw_cls_obj_check_mtime { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(mtime, bl); uint8_t c; @@ -593,18 +593,18 @@ struct rgw_cls_usage_log_add_op { rgw_usage_log_info info; rgw_user user; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(info, bl); encode(user.to_str(), bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(info, bl); if (struct_v >= 2) { - string s; + std::string s; decode(s, bl); user.from_str(s); } @@ -619,14 +619,14 @@ struct rgw_cls_bi_get_op { rgw_cls_bi_get_op() : type(BIIndexType::Plain) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(key, bl); encode((uint8_t)type, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(key, bl); uint8_t c; @@ -642,13 +642,13 @@ struct rgw_cls_bi_get_ret { rgw_cls_bi_get_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -661,13 +661,13 @@ struct rgw_cls_bi_put_op { rgw_cls_bi_put_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -677,12 +677,12 @@ WRITE_CLASS_ENCODER(rgw_cls_bi_put_op) struct rgw_cls_bi_list_op { uint32_t max; - string name; - string marker; + std::string name; + std::string marker; rgw_cls_bi_list_op() : max(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(max, bl); encode(name, bl); @@ -690,7 +690,7 @@ struct rgw_cls_bi_list_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(max, bl); decode(name, bl); @@ -701,19 +701,19 @@ struct rgw_cls_bi_list_op { WRITE_CLASS_ENCODER(rgw_cls_bi_list_op) struct rgw_cls_bi_list_ret { - list entries; + std::list entries; bool is_truncated; rgw_cls_bi_list_ret() : is_truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(is_truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(is_truncated, bl); @@ -725,13 +725,13 @@ WRITE_CLASS_ENCODER(rgw_cls_bi_list_ret) struct rgw_cls_usage_log_read_op { uint64_t start_epoch; uint64_t end_epoch; - string owner; - string bucket; + std::string owner; + std::string bucket; - string iter; // should be empty for the first call, non empty for subsequent calls + std::string iter; // should be empty for the first call, non empty for subsequent calls uint32_t max_entries; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(start_epoch, bl); encode(end_epoch, bl); @@ -742,7 +742,7 @@ struct rgw_cls_usage_log_read_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(start_epoch, bl); decode(end_epoch, bl); @@ -758,11 +758,11 @@ struct rgw_cls_usage_log_read_op { WRITE_CLASS_ENCODER(rgw_cls_usage_log_read_op) struct rgw_cls_usage_log_read_ret { - map usage; + std::map usage; bool truncated; - string next_iter; + std::string next_iter; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(usage, bl); encode(truncated, bl); @@ -770,7 +770,7 @@ struct rgw_cls_usage_log_read_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(usage, bl); decode(truncated, bl); @@ -783,10 +783,10 @@ WRITE_CLASS_ENCODER(rgw_cls_usage_log_read_ret) struct rgw_cls_usage_log_trim_op { uint64_t start_epoch; uint64_t end_epoch; - string user; - string bucket; + std::string user; + std::string bucket; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(3, 2, bl); encode(start_epoch, bl); encode(end_epoch, bl); @@ -795,7 +795,7 @@ struct rgw_cls_usage_log_trim_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(3, bl); decode(start_epoch, bl); decode(end_epoch, bl); @@ -813,57 +813,57 @@ struct cls_rgw_gc_set_entry_op { cls_rgw_gc_obj_info info; cls_rgw_gc_set_entry_op() : expiration_secs(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(expiration_secs, bl); encode(info, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(expiration_secs, bl); decode(info, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_gc_set_entry_op) struct cls_rgw_gc_defer_entry_op { uint32_t expiration_secs; - string tag; + std::string tag; cls_rgw_gc_defer_entry_op() : expiration_secs(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(expiration_secs, bl); encode(tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(expiration_secs, bl); decode(tag, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_gc_defer_entry_op) struct cls_rgw_gc_list_op { - string marker; + std::string marker; uint32_t max; bool expired_only; cls_rgw_gc_list_op() : max(0), expired_only(true) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(marker, bl); encode(max, bl); @@ -871,7 +871,7 @@ struct cls_rgw_gc_list_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(marker, bl); decode(max, bl); @@ -881,19 +881,19 @@ struct cls_rgw_gc_list_op { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_gc_list_op) struct cls_rgw_gc_list_ret { - list entries; - string next_marker; + std::list entries; + std::string next_marker; bool truncated; cls_rgw_gc_list_ret() : truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(entries, bl); encode(next_marker, bl); @@ -901,7 +901,7 @@ struct cls_rgw_gc_list_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(entries, bl); if (struct_v >= 2) @@ -910,119 +910,119 @@ struct cls_rgw_gc_list_ret { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_gc_list_ret) struct cls_rgw_gc_remove_op { - vector tags; + std::vector tags; cls_rgw_gc_remove_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(tags, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(tags, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_gc_remove_op) struct cls_rgw_bi_log_list_op { - string marker; + std::string marker; uint32_t max; cls_rgw_bi_log_list_op() : max(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(marker, bl); encode(max, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(marker, bl); decode(max, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_bi_log_list_op) struct cls_rgw_bi_log_trim_op { - string start_marker; - string end_marker; + std::string start_marker; + std::string end_marker; cls_rgw_bi_log_trim_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(start_marker, bl); encode(end_marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(start_marker, bl); decode(end_marker, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_bi_log_trim_op) struct cls_rgw_bi_log_list_ret { - list entries; + std::list entries; bool truncated; cls_rgw_bi_log_list_ret() : truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(truncated, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_bi_log_list_ret) struct cls_rgw_lc_get_next_entry_op { - string marker; + std::string marker; cls_rgw_lc_get_next_entry_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(marker, bl); DECODE_FINISH(bl); @@ -1036,13 +1036,13 @@ struct cls_rgw_lc_get_next_entry_ret { rgw_lc_entry_t entry; cls_rgw_lc_get_next_entry_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -1052,17 +1052,17 @@ struct cls_rgw_lc_get_next_entry_ret { WRITE_CLASS_ENCODER(cls_rgw_lc_get_next_entry_ret) struct cls_rgw_lc_get_entry_op { - string marker; + std::string marker; cls_rgw_lc_get_entry_op() {} cls_rgw_lc_get_entry_op(const std::string& _marker) : marker(_marker) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(marker, bl); DECODE_FINISH(bl); @@ -1075,13 +1075,13 @@ struct cls_rgw_lc_get_entry_ret { cls_rgw_lc_get_entry_ret() {} cls_rgw_lc_get_entry_ret(rgw_lc_entry_t&& _entry) : entry(std::move(_entry)) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -1095,13 +1095,13 @@ struct cls_rgw_lc_rm_entry_op { rgw_lc_entry_t entry; cls_rgw_lc_rm_entry_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -1113,13 +1113,13 @@ struct cls_rgw_lc_set_entry_op { rgw_lc_entry_t entry; cls_rgw_lc_set_entry_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); @@ -1133,13 +1133,13 @@ struct cls_rgw_lc_put_head_op { cls_rgw_lc_put_head_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(head, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(head, bl); DECODE_FINISH(bl); @@ -1153,13 +1153,13 @@ struct cls_rgw_lc_get_head_ret { cls_rgw_lc_get_head_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(head, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(head, bl); DECODE_FINISH(bl); @@ -1169,19 +1169,19 @@ struct cls_rgw_lc_get_head_ret { WRITE_CLASS_ENCODER(cls_rgw_lc_get_head_ret) struct cls_rgw_lc_list_entries_op { - string marker; + std::string marker; uint32_t max_entries = 0; cls_rgw_lc_list_entries_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(marker, bl); encode(max_entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(marker, bl); decode(max_entries, bl); @@ -1192,19 +1192,19 @@ struct cls_rgw_lc_list_entries_op { WRITE_CLASS_ENCODER(cls_rgw_lc_list_entries_op) struct cls_rgw_lc_list_entries_ret { - map entries; + std::map entries; bool is_truncated{false}; cls_rgw_lc_list_entries_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(entries, bl); encode(is_truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(entries, bl); if (struct_v >= 2) { @@ -1221,68 +1221,68 @@ struct cls_rgw_reshard_add_op { cls_rgw_reshard_add_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_add_op) struct cls_rgw_reshard_list_op { uint32_t max{0}; - string marker; + std::string marker; cls_rgw_reshard_list_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(max, bl); encode(marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(max, bl); decode(marker, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_list_op) struct cls_rgw_reshard_list_ret { - list entries; + std::list entries; bool is_truncated{false}; cls_rgw_reshard_list_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(is_truncated, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(is_truncated, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_list_ret) @@ -1291,19 +1291,19 @@ struct cls_rgw_reshard_get_op { cls_rgw_reshard_get_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_get_op) @@ -1312,30 +1312,30 @@ struct cls_rgw_reshard_get_ret { cls_rgw_reshard_get_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_get_ret) struct cls_rgw_reshard_remove_op { - string tenant; - string bucket_name; - string bucket_id; + std::string tenant; + std::string bucket_name; + std::string bucket_id; cls_rgw_reshard_remove_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(tenant, bl); encode(bucket_name, bl); @@ -1343,106 +1343,106 @@ struct cls_rgw_reshard_remove_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(tenant, bl); decode(bucket_name, bl); decode(bucket_id, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_remove_op) struct cls_rgw_set_bucket_resharding_op { cls_rgw_bucket_instance_entry entry; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entry, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entry, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_set_bucket_resharding_op) struct cls_rgw_clear_bucket_resharding_op { - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_clear_bucket_resharding_op) struct cls_rgw_guard_bucket_resharding_op { int ret_err{0}; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(ret_err, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(ret_err, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_guard_bucket_resharding_op) struct cls_rgw_get_bucket_resharding_op { - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_op) struct cls_rgw_get_bucket_resharding_ret { cls_rgw_bucket_instance_entry new_instance; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(new_instance, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(new_instance, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; }; WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_ret) diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index f820003a2ff5..c175d3ba1d4a 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -5,6 +5,11 @@ #include "common/ceph_json.h" #include "include/utime.h" +using std::list; +using std::string; + +using ceph::bufferlist; +using ceph::Formatter; void rgw_zone_set_entry::from_str(const string& s) { @@ -30,7 +35,7 @@ string rgw_zone_set_entry::to_str() const void rgw_zone_set_entry::encode(bufferlist &bl) const { /* no ENCODE_START, ENCODE_END for backward compatibility */ - ceph::encode(to_str(), bl); + ceph::encode(to_str(), bl); } void rgw_zone_set_entry::decode(bufferlist::const_iterator &bl) @@ -156,8 +161,7 @@ void rgw_bucket_dir_entry::generate_test_instances(list& list l; rgw_bucket_dir_entry_meta::generate_test_instances(l); - list::iterator iter; - for (iter = l.begin(); iter != l.end(); ++iter) { + for (auto iter = l.begin(); iter != l.end(); ++iter) { rgw_bucket_dir_entry_meta *m = *iter; rgw_bucket_dir_entry *e = new rgw_bucket_dir_entry; e->key.name = "name"; @@ -576,11 +580,10 @@ void rgw_bucket_category_stats::dump(Formatter *f) const void rgw_bucket_dir_header::generate_test_instances(list& o) { list l; - list::iterator iter; rgw_bucket_category_stats::generate_test_instances(l); - uint8_t i; - for (i = 0, iter = l.begin(); iter != l.end(); ++iter, ++i) { + uint8_t i = 0; + for (auto iter = l.begin(); iter != l.end(); ++iter, ++i) { RGWObjCategory c = static_cast(i); rgw_bucket_dir_header *h = new rgw_bucket_dir_header; rgw_bucket_category_stats *s = *iter; @@ -612,18 +615,16 @@ void rgw_bucket_dir_header::dump(Formatter *f) const void rgw_bucket_dir::generate_test_instances(list& o) { list l; - list::iterator iter; rgw_bucket_dir_header::generate_test_instances(l); - uint8_t i; - for (i = 0, iter = l.begin(); iter != l.end(); ++iter, ++i) { + uint8_t i = 0; + for (auto iter = l.begin(); iter != l.end(); ++iter, ++i) { rgw_bucket_dir *d = new rgw_bucket_dir; rgw_bucket_dir_header *h = *iter; d->header = *h; list el; - list::iterator eiter; - for (eiter = el.begin(); eiter != el.end(); ++eiter) { + for (auto eiter = el.begin(); eiter != el.end(); ++eiter) { rgw_bucket_dir_entry *e = *eiter; d->m[e->key.name] = *e; @@ -670,8 +671,7 @@ void rgw_usage_log_entry::dump(Formatter *f) const f->open_array_section("categories"); if (usage_map.size() > 0) { - map::const_iterator it; - for (it = usage_map.begin(); it != usage_map.end(); it++) { + for (auto it = usage_map.begin(); it != usage_map.end(); it++) { const rgw_usage_data& total_usage = it->second; f->open_object_section("entry"); f->dump_string("category", it->first.c_str()); diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 0bd197ae856a..2187603f26cd 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -18,13 +18,10 @@ class JSONObj; -namespace ceph { - class Formatter; -} using ceph::operator <<; struct rgw_zone_set_entry { - string zone; + std::string zone; std::optional location_key; bool operator<(const rgw_zone_set_entry& e) const { @@ -38,20 +35,20 @@ struct rgw_zone_set_entry { } rgw_zone_set_entry() {} - rgw_zone_set_entry(const string& _zone, + rgw_zone_set_entry(const std::string& _zone, std::optional _location_key) : zone(_zone), location_key(_location_key) {} - rgw_zone_set_entry(const string& s) { + rgw_zone_set_entry(const std::string& s) { from_str(s); } - void from_str(const string& s); - string to_str() const; + void from_str(const std::string& s); + std::string to_str() const; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &bl); + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &bl); - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_zone_set_entry) @@ -59,17 +56,17 @@ WRITE_CLASS_ENCODER(rgw_zone_set_entry) struct rgw_zone_set { std::set entries; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { /* no ENCODE_START, ENCODE_END for backward compatibility */ ceph::encode(entries, bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { /* no DECODE_START, DECODE_END for backward compatibility */ ceph::decode(entries, bl); } - void insert(const string& zone, std::optional location_key); - bool exists(const string& zone, std::optional location_key) const; + void insert(const std::string& zone, std::optional location_key); + bool exists(const std::string& zone, std::optional location_key) const; }; WRITE_CLASS_ENCODER(rgw_zone_set) @@ -110,19 +107,19 @@ enum RGWCheckMTimeType { #define ROUND_BLOCK_SIZE 4096 -static inline uint64_t cls_rgw_get_rounded_size(uint64_t size) { +inline uint64_t cls_rgw_get_rounded_size(uint64_t size) { return (size + ROUND_BLOCK_SIZE - 1) & ~(ROUND_BLOCK_SIZE - 1); } /* - * This takes a string that either wholly contains a delimiter or is a + * This takes a std::string that either wholly contains a delimiter or is a * path that ends with a delimiter and appends a new character to the * end such that when a we request bucket-index entries *after* this, * we'll get the next object after the "subdirectory". This works * because we append a '\xFF' charater, and no valid UTF-8 character * can contain that byte, so no valid entries can be skipped. */ -static inline std::string cls_rgw_after_delim(const std::string& path) { +inline std::string cls_rgw_after_delim(const std::string& path) { // assert: ! path.empty() return path + '\xFF'; } @@ -134,7 +131,7 @@ struct rgw_bucket_pending_info { rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY), op(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(2, 2, bl); uint8_t s = (uint8_t)state; encode(s, bl); @@ -142,7 +139,7 @@ struct rgw_bucket_pending_info { encode(op, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); uint8_t s; decode(s, bl); @@ -151,9 +148,9 @@ struct rgw_bucket_pending_info { decode(op, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_pending_info) @@ -179,19 +176,19 @@ struct rgw_bucket_dir_entry_meta { RGWObjCategory category; uint64_t size; ceph::real_time mtime; - string etag; - string owner; - string owner_display_name; - string content_type; + std::string etag; + std::string owner; + std::string owner_display_name; + std::string content_type; uint64_t accounted_size; - string user_data; - string storage_class; + std::string user_data; + std::string storage_class; bool appendable; rgw_bucket_dir_entry_meta() : category(RGWObjCategory::None), size(0), accounted_size(0), appendable(false) { } - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(7, 3, bl); encode(category, bl); encode(size, bl); @@ -207,7 +204,7 @@ struct rgw_bucket_dir_entry_meta { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); decode(category, bl); decode(size, bl); @@ -229,14 +226,14 @@ struct rgw_bucket_dir_entry_meta { decode(appendable, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta) template -void encode_packed_val(T val, bufferlist& bl) +void encode_packed_val(T val, ceph::buffer::list& bl) { using ceph::encode; if ((uint64_t)val < 0x80) { @@ -265,7 +262,7 @@ void encode_packed_val(T val, bufferlist& bl) } template -void decode_packed_val(T& val, bufferlist::const_iterator& bl) +void decode_packed_val(T& val, ceph::buffer::list::const_iterator& bl) { using ceph::decode; unsigned char c; @@ -307,7 +304,7 @@ void decode_packed_val(T& val, bufferlist::const_iterator& bl) } break; default: - throw buffer::error(); + throw ceph::buffer::error(); } } @@ -317,33 +314,33 @@ struct rgw_bucket_entry_ver { rgw_bucket_entry_ver() : pool(-1), epoch(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode_packed_val(pool, bl); encode_packed_val(epoch, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode_packed_val(pool, bl); decode_packed_val(epoch, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_entry_ver) struct cls_rgw_obj_key { - string name; - string instance; + std::string name; + std::string instance; cls_rgw_obj_key() {} - cls_rgw_obj_key(const string &_name) : name(_name) {} - cls_rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {} + cls_rgw_obj_key(const std::string &_name) : name(_name) {} + cls_rgw_obj_key(const std::string& n, const std::string& i) : name(n), instance(i) {} - void set(const string& _name) { + void set(const std::string& _name) { name = _name; } @@ -364,24 +361,24 @@ struct cls_rgw_obj_key { bool empty() const { return name.empty(); } - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(name, bl); encode(instance, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(name, bl); decode(instance, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_string("name", name); f->dump_string("instance", instance); } void decode_json(JSONObj *obj); - static void generate_test_instances(list& ls) { + static void generate_test_instances(std::list& ls) { ls.push_back(new cls_rgw_obj_key); ls.push_back(new cls_rgw_obj_key); ls.back()->name = "name"; @@ -412,16 +409,16 @@ struct rgw_bucket_dir_entry { std::string locator; bool exists; rgw_bucket_dir_entry_meta meta; - multimap pending_map; + std::multimap pending_map; uint64_t index_ver; - string tag; + std::string tag; uint16_t flags; uint64_t versioned_epoch; rgw_bucket_dir_entry() : exists(false), index_ver(0), flags(0), versioned_epoch(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(8, 3, bl); encode(key.name, bl); encode(ver.epoch, bl); @@ -437,7 +434,7 @@ struct rgw_bucket_dir_entry { encode(versioned_epoch, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl); decode(key.name, bl); decode(ver.epoch, bl); @@ -487,9 +484,9 @@ struct rgw_bucket_dir_entry { return flags & rgw_bucket_dir_entry::FLAG_COMMON_PREFIX; } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_dir_entry) @@ -504,12 +501,12 @@ struct rgw_bucket_category_stats; struct rgw_cls_bi_entry { BIIndexType type; - string idx; - bufferlist data; + std::string idx; + ceph::buffer::list data; rgw_cls_bi_entry() : type(BIIndexType::Invalid) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(type, bl); encode(idx, bl); @@ -517,7 +514,7 @@ struct rgw_cls_bi_entry { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); uint8_t c; decode(c, bl); @@ -527,7 +524,7 @@ struct rgw_cls_bi_entry { DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL); bool get_info(cls_rgw_obj_key *key, RGWObjCategory *category, @@ -545,14 +542,14 @@ enum OLHLogOp { struct rgw_bucket_olh_log_entry { uint64_t epoch; OLHLogOp op; - string op_tag; + std::string op_tag; cls_rgw_obj_key key; bool delete_marker; rgw_bucket_olh_log_entry() : epoch(0), op(CLS_RGW_OLH_OP_UNKNOWN), delete_marker(false) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(epoch, bl); encode((__u8)op, bl); @@ -561,7 +558,7 @@ struct rgw_bucket_olh_log_entry { encode(delete_marker, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(epoch, bl); uint8_t c; @@ -572,8 +569,8 @@ struct rgw_bucket_olh_log_entry { decode(delete_marker, bl); DECODE_FINISH(bl); } - static void generate_test_instances(list& o); - void dump(Formatter *f) const; + static void generate_test_instances(std::list& o); + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry) @@ -582,14 +579,14 @@ struct rgw_bucket_olh_entry { cls_rgw_obj_key key; bool delete_marker; uint64_t epoch; - map > pending_log; - string tag; + std::map > pending_log; + std::string tag; bool exists; bool pending_removal; rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false), pending_removal(false) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); encode(key, bl); encode(delete_marker, bl); @@ -600,7 +597,7 @@ struct rgw_bucket_olh_entry { encode(pending_removal, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(1, bl); decode(key, bl); decode(delete_marker, bl); @@ -611,29 +608,29 @@ struct rgw_bucket_olh_entry { decode(pending_removal, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_bucket_olh_entry) struct rgw_bi_log_entry { - string id; - string object; - string instance; + std::string id; + std::string object; + std::string instance; ceph::real_time timestamp; rgw_bucket_entry_ver ver; RGWModifyOp op; RGWPendingState state; uint64_t index_ver; - string tag; + std::string tag; uint16_t bilog_flags; - string owner; /* only being set if it's a delete marker */ - string owner_display_name; /* only being set if it's a delete marker */ + std::string owner; /* only being set if it's a delete marker */ + std::string owner_display_name; /* only being set if it's a delete marker */ rgw_zone_set zones_trace; rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN), state(CLS_RGW_STATE_PENDING_MODIFY), index_ver(0), bilog_flags(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(4, 1, bl); encode(id, bl); encode(object, bl); @@ -652,7 +649,7 @@ struct rgw_bi_log_entry { encode(zones_trace, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START(4, bl); decode(id, bl); decode(object, bl); @@ -678,9 +675,9 @@ struct rgw_bi_log_entry { } DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); bool is_versioned() { return ((bilog_flags & RGW_BILOG_FLAG_VERSIONED_OP) != 0); @@ -696,7 +693,7 @@ struct rgw_bucket_category_stats { rgw_bucket_category_stats() : total_size(0), total_size_rounded(0), num_entries(0) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(3, 2, bl); encode(total_size, bl); encode(total_size_rounded, bl); @@ -704,7 +701,7 @@ struct rgw_bucket_category_stats { encode(actual_size, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); decode(total_size, bl); decode(total_size_rounded, bl); @@ -716,8 +713,8 @@ struct rgw_bucket_category_stats { } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_category_stats) @@ -727,7 +724,7 @@ enum class cls_rgw_reshard_status : uint8_t { DONE = 2 }; -static inline std::string to_string(const cls_rgw_reshard_status status) +inline std::string to_string(const cls_rgw_reshard_status status) { switch (status) { case cls_rgw_reshard_status::NOT_RESHARDING: @@ -747,10 +744,10 @@ struct cls_rgw_bucket_instance_entry { using RESHARD_STATUS = cls_rgw_reshard_status; cls_rgw_reshard_status reshard_status{RESHARD_STATUS::NOT_RESHARDING}; - string new_bucket_instance_id; + std::string new_bucket_instance_id; int32_t num_shards{-1}; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode((uint8_t)reshard_status, bl); encode(new_bucket_instance_id, bl); @@ -758,7 +755,7 @@ struct cls_rgw_bucket_instance_entry { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); uint8_t s; decode(s, bl); @@ -768,15 +765,15 @@ struct cls_rgw_bucket_instance_entry { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); void clear() { reshard_status = RESHARD_STATUS::NOT_RESHARDING; new_bucket_instance_id.clear(); } - void set_status(const string& new_instance_id, + void set_status(const std::string& new_instance_id, int32_t new_num_shards, cls_rgw_reshard_status s) { reshard_status = s; @@ -794,17 +791,17 @@ struct cls_rgw_bucket_instance_entry { WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry) struct rgw_bucket_dir_header { - map stats; + std::map stats; uint64_t tag_timeout; uint64_t ver; uint64_t master_ver; - string max_marker; + std::string max_marker; cls_rgw_bucket_instance_entry new_instance; bool syncstopped; rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0), syncstopped(false) {} - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(7, 2, bl); encode(stats, bl); encode(tag_timeout, bl); @@ -815,7 +812,7 @@ struct rgw_bucket_dir_header { encode(syncstopped,bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl); decode(stats, bl); if (struct_v > 2) { @@ -842,8 +839,8 @@ struct rgw_bucket_dir_header { } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); bool resharding() const { return new_instance.resharding(); @@ -856,22 +853,22 @@ WRITE_CLASS_ENCODER(rgw_bucket_dir_header) struct rgw_bucket_dir { rgw_bucket_dir_header header; - boost::container::flat_map m; + boost::container::flat_map m; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { ENCODE_START(2, 2, bl); encode(header, bl); encode(m, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); decode(header, bl); decode(m, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_bucket_dir) @@ -884,7 +881,7 @@ struct rgw_usage_data { rgw_usage_data() : bytes_sent(0), bytes_received(0), ops(0), successful_ops(0) {} rgw_usage_data(uint64_t sent, uint64_t received) : bytes_sent(sent), bytes_received(received), ops(0), successful_ops(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(bytes_sent, bl); encode(bytes_received, bl); @@ -893,7 +890,7 @@ struct rgw_usage_data { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(bytes_sent, bl); decode(bytes_received, bl); @@ -915,16 +912,16 @@ WRITE_CLASS_ENCODER(rgw_usage_data) struct rgw_usage_log_entry { rgw_user owner; rgw_user payer; /* if empty, same as owner */ - string bucket; + std::string bucket; uint64_t epoch; rgw_usage_data total_usage; /* this one is kept for backwards compatibility */ - map usage_map; + std::map usage_map; rgw_usage_log_entry() : epoch(0) {} - rgw_usage_log_entry(string& o, string& b) : owner(o), bucket(b), epoch(0) {} - rgw_usage_log_entry(string& o, string& p, string& b) : owner(o), payer(p), bucket(b), epoch(0) {} + rgw_usage_log_entry(std::string& o, std::string& b) : owner(o), bucket(b), epoch(0) {} + rgw_usage_log_entry(std::string& o, std::string& p, std::string& b) : owner(o), payer(p), bucket(b), epoch(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(3, 1, bl); encode(owner.to_str(), bl); encode(bucket, bl); @@ -939,9 +936,9 @@ struct rgw_usage_log_entry { } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(3, bl); - string s; + std::string s; decode(s, bl); owner.from_str(s); decode(bucket, bl); @@ -956,14 +953,15 @@ struct rgw_usage_log_entry { decode(usage_map, bl); } if (struct_v >= 3) { - string p; + std::string p; decode(p, bl); payer.from_str(p); } DECODE_FINISH(bl); } - void aggregate(const rgw_usage_log_entry& e, map *categories = NULL) { + void aggregate(const rgw_usage_log_entry& e, + std::map *categories = NULL) { if (owner.empty()) { owner = e.owner; bucket = e.bucket; @@ -971,44 +969,44 @@ struct rgw_usage_log_entry { payer = e.payer; } - map::const_iterator iter; - for (iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) { + for (auto iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) { if (!categories || !categories->size() || categories->count(iter->first)) { add(iter->first, iter->second); } } } - void sum(rgw_usage_data& usage, map& categories) const { + void sum(rgw_usage_data& usage, + std::map& categories) const { usage = rgw_usage_data(); - for (map::const_iterator iter = usage_map.begin(); iter != usage_map.end(); ++iter) { + for (auto iter = usage_map.begin(); iter != usage_map.end(); ++iter) { if (!categories.size() || categories.count(iter->first)) { usage.aggregate(iter->second); } } } - void add(const string& category, const rgw_usage_data& data) { + void add(const std::string& category, const rgw_usage_data& data) { usage_map[category].aggregate(data); total_usage.aggregate(data); } - void dump(Formatter* f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter* f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(rgw_usage_log_entry) struct rgw_usage_log_info { - vector entries; + std::vector entries; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); DECODE_FINISH(bl); @@ -1019,20 +1017,20 @@ struct rgw_usage_log_info { WRITE_CLASS_ENCODER(rgw_usage_log_info) struct rgw_user_bucket { - string user; - string bucket; + std::string user; + std::string bucket; rgw_user_bucket() {} - rgw_user_bucket(const string& u, const string& b) : user(u), bucket(b) {} + rgw_user_bucket(const std::string& u, const std::string& b) : user(u), bucket(b) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(user, bl); encode(bucket, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(user, bl); decode(bucket, bl); @@ -1057,14 +1055,14 @@ enum cls_rgw_gc_op { }; struct cls_rgw_obj { - string pool; + std::string pool; cls_rgw_obj_key key; - string loc; + std::string loc; cls_rgw_obj() {} - cls_rgw_obj(string& _p, cls_rgw_obj_key& _k) : pool(_p), key(_k) {} + cls_rgw_obj(std::string& _p, cls_rgw_obj_key& _k) : pool(_p), key(_k) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(pool, bl); encode(key.name, bl); @@ -1073,7 +1071,7 @@ struct cls_rgw_obj { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(pool, bl); decode(key.name, bl); @@ -1084,13 +1082,13 @@ struct cls_rgw_obj { DECODE_FINISH(bl); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_string("pool", pool); f->dump_string("oid", key.name); f->dump_string("key", loc); f->dump_string("instance", key.instance); } - static void generate_test_instances(list& ls) { + static void generate_test_instances(std::list& ls) { ls.push_back(new cls_rgw_obj); ls.push_back(new cls_rgw_obj); ls.back()->pool = "mypool"; @@ -1101,11 +1099,11 @@ struct cls_rgw_obj { WRITE_CLASS_ENCODER(cls_rgw_obj) struct cls_rgw_obj_chain { - list objs; + std::list objs; cls_rgw_obj_chain() {} - void push_obj(const string& pool, const cls_rgw_obj_key& key, const string& loc) { + void push_obj(const std::string& pool, const cls_rgw_obj_key& key, const std::string& loc) { cls_rgw_obj obj; obj.pool = pool; obj.key = key; @@ -1113,28 +1111,28 @@ struct cls_rgw_obj_chain { objs.push_back(obj); } - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(objs, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(objs, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->open_array_section("objs"); - for (list::const_iterator p = objs.begin(); p != objs.end(); ++p) { + for (std::list::const_iterator p = objs.begin(); p != objs.end(); ++p) { f->open_object_section("obj"); p->dump(f); f->close_section(); } f->close_section(); } - static void generate_test_instances(list& ls) { + static void generate_test_instances(std::list& ls) { ls.push_back(new cls_rgw_obj_chain); } @@ -1146,13 +1144,13 @@ WRITE_CLASS_ENCODER(cls_rgw_obj_chain) struct cls_rgw_gc_obj_info { - string tag; + std::string tag; cls_rgw_obj_chain chain; ceph::real_time time; cls_rgw_gc_obj_info() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(tag, bl); encode(chain, bl); @@ -1160,7 +1158,7 @@ struct cls_rgw_gc_obj_info ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(tag, bl); decode(chain, bl); @@ -1168,14 +1166,14 @@ struct cls_rgw_gc_obj_info DECODE_FINISH(bl); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_string("tag", tag); f->open_object_section("chain"); chain.dump(f); f->close_section(); f->dump_stream("time") << time; } - static void generate_test_instances(list& ls) { + static void generate_test_instances(std::list& ls) { ls.push_back(new cls_rgw_gc_obj_info); ls.push_back(new cls_rgw_gc_obj_info); ls.back()->tag = "footag"; @@ -1188,11 +1186,11 @@ WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info) struct cls_rgw_lc_obj_head { time_t start_date = 0; - string marker; + std::string marker; cls_rgw_lc_obj_head() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); uint64_t t = start_date; encode(t, bl); @@ -1200,7 +1198,7 @@ struct cls_rgw_lc_obj_head ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); uint64_t t; decode(t, bl); @@ -1209,24 +1207,24 @@ struct cls_rgw_lc_obj_head DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_rgw_lc_obj_head) struct cls_rgw_reshard_entry { ceph::real_time time; - string tenant; - string bucket_name; - string bucket_id; - string new_instance_id; + std::string tenant; + std::string bucket_name; + std::string bucket_id; + std::string new_instance_id; uint32_t old_num_shards{0}; uint32_t new_num_shards{0}; cls_rgw_reshard_entry() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(time, bl); encode(tenant, bl); @@ -1238,7 +1236,7 @@ struct cls_rgw_reshard_entry ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(time, bl); decode(tenant, bl); @@ -1250,11 +1248,11 @@ struct cls_rgw_reshard_entry DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); - static void generate_key(const string& tenant, const string& bucket_name, string *key); - void get_key(string *key) const; + static void generate_key(const std::string& tenant, const std::string& bucket_name, std::string *key); + void get_key(std::string *key) const; }; WRITE_CLASS_ENCODER(cls_rgw_reshard_entry) diff --git a/src/cls/rgw_gc/cls_rgw_gc.cc b/src/cls/rgw_gc/cls_rgw_gc.cc index 976e49ea52e1..7970e9e07a2f 100644 --- a/src/cls/rgw_gc/cls_rgw_gc.cc +++ b/src/cls/rgw_gc/cls_rgw_gc.cc @@ -22,6 +22,14 @@ #define GC_LIST_DEFAULT_MAX 128 +using std::string; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; +using ceph::make_timespan; +using ceph::real_time; + CLS_VER(1,0) CLS_NAME(rgw_gc) @@ -32,7 +40,7 @@ static int cls_rgw_gc_queue_init(cls_method_context_t hctx, bufferlist *in, buff cls_rgw_gc_queue_init_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_init: failed to decode entry\n"); return -EINVAL; } @@ -57,7 +65,7 @@ static int cls_rgw_gc_queue_enqueue(cls_method_context_t hctx, bufferlist *in, b cls_rgw_gc_set_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_gc_queue_enqueue: failed to decode entry\n"); return -EINVAL; } @@ -94,7 +102,7 @@ static int cls_rgw_gc_queue_list_entries(cls_method_context_t hctx, bufferlist * cls_rgw_gc_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_list_entries(): failed to decode input\n"); return -EINVAL; } @@ -110,7 +118,7 @@ static int cls_rgw_gc_queue_list_entries(cls_method_context_t hctx, bufferlist * auto iter_urgent_data = head.bl_urgent_data.cbegin(); try { decode(urgent_data, iter_urgent_data); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_list_entries(): failed to decode urgent data\n"); return -EINVAL; } @@ -143,7 +151,7 @@ static int cls_rgw_gc_queue_list_entries(cls_method_context_t hctx, bufferlist * cls_rgw_gc_obj_info info; try { decode(info, it.data); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_list_entries(): failed to decode gc info\n"); return -EINVAL; } @@ -170,7 +178,7 @@ static int cls_rgw_gc_queue_list_entries(cls_method_context_t hctx, bufferlist * auto iter = bl_xattrs.cbegin(); try { decode(xattr_urgent_data_map, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_gc_queue_list_entries(): failed to decode xattrs urgent data map\n"); return -EINVAL; } //end - catch @@ -225,7 +233,7 @@ static int cls_rgw_gc_queue_remove_entries(cls_method_context_t hctx, bufferlist cls_rgw_gc_queue_remove_entries_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_remove_entries(): failed to decode input\n"); return -EINVAL; } @@ -241,7 +249,7 @@ static int cls_rgw_gc_queue_remove_entries(cls_method_context_t hctx, bufferlist auto iter_urgent_data = head.bl_urgent_data.cbegin(); try { decode(urgent_data, iter_urgent_data); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_remove_entries(): failed to decode urgent data\n"); return -EINVAL; } @@ -272,7 +280,7 @@ static int cls_rgw_gc_queue_remove_entries(cls_method_context_t hctx, bufferlist cls_rgw_gc_obj_info info; try { decode(info, it.data); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_remove_entries(): failed to decode gc info\n"); return -EINVAL; } @@ -306,7 +314,7 @@ static int cls_rgw_gc_queue_remove_entries(cls_method_context_t hctx, bufferlist auto iter = bl_xattrs.cbegin(); try { decode(xattr_urgent_data_map, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_remove_entries(): failed to decode xattrs urgent data map\n"); return -EINVAL; } //end - catch @@ -374,7 +382,7 @@ static int cls_rgw_gc_queue_update_entry(cls_method_context_t hctx, bufferlist * cls_rgw_gc_queue_defer_entry_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_update_entry(): failed to decode input\n"); return -EINVAL; } @@ -393,7 +401,7 @@ static int cls_rgw_gc_queue_update_entry(cls_method_context_t hctx, bufferlist * cls_rgw_gc_urgent_data urgent_data; try { decode(urgent_data, bl_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(5, "ERROR: cls_rgw_gc_queue_update_entry(): failed to decode urgent data\n"); return -EINVAL; } @@ -418,7 +426,7 @@ static int cls_rgw_gc_queue_update_entry(cls_method_context_t hctx, bufferlist * auto iter = bl_xattrs.cbegin(); try { decode(xattr_urgent_data_map, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_gc_queue_update_entry(): failed to decode xattrs urgent data map\n"); return -EINVAL; } //end - catch @@ -465,7 +473,7 @@ static int cls_rgw_gc_queue_update_entry(cls_method_context_t hctx, bufferlist * auto iter = bl_xattrs.cbegin(); try { decode(xattr_urgent_data_map, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_rgw_gc_queue_remove_entries(): failed to decode xattrs urgent data map\n"); return -EINVAL; } //end - catch diff --git a/src/cls/rgw_gc/cls_rgw_gc_client.cc b/src/cls/rgw_gc/cls_rgw_gc_client.cc index 907a58d23770..415ce8b751aa 100644 --- a/src/cls/rgw_gc/cls_rgw_gc_client.cc +++ b/src/cls/rgw_gc/cls_rgw_gc_client.cc @@ -9,6 +9,12 @@ #include "cls/queue/cls_queue_const.h" #include "cls/rgw_gc/cls_rgw_gc_client.h" +using std::list; +using std::string; + +using ceph::decode; +using ceph::encode; + using namespace librados; void cls_rgw_gc_queue_init(ObjectWriteOperation& op, uint64_t size, uint64_t num_deferred_entries) @@ -32,7 +38,7 @@ int cls_rgw_gc_queue_get_capacity(IoCtx& io_ctx, const string& oid, uint64_t& si auto iter = out.cbegin(); try { decode(op_ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } @@ -69,7 +75,7 @@ int cls_rgw_gc_queue_list_entries(IoCtx& io_ctx, const string& oid, const string auto iter = out.cbegin(); try { decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } diff --git a/src/cls/rgw_gc/cls_rgw_gc_client.h b/src/cls/rgw_gc/cls_rgw_gc_client.h index 35654e76c035..88a042fc945b 100644 --- a/src/cls/rgw_gc/cls_rgw_gc_client.h +++ b/src/cls/rgw_gc/cls_rgw_gc_client.h @@ -1,16 +1,22 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_RGW_GC_CLIENT_H #define CEPH_CLS_RGW_GC_CLIENT_H #include "include/rados/librados.hpp" -#include "cls/rgw_gc/cls_rgw_gc_types.h" -#include "cls/queue/cls_queue_ops.h" + #include "common/ceph_time.h" +#include "cls/queue/cls_queue_ops.h" +#include "cls/rgw/cls_rgw_types.h" +#include "cls/rgw_gc/cls_rgw_gc_types.h" + void cls_rgw_gc_queue_init(librados::ObjectWriteOperation& op, uint64_t size, uint64_t num_deferred_entries); -int cls_rgw_gc_queue_get_capacity(librados::IoCtx& io_ctx, const string& oid, uint64_t& size); +int cls_rgw_gc_queue_get_capacity(librados::IoCtx& io_ctx, const std::string& oid, uint64_t& size); void cls_rgw_gc_queue_enqueue(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const cls_rgw_gc_obj_info& info); -int cls_rgw_gc_queue_list_entries(librados::IoCtx& io_ctx, const string& oid, const string& marker, uint32_t max, bool expired_only, - list& entries, bool *truncated, string& next_marker); +int cls_rgw_gc_queue_list_entries(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, uint32_t max, bool expired_only, + std::list& entries, bool *truncated, std::string& next_marker); void cls_rgw_gc_queue_remove_entries(librados::ObjectWriteOperation& op, uint32_t num_entries); void cls_rgw_gc_queue_defer_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const cls_rgw_gc_obj_info& info); diff --git a/src/cls/rgw_gc/cls_rgw_gc_ops.h b/src/cls/rgw_gc/cls_rgw_gc_ops.h index e2f55fb75936..95f791c09b94 100644 --- a/src/cls/rgw_gc/cls_rgw_gc_ops.h +++ b/src/cls/rgw_gc/cls_rgw_gc_ops.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_RGW_GC_OPS_H #define CEPH_CLS_RGW_GC_OPS_H @@ -9,14 +12,14 @@ struct cls_rgw_gc_queue_init_op { cls_rgw_gc_queue_init_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(size, bl); encode(num_deferred_entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(size, bl); decode(num_deferred_entries, bl); @@ -31,13 +34,13 @@ struct cls_rgw_gc_queue_remove_entries_op { cls_rgw_gc_queue_remove_entries_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(num_entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(num_entries, bl); DECODE_FINISH(bl); @@ -50,14 +53,14 @@ struct cls_rgw_gc_queue_defer_entry_op { cls_rgw_gc_obj_info info; cls_rgw_gc_queue_defer_entry_op() : expiration_secs(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(expiration_secs, bl); encode(info, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(expiration_secs, bl); decode(info, bl); @@ -65,4 +68,4 @@ struct cls_rgw_gc_queue_defer_entry_op { } }; WRITE_CLASS_ENCODER(cls_rgw_gc_queue_defer_entry_op) -#endif /* CEPH_CLS_RGW_GC_OPS_H */ \ No newline at end of file +#endif /* CEPH_CLS_RGW_GC_OPS_H */ diff --git a/src/cls/rgw_gc/cls_rgw_gc_types.h b/src/cls/rgw_gc/cls_rgw_gc_types.h index cfcac55f5bea..da9d08036e6b 100644 --- a/src/cls/rgw_gc/cls_rgw_gc_types.h +++ b/src/cls/rgw_gc/cls_rgw_gc_types.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_RGW_GC_TYPES_H #define CEPH_CLS_RGW_GC_TYPES_H @@ -6,12 +9,12 @@ struct cls_rgw_gc_urgent_data { - std::unordered_map urgent_data_map; + std::unordered_map urgent_data_map; uint32_t num_urgent_data_entries{0}; // requested by user uint32_t num_head_urgent_entries{0}; // actual number of entries in queue head uint32_t num_xattr_urgent_entries{0}; // actual number of entries in xattr in case of spill over - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(urgent_data_map, bl); encode(num_urgent_data_entries, bl); @@ -20,7 +23,7 @@ struct cls_rgw_gc_urgent_data ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(urgent_data_map, bl); decode(num_urgent_data_entries, bl); @@ -31,4 +34,4 @@ struct cls_rgw_gc_urgent_data }; WRITE_CLASS_ENCODER(cls_rgw_gc_urgent_data) -#endif \ No newline at end of file +#endif diff --git a/src/cls/timeindex/cls_timeindex.cc b/src/cls/timeindex/cls_timeindex.cc index 92ea15be5f82..5ad8883d84cb 100644 --- a/src/cls/timeindex/cls_timeindex.cc +++ b/src/cls/timeindex/cls_timeindex.cc @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include @@ -9,6 +9,11 @@ #include "include/compat.h" +using std::map; +using std::string; + +using ceph::bufferlist; + CLS_VER(1,0) CLS_NAME(timeindex) @@ -61,12 +66,12 @@ static int cls_timeindex_add(cls_method_context_t hctx, cls_timeindex_add_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_timeindex_add_op(): failed to decode op"); return -EINVAL; } - for (list::iterator iter = op.entries.begin(); + for (auto iter = op.entries.begin(); iter != op.entries.end(); ++iter) { cls_timeindex_entry& entry = *iter; @@ -94,7 +99,7 @@ static int cls_timeindex_list(cls_method_context_t hctx, cls_timeindex_list_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_timeindex_list_op(): failed to decode op"); return -EINVAL; } @@ -128,8 +133,8 @@ static int cls_timeindex_list(cls_method_context_t hctx, return rc; } - list& entries = ret.entries; - map::iterator iter = keys.begin(); + auto& entries = ret.entries; + auto iter = keys.begin(); string marker; @@ -175,7 +180,7 @@ static int cls_timeindex_trim(cls_method_context_t hctx, cls_timeindex_trim_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_timeindex_trim: failed to decode entry"); return -EINVAL; } @@ -205,7 +210,7 @@ static int cls_timeindex_trim(cls_method_context_t hctx, return rc; } - map::iterator iter = keys.begin(); + auto iter = keys.begin(); bool removed = false; for (; iter != keys.end(); ++iter) { diff --git a/src/cls/timeindex/cls_timeindex_client.h b/src/cls/timeindex/cls_timeindex_client.h index ce6392f6d139..818d4b0c4671 100644 --- a/src/cls/timeindex/cls_timeindex_client.h +++ b/src/cls/timeindex/cls_timeindex_client.h @@ -27,7 +27,7 @@ public: ///* dtor ~TimeindexListCtx() {} - void handle_completion(int r, bufferlist& bl) override { + void handle_completion(int r, ceph::buffer::list& bl) override { if (r >= 0) { cls_timeindex_list_ret ret; try { @@ -39,7 +39,7 @@ public: *truncated = ret.truncated; if (marker) *marker = ret.marker; - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { // nothing we can do about it atm } } @@ -50,7 +50,7 @@ void cls_timeindex_add_prepare_entry( cls_timeindex_entry& entry, const utime_t& key_timestamp, const std::string& key_ext, - bufferlist& bl); + ceph::buffer::list& bl); void cls_timeindex_add( librados::ObjectWriteOperation& op, @@ -64,7 +64,7 @@ void cls_timeindex_add( librados::ObjectWriteOperation& op, const utime_t& timestamp, const std::string& name, - const bufferlist& bl); + const ceph::buffer::list& bl); void cls_timeindex_list( librados::ObjectReadOperation& op, diff --git a/src/cls/timeindex/cls_timeindex_ops.h b/src/cls/timeindex/cls_timeindex_ops.h index 05aa8b19ba88..f40058954dce 100644 --- a/src/cls/timeindex/cls_timeindex_ops.h +++ b/src/cls/timeindex/cls_timeindex_ops.h @@ -7,17 +7,17 @@ #include "cls_timeindex_types.h" struct cls_timeindex_add_op { - list entries; + std::list entries; cls_timeindex_add_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); DECODE_FINISH(bl); @@ -27,14 +27,14 @@ WRITE_CLASS_ENCODER(cls_timeindex_add_op) struct cls_timeindex_list_op { utime_t from_time; - string marker; /* if not empty, overrides from_time */ + std::string marker; /* if not empty, overrides from_time */ utime_t to_time; /* not inclusive */ int max_entries; /* upperbound to returned num of entries might return less than that and still be truncated */ cls_timeindex_list_op() : max_entries(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(from_time, bl); encode(marker, bl); @@ -43,7 +43,7 @@ struct cls_timeindex_list_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(from_time, bl); decode(marker, bl); @@ -55,13 +55,13 @@ struct cls_timeindex_list_op { WRITE_CLASS_ENCODER(cls_timeindex_list_op) struct cls_timeindex_list_ret { - list entries; - string marker; + std::list entries; + std::string marker; bool truncated; cls_timeindex_list_ret() : truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(marker, bl); @@ -69,7 +69,7 @@ struct cls_timeindex_list_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(marker, bl); @@ -87,12 +87,12 @@ WRITE_CLASS_ENCODER(cls_timeindex_list_ret) struct cls_timeindex_trim_op { utime_t from_time; utime_t to_time; /* inclusive */ - string from_marker; - string to_marker; + std::string from_marker; + std::string to_marker; cls_timeindex_trim_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(from_time, bl); encode(to_time, bl); @@ -101,7 +101,7 @@ struct cls_timeindex_trim_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(from_time, bl); decode(to_time, bl); diff --git a/src/cls/timeindex/cls_timeindex_types.h b/src/cls/timeindex/cls_timeindex_types.h index 90ac3b8e55d0..d33886881be5 100644 --- a/src/cls/timeindex/cls_timeindex_types.h +++ b/src/cls/timeindex/cls_timeindex_types.h @@ -16,13 +16,13 @@ struct cls_timeindex_entry { utime_t key_ts; /* Not mandatory. The name_ext field, if not empty, will form second * part of the key. */ - string key_ext; + std::string key_ext; /* Become value of OMAP-based mapping. */ - bufferlist value; + ceph::buffer::list value; cls_timeindex_entry() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(key_ts, bl); encode(key_ext, bl); @@ -30,7 +30,7 @@ struct cls_timeindex_entry { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(key_ts, bl); decode(key_ext, bl); @@ -38,8 +38,8 @@ struct cls_timeindex_entry { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(cls_timeindex_entry) diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc index e80e6e231c27..20809daf0bc0 100644 --- a/src/cls/user/cls_user.cc +++ b/src/cls/user/cls_user.cc @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include @@ -8,6 +8,13 @@ #include "cls_user_ops.h" +using std::map; +using std::string; + +using ceph::bufferlist; +using ceph::decode; +using ceph::encode; + CLS_VER(1,0) CLS_NAME(user) @@ -56,7 +63,7 @@ static int get_existing_bucket_entry(cls_method_context_t hctx, const string& bu try { auto iter = bl.cbegin(); decode(entry, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: failed to decode entry %s", key.c_str()); return -EIO; } @@ -79,7 +86,7 @@ static int read_header(cls_method_context_t hctx, cls_user_header *header) try { decode(*header, bl); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: failed to decode user header"); return -EIO; } @@ -115,7 +122,7 @@ static int cls_user_set_buckets_info(cls_method_context_t hctx, bufferlist *in, cls_user_set_buckets_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_user_add_op(): failed to decode op"); return -EINVAL; } @@ -127,8 +134,7 @@ static int cls_user_set_buckets_info(cls_method_context_t hctx, bufferlist *in, return ret; } - for (list::iterator iter = op.entries.begin(); - iter != op.entries.end(); ++iter) { + for (auto iter = op.entries.begin(); iter != op.entries.end(); ++iter) { cls_user_bucket_entry& update_entry = *iter; string key; @@ -200,7 +206,7 @@ static int cls_user_complete_stats_sync(cls_method_context_t hctx, bufferlist *i cls_user_complete_stats_sync_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_user_add_op(): failed to decode op"); return -EINVAL; } @@ -233,7 +239,7 @@ static int cls_user_remove_bucket(cls_method_context_t hctx, bufferlist *in, buf cls_user_remove_bucket_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_user_add_op(): failed to decode op"); return -EINVAL; } @@ -285,7 +291,7 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff cls_user_list_buckets_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_user_list_op(): failed to decode op"); return -EINVAL; } @@ -313,8 +319,8 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff to_index.c_str(), match_prefix.c_str()); - list& entries = ret.entries; - map::iterator iter = keys.begin(); + auto& entries = ret.entries; + auto iter = keys.begin(); string marker; @@ -333,7 +339,7 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff cls_user_bucket_entry e; decode(e, biter); entries.push_back(e); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: cls_user_list: could not decode entry, index=%s", index.c_str()); } } @@ -354,7 +360,7 @@ static int cls_user_get_header(cls_method_context_t hctx, bufferlist *in, buffer cls_user_get_header_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_user_get_header_op(): failed to decode op"); return -EINVAL; } @@ -382,7 +388,7 @@ static int cls_user_reset_stats(cls_method_context_t hctx, try { auto bliter = in->cbegin(); decode(op, bliter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s failed to decode op", __func__); return -EINVAL; } @@ -407,7 +413,7 @@ static int cls_user_reset_stats(cls_method_context_t hctx, auto bl = kv.second; auto bliter = bl.cbegin(); decode(e, bliter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: %s failed to decode bucket entry for %s", __func__, kv.first.c_str()); return -EIO; @@ -449,4 +455,3 @@ CLS_INIT(user) cls_register_cxx_method(h_class, "reset_user_stats", CLS_METHOD_RD | CLS_METHOD_WR, cls_user_reset_stats, &h_user_reset_stats); return; } - diff --git a/src/cls/user/cls_user_client.cc b/src/cls/user/cls_user_client.cc index f68348627350..b74f55b48b2f 100644 --- a/src/cls/user/cls_user_client.cc +++ b/src/cls/user/cls_user_client.cc @@ -6,9 +6,15 @@ #include "cls/user/cls_user_client.h" #include "include/rados/librados.hpp" +using std::list; +using std::string; -using namespace librados; +using ceph::bufferlist; +using ceph::real_clock; +using librados::IoCtx; +using librados::ObjectOperationCompletion; +using librados::ObjectReadOperation; void cls_user_set_buckets(librados::ObjectWriteOperation& op, list& entries, bool add) { @@ -59,7 +65,7 @@ public: *truncated = ret.truncated; if (marker) *marker = ret.marker; - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { r = -EIO; } } @@ -108,7 +114,7 @@ public: decode(ret, iter); if (header) *header = ret.header; - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { r = -EIO; } if (ret_ctx) { @@ -148,7 +154,7 @@ int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *c encode(call, in); ObjectReadOperation op; op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */ - AioCompletion *c = librados::Rados::aio_create_completion(nullptr, nullptr); + auto c = librados::Rados::aio_create_completion(nullptr, nullptr); int r = io_ctx.aio_operate(oid, c, &op, NULL); c->release(); if (r < 0) diff --git a/src/cls/user/cls_user_client.h b/src/cls/user/cls_user_client.h index 077c15dced77..03d975c59cb5 100644 --- a/src/cls/user/cls_user_client.h +++ b/src/cls/user/cls_user_client.h @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #ifndef CEPH_CLS_USER_CLIENT_H @@ -18,19 +18,19 @@ public: * user objclass */ -void cls_user_set_buckets(librados::ObjectWriteOperation& op, list& entries, bool add); +void cls_user_set_buckets(librados::ObjectWriteOperation& op, std::list& entries, bool add); void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op); void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_bucket& bucket); void cls_user_bucket_list(librados::ObjectReadOperation& op, - const string& in_marker, - const string& end_marker, - int max_entries, - list& entries, - string *out_marker, - bool *truncated, - int *pret); + const std::string& in_marker, + const std::string& end_marker, + int max_entries, + std::list& entries, + std::string *out_marker, + bool *truncated, + int *pret); void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header, int *pret); -int cls_user_get_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx); +int cls_user_get_header_async(librados::IoCtx& io_ctx, std::string& oid, RGWGetUserHeader_CB *ctx); void cls_user_reset_stats(librados::ObjectWriteOperation& op); #endif diff --git a/src/cls/user/cls_user_ops.cc b/src/cls/user/cls_user_ops.cc index 65d889bbc5c2..5ae9d2c93b82 100644 --- a/src/cls/user/cls_user_ops.cc +++ b/src/cls/user/cls_user_ops.cc @@ -1,10 +1,14 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include "cls/user/cls_user_ops.h" #include "common/Formatter.h" #include "common/ceph_json.h" +using std::list; + +using ceph::Formatter; + void cls_user_set_buckets_op::dump(Formatter *f) const { encode_json("entries", entries, f); diff --git a/src/cls/user/cls_user_ops.h b/src/cls/user/cls_user_ops.h index fa4b1f31b67b..8b957a79f93d 100644 --- a/src/cls/user/cls_user_ops.h +++ b/src/cls/user/cls_user_ops.h @@ -7,13 +7,13 @@ #include "cls_user_types.h" struct cls_user_set_buckets_op { - list entries; + std::list entries; bool add; - real_time time; /* op time */ + ceph::real_time time; /* op time */ cls_user_set_buckets_op() : add(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(add, bl); @@ -21,7 +21,7 @@ struct cls_user_set_buckets_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(add, bl); @@ -29,8 +29,8 @@ struct cls_user_set_buckets_op { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_set_buckets_op) @@ -39,33 +39,33 @@ struct cls_user_remove_bucket_op { cls_user_remove_bucket_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(bucket, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(bucket, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_remove_bucket_op) struct cls_user_list_buckets_op { - string marker; - string end_marker; + std::string marker; + std::string end_marker; int max_entries; /* upperbound to returned num of entries might return less than that and still be truncated */ cls_user_list_buckets_op() : max_entries(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(2, 1, bl); encode(marker, bl); encode(max_entries, bl); @@ -73,7 +73,7 @@ struct cls_user_list_buckets_op { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(2, bl); decode(marker, bl); decode(max_entries, bl); @@ -83,19 +83,19 @@ struct cls_user_list_buckets_op { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_list_buckets_op) struct cls_user_list_buckets_ret { - list entries; - string marker; + std::list entries; + std::string marker; bool truncated; cls_user_list_buckets_ret() : truncated(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(entries, bl); encode(marker, bl); @@ -103,7 +103,7 @@ struct cls_user_list_buckets_ret { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(entries, bl); decode(marker, bl); @@ -111,8 +111,8 @@ struct cls_user_list_buckets_ret { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_list_buckets_ret) @@ -120,39 +120,39 @@ WRITE_CLASS_ENCODER(cls_user_list_buckets_ret) struct cls_user_get_header_op { cls_user_get_header_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_get_header_op) struct cls_user_reset_stats_op { - real_time time; + ceph::real_time time; cls_user_reset_stats_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(time, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(time, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_reset_stats_op); @@ -161,42 +161,42 @@ struct cls_user_get_header_ret { cls_user_get_header_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(header, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(header, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_get_header_ret) struct cls_user_complete_stats_sync_op { - real_time time; + ceph::real_time time; cls_user_complete_stats_sync_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(time, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(time, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_complete_stats_sync_op) diff --git a/src/cls/user/cls_user_types.cc b/src/cls/user/cls_user_types.cc index be3280ca2bd9..0d823f0bea20 100644 --- a/src/cls/user/cls_user_types.cc +++ b/src/cls/user/cls_user_types.cc @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include "cls/user/cls_user_types.h" @@ -6,6 +6,13 @@ #include "common/ceph_json.h" #include "include/utime.h" +using std::list; +using std::string; + +using ceph::Formatter; +using ceph::bufferlist; +using ceph::real_clock; + void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i) { char buf[16]; diff --git a/src/cls/user/cls_user_types.h b/src/cls/user/cls_user_types.h index 8efd8bc5f6fe..a139449d3c3e 100644 --- a/src/cls/user/cls_user_types.h +++ b/src/cls/user/cls_user_types.h @@ -1,4 +1,4 @@ -// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #ifndef CEPH_CLS_USER_TYPES_H @@ -23,7 +23,7 @@ struct cls_user_bucket { std::string data_extra_pool; } explicit_placement; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { /* since new version of this structure is not backward compatible, * we have older rgw running against newer osd if we encode it * in the new way. Only encode newer version if placement_id is @@ -47,7 +47,7 @@ struct cls_user_bucket { ENCODE_FINISH(bl); } } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl); decode(name, bl); if (struct_v < 8) { @@ -89,8 +89,8 @@ struct cls_user_bucket { return name.compare(b.name) < 0; } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_bucket) @@ -107,11 +107,11 @@ struct cls_user_bucket_entry { cls_user_bucket_entry() : size(0), size_rounded(0), count(0), user_stats_sync(false) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(9, 5, bl); uint64_t s = size; __u32 mt = ceph::real_clock::to_time_t(creation_time); - string empty_str; // originally had the bucket name here, but we encode bucket later + std::string empty_str; // originally had the bucket name here, but we encode bucket later encode(empty_str, bl); encode(s, bl); encode(mt, bl); @@ -124,11 +124,11 @@ struct cls_user_bucket_entry { //::encode(placement_rule, bl); removed in v9 ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START_LEGACY_COMPAT_LEN(9, 5, 5, bl); __u32 mt; uint64_t s; - string empty_str; // backward compatibility + std::string empty_str; // backward compatibility decode(empty_str, bl); decode(s, bl); decode(mt, bl); @@ -153,8 +153,8 @@ struct cls_user_bucket_entry { } DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_bucket_entry) @@ -168,14 +168,14 @@ struct cls_user_stats { total_bytes(0), total_bytes_rounded(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(total_entries, bl); encode(total_bytes, bl); encode(total_bytes_rounded, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(total_entries, bl); decode(total_bytes, bl); @@ -183,8 +183,8 @@ struct cls_user_stats { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_stats) @@ -196,14 +196,14 @@ struct cls_user_header { ceph::real_time last_stats_sync; /* last time a full stats sync completed */ ceph::real_time last_stats_update; /* last time a stats update was done */ - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(stats, bl); encode(last_stats_sync, bl); encode(last_stats_update, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(stats, bl); decode(last_stats_sync, bl); @@ -211,8 +211,8 @@ struct cls_user_header { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - static void generate_test_instances(list& ls); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& ls); }; WRITE_CLASS_ENCODER(cls_user_header) @@ -222,5 +222,3 @@ void cls_user_gen_test_stats(cls_user_stats *stats); void cls_user_gen_test_header(cls_user_header *h); #endif - - diff --git a/src/cls/version/cls_version.cc b/src/cls/version/cls_version.cc index 61f9fec022b0..2e8ec91edd3a 100644 --- a/src/cls/version/cls_version.cc +++ b/src/cls/version/cls_version.cc @@ -9,6 +9,10 @@ #include "include/compat.h" +using std::list; + +using ceph::bufferlist; + CLS_VER(1,0) CLS_NAME(version) @@ -66,7 +70,7 @@ static int read_version(cls_method_context_t hctx, obj_version *objv, bool impli try { auto iter = bl.cbegin(); decode(*objv, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(0, "ERROR: read_version(): failed to decode version entry\n"); return -EIO; } @@ -82,7 +86,7 @@ static int cls_version_set(cls_method_context_t hctx, bufferlist *in, bufferlist cls_version_set_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_version_get(): failed to decode entry\n"); return -EINVAL; } @@ -148,7 +152,7 @@ static int cls_version_inc(cls_method_context_t hctx, bufferlist *in, bufferlist cls_version_inc_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_version_get(): failed to decode entry\n"); return -EINVAL; } @@ -177,7 +181,7 @@ static int cls_version_check(cls_method_context_t hctx, bufferlist *in, bufferli cls_version_check_op op; try { decode(op, in_iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { CLS_LOG(1, "ERROR: cls_version_get(): failed to decode entry\n"); return -EINVAL; } @@ -186,7 +190,7 @@ static int cls_version_check(cls_method_context_t hctx, bufferlist *in, bufferli int ret = read_version(hctx, &objv, false); if (ret < 0) return ret; - + if (!check_conds(op.conds, objv)) { CLS_LOG(20, "cls_version: failed condition check"); return -ECANCELED; diff --git a/src/cls/version/cls_version_client.cc b/src/cls/version/cls_version_client.cc index 3c1792aaa8a5..769a7b77b635 100644 --- a/src/cls/version/cls_version_client.cc +++ b/src/cls/version/cls_version_client.cc @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #include #include "cls/version/cls_version_client.h" @@ -29,7 +32,7 @@ void cls_version_inc(librados::ObjectWriteOperation& op, obj_version& objv, Vers bufferlist in; cls_version_inc_op call; call.objv = objv; - + obj_version_cond c; c.cond = cond; c.ver = objv; @@ -67,7 +70,7 @@ public: auto iter = outbl.cbegin(); decode(ret, iter); *objv = ret.objv; - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { // nothing we can do about it atm } } @@ -80,7 +83,7 @@ void cls_version_read(librados::ObjectReadOperation& op, obj_version *objv) op.exec("version", "read", inbl, new VersionReadCtx(objv)); } -int cls_version_read(librados::IoCtx& io_ctx, string& oid, obj_version *ver) +int cls_version_read(librados::IoCtx& io_ctx, std::string& oid, obj_version *ver) { bufferlist in, out; int r = io_ctx.exec(oid, "version", "read", in, out); @@ -91,7 +94,7 @@ int cls_version_read(librados::IoCtx& io_ctx, string& oid, obj_version *ver) try { auto iter = out.cbegin(); decode(ret, iter); - } catch (buffer::error& err) { + } catch (ceph::buffer::error& err) { return -EIO; } diff --git a/src/cls/version/cls_version_client.h b/src/cls/version/cls_version_client.h index 5dc039bcbe1e..19457855a02d 100644 --- a/src/cls/version/cls_version_client.h +++ b/src/cls/version/cls_version_client.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_VERSION_CLIENT_H #define CEPH_CLS_VERSION_CLIENT_H @@ -21,7 +24,7 @@ void cls_version_read(librados::ObjectReadOperation& op, obj_version *objv); // these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw. // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec() #ifndef CLS_CLIENT_HIDE_IOCTX -int cls_version_read(librados::IoCtx& io_ctx, string& oid, obj_version *ver); +int cls_version_read(librados::IoCtx& io_ctx, std::string& oid, obj_version *ver); #endif void cls_version_check(librados::ObjectOperation& op, obj_version& ver, VersionCond cond); diff --git a/src/cls/version/cls_version_ops.h b/src/cls/version/cls_version_ops.h index 36592fa6ad00..62cd1172982a 100644 --- a/src/cls/version/cls_version_ops.h +++ b/src/cls/version/cls_version_ops.h @@ -11,13 +11,13 @@ struct cls_version_set_op { cls_version_set_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(objv, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(objv, bl); DECODE_FINISH(bl); @@ -27,18 +27,18 @@ WRITE_CLASS_ENCODER(cls_version_set_op) struct cls_version_inc_op { obj_version objv; - list conds; + std::list conds; cls_version_inc_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(objv, bl); encode(conds, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(objv, bl); decode(conds, bl); @@ -49,18 +49,18 @@ WRITE_CLASS_ENCODER(cls_version_inc_op) struct cls_version_check_op { obj_version objv; - list conds; + std::list conds; cls_version_check_op() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(objv, bl); encode(conds, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(objv, bl); decode(conds, bl); @@ -74,13 +74,13 @@ struct cls_version_read_ret { cls_version_read_ret() {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(objv, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(objv, bl); DECODE_FINISH(bl); diff --git a/src/cls/version/cls_version_types.cc b/src/cls/version/cls_version_types.cc index 4ec678675d88..b82f6aa8a5dd 100644 --- a/src/cls/version/cls_version_types.cc +++ b/src/cls/version/cls_version_types.cc @@ -1,10 +1,12 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab #include "cls/version/cls_version_types.h" #include "common/Formatter.h" #include "common/ceph_json.h" -void obj_version::dump(Formatter *f) const +void obj_version::dump(ceph::Formatter *f) const { f->dump_int("ver", ver); f->dump_string("tag", tag); @@ -15,4 +17,3 @@ void obj_version::decode_json(JSONObj *obj) JSONDecoder::decode_json("ver", ver, obj); JSONDecoder::decode_json("tag", tag, obj); } - diff --git a/src/cls/version/cls_version_types.h b/src/cls/version/cls_version_types.h index ffcb73fa1154..62cc16e33d52 100644 --- a/src/cls/version/cls_version_types.h +++ b/src/cls/version/cls_version_types.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_VERSION_TYPES_H #define CEPH_CLS_VERSION_TYPES_H @@ -9,18 +12,18 @@ class JSONObj; struct obj_version { uint64_t ver; - string tag; + std::string tag; obj_version() : ver(0) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(ver, bl); encode(tag, bl); ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(ver, bl); decode(tag, bl); @@ -50,9 +53,9 @@ struct obj_version { tag.compare(v.tag) == 0); } - void dump(Formatter *f) const; + void dump(ceph::Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(obj_version) @@ -71,7 +74,7 @@ struct obj_version_cond { struct obj_version ver; VersionCond cond; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(ver, bl); uint32_t c = (uint32_t)cond; @@ -79,7 +82,7 @@ struct obj_version_cond { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(ver, bl); uint32_t c;