From: Jane Zhu Date: Sat, 4 Apr 2026 16:55:07 +0000 (+0000) Subject: fixup! rgw: break the coupling of olh epoch and epochs of olh ops, and make the epoch... X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b438348a65e84af3652d6a8e59196f9b7f3dd257;p=ceph.git fixup! rgw: break the coupling of olh epoch and epochs of olh ops, and make the epochs of olh ops ever-increasing add an olh op log for a missed success scenario in olh handling Signed-off-by: Jane Zhu --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index fae739d10cc8..be0e4ee38a44 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -1399,6 +1399,8 @@ static int read_olh(cls_method_context_t hctx,cls_rgw_obj_key& obj_key, rgw_buck static void update_olh_log(rgw_bucket_olh_entry& olh_data_entry, OLHLogOp op, const string& op_tag, cls_rgw_obj_key& key, bool delete_marker, uint64_t epoch) { + CLS_LOG(20, "%s: op=%d op_tag=%s key=%s epoch=%lu", __func__, + op, op_tag.c_str(), key.to_string().c_str(), epoch); vector& log = olh_data_entry.pending_log[epoch]; rgw_bucket_olh_log_entry log_entry; log_entry.epoch = epoch; @@ -1812,6 +1814,9 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer return -EINVAL; } + CLS_LOG(20, "%s: op_tag=%s key=%s olh_epoch=%lu", __func__, + op.op_tag.c_str(), op.key.to_string().c_str(), op.olh_epoch); + struct rgw_bucket_dir_header header; int rc = read_bucket_header(hctx, &header); if (rc < 0) { @@ -1846,6 +1851,16 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer return ret; } + /* read olh */ + BIOLHEntry olh(hctx, op.key); + bool olh_found = false; + ret = olh.init(&olh_found); + if (ret < 0) { + return ret; + } + + uint64_t now_epoch = duration_cast(real_clock::now().time_since_epoch()).count(); + if (existed && !real_clock::is_zero(op.unmod_since)) { timespec mtime = ceph::real_clock::to_timespec(obj.mtime()); timespec unmod = ceph::real_clock::to_timespec(op.unmod_since); @@ -1854,7 +1869,13 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer unmod.tv_nsec = 0; } if (mtime >= unmod) { - return 0; /* no need tof set error, we just return 0 and avoid + olh.update_log(CLS_RGW_OLH_OP_STALE, op.op_tag, op.key, false, now_epoch); + ret = olh.write(header); + if (ret < 0) { + CLS_LOG(0, "ERROR: failed to update olh ret=%d", ret); + return ret; + } + return 0; /* no need to set error, we just return 0 and avoid * writing to the bi log */ } } @@ -1897,18 +1918,9 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer obj.init_as_delete_marker(op.meta); } - /* read olh */ - BIOLHEntry olh(hctx, op.key); - bool olh_found = false; - ret = olh.init(&olh_found); - if (ret < 0) { - return ret; - } - const uint64_t prev_epoch = olh.get_epoch(); // op.olh_epoch is provided (> 0) in the case when a remote epoch is coming in as the result of multisite sync; - uint64_t now_epoch = duration_cast(real_clock::now().time_since_epoch()).count(); uint64_t candidate_epoch = op.olh_epoch ? op.olh_epoch : now_epoch; if (olh.start_modify(candidate_epoch)) { // promote this version to current if it's a newer epoch, or if it matches the @@ -2049,6 +2061,9 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, return -EINVAL; } + CLS_LOG(20, "%s: op_tag=%s key=%s olh_epoch=%lu", __func__, + op.op_tag.c_str(), op.key.to_string().c_str(), op.olh_epoch); + cls_rgw_obj_key dest_key = op.key; struct rgw_bucket_dir_header header; @@ -2155,7 +2170,7 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, if (!obj.is_delete_marker()) { olh.update_log(CLS_RGW_OLH_OP_REMOVE_INSTANCE, op.op_tag, op.key, false, now_epoch); } else { - olh.update_log(CLS_RGW_OLH_OP_STALE, op.op_tag, op.key, false, now_epoch); + olh.update_log(CLS_RGW_OLH_OP_STALE, op.op_tag, op.key, true, now_epoch); /* this is a delete marker, it's our responsibility to remove its * instance entry */ @@ -2177,7 +2192,7 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, } if (obj.is_delete_marker()) { - olh.update_log(CLS_RGW_OLH_OP_STALE, op.op_tag, op.key, false, now_epoch); + olh.update_log(CLS_RGW_OLH_OP_STALE, op.op_tag, op.key, true, now_epoch); ret = olh.write(header); if (ret < 0) { diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 26b983b8d284..459343f8caf6 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -9416,7 +9416,9 @@ int RGWRados::apply_olh_log(const DoutPrefixProvider *dpp, /* update olh object */ r = rgw_rados_operate(dpp, ref.ioctx, ref.obj.oid, std::move(op), y); if (r < 0) { - ldpp_dout(dpp, 0) << "ERROR: " << __func__ << ": could not apply olh update to oid \"" << ref.obj.oid << "\", r=" << r << dendl; + if (r != -ECANCELED) { + ldpp_dout(dpp, 0) << "ERROR: " << __func__ << ": could not apply olh update to oid \"" << ref.obj.oid << "\", r=" << r << dendl; + } return r; }