Skip to content

Commit

Permalink
rgw: fetch_remote_obj() applies olh even if object is current
Browse files Browse the repository at this point in the history
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 <cbodley@redhat.com>
(cherry picked from commit b5ecc4e)
  • Loading branch information
cbodley authored and Prashant D committed Jul 23, 2018
1 parent 12487e1 commit b365b31
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
25 changes: 21 additions & 4 deletions src/rgw/rgw_rados.cc
Expand Up @@ -8168,7 +8168,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;
Expand Down Expand Up @@ -11259,7 +11268,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);
Expand Down Expand Up @@ -11289,6 +11299,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;
}

Expand Down Expand Up @@ -11581,7 +11595,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;

Expand Down Expand Up @@ -11612,7 +11627,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) {
Expand Down
7 changes: 5 additions & 2 deletions src/rgw/rgw_rados.h
Expand Up @@ -3391,7 +3391,9 @@ class RGWRados : public AdminSocketHook
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<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated);
Expand All @@ -3402,7 +3404,8 @@ class RGWRados : public AdminSocketHook
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);

Expand Down

0 comments on commit b365b31

Please sign in to comment.