From 5e2d2b56eafe0ac94df6811c1b41a633cdf9a14d Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Mon, 3 Nov 2025 14:14:45 +0530 Subject: [PATCH] rgw/cloud-restore: Read size once restore is completed Include `size` param in the restore API to read the actual object size once restore is completed. This is needed to send bucket notification to the client. Signed-off-by: Soumya Koduri --- src/rgw/driver/daos/rgw_sal_daos.cc | 1 + src/rgw/driver/daos/rgw_sal_daos.h | 1 + src/rgw/driver/posix/rgw_sal_posix.cc | 1 + src/rgw/driver/posix/rgw_sal_posix.h | 1 + src/rgw/driver/rados/rgw_rados.cc | 6 ++++-- src/rgw/driver/rados/rgw_rados.h | 1 + src/rgw/driver/rados/rgw_sal_rados.cc | 3 ++- src/rgw/driver/rados/rgw_sal_rados.h | 1 + src/rgw/rgw_restore.cc | 5 ++--- src/rgw/rgw_sal.h | 1 + src/rgw/rgw_sal_filter.cc | 3 ++- src/rgw/rgw_sal_filter.h | 1 + src/rgw/rgw_sal_store.h | 1 + 13 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/rgw/driver/daos/rgw_sal_daos.cc b/src/rgw/driver/daos/rgw_sal_daos.cc index c1cdc5978912b..d04a0b3b92d4e 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.cc +++ b/src/rgw/driver/daos/rgw_sal_daos.cc @@ -1035,6 +1035,7 @@ int DaosObject::restore_obj_from_cloud(Bucket* bucket, uint64_t olh_epoch, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) { diff --git a/src/rgw/driver/daos/rgw_sal_daos.h b/src/rgw/driver/daos/rgw_sal_daos.h index ab525b7217066..b95c6e49c5c6e 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.h +++ b/src/rgw/driver/daos/rgw_sal_daos.h @@ -661,6 +661,7 @@ class DaosObject : public StoreObject { uint64_t olh_epoch, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) override; virtual bool placement_rules_match(rgw_placement_rule& r1, diff --git a/src/rgw/driver/posix/rgw_sal_posix.cc b/src/rgw/driver/posix/rgw_sal_posix.cc index e3bf6838ad6e2..68f5f05990042 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.cc +++ b/src/rgw/driver/posix/rgw_sal_posix.cc @@ -3243,6 +3243,7 @@ int POSIXObject::restore_obj_from_cloud(Bucket* bucket, CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) { diff --git a/src/rgw/driver/posix/rgw_sal_posix.h b/src/rgw/driver/posix/rgw_sal_posix.h index 0253ac785eb14..443842838b5d1 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.h +++ b/src/rgw/driver/posix/rgw_sal_posix.h @@ -1080,6 +1080,7 @@ public: CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) override; virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override; diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 94e6ac03dc50b..c50355d7ae265 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -5472,6 +5472,7 @@ int RGWRados::restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx, RGWObjTier& tier_config, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider *dpp, optional_yield y) { @@ -5693,8 +5694,9 @@ int RGWRados::restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx, return ret; } - // this returned size can be used to send bucket notification - return accounted_size; + // set size to be used to send bucket notification + size = accounted_size; + return 0; } int RGWRados::check_bucket_empty(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, optional_yield y) diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index c0f72bc730fed..8a6e39e97f88e 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1294,6 +1294,7 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx, RGWObjTier& tier_config, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider *dpp, optional_yield y); diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index ef1c3f56b5822..da4cbd32a5398 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -3079,6 +3079,7 @@ int RadosObject::restore_obj_from_cloud(Bucket* bucket, CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) { @@ -3154,7 +3155,7 @@ int RadosObject::restore_obj_from_cloud(Bucket* bucket, * avoid any races */ ret = store->getRados()->restore_obj_from_cloud(tier_ctx, *rados_ctx, bucket->get_info(), get_obj(), - tier_config, days, in_progress, dpp, y); + tier_config, days, in_progress, size, dpp, y); if (ret < 0) { //failed to restore ldpp_dout(dpp, 0) << "Restoring object(" << get_key() << ") from the cloud endpoint(" << endpoint << ") failed, ret=" << ret << dendl; diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index e236e60c02258..5fa42b6c4d45a 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -644,6 +644,7 @@ class RadosObject : public StoreObject { CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) override; virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override; diff --git a/src/rgw/rgw_restore.cc b/src/rgw/rgw_restore.cc index 54c96a3c05044..c3ef799b941a0 100644 --- a/src/rgw/rgw_restore.cc +++ b/src/rgw/rgw_restore.cc @@ -514,9 +514,9 @@ int Restore::process_restore_entry(RestoreEntry& entry, optional_yield y) goto done; } + uint64_t size; // now go ahead with restoring object - // XXX: first check if its already restored? - ret = obj->restore_obj_from_cloud(bucket.get(), tier.get(), cct, days, in_progress, + ret = obj->restore_obj_from_cloud(bucket.get(), tier.get(), cct, days, in_progress, size, this, y); if (ret < 0) { ldpp_dout(this, -1) << __PRETTY_FUNCTION__ << ": Restore of object(" << obj->get_key() << ") failed" << ret << dendl; @@ -540,7 +540,6 @@ int Restore::process_restore_entry(RestoreEntry& entry, optional_yield y) etag = rgw_bl_str(attr_iter->second); } - uint64_t size = ret; // send notification in case the restore is successfully completed send_notification(this, driver, obj.get(), bucket.get(), etag, size, obj->get_key().instance, diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 02b293bac5354..2d820af5dea8a 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1283,6 +1283,7 @@ class Object { CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) = 0; /** Check to see if two placement rules match */ diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index 48298a3f4a086..0cc849ce90530 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -1150,11 +1150,12 @@ int FilterObject::restore_obj_from_cloud(Bucket* bucket, CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) { return next->restore_obj_from_cloud(nextBucket(bucket), nextPlacementTier(tier), - cct, days, in_progress, dpp, y); + cct, days, in_progress, size, dpp, y); } bool FilterObject::placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index 7199da21e6c9f..c3f628badedb5 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -840,6 +840,7 @@ public: CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) override; virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override; diff --git a/src/rgw/rgw_sal_store.h b/src/rgw/rgw_sal_store.h index a6a7a4c8e9063..d64403d7f1d06 100644 --- a/src/rgw/rgw_sal_store.h +++ b/src/rgw/rgw_sal_store.h @@ -373,6 +373,7 @@ class StoreObject : public Object { CephContext* cct, std::optional days, bool& in_progress, + uint64_t& size, const DoutPrefixProvider* dpp, optional_yield y) override { return -1; -- 2.39.5