Skip to content

Commit 45db16e

Browse files
authored
Merge pull request ceph#58133 from TRYTOBE8TME/wip-rgw-null-ver-final
src/rgw: Deleting an object with null version fix
2 parents cf51417 + 92002be commit 45db16e

File tree

13 files changed

+105
-29
lines changed

13 files changed

+105
-29
lines changed

src/cls/rgw/cls_rgw.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,6 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in,
18871887
}
18881888

18891889
cls_rgw_obj_key dest_key = op.key;
1890-
if (dest_key.instance == "null") {
1891-
dest_key.instance.clear();
1892-
}
18931890

18941891
BIVerObjEntry obj(hctx, dest_key);
18951892
BIOLHEntry olh(hctx, dest_key);

src/cls/rgw/cls_rgw_client.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,11 @@ void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op, const cls_rgw_o
535535

536536
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid,
537537
const cls_rgw_obj_key& key, const string& op_tag,
538-
const string& olh_tag, uint64_t olh_epoch, bool log_op, const rgw_zone_set& zones_trace)
538+
const string& olh_tag, uint64_t olh_epoch, bool log_op,
539+
uint16_t bilog_flags, const rgw_zone_set& zones_trace)
539540
{
540541
librados::ObjectWriteOperation op;
541-
cls_rgw_bucket_unlink_instance(op, key, op_tag, olh_tag, olh_epoch, log_op, zones_trace);
542+
cls_rgw_bucket_unlink_instance(op, key, op_tag, olh_tag, olh_epoch, log_op, bilog_flags, zones_trace);
542543
int r = io_ctx.operate(oid, &op);
543544
if (r < 0)
544545
return r;
@@ -548,7 +549,8 @@ int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid,
548549

549550
void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op,
550551
const cls_rgw_obj_key& key, const string& op_tag,
551-
const string& olh_tag, uint64_t olh_epoch, bool log_op, const rgw_zone_set& zones_trace)
552+
const string& olh_tag, uint64_t olh_epoch, bool log_op,
553+
uint16_t bilog_flags, const rgw_zone_set& zones_trace)
552554
{
553555
bufferlist in, out;
554556
rgw_cls_unlink_instance_op call;
@@ -558,6 +560,7 @@ void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op,
558560
call.olh_tag = olh_tag;
559561
call.log_op = log_op;
560562
call.zones_trace = zones_trace;
563+
call.bilog_flags = bilog_flags;
561564
encode(call, in);
562565
op.exec(RGW_CLASS, RGW_BUCKET_UNLINK_INSTANCE, in);
563566
}

src/cls/rgw/cls_rgw_client.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op,
381381
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, const rgw_zone_set& zones_trace);
382382
void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op,
383383
const cls_rgw_obj_key& key, const std::string& op_tag,
384-
const std::string& olh_tag, uint64_t olh_epoch, bool log_op, const rgw_zone_set& zones_trace);
384+
const std::string& olh_tag, uint64_t olh_epoch, bool log_op, uint16_t bilog_flags, const rgw_zone_set& zones_trace);
385385
void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const std::string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret);
386386
void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const std::string& olh_tag);
387387
void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const std::string& olh_tag);
@@ -395,7 +395,8 @@ int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const std::string& oid,
395395
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, const rgw_zone_set& zones_trace);
396396
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const std::string& oid,
397397
const cls_rgw_obj_key& key, const std::string& op_tag,
398-
const std::string& olh_tag, uint64_t olh_epoch, bool log_op, const rgw_zone_set& zones_trace);
398+
const std::string& olh_tag, uint64_t olh_epoch, bool log_op,
399+
uint16_t bilog_flags, const rgw_zone_set& zones_trace);
399400
int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, std::string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
400401
const std::string& olh_tag, rgw_cls_read_olh_log_ret& log_ret);
401402
int cls_rgw_clear_olh(librados::IoCtx& io_ctx, std::string& oid, const cls_rgw_obj_key& olh, const std::string& olh_tag);

src/cls/rgw/cls_rgw_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ inline std::ostream& operator<<(std::ostream& out, RGWModifyOp op) {
111111

112112
enum RGWBILogFlags {
113113
RGW_BILOG_FLAG_VERSIONED_OP = 0x1,
114+
RGW_BILOG_NULL_VERSION = 0X2,
114115
};
115116

116117
enum RGWCheckMTimeType {
@@ -660,6 +661,11 @@ struct rgw_bi_log_entry {
660661
bool is_versioned() {
661662
return ((bilog_flags & RGW_BILOG_FLAG_VERSIONED_OP) != 0);
662663
}
664+
665+
bool is_null_verid() {
666+
return ((bilog_flags & RGW_BILOG_NULL_VERSION) != 0);
667+
}
668+
663669
};
664670
WRITE_CLASS_ENCODER(rgw_bi_log_entry)
665671

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ bool rgw_bucket_object_check_filter(const std::string& oid)
146146

147147
int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, rgw::sal::Bucket* bucket, rgw_obj_key& key, optional_yield y)
148148
{
149-
if (key.instance.empty()) {
150-
key.instance = "null";
151-
}
152149

153150
std::unique_ptr<rgw::sal::Object> object = bucket->get_object(key);
154151

src/rgw/driver/rados/rgw_cr_rados.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,15 @@ int RGWAsyncRemoveObj::_send_request(const DoutPrefixProvider *dpp)
936936
if (versioned) {
937937
del_op->params.versioning_status = BUCKET_VERSIONED;
938938
}
939+
939940
del_op->params.olh_epoch = versioned_epoch;
940941
del_op->params.marker_version_id = marker_version_id;
941942
del_op->params.obj_owner.id = rgw_user(owner);
942943
del_op->params.obj_owner.display_name = owner_display_name;
943944
del_op->params.mtime = timestamp;
944945
del_op->params.high_precision_time = true;
945946
del_op->params.zones_trace = &zones_trace;
947+
del_op->params.null_verid = false;
946948

947949
ret = del_op->delete_obj(dpp, null_yield, true);
948950
if (ret < 0) {

src/rgw/driver/rados/rgw_data_sync.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4391,6 +4391,7 @@ class RGWBucketSyncSingleEntryCR : public RGWCoroutine {
43914391

43924392
rgw_obj_key key;
43934393
bool versioned;
4394+
bool null_verid;
43944395
std::optional<uint64_t> versioned_epoch;
43954396
rgw_bucket_entry_owner owner;
43964397
real_time timestamp;
@@ -4418,6 +4419,7 @@ class RGWBucketSyncSingleEntryCR : public RGWCoroutine {
44184419
RGWBucketSyncSingleEntryCR(RGWDataSyncCtx *_sc,
44194420
rgw_bucket_sync_pipe& _sync_pipe,
44204421
const rgw_obj_key& _key, bool _versioned,
4422+
bool _null_verid,
44214423
std::optional<uint64_t> _versioned_epoch,
44224424
real_time& _timestamp,
44234425
const rgw_bucket_entry_owner& _owner,
@@ -4426,7 +4428,8 @@ class RGWBucketSyncSingleEntryCR : public RGWCoroutine {
44264428
RGWSyncTraceNodeRef& _tn_parent) : RGWCoroutine(_sc->cct),
44274429
sc(_sc), sync_env(_sc->env),
44284430
sync_pipe(_sync_pipe), bs(_sync_pipe.info.source_bs),
4429-
key(_key), versioned(_versioned), versioned_epoch(_versioned_epoch),
4431+
key(_key), versioned(_versioned),
4432+
null_verid(_null_verid),versioned_epoch(_versioned_epoch),
44304433
owner(_owner),
44314434
timestamp(_timestamp), op(_op),
44324435
op_state(_op_state),
@@ -4504,6 +4507,9 @@ class RGWBucketSyncSingleEntryCR : public RGWCoroutine {
45044507
if (op == CLS_RGW_OP_UNLINK_INSTANCE) {
45054508
versioned = true;
45064509
}
4510+
if (null_verid) {
4511+
key.instance = "null";
4512+
}
45074513
tn->log(10, SSTR("removing obj: " << sc->source_zone << "/" << bs.bucket << "/" << key << "[" << versioned_epoch.value_or(0) << "]"));
45084514
call(data_sync_module->remove_object(dpp, sc, sync_pipe, key, timestamp, versioned, versioned_epoch.value_or(0), &zones_trace));
45094515
// our copy of the object is more recent, continue as if it succeeded
@@ -4714,6 +4720,7 @@ int RGWBucketFullSyncCR::operate(const DoutPrefixProvider *dpp)
47144720
using SyncCR = RGWBucketSyncSingleEntryCR<rgw_obj_key, rgw_obj_key>;
47154721
yield spawn(new SyncCR(sc, sync_pipe, entry->key,
47164722
false, /* versioned, only matters for object removal */
4723+
false,
47174724
entry->versioned_epoch, entry->mtime,
47184725
entry->owner, entry->get_modify_op(), CLS_RGW_STATE_COMPLETE,
47194726
entry->key, &marker_tracker, zones_trace, tn),
@@ -5122,7 +5129,7 @@ int RGWBucketShardIncrementalSyncCR::operate(const DoutPrefixProvider *dpp)
51225129
tn->log(20, SSTR("entry->timestamp=" << entry->timestamp));
51235130
using SyncCR = RGWBucketSyncSingleEntryCR<string, rgw_obj_key>;
51245131
spawn(new SyncCR(sc, sync_pipe, key,
5125-
entry->is_versioned(), versioned_epoch,
5132+
entry->is_versioned(), entry->is_null_verid(), versioned_epoch,
51265133
entry->timestamp, owner, entry->op, entry->state,
51275134
cur_id, &marker_tracker, entry->zones_trace, tn),
51285135
false);

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx,
30553055

30563056
/* Need to remove the archived copy. */
30573057
ret = delete_obj(dpp, obj_ctx, archive_binfo, archive_obj,
3058-
archive_binfo.versioning_status(), y);
3058+
archive_binfo.versioning_status(), y, false);
30593059

30603060
return ret;
30613061
};
@@ -5738,7 +5738,7 @@ int RGWRados::Object::Delete::delete_obj(optional_yield y, const DoutPrefixProvi
57385738
}
57395739
result.delete_marker = dirent.is_delete_marker();
57405740
r = store->unlink_obj_instance(dpp, target->get_ctx(), target->get_bucket_info(), obj, params.olh_epoch,
5741-
y, params.zones_trace, add_log);
5741+
y, params.bilog_flags, params.null_verid, params.zones_trace, add_log);
57425742
if (r < 0) {
57435743
return r;
57445744
}
@@ -5834,6 +5834,11 @@ int RGWRados::Object::Delete::delete_obj(optional_yield y, const DoutPrefixProvi
58345834
index_op.set_zones_trace(params.zones_trace);
58355835
index_op.set_bilog_flags(params.bilog_flags);
58365836

5837+
if (params.null_verid) {
5838+
index_op.set_bilog_flags(params.bilog_flags | RGW_BILOG_NULL_VERSION);
5839+
}
5840+
5841+
58375842
r = index_op.prepare(dpp, CLS_RGW_OP_DEL, &state->write_tag, y, log_op);
58385843
if (r < 0)
58395844
return r;
@@ -5885,6 +5890,7 @@ int RGWRados::delete_obj(const DoutPrefixProvider *dpp,
58855890
const RGWBucketInfo& bucket_info,
58865891
const rgw_obj& obj,
58875892
int versioning_status, optional_yield y,// versioning flags defined in enum RGWBucketFlags
5893+
bool null_verid,
58885894
uint16_t bilog_flags,
58895895
const real_time& expiration_time,
58905896
rgw_zone_set *zones_trace,
@@ -5898,6 +5904,7 @@ int RGWRados::delete_obj(const DoutPrefixProvider *dpp,
58985904
del_op.params.bilog_flags = bilog_flags;
58995905
del_op.params.expiration_time = expiration_time;
59005906
del_op.params.zones_trace = zones_trace;
5907+
del_op.params.null_verid = null_verid;
59015908

59025909
return del_op.delete_obj(y, dpp, log_op ? rgw::sal::FLAG_LOG_OP : 0);
59035910
}
@@ -7841,6 +7848,7 @@ int RGWRados::bucket_index_unlink_instance(const DoutPrefixProvider *dpp,
78417848
const rgw_obj& obj_instance,
78427849
const string& op_tag, const string& olh_tag,
78437850
uint64_t olh_epoch, optional_yield y,
7851+
uint16_t bilog_flags,
78447852
rgw_zone_set *_zones_trace, bool log_op)
78457853
{
78467854
rgw_rados_ref ref;
@@ -7865,7 +7873,7 @@ int RGWRados::bucket_index_unlink_instance(const DoutPrefixProvider *dpp,
78657873
op.assert_exists(); // bucket index shard must exist
78667874
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
78677875
cls_rgw_bucket_unlink_instance(op, key, op_tag,
7868-
olh_tag, olh_epoch, log_op, zones_trace);
7876+
olh_tag, olh_epoch, log_op, bilog_flags, zones_trace);
78697877
return rgw_rados_operate(dpp, ref.ioctx, ref.obj.oid, &op, y);
78707878
}, y);
78717879
if (r < 0) {
@@ -8068,8 +8076,10 @@ int RGWRados::apply_olh_log(const DoutPrefixProvider *dpp,
80688076
bufferlist& olh_tag,
80698077
std::map<uint64_t, std::vector<rgw_bucket_olh_log_entry> >& log,
80708078
uint64_t *plast_ver,
8071-
optional_yield y, rgw_zone_set* zones_trace,
8072-
bool log_op)
8079+
optional_yield y,
8080+
bool null_verid,
8081+
rgw_zone_set* zones_trace,
8082+
bool log_op)
80738083
{
80748084
if (log.empty()) {
80758085
return 0;
@@ -8182,7 +8192,7 @@ int RGWRados::apply_olh_log(const DoutPrefixProvider *dpp,
81828192
liter != remove_instances.end(); ++liter) {
81838193
cls_rgw_obj_key& key = *liter;
81848194
rgw_obj obj_instance(bucket, key);
8185-
int ret = delete_obj(dpp, obj_ctx, bucket_info, obj_instance, 0, y, RGW_BILOG_FLAG_VERSIONED_OP, ceph::real_time(), zones_trace, log_op);
8195+
int ret = delete_obj(dpp, obj_ctx, bucket_info, obj_instance, 0, y, null_verid, RGW_BILOG_FLAG_VERSIONED_OP, ceph::real_time(), zones_trace, log_op);
81868196
if (ret < 0 && ret != -ENOENT) {
81878197
ldpp_dout(dpp, 0) << "ERROR: delete_obj() returned " << ret << " obj_instance=" << obj_instance << dendl;
81888198
return ret;
@@ -8286,7 +8296,7 @@ int RGWRados::clear_olh(const DoutPrefixProvider *dpp,
82868296
/*
82878297
* read olh log and apply it
82888298
*/
8289-
int RGWRados::update_olh(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, const rgw_obj& obj, optional_yield y, rgw_zone_set *zones_trace, bool log_op)
8299+
int RGWRados::update_olh(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, const rgw_obj& obj, optional_yield y, rgw_zone_set *zones_trace, bool null_verid, bool log_op)
82908300
{
82918301
map<uint64_t, vector<rgw_bucket_olh_log_entry> > log;
82928302
bool is_truncated;
@@ -8297,7 +8307,7 @@ int RGWRados::update_olh(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, R
82978307
if (ret < 0) {
82988308
return ret;
82998309
}
8300-
ret = apply_olh_log(dpp, obj_ctx, *state, bucket_info, obj, state->olh_tag, log, &ver_marker, y, zones_trace, log_op);
8310+
ret = apply_olh_log(dpp, obj_ctx, *state, bucket_info, obj, state->olh_tag, log, &ver_marker, y, null_verid, zones_trace, log_op);
83018311
if (ret < 0) {
83028312
return ret;
83038313
}
@@ -8399,7 +8409,7 @@ int RGWRados::set_olh(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx,
83998409
}
84008410

84018411
int RGWRados::unlink_obj_instance(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj,
8402-
uint64_t olh_epoch, optional_yield y, rgw_zone_set *zones_trace, bool log_op)
8412+
uint64_t olh_epoch, optional_yield y, uint16_t bilog_flags, bool null_verid, rgw_zone_set *zones_trace, bool log_op)
84038413
{
84048414
string op_tag;
84058415

@@ -8438,7 +8448,13 @@ int RGWRados::unlink_obj_instance(const DoutPrefixProvider *dpp, RGWObjectCtx& o
84388448
std::this_thread::sleep_for(cct->_conf->rgw_debug_inject_latency_bi_unlink * std::chrono::seconds{1});
84398449
}
84408450

8441-
ret = bucket_index_unlink_instance(dpp, bucket_info, target_obj, op_tag, olh_tag, olh_epoch, y, zones_trace, log_op);
8451+
if (null_verid) {
8452+
bilog_flags = bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP | RGW_BILOG_NULL_VERSION;
8453+
} else {
8454+
bilog_flags = bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP;
8455+
}
8456+
8457+
ret = bucket_index_unlink_instance(dpp, bucket_info, target_obj, op_tag, olh_tag, olh_epoch, y, bilog_flags, zones_trace, log_op);
84428458
if (ret < 0) {
84438459
olh_cancel_modification(dpp, bucket_info, *state, olh_obj, op_tag, y);
84448460
ldpp_dout(dpp, 20) << "bucket_index_unlink_instance() target_obj=" << target_obj << " returned " << ret << dendl;
@@ -8448,7 +8464,7 @@ int RGWRados::unlink_obj_instance(const DoutPrefixProvider *dpp, RGWObjectCtx& o
84488464
// it's possible that the pending xattr from this op prevented the olh
84498465
// object from being cleaned by another thread that was deleting the last
84508466
// existing version. We invoke a best-effort update_olh here to handle this case.
8451-
int r = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj, y, zones_trace, log_op);
8467+
int r = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj, y, zones_trace, null_verid, log_op);
84528468
if (r < 0 && r != -ECANCELED) {
84538469
ldpp_dout(dpp, 20) << "update_olh() target_obj=" << olh_obj << " returned " << r << dendl;
84548470
}
@@ -8462,7 +8478,7 @@ int RGWRados::unlink_obj_instance(const DoutPrefixProvider *dpp, RGWObjectCtx& o
84628478
return -EIO;
84638479
}
84648480

8465-
ret = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj, y, zones_trace, log_op);
8481+
ret = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj, y, zones_trace, null_verid, log_op);
84668482
if (ret == -ECANCELED) { /* already did what we needed, no need to retry, raced with another user */
84678483
return 0;
84688484
}

0 commit comments

Comments
 (0)