]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: additional lc notify cleanups
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 8 Nov 2023 19:02:33 +0000 (14:02 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 4 Jan 2024 20:23:27 +0000 (15:23 -0500)
Follow the same formula to build up obj_state and version_id
in all call sites.

Resolves: rhbz#2163667

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc

index f117aaa81f848df00da5948cd48e64ba10b1f4bf..fec80339d0ffb9045e7a01c994a612f944a2e47e 100644 (file)
@@ -525,9 +525,6 @@ static int remove_expired_obj(
   auto& version_id = obj_key.instance;
   std::unique_ptr<rgw::sal::Notification> notify;
 
-  std::unique_ptr<rgw::sal::User> user;
-  user = driver->get_user(bucket_info.owner);
-
   /* per discussion w/Daniel, Casey,and Eric, we *do need*
    * a new sal object handle, based on the following decision
    * to clear obj_key.instance--which happens in the case
@@ -555,7 +552,7 @@ static int remove_expired_obj(
   del_op->params.unmod_since = meta.mtime;
 
   // notification supported only for RADOS driver for now
-  notify = driver->get_notification(dpp, oc.obj.get(), nullptr, event_type,
+  notify = driver->get_notification(dpp, obj.get(), nullptr, event_type,
                                   oc.bucket, lc_id,
                                   const_cast<std::string&>(oc.bucket->get_tenant()),
                                   lc_req_id, null_yield);
@@ -834,18 +831,25 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
     int ret{0};
     auto wt = boost::get<std::tuple<lc_op, rgw_bucket_dir_entry>>(wi);
     auto& [rule, obj] = wt;
+
     if (obj_has_expired(this, cct, obj.meta.mtime, rule.mp_expiration)) {
       rgw_obj_key key(obj.key);
-      std::unique_ptr<rgw::sal::MultipartUpload> mpu = target->get_multipart_upload(key.name);
-      std::unique_ptr<rgw::sal::Object> sal_obj
-       = target->get_object(key);
+      auto mpu = target->get_multipart_upload(key.name);
+      auto sal_obj = target->get_object(key);
+
+      RGWObjState* obj_state{nullptr};
+      ret = sal_obj->get_obj_state(this, &obj_state, null_yield, true);
+      if (ret < 0) {
+       return ret;
+      }
+
       std::unique_ptr<rgw::sal::Notification> notify
        = driver->get_notification(
          this, sal_obj.get(), nullptr, event_type,
          target, lc_id,
          const_cast<std::string&>(target->get_tenant()),
          lc_req_id, null_yield);
-                       auto& version_id = obj.key.instance;
+      auto& version_id = obj.key.instance;
 
       ret = notify->publish_reserve(this, nullptr);
       if (ret < 0) {
@@ -860,12 +864,13 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
       ret = mpu->abort(this, cct, null_yield);
       if (ret == 0) {
         int publish_ret = notify->publish_commit(
-            this, sal_obj->get_obj_size(), ceph::real_clock::now(),
-            sal_obj->get_attrs()[RGW_ATTR_ETAG].to_str(),
-                                               version_id);
+            this, obj_state->size,
+           ceph::real_clock::now(),
+            obj_state->attrset[RGW_ATTR_ETAG].to_str(),
+           version_id);
         if (publish_ret < 0) {
           ldpp_dout(wk->get_lc(), 5)
-              << "WARNING: notify publish_commit failed, with error: " << publish_ret
+              << "WARNING: notify publish_commit failed, with error: " << ret
               << dendl;
         }
         if (perfcounter) {
@@ -1332,10 +1337,14 @@ public:
 
     /* notifications */
     auto& bucket = oc.bucket;
-    std::string version_id;
-
     auto& obj = oc.obj;
 
+    RGWObjState* obj_state{nullptr};
+    ret = obj->get_obj_state(oc.dpp, &obj_state, null_yield, true);
+    if (ret < 0) {
+      return ret;
+    }
+
     const auto event_type = (bucket->versioned() &&
                             oc.o.is_current() && !oc.o.is_delete_marker()) ?
       rgw::notify::ObjectTransitionCurrent :
@@ -1347,6 +1356,7 @@ public:
        bucket, lc_id,
        const_cast<std::string&>(oc.bucket->get_tenant()),
        lc_req_id, null_yield);
+    auto& version_id = oc.o.key.instance;
 
     ret = notify->publish_reserve(oc.dpp, nullptr);
     if (ret < 0) {
@@ -1365,9 +1375,9 @@ public:
       return ret;
     } else {
       // send request to notification manager
-      int publish_ret = notify->publish_commit(oc.dpp, obj->get_obj_size(),
+      int publish_ret =  notify->publish_commit(oc.dpp, obj_state->size,
                                    ceph::real_clock::now(),
-                                   obj->get_attrs()[RGW_ATTR_ETAG].to_str(),
+                                   obj_state->attrset[RGW_ATTR_ETAG].to_str(),
                                    version_id);
       if (publish_ret < 0) {
        ldpp_dout(oc.dpp, 5) <<