From: Jane Zhu Date: Thu, 19 Mar 2026 21:09:18 +0000 (+0000) Subject: rgw: ensure backward compatibility on handling CLS_RGW_OLH_OP_STALE during upgrade X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4b8c63ace17e846fe289490ba2f69b6d4fc3f30;p=ceph.git rgw: ensure backward compatibility on handling CLS_RGW_OLH_OP_STALE during upgrade Signed-off-by: Jane Zhu --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 0630c01922b8..fae739d10cc8 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -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; diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 0b590cd756d6..01b91629191f 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -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(&log_ret, &op_ret)); } diff --git a/src/cls/rgw/cls_rgw_ops.cc b/src/cls/rgw/cls_rgw_ops.cc index 1a2f49c19ca1..c68d8e167326 100644 --- a/src/cls/rgw/cls_rgw_ops.cc +++ b/src/cls/rgw/cls_rgw_ops.cc @@ -249,6 +249,7 @@ list 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::generate_test_instances() diff --git a/src/cls/rgw/cls_rgw_ops.h b/src/cls/rgw/cls_rgw_ops.h index f3caada0b79f..0ab993232894 100644 --- a/src/cls/rgw/cls_rgw_ops.h +++ b/src/cls/rgw/cls_rgw_ops.h @@ -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 generate_test_instances();