From 402230363f87a170b73741a051770ef68f6d1c4b Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Mon, 27 Jun 2022 14:13:19 +0530 Subject: [PATCH] rgw/dbstore: Lifecycle support Fixed issues with LC rule processing in dbstore. Also wrt object transition, for now just the target storage class is updated for that object in the object table without any other special action taken. TODO: Once zonegroup, zone and storage-classes can be configured for dbstore, need to validate target storage-class/placement rules and also perform any other actions necessary (for eg., moving objects to another table etc., if in case each storage class needs to have separate object table) Signed-off-by: Soumya Koduri --- src/rgw/rgw_lc.cc | 36 +++++++++-------- src/rgw/rgw_sal_dbstore.cc | 8 +++- src/rgw/store/dbstore/common/dbstore.cc | 54 +++++++++++++++++++++++++ src/rgw/store/dbstore/common/dbstore.h | 7 ++-- 4 files changed, 84 insertions(+), 21 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index c4604d3e4fe..57f412559bc 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -27,8 +27,7 @@ #include "rgw_zone.h" #include "rgw_string.h" #include "rgw_multi.h" -#include "rgw_sal_rados.h" -#include "rgw_rados.h" +#include "rgw_sal.h" #include "rgw_lc_tier.h" #include "rgw_notify.h" @@ -523,6 +522,7 @@ static int remove_expired_obj( auto& meta = o.meta; int ret; std::string version_id; + std::unique_ptr notify; if (!remove_indeed) { obj_key.instance.clear(); @@ -560,30 +560,34 @@ static int remove_expired_obj( del_op->params.unmod_since = meta.mtime; del_op->params.marker_version_id = version_id; - std::unique_ptr notify - = store->get_notification(dpp, obj.get(), nullptr, event_type, + rgw::sal::RadosStore *rados = dynamic_cast(oc.store); + if (rados) { + // notification supported only for RADOS store for now + notify + = store->get_notification(dpp, obj.get(), nullptr, event_type, bucket.get(), lc_id, const_cast(oc.bucket->get_tenant()), lc_req_id, null_yield); - /* can eliminate cast when reservation is lifted into Notification */ - auto notify_res = static_cast(notify.get())->get_reservation(); + /* can eliminate cast when reservation is lifted into Notification */ + auto notify_res = static_cast(notify.get())->get_reservation(); - ret = rgw::notify::publish_reserve(dpp, event_type, notify_res, nullptr); - if (ret < 0) { - ldpp_dout(dpp, 1) - << "ERROR: notify reservation failed, deferring delete of object k=" - << o.key - << dendl; - return ret; + ret = rgw::notify::publish_reserve(dpp, event_type, notify_res, nullptr); + if ( ret < 0) { + ldpp_dout(dpp, 1) + << "ERROR: notify reservation failed, deferring delete of object k=" + << o.key + << dendl; + return ret; + } } - ret = del_op->delete_obj(dpp, null_yield); if (ret < 0) { ldpp_dout(dpp, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl; - } else { - // send request to notification manager + } else if (rados) { + // send request to notification manager + auto notify_res = static_cast(notify.get())->get_reservation(); (void) rgw::notify::publish_commit( obj.get(), obj->get_obj_size(), ceph::real_clock::now(), obj->get_attrs()[RGW_ATTR_ETAG].to_str(), version_id, event_type, diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index c06fc814d0c..dbf0f812920 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -734,7 +734,9 @@ namespace rgw::sal { const DoutPrefixProvider* dpp, optional_yield y) { - return 0; + DB::Object op_target(store->getDB(), + get_bucket()->get_info(), get_obj()); + return op_target.transition(dpp, placement_rule, mtime, olh_epoch); } int DBObject::transition_to_cloud(Bucket* bucket, @@ -1609,7 +1611,9 @@ namespace rgw::sal { bool DBStore::valid_placement(const rgw_placement_rule& rule) { - return zone.get_rgw_params().valid_placement(rule); + // XXX: Till zonegroup, zone and storage-classes can be configured + // for dbstore return true + return true; //zone.get_rgw_params().valid_placement(rule); } std::unique_ptr DBStore::get_user(const rgw_user &u) diff --git a/src/rgw/store/dbstore/common/dbstore.cc b/src/rgw/store/dbstore/common/dbstore.cc index ecd8b5a9e87..ad71cd0bcbd 100644 --- a/src/rgw/store/dbstore/common/dbstore.cc +++ b/src/rgw/store/dbstore/common/dbstore.cc @@ -1133,6 +1133,60 @@ out: return ret; } +int DB::Object::transition(const DoutPrefixProvider *dpp, + const rgw_placement_rule& rule, + const real_time& mtime, + uint64_t olh_epoch) +{ + int ret = 0; + + DBOpParams params = {}; + map *attrset; + + store->InitializeParams(dpp, ¶ms); + InitializeParamsfromObject(dpp, ¶ms); + + ret = store->ProcessOp(dpp, "GetObject", ¶ms); + + if (ret) { + ldpp_dout(dpp, 0) <<"In GetObject failed err:(" <ProcessOp(dpp, "UpdateObject", ¶ms); + + if (ret) { + ldpp_dout(dpp, 0)<<"In UpdateObject failed err:(" <