Skip to content

Commit 0daa092

Browse files
authored
Merge pull request ceph#58288 from cbodley/wip-66705
rgw: fix multipart get part when count==1 Reviewed-by: Matt Benjamin <[email protected]> Reviewed-by: Daniel Gryniewicz <[email protected]>
2 parents 2f02bce + 562e0ce commit 0daa092

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
@@ -6650,12 +6650,15 @@ static int get_part_obj_state(const DoutPrefixProvider* dpp, optional_yield y,
66506650
}
66516651
// navigate to the requested part in the manifest
66526652
RGWObjManifest::obj_iterator end = manifest->obj_end(dpp);
6653-
if (end.get_cur_part_id() == 0) { // not multipart
6653+
const int last_part_id = end.get_cur_part_id();
6654+
if (last_part_id == 0) { // not multipart
66546655
ldpp_dout(dpp, 20) << "object does not have a multipart manifest" << dendl;
66556656
return -ERR_INVALID_PART;
66566657
}
66576658
if (parts_count) {
6658-
*parts_count = end.get_cur_part_id() - 1;
6659+
// when a multipart upload only contains a single part, the last part id
6660+
// is off by one. don't let parts_count go to 0
6661+
*parts_count = std::max(1, last_part_id - 1);
66596662
}
66606663
ldpp_dout(dpp, 20) << "seeking to part #" << part_num
66616664
<< " in the object manifest" << dendl;
@@ -6715,7 +6718,7 @@ static int get_part_obj_state(const DoutPrefixProvider* dpp, optional_yield y,
67156718
do {
67166719
++iter;
67176720
gen.create_next(iter.get_ofs() - part_offset);
6718-
} while (iter.get_cur_part_id() == part_num);
6721+
} while (iter != end && iter.get_cur_part_id() == part_num);
67196722

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

0 commit comments

Comments
 (0)