From: Casey Bodley Date: Fri, 1 Jun 2018 13:11:43 +0000 (-0400) Subject: rgw: fetch_remote_obj() applies olh even if object is current X-Git-Tag: v12.2.9~85^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=20e883b9a1545c43e892263e0e428ece3bc42e93;p=ceph.git 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 (cherry picked from commit b5ecc4eaaaaa4f9950ad934a015255171abeb01e) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c2265a2035c8..431a1b01a3a7 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8120,7 +8120,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; @@ -11219,7 +11228,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); @@ -11249,6 +11259,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; } @@ -11541,7 +11555,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; @@ -11572,7 +11587,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 e2ae513a313a..9b4d052c3e77 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3360,7 +3360,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); @@ -3371,7 +3373,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);