]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: ensure backward compatibility on handling CLS_RGW_OLH_OP_STALE during upgrade
authorJane Zhu <jzhu116@bloomberg.net>
Thu, 19 Mar 2026 21:09:18 +0000 (21:09 +0000)
committerJane Zhu <jzhu116@bloomberg.net>
Sat, 4 Apr 2026 17:02:17 +0000 (17:02 +0000)
Signed-off-by: Jane Zhu <jzhu116@bloomberg.net>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_ops.cc
src/cls/rgw/cls_rgw_ops.h

index 0630c01922b81c67130321f84ca233485f76df48..fae739d10cc8efc097edbf6f2aefe20ddc0b81a6 100644 (file)
@@ -2267,6 +2267,19 @@ static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bu
     op_ret.is_truncated = (iter != log.end());
   }
 
+  // this is for backward compatibility
+  if (!op.get_stales) {
+    auto iter = op_ret.log.begin();
+    while (iter != op_ret.log.end()) {
+      std::erase_if(iter->second, [](const auto& e) { return e.op == CLS_RGW_OLH_OP_STALE; });
+      if (iter->second.empty()) {
+        iter = op_ret.log.erase(iter);
+      } else {
+        ++iter;
+      }
+    }
+  }
+
   encode(op_ret, *out);
 
   return 0;
index 0b590cd756d631f8c3d10ea0cb1d3b32f6424e25..01b91629191fc1002cbf6177e46c5365bdf99618 100644 (file)
@@ -360,6 +360,7 @@ void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_ke
   call.olh = olh;
   call.ver_marker = ver_marker;
   call.olh_tag = olh_tag;
+  call.get_stales = true;
   encode(call, in);
   op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, new ClsBucketIndexOpCtx<rgw_cls_read_olh_log_ret>(&log_ret, &op_ret));
 }
index 1a2f49c19ca1898b9a52d3784bd8b82c94130148..c68d8e16732686a2bf4a56295a07959463e59841 100644 (file)
@@ -249,6 +249,7 @@ list<rgw_cls_read_olh_log_op> rgw_cls_read_olh_log_op::generate_test_instances()
   op.olh.name = "name";
   op.ver_marker = 123;
   op.olh_tag = "olh_tag";
+  op.get_stales = true;
 
   o.push_back(std::move(op));
   o.emplace_back();
@@ -260,6 +261,7 @@ void rgw_cls_read_olh_log_op::dump(Formatter *f) const
   encode_json("olh", olh, f);
   encode_json("ver_marker", ver_marker, f);
   encode_json("olh_tag", olh_tag, f);
+  encode_json("get_stales", get_stales, f);
 }
 
 list<rgw_cls_read_olh_log_ret> rgw_cls_read_olh_log_ret::generate_test_instances()
index f3caada0b79f805cf8eef2fba1c57eb9ea9ba8e6..0ab993232894b85d7b908ea186e7e5591819a5e6 100644 (file)
@@ -285,21 +285,26 @@ struct rgw_cls_read_olh_log_op
   cls_rgw_obj_key olh;
   uint64_t ver_marker;
   std::string olh_tag;
+  bool get_stales;
 
-  rgw_cls_read_olh_log_op() : ver_marker(0) {}
+  rgw_cls_read_olh_log_op() : ver_marker(0), get_stales(false) {}
 
   void encode(ceph::buffer::list &bl) const {
-    ENCODE_START(1, 1, bl);
+    ENCODE_START(2, 1, bl);
     encode(olh, bl);
     encode(ver_marker, bl);
     encode(olh_tag, bl);
+    encode(get_stales, bl);
     ENCODE_FINISH(bl);
   }
   void decode(ceph::buffer::list::const_iterator &bl) {
-    DECODE_START(1, bl);
+    DECODE_START(2, bl);
     decode(olh, bl);
     decode(ver_marker, bl);
     decode(olh_tag, bl);
+    if (struct_v >= 2) {
+      decode(get_stales, bl);
+    }
     DECODE_FINISH(bl);
   }
   static std::list<rgw_cls_read_olh_log_op> generate_test_instances();