Skip to content

Commit 3968e96

Browse files
authored
Merge pull request ceph#64272 from linuxbox2/wip-matt-70853
rgwlc: fix removal of delete markers (SAL)
2 parents c1491dc + 8654b1f commit 3968e96

File tree

7 files changed

+39
-15
lines changed

7 files changed

+39
-15
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6921,12 +6921,12 @@ int RGWRados::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx,
69216921
RGWObjStateManifest* sm = nullptr;
69226922
int r = get_obj_state(dpp, rctx, bucket_info, obj, &sm,
69236923
follow_olh, y, assume_noent);
6924-
if (r < 0) {
6925-
return r;
6926-
}
69276924
if (pstate) {
69286925
*pstate = &sm->state;
69296926
}
6927+
if (r < 0) {
6928+
return r;
6929+
}
69306930
if (pmanifest) {
69316931
if (sm->manifest) {
69326932
*pmanifest = &(*sm->manifest);
@@ -9532,6 +9532,8 @@ int RGWRados::follow_olh(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_in
95329532
}
95339533

95349534
if (olh.removed) {
9535+
/* the object is a delete marker */
9536+
state->is_dm = true;
95359537
return -ENOENT;
95369538
}
95379539

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,9 @@ int RadosObject::load_obj_state(const DoutPrefixProvider* dpp, optional_yield y,
27822782

27832783
int ret = store->getRados()->get_obj_state(dpp, rados_ctx, bucket->get_info(), get_obj(), &pstate, &manifest, follow_olh, y);
27842784
if (ret < 0) {
2785+
if (ret == -ENOENT) {
2786+
state.is_dm = pstate->is_dm;
2787+
}
27852788
return ret;
27862789
}
27872790

src/rgw/rgw_lc.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,15 @@ static int remove_expired_obj(const DoutPrefixProvider* dpp,
623623
auto obj = oc.bucket->get_object(obj_key);
624624
ret = obj->load_obj_state(dpp, null_yield, true);
625625
if (ret < 0) {
626-
ldpp_dout(oc.dpp, 0) <<
627-
fmt::format("ERROR: get_obj_state() failed in {} for object k={} error r={}",
628-
__func__, oc.o.key.to_string(), ret) << dendl;
629-
return ret;
626+
/* for delete markers, we expect load_obj_state() to "fail"
627+
* with -ENOENT */
628+
if (! (o.is_delete_marker() &&
629+
(ret == -ENOENT))) {
630+
ldpp_dout(oc.dpp, 0) <<
631+
fmt::format("ERROR: get_obj_state() failed in {} for object k={} error r={}",
632+
__func__, oc.o.key.to_string(), ret) << dendl;
633+
return ret;
634+
}
630635
}
631636

632637
auto have_notify = !event_types.empty();
@@ -1280,13 +1285,14 @@ class LCOpAction_DMExpiration : public LCOpAction {
12801285
<< oc.wq->thr_name() << dendl;
12811286
return false;
12821287
}
1288+
/* don't remove the delete marker if that would expose a non-current
1289+
* version as current */
12831290
if (oc.next_has_same_name(o.key.name)) {
12841291
ldpp_dout(dpp, 20) << __func__ << "(): key=" << o.key
1285-
<< ": next is same object, skipping "
1292+
<< ": dm expiration would expose a non-current version, skipping "
12861293
<< oc.wq->thr_name() << dendl;
12871294
return false;
12881295
}
1289-
12901296
*exp_time = real_clock::now();
12911297

12921298
return true;

src/rgw/rgw_rest.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,20 @@ int RGWHandler_REST::read_permissions(RGWOp* op_obj, optional_yield y)
19311931
return -EINVAL;
19321932
}
19331933

1934-
return do_read_permissions(op_obj, only_bucket, y);
1934+
auto ret = do_read_permissions(op_obj, only_bucket, y);
1935+
switch (s->op) {
1936+
case OP_HEAD:
1937+
case OP_GET:
1938+
if (ret == -ENOENT /* note, access already accounted for */) [[unlikely]] {
1939+
(void) s->object->load_obj_state(s, s->yield, true /* follow_olh */);
1940+
auto tf = s->object->is_delete_marker() ? "true" : "false";
1941+
dump_header(s, "x-amz-delete-marker", tf);
1942+
}
1943+
default:
1944+
break;
1945+
}
1946+
1947+
return ret;
19351948
}
19361949

19371950
void RGWRESTMgr::register_resource(string resource, RGWRESTMgr *mgr)

src/rgw/rgw_sal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,8 @@ class Object {
12231223
virtual void set_compressed() = 0;
12241224
/** Check if this object is compressed */
12251225
virtual bool is_compressed() = 0;
1226+
/** True if this object is a delete marker (newest version is deleted) */
1227+
virtual bool is_delete_marker() = 0;
12261228
/** Check if object is synced */
12271229
virtual bool is_sync_completed(const DoutPrefixProvider* dpp,
12281230
optional_yield y,
@@ -1344,8 +1346,6 @@ class Object {
13441346
virtual void set_hash_source(std::string s) = 0;
13451347
/** Build an Object Identifier string for this object */
13461348
virtual std::string get_oid(void) const = 0;
1347-
/** True if this object is a delete marker (newest version is deleted) */
1348-
virtual bool get_delete_marker(void) = 0;
13491349
/** True if this object is stored in the extra data pool */
13501350
virtual bool get_in_extra_data(void) = 0;
13511351
/** True if this object exists in the store */

src/rgw/rgw_sal_filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ class FilterObject : public Object {
789789
virtual bool is_prefetch_data() override { return next->is_prefetch_data(); }
790790
virtual void set_compressed() override { return next->set_compressed(); }
791791
virtual bool is_compressed() override { return next->is_compressed(); }
792+
virtual bool is_delete_marker() override { return next->is_delete_marker(); }
792793
bool is_sync_completed(const DoutPrefixProvider* dpp, optional_yield y,
793794
const ceph::real_time& obj_mtime) override {
794795
return next->is_sync_completed(dpp, y, obj_mtime);
@@ -863,7 +864,6 @@ class FilterObject : public Object {
863864
virtual std::string get_hash_source(void) override { return next->get_hash_source(); };
864865
virtual void set_hash_source(std::string s) override { return next->set_hash_source(s); };
865866
virtual std::string get_oid(void) const override { return next->get_oid(); };
866-
virtual bool get_delete_marker(void) override { return next->get_delete_marker(); };
867867
virtual bool get_in_extra_data(void) override { return next->get_in_extra_data(); };
868868
virtual bool exists(void) override { return next->exists(); };
869869
virtual void set_in_extra_data(bool i) override { return next->set_in_extra_data(i); };

src/rgw/rgw_sal_store.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct RGWObjState {
2525
bool is_atomic{false};
2626
bool has_attrs{false};
2727
bool exists{false};
28+
bool is_dm{false};
2829
uint64_t size{0}; //< size of raw object
2930
uint64_t accounted_size{0}; //< size before compression, encryption
3031
ceph::real_time mtime;
@@ -279,7 +280,6 @@ class StoreObject : public Object {
279280
protected:
280281
RGWObjState state;
281282
Bucket* bucket = nullptr;
282-
bool delete_marker{false};
283283
jspan_context trace_ctx{false, false};
284284

285285
public:
@@ -299,6 +299,7 @@ class StoreObject : public Object {
299299
virtual bool is_prefetch_data() override { return state.prefetch_data; }
300300
virtual void set_compressed() override { state.compressed = true; }
301301
virtual bool is_compressed() override { return state.compressed; }
302+
virtual bool is_delete_marker() override { return state.is_dm; }
302303
virtual void invalidate() override {
303304
rgw_obj obj = state.obj;
304305
bool is_atomic = state.is_atomic;
@@ -342,7 +343,6 @@ class StoreObject : public Object {
342343
virtual std::string get_hash_source(void) override { return state.obj.index_hash_source; }
343344
virtual void set_hash_source(std::string s) override { state.obj.index_hash_source = s; }
344345
virtual std::string get_oid(void) const override { return state.obj.key.get_oid(); }
345-
virtual bool get_delete_marker(void) override { return delete_marker; }
346346
virtual bool get_in_extra_data(void) override { return state.obj.is_in_extra_data(); }
347347
virtual bool exists(void) override { return state.exists; }
348348
virtual void set_in_extra_data(bool i) override { state.obj.set_in_extra_data(i); }

0 commit comments

Comments
 (0)