From b5ecc4eaaaaa4f9950ad934a015255171abeb01e Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 1 Jun 2018 09:11:43 -0400 Subject: [PATCH] rgw: fetch_remote_obj() applies olh even if object is current even if we already have the latest version of an object, it may have synced without a valid olh epoch. so we still need to apply its olh modifications with this epoch. this change also has to be added to the data changes log Signed-off-by: Casey Bodley --- src/rgw/rgw_rados.cc | 25 +++++++++++++++++++++---- src/rgw/rgw_rados.h | 7 +++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 614abdffd0cfc..7f14029b21615 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8213,7 +8213,16 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, return 0; set_err_state: if (copy_if_newer && ret == -ERR_NOT_MODIFIED) { - ret = 0; + // we may have already fetched during sync of OP_ADD, but were waiting + // for OP_LINK_OLH to call set_olh() with a real olh_epoch + if (olh_epoch && *olh_epoch > 0) { + constexpr bool log_data_change = true; + ret = set_olh(obj_ctx, dest_bucket_info, dest_obj, false, nullptr, + *olh_epoch, real_time(), false, zones_trace, log_data_change); + } else { + // we already have the latest copy + ret = 0; + } } if (opstate) { RGWOpState::OpState state; @@ -11304,7 +11313,8 @@ int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjStat const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, - real_time unmod_since, bool high_precision_time, rgw_zone_set *_zones_trace) + real_time unmod_since, bool high_precision_time, + rgw_zone_set *_zones_trace, bool log_data_change) { rgw_rados_ref ref; int r = get_obj_head_ref(bucket_info, obj_instance, &ref); @@ -11335,6 +11345,10 @@ int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjStat return r; } + if (log_data_change && bucket_info.datasync_flag_enabled()) { + data_log->add_entry(bs.bucket, bs.shard_id); + } + return 0; } @@ -11627,7 +11641,8 @@ int RGWRados::update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const RGWBuc } int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta, - uint64_t olh_epoch, real_time unmod_since, bool high_precision_time, rgw_zone_set *zones_trace) + uint64_t olh_epoch, real_time unmod_since, bool high_precision_time, + rgw_zone_set *zones_trace, bool log_data_change) { string op_tag; @@ -11658,7 +11673,9 @@ int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const r } return ret; } - ret = bucket_index_link_olh(bucket_info, *state, target_obj, delete_marker, op_tag, meta, olh_epoch, unmod_since, high_precision_time, zones_trace); + ret = bucket_index_link_olh(bucket_info, *state, target_obj, delete_marker, + op_tag, meta, olh_epoch, unmod_since, high_precision_time, + zones_trace, log_data_change); if (ret < 0) { ldout(cct, 20) << "bucket_index_link_olh() target_obj=" << target_obj << " delete_marker=" << (int)delete_marker << " returned " << ret << dendl; if (ret == -ECANCELED) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 9d8a7bae593d8..3ef1e43326d82 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3389,7 +3389,9 @@ public: const rgw_obj& obj_instance, bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, - ceph::real_time unmod_since, bool high_precision_time, rgw_zone_set *zones_trace = nullptr); + ceph::real_time unmod_since, bool high_precision_time, + rgw_zone_set *zones_trace = nullptr, + bool log_data_change = false); int bucket_index_unlink_instance(const RGWBucketInfo& bucket_info, const rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch, rgw_zone_set *zones_trace = nullptr); int bucket_index_read_olh_log(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver_marker, map > *log, bool *is_truncated); @@ -3400,7 +3402,8 @@ public: uint64_t *plast_ver, rgw_zone_set *zones_trace = nullptr); int update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const RGWBucketInfo& bucket_info, const rgw_obj& obj, rgw_zone_set *zones_trace = nullptr); int set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta, - uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, rgw_zone_set *zones_trace = nullptr); + uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, + rgw_zone_set *zones_trace = nullptr, bool log_data_change = false); int unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj, uint64_t olh_epoch, rgw_zone_set *zones_trace = nullptr); -- 2.39.5