From 6833234fd29646d4130c974c457a8c7ded85239e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 24 Aug 2019 23:41:57 +0800 Subject: [PATCH] rgw: RGWObjManifest::obj_iterator::seek always update locations we should update explicit loc and location even if `ofs >= manifest->obj_size`. there is chance that we are updating an end iterator whose ofs is equal to obj_size. before being updated, the end iterator points to an implicit location, while after being updated, the manifest could be using an explicit location, so we should update the end iterator as well. Fixes: https://tracker.ceph.com/issues/41416 Signed-off-by: Kefu Chai --- src/rgw/rgw_dencoder.cc | 12 ++++++++---- src/rgw/rgw_obj_manifest.h | 4 +--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_dencoder.cc b/src/rgw/rgw_dencoder.cc index 4fef224f33e..461741ce5d9 100644 --- a/src/rgw/rgw_dencoder.cc +++ b/src/rgw/rgw_dencoder.cc @@ -48,11 +48,11 @@ void RGWObjManifest::obj_iterator::seek(uint64_t o) if (explicit_iter != manifest->objs.begin()) { --explicit_iter; } - if (ofs >= manifest->obj_size) { + if (ofs < manifest->obj_size) { + update_explicit_pos(); + } else { ofs = manifest->obj_size; - return; } - update_explicit_pos(); update_location(); return; } @@ -116,7 +116,11 @@ void RGWObjManifest::obj_iterator::seek(uint64_t o) void RGWObjManifest::obj_iterator::update_location() { if (manifest->explicit_objs) { - location = explicit_iter->second.loc; + if (manifest->empty()) { + location = rgw_obj_select{}; + } else { + location = explicit_iter->second.loc; + } return; } diff --git a/src/rgw/rgw_obj_manifest.h b/src/rgw/rgw_obj_manifest.h index 59abaf36abe..942ecb63b6e 100644 --- a/src/rgw/rgw_obj_manifest.h +++ b/src/rgw/rgw_obj_manifest.h @@ -451,9 +451,7 @@ public: : obj_iterator(_m, 0) {} obj_iterator(RGWObjManifest *_m, uint64_t _ofs) : manifest(_m) { - if (!manifest->empty()) { - seek(_ofs); - } + seek(_ofs); } void seek(uint64_t ofs); -- 2.39.5