From: Daniel Gryniewicz Date: Tue, 10 Aug 2021 13:40:54 +0000 (-0400) Subject: RGW - Zipper - remove last rgw_raw_obj from API X-Git-Tag: v17.1.0~1072^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2cb94876edf1207546cae570454d4ec994c31b2f;p=ceph.git RGW - Zipper - remove last rgw_raw_obj from API Remove the remaining rgw_raw_obj from the API. This consists of: - move get/delete raw_obj from Store to RadosStore; it's only needed by RadosStore code - Add a layout formatter to the API - remove head_obj and get_manifest() from ReadOp - Remove GCChain (no longer needed) Signed-off-by: Daniel Gryniewicz --- diff --git a/src/rgw/rgw_etag_verifier.cc b/src/rgw/rgw_etag_verifier.cc index 3a22e7e6b16bc..52f7c7948421f 100644 --- a/src/rgw/rgw_etag_verifier.cc +++ b/src/rgw/rgw_etag_verifier.cc @@ -2,6 +2,7 @@ // vim: ts=8 sw=2 smarttab ft=cpp #include "rgw_etag_verifier.h" +#include "rgw_obj_manifest.h" #define dout_subsys ceph_subsys_rgw diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index a495cdb6e4984..3f186a5c970db 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -27,7 +27,7 @@ #include "rgw_string.h" #include "rgw_multi.h" #include "rgw_sal.h" -#include "rgw_sal.h" +#include "rgw_rados.h" // this seems safe to use, at least for now--arguably, we should // prefer header-only fmt, in general diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 7c4f404a8819c..d66ad3a504a00 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -20,7 +20,6 @@ #include "cls/rgw/cls_rgw_types.h" #include "rgw_tag.h" #include "rgw_sal.h" -#include "rgw_rados.h" #include #include diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index b2c4e8093264c..9c9e70b1cf626 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -13,6 +13,7 @@ #include "rgw_client_io.h" #include "rgw_rest.h" #include "rgw_zone.h" +#include "rgw_rados.h" #include "services/svc_zone.h" diff --git a/src/rgw/rgw_obj_manifest.h b/src/rgw/rgw_obj_manifest.h index 45b9aaea0ef34..a5df7a4b25512 100644 --- a/src/rgw/rgw_obj_manifest.h +++ b/src/rgw/rgw_obj_manifest.h @@ -23,6 +23,9 @@ class RGWSI_Zone; struct RGWZoneGroup; struct RGWZoneParams; class RGWRados; +namespace rgw { namespace sal { + class RadosStore; +} }; class rgw_obj_select { rgw_placement_rule placement_rule; @@ -45,7 +48,7 @@ public: } rgw_raw_obj get_raw_obj(const RGWZoneGroup& zonegroup, const RGWZoneParams& zone_params) const; - rgw_raw_obj get_raw_obj(rgw::sal::Store* store) const; + rgw_raw_obj get_raw_obj(rgw::sal::RadosStore* store) const; rgw_obj_select& operator=(const rgw_obj& rhs) { obj = rhs; @@ -527,7 +530,7 @@ public: int create_next(uint64_t ofs); rgw_raw_obj get_cur_obj(RGWZoneGroup& zonegroup, RGWZoneParams& zone_params) { return cur_obj.get_raw_obj(zonegroup, zone_params); } - rgw_raw_obj get_cur_obj(rgw::sal::Store* store) const { return cur_obj.get_raw_obj(store); } + rgw_raw_obj get_cur_obj(rgw::sal::RadosStore* store) const { return cur_obj.get_raw_obj(store); } /* total max size of current stripe (including head obj) */ uint64_t cur_stripe_max_size() const { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 4cb9bed0197c1..620891cc935d4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -7519,18 +7519,6 @@ void RGWGetObjLayout::execute(optional_yield y) { /* Make sure bucket is correct */ s->object->set_bucket(s->bucket.get()); - - std::unique_ptr stat_op(s->object->get_read_op(s->obj_ctx)); - - - op_ret = stat_op->prepare(y, this); - if (op_ret < 0) { - return; - } - - head_obj = stat_op->result.head_obj; - - op_ret = stat_op->get_manifest(this, &manifest, y); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 20bddbed1dc55..3d4cc1e2b195b 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -42,8 +42,8 @@ #include "rgw_cors.h" #include "rgw_quota.h" #include "rgw_putobj.h" -#include "rgw_multi.h" #include "rgw_sal.h" +#include "rgw_compression_types.h" #include "rgw_lc.h" #include "rgw_torrent.h" @@ -63,6 +63,7 @@ using ceph::crypto::SHA1; struct req_state; class RGWOp; class RGWRados; +class RGWMultiCompleteUpload; namespace rgw { @@ -2319,10 +2320,6 @@ public: }; /* RGWRMAttrs */ class RGWGetObjLayout : public RGWOp { -protected: - RGWObjManifest *manifest{nullptr}; - rgw_raw_obj head_obj; - public: RGWGetObjLayout() { } diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 711164dc8e211..661bbc9e35029 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -453,7 +453,7 @@ int RGWOrphanSearch::handle_stat_result(const DoutPrefixProvider *dpp, map(store)); string s = loc.oid; obj_oids.insert(obj_fingerprint(s)); } @@ -1040,7 +1040,7 @@ int RGWRadosList::handle_stat_result(const DoutPrefixProvider *dpp, RGWObjManifest::obj_iterator miter; for (miter = manifest.obj_begin(dpp); miter != manifest.obj_end(dpp); ++miter) { const rgw_raw_obj& loc = - miter.get_location().get_raw_obj(store); + miter.get_location().get_raw_obj(static_cast(store)); string s = loc.oid; obj_oids.insert(s); } @@ -1501,7 +1501,7 @@ int RGWRadosList::do_incomplete_multipart(const DoutPrefixProvider *dpp, obj_it != manifest.obj_end(dpp); ++obj_it) { const rgw_raw_obj& loc = - obj_it.get_location().get_raw_obj(store); + obj_it.get_location().get_raw_obj(static_cast(store)); std::cout << loc.oid << std::endl; } // for (auto obj_it } // for (auto& p diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index afe33b7026c34..cce925df30cc2 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -383,7 +383,7 @@ int MultipartObjectProcessor::prepare_head() } rgw_raw_obj stripe_obj = manifest_gen.get_cur_obj(store); - head_obj->raw_obj_to_obj(stripe_obj); + dynamic_cast(head_obj.get())->raw_obj_to_obj(stripe_obj); head_obj->set_hash_source(target_obj->get_name()); r = writer.set_stripe_obj(stripe_obj); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a608d608ad875..9b4f77a8ca9a8 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -149,7 +149,7 @@ rgw_raw_obj rgw_obj_select::get_raw_obj(const RGWZoneGroup& zonegroup, const RGW return raw_obj; } -rgw_raw_obj rgw_obj_select::get_raw_obj(rgw::sal::Store* store) const +rgw_raw_obj rgw_obj_select::get_raw_obj(rgw::sal::RadosStore* store) const { if (!is_raw) { rgw_raw_obj r; @@ -5308,7 +5308,8 @@ static void generate_fake_tag(const DoutPrefixProvider *dpp, rgw::sal::Store* st if (mi != manifest.obj_end(dpp)) { if (manifest.has_tail()) // first object usually points at the head, let's skip to a more unique part ++mi; - tag = mi.get_location().get_raw_obj(store).oid; + rgw::sal::RadosStore* rstore = dynamic_cast(store); + tag = mi.get_location().get_raw_obj(rstore).oid; tag.append("_"); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 9d3870b0e2d27..be39b4ede0d5d 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -148,13 +148,6 @@ struct RGWUsageBatch { } }; -class RGWGetDataCB { -public: - virtual int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) = 0; - RGWGetDataCB() {} - virtual ~RGWGetDataCB() {} -}; - struct RGWCloneRangeInfo { rgw_obj src; off_t src_ofs; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 9f6bd8f02f08b..84adbf01dc1c0 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4024,26 +4024,7 @@ void RGWGetObjLayout_ObjStore_S3::send_response() } f.open_object_section("result"); - ::encode_json("head", head_obj, &f); - ::encode_json("manifest", *manifest, &f); - f.open_array_section("data_location"); - for (auto miter = manifest->obj_begin(this); miter != manifest->obj_end(this); ++miter) { - f.open_object_section("obj"); - rgw_raw_obj raw_loc = miter.get_location().get_raw_obj(store); - uint64_t ofs = miter.get_ofs(); - uint64_t left = manifest->get_obj_size() - ofs; - ::encode_json("ofs", miter.get_ofs(), &f); - ::encode_json("loc", raw_loc, &f); - ::encode_json("loc_ofs", miter.location_ofs(), &f); - uint64_t loc_size = miter.get_stripe_size(); - if (loc_size > left) { - loc_size = left; - } - ::encode_json("loc_size", loc_size, &f); - f.close_section(); - rgw_flush_formatter(s, &f); - } - f.close_section(); + s->object->get_obj_layout(this, s->yield, &f, s->obj_ctx); f.close_section(); rgw_flush_formatter(s, &f); } diff --git a/src/rgw/rgw_rest_s3_rados.cc b/src/rgw/rgw_rest_s3_rados.cc new file mode 100644 index 0000000000000..47e0393bd727d --- /dev/null +++ b/src/rgw/rgw_rest_s3_rados.cc @@ -0,0 +1,46 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#include "rgw_rest_s3_rados.h" +#include "rgw_sal_rados.h" +#include "rgw_rest.h" +#include "rgw_obj_manifest.h" + +void RGWGetObjLayout_ObjStore_S3::send_response() +{ + if (op_ret) + set_req_state_err(s, op_ret); + dump_errno(s); + end_header(s, this, "application/json"); + + JSONFormatter f; + + if (op_ret < 0) { + return; + } + + f.open_object_section("result"); + ::encode_json("head", head_obj, &f); + ::encode_json("manifest", *manifest, &f); + f.open_array_section("data_location"); + for (auto miter = manifest->obj_begin(this); miter != manifest->obj_end(this); ++miter) { + f.open_object_section("obj"); + rgw_raw_obj raw_loc = miter.get_location().get_raw_obj(static_cast(store)); + uint64_t ofs = miter.get_ofs(); + uint64_t left = manifest->get_obj_size() - ofs; + ::encode_json("ofs", miter.get_ofs(), &f); + ::encode_json("loc", raw_loc, &f); + ::encode_json("loc_ofs", miter.location_ofs(), &f); + uint64_t loc_size = miter.get_stripe_size(); + if (loc_size > left) { + loc_size = left; + } + ::encode_json("loc_size", loc_size, &f); + f.close_section(); + rgw_flush_formatter(s, &f); + } + f.close_section(); + f.close_section(); + rgw_flush_formatter(s, &f); +} + diff --git a/src/rgw/rgw_rest_s3_rados.h b/src/rgw/rgw_rest_s3_rados.h new file mode 100644 index 0000000000000..2a3e4d4c25f5c --- /dev/null +++ b/src/rgw/rgw_rest_s3_rados.h @@ -0,0 +1,15 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#pragma once + +#include "rgw_op_rados.h" + +class RGWGetObjLayout_ObjStore_S3 : public RGWGetObjLayout { +public: + RGWGetObjLayout_ObjStore_S3() {} + ~RGWGetObjLayout_ObjStore_S3() {} + + void send_response() override; +}; + diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 0c12348b44e20..2c2f26df0147c 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -43,6 +43,13 @@ namespace rgw { namespace IAM { struct Policy; } } +class RGWGetDataCB { +public: + virtual int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) = 0; + RGWGetDataCB() {} + virtual ~RGWGetDataCB() {} +}; + struct RGWUsageIter { std::string read_iter; uint32_t index; @@ -202,13 +209,8 @@ class Store { virtual std::unique_ptr get_completions(void) = 0; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, struct req_state* s, rgw::notify::EventType event_type, const std::string* object_name=nullptr) = 0; - virtual std::unique_ptr get_gc_chain(rgw::sal::Object* obj) = 0; virtual RGWLC* get_rgwlc(void) = 0; virtual RGWCoroutinesManagerRegistry* get_cr_registry() = 0; - virtual int delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj) = 0; - virtual int delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio) = 0; - virtual void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) = 0; - virtual int get_raw_chunk_size(const DoutPrefixProvider* dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) = 0; virtual int log_usage(const DoutPrefixProvider *dpp, std::map& usage_info) = 0; virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) = 0; @@ -590,18 +592,11 @@ class Object { rgw_obj* target_obj{nullptr}; // XXX dang remove? } params; - struct Result { - rgw_raw_obj head_obj; - - Result() : head_obj() {} - } result; - virtual ~ReadOp() = default; virtual int prepare(optional_yield y, const DoutPrefixProvider* dpp) = 0; virtual int read(int64_t ofs, int64_t end, bufferlist& bl, optional_yield y, const DoutPrefixProvider* dpp) = 0; virtual int iterate(const DoutPrefixProvider* dpp, int64_t ofs, int64_t end, RGWGetDataCB* cb, optional_yield y) = 0; - virtual int get_manifest(const DoutPrefixProvider* dpp, RGWObjManifest **pmanifest, optional_yield y) = 0; virtual int get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) = 0; }; @@ -744,7 +739,6 @@ class Object { virtual int copy_obj_data(RGWObjectCtx& rctx, Bucket* dest_bucket, Object* dest_obj, uint16_t olh_epoch, std::string* petag, const DoutPrefixProvider* dpp, optional_yield y) = 0; virtual bool is_expired() = 0; virtual void gen_rand_obj_instance_name() = 0; - virtual void raw_obj_to_obj(const rgw_raw_obj& raw_obj) = 0; virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) = 0; virtual int transition(RGWObjectCtx& rctx, Bucket* bucket, @@ -759,6 +753,7 @@ class Object { uint64_t* alignment = nullptr) = 0; virtual void get_max_aligned_size(uint64_t size, uint64_t alignment, uint64_t* max_size) = 0; virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) = 0; + virtual int get_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f, RGWObjectCtx* obj_ctx) = 0; Attrs& get_attrs(void) { return attrs; } const Attrs& get_attrs(void) const { return attrs; } @@ -987,19 +982,6 @@ protected: const ceph::real_time& mtime, const std::string& etag, const std::string& version) = 0; }; -class GCChain { -protected: - Object* obj; - - public: - GCChain(Object* _obj) : obj(_obj) {} - virtual ~GCChain() = default; - - virtual void update(const DoutPrefixProvider *dpp, RGWObjManifest* manifest) = 0; - virtual int send(const std::string& tag) = 0; - virtual void delete_inline(const DoutPrefixProvider *dpp, const std::string& tag) = 0; -}; - class Writer : public ObjectProcessor { protected: const DoutPrefixProvider* dpp; diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 4eda3c5cf228b..99dc875316e00 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -737,31 +737,6 @@ namespace rgw::sal { return 0; } - std::unique_ptr DBStore::get_gc_chain(rgw::sal::Object* obj) - { - return 0; - } - - int DBStore::delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj) - { - return 0; - } - - int DBStore::delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio) - { - return 0; - } - - void DBStore::get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) - { - return; - } - - int DBStore::get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) - { - return 0; - } - int DBStore::log_usage(const DoutPrefixProvider *dpp, map& usage_info) { return 0; diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index e5d584f1f92f0..01eef17246d60 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -302,13 +302,8 @@ namespace rgw { namespace sal { virtual std::unique_ptr get_completions(void) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, struct req_state* s, rgw::notify::EventType event_type, const std::string* object_name=nullptr) override; - virtual std::unique_ptr get_gc_chain(rgw::sal::Object* obj) override; virtual RGWLC* get_rgwlc(void) override { return NULL; } virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return NULL; } - virtual int delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj) override; - virtual int delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio) override; - virtual void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) override; - virtual int get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) override; virtual int log_usage(const DoutPrefixProvider *dpp, map& usage_info) override; virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index a943d06842bf6..0b628855203df 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -1184,11 +1184,6 @@ std::unique_ptr RadosStore::get_notification(rgw::sal::Object* obj return std::unique_ptr(new RadosNotification(s, this, obj, s, event_type, object_name)); } -std::unique_ptr RadosStore::get_gc_chain(rgw::sal::Object* obj) -{ - return std::unique_ptr(new RadosGCChain(this, obj)); -} - int RadosStore::delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj) { return rados->delete_raw_obj(dpp, obj); @@ -1755,6 +1750,55 @@ bool RadosObject::placement_rules_match(rgw_placement_rule& r1, rgw_placement_ru return p1 == p2; } +int RadosObject::get_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f, RGWObjectCtx* obj_ctx) +{ + int ret; + RGWObjManifest *manifest{nullptr}; + rgw_raw_obj head_obj; + + RGWRados::Object op_target(store->getRados(), get_bucket()->get_info(), + *obj_ctx, get_obj()); + RGWRados::Object::Read parent_op(&op_target); + uint64_t obj_size; + + parent_op.params.obj_size = &obj_size; + parent_op.params.attrs = &get_attrs(); + + ret = parent_op.prepare(y, dpp); + if (ret < 0) { + return ret; + } + + head_obj = parent_op.state.head_obj; + + ret = op_target.get_manifest(dpp, &manifest, y); + if (ret < 0) { + return ret; + } + + ::encode_json("head", head_obj, f); + ::encode_json("manifest", *manifest, f); + f->open_array_section("data_location"); + for (auto miter = manifest->obj_begin(dpp); miter != manifest->obj_end(dpp); ++miter) { + f->open_object_section("obj"); + rgw_raw_obj raw_loc = miter.get_location().get_raw_obj(store); + uint64_t ofs = miter.get_ofs(); + uint64_t left = manifest->get_obj_size() - ofs; + ::encode_json("ofs", miter.get_ofs(), f); + ::encode_json("loc", raw_loc, f); + ::encode_json("loc_ofs", miter.location_ofs(), f); + uint64_t loc_size = miter.get_stripe_size(); + if (loc_size > left) { + loc_size = left; + } + ::encode_json("loc_size", loc_size, f); + f->close_section(); + } + f->close_section(); + + return 0; +} + std::unique_ptr RadosObject::get_read_op(RGWObjectCtx* ctx) { return std::unique_ptr(new RadosObject::RadosReadOp(this, ctx)); @@ -1792,7 +1836,6 @@ int RadosObject::RadosReadOp::prepare(optional_yield y, const DoutPrefixProvider source->set_key(parent_op.state.obj.key); source->set_obj_size(obj_size); - result.head_obj = parent_op.state.head_obj; return ret; } @@ -1802,12 +1845,6 @@ int RadosObject::RadosReadOp::read(int64_t ofs, int64_t end, bufferlist& bl, opt return parent_op.read(ofs, end, bl, y, dpp); } -int RadosObject::RadosReadOp::get_manifest(const DoutPrefixProvider* dpp, RGWObjManifest **pmanifest, - optional_yield y) -{ - return op_target.get_manifest(dpp, pmanifest, y); -} - int RadosObject::RadosReadOp::get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) { return parent_op.get_attr(dpp, name, dest, y); @@ -2066,7 +2103,7 @@ int RadosMultipartUpload::abort(const DoutPrefixProvider *dpp, CephContext *cct, std::unique_ptr meta_obj = get_meta_obj(); meta_obj->set_in_extra_data(true); meta_obj->set_hash_source(mp_obj.get_key()); - std::unique_ptr chain = store->get_gc_chain(meta_obj.get()); + cls_rgw_obj_chain chain; list remove_objs; bool truncated; int marker = 0; @@ -2093,12 +2130,13 @@ int RadosMultipartUpload::abort(const DoutPrefixProvider *dpp, CephContext *cct, if (ret < 0 && ret != -ENOENT) return ret; } else { - chain->update(dpp, &obj_part->info.manifest); + auto target = meta_obj->get_obj(); + store->getRados()->update_gc_chain(dpp, target, obj_part->info.manifest, &chain); RGWObjManifest::obj_iterator oiter = obj_part->info.manifest.obj_begin(dpp); if (oiter != obj_part->info.manifest.obj_end(dpp)) { std::unique_ptr head = bucket->get_object(rgw_obj_key()); rgw_raw_obj raw_head = oiter.get_location().get_raw_obj(store); - head->raw_obj_to_obj(raw_head); + dynamic_cast(head.get())->raw_obj_to_obj(raw_head); rgw_obj_index_key key; head->get_key().get_index_key(&key); @@ -2110,14 +2148,14 @@ int RadosMultipartUpload::abort(const DoutPrefixProvider *dpp, CephContext *cct, } while (truncated); /* use upload id as tag and do it synchronously */ - ret = chain->send(mp_obj.get_upload_id()); + ret = store->getRados()->send_chain_to_gc(chain, mp_obj.get_upload_id()); if (ret < 0) { ldpp_dout(dpp, 5) << __func__ << ": gc->send_chain() returned " << ret << dendl; if (ret == -ENOENT) { return -ERR_NO_SUCH_UPLOAD; } //Delete objects inline if send chain to gc fails - chain->delete_inline(dpp, mp_obj.get_upload_id()); + store->getRados()->delete_objs_inline(dpp, chain, mp_obj.get_upload_id()); } std::unique_ptr del_op = meta_obj->get_delete_op(obj_ctx); @@ -2652,22 +2690,6 @@ int RadosNotification::publish_commit(const DoutPrefixProvider* dpp, uint64_t si return rgw::notify::publish_commit(obj, size, mtime, etag, version, event_type, res, dpp); } -void RadosGCChain::update(const DoutPrefixProvider *dpp, RGWObjManifest* manifest) -{ - rgw_obj target = obj->get_obj(); - store->getRados()->update_gc_chain(dpp, target, *manifest, &chain); -} - -int RadosGCChain::send(const std::string& tag) -{ - return store->getRados()->send_chain_to_gc(chain, tag); -} - -void RadosGCChain::delete_inline(const DoutPrefixProvider *dpp, const std::string& tag) -{ - store->getRados()->delete_objs_inline(dpp, chain, tag); -} - int RadosAtomicWriter::prepare(optional_yield y) { return processor.prepare(y); diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index b2c8a46251dac..3a9db6e045bc2 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -1,4 +1,4 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- + // vim: ts=8 sw=2 smarttab ft=cpp /* @@ -95,7 +95,6 @@ class RadosObject : public Object { virtual int prepare(optional_yield y, const DoutPrefixProvider* dpp) override; virtual int read(int64_t ofs, int64_t end, bufferlist& bl, optional_yield y, const DoutPrefixProvider* dpp) override; virtual int iterate(const DoutPrefixProvider* dpp, int64_t ofs, int64_t end, RGWGetDataCB* cb, optional_yield y) override; - virtual int get_manifest(const DoutPrefixProvider* dpp, RGWObjManifest **pmanifest, optional_yield y) override; virtual int get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) override; }; @@ -189,7 +188,6 @@ class RadosObject : public Object { virtual int copy_obj_data(RGWObjectCtx& rctx, Bucket* dest_bucket, Object* dest_obj, uint16_t olh_epoch, std::string* petag, const DoutPrefixProvider* dpp, optional_yield y) override; virtual bool is_expired() override; virtual void gen_rand_obj_instance_name() override; - virtual void raw_obj_to_obj(const rgw_raw_obj& raw_obj) override; void get_raw_obj(rgw_raw_obj* raw_obj); virtual std::unique_ptr clone() override { return std::unique_ptr(new RadosObject(*this)); @@ -208,6 +206,7 @@ class RadosObject : public Object { uint64_t* alignment = nullptr) override; virtual void get_max_aligned_size(uint64_t size, uint64_t alignment, uint64_t* max_size) override; virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override; + virtual int get_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f, RGWObjectCtx* obj_ctx) override; /* Swift versioning */ virtual int swift_versioning_restore(RGWObjectCtx* obj_ctx, @@ -235,6 +234,9 @@ class RadosObject : public Object { virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val, bool must_exist, optional_yield y) override; + /* Internal to RadosStore */ + void raw_obj_to_obj(const rgw_raw_obj& raw_obj); + private: int read_attrs(const DoutPrefixProvider* dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr); }; @@ -424,13 +426,8 @@ class RadosStore : public Store { virtual std::unique_ptr get_lifecycle(void) override; virtual std::unique_ptr get_completions(void) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, struct req_state* s, rgw::notify::EventType event_type, const std::string* object_name=nullptr) override; - virtual std::unique_ptr get_gc_chain(rgw::sal::Object* obj) override; virtual RGWLC* get_rgwlc(void) override { return rados->get_lc(); } virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return rados->get_cr_registry(); } - virtual int delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj) override; - virtual int delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio) override; - virtual void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) override; - virtual int get_raw_chunk_size(const DoutPrefixProvider* dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) override; virtual int log_usage(const DoutPrefixProvider *dpp, std::map& usage_info) override; virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override; @@ -509,6 +506,10 @@ class RadosStore : public Store { /* Unique to RadosStore */ int get_obj_head_ioctx(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx* ioctx); + int delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj); + int delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio); + void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj); + int get_raw_chunk_size(const DoutPrefixProvider* dpp, const rgw_raw_obj& obj, uint64_t* chunk_size); void setRados(RGWRados * st) { rados = st; } RGWRados* getRados(void) { return rados; } @@ -638,20 +639,6 @@ class RadosNotification : public Notification { const ceph::real_time& mtime, const std::string& etag, const std::string& version) override; }; -class RadosGCChain : public GCChain { -protected: - RadosStore* store; - cls_rgw_obj_chain chain; - - public: - RadosGCChain(RadosStore* _store, Object* _obj) : GCChain(_obj), store(_store) {} - ~RadosGCChain() = default; - - virtual void update(const DoutPrefixProvider *dpp, RGWObjManifest* manifest) override; - virtual int send(const std::string& tag) override; - virtual void delete_inline(const DoutPrefixProvider *dpp, const std::string& tag) override; -}; - class RadosAtomicWriter : public Writer { protected: rgw::sal::RadosStore* store; diff --git a/src/rgw/rgw_torrent.h b/src/rgw/rgw_torrent.h index 89868c4f9da8a..cc84a1778ceb6 100644 --- a/src/rgw/rgw_torrent.h +++ b/src/rgw/rgw_torrent.h @@ -11,7 +11,6 @@ #include "common/ceph_time.h" -#include "rgw_rados.h" #include "rgw_common.h" using ceph::crypto::SHA1;