Skip to content

Commit 562e0ce

Browse files
committed
rgw: fix multipart get part when count==1
the RGWObjManifest for multipart uploads is subtly different when there's only a single part. in that case, get_cur_part_id() for the final rule returns 1 where it otherwise returns (parts_count + 1) this caused two problems: * we returned a parts_count of 0 instead 1, and * the do-while loop got stuck in an infinite loop expecting the last rule's part id to be higher than the requested part id Fixes: https://tracker.ceph.com/issues/66705 Signed-off-by: Casey Bodley <cbodley@redhat.com>
1 parent bdbef73 commit 562e0ce

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6639,12 +6639,15 @@ static int get_part_obj_state(const DoutPrefixProvider* dpp, optional_yield y,
66396639
}
66406640
// navigate to the requested part in the manifest
66416641
RGWObjManifest::obj_iterator end = manifest->obj_end(dpp);
6642-
if (end.get_cur_part_id() == 0) { // not multipart
6642+
const int last_part_id = end.get_cur_part_id();
6643+
if (last_part_id == 0) { // not multipart
66436644
ldpp_dout(dpp, 20) << "object does not have a multipart manifest" << dendl;
66446645
return -ERR_INVALID_PART;
66456646
}
66466647
if (parts_count) {
6647-
*parts_count = end.get_cur_part_id() - 1;
6648+
// when a multipart upload only contains a single part, the last part id
6649+
// is off by one. don't let parts_count go to 0
6650+
*parts_count = std::max(1, last_part_id - 1);
66486651
}
66496652
ldpp_dout(dpp, 20) << "seeking to part #" << part_num
66506653
<< " in the object manifest" << dendl;
@@ -6704,7 +6707,7 @@ static int get_part_obj_state(const DoutPrefixProvider* dpp, optional_yield y,
67046707
do {
67056708
++iter;
67066709
gen.create_next(iter.get_ofs() - part_offset);
6707-
} while (iter.get_cur_part_id() == part_num);
6710+
} while (iter != end && iter.get_cur_part_id() == part_num);
67086711

67096712
// update the object size
67106713
sm->state.size = part_manifest.get_obj_size();

0 commit comments

Comments
 (0)