}
entries.reserve(trash_image_specs.size());
- for (const auto &entry : trash_image_specs) {
+ for (const auto& [image_id, spec] : trash_image_specs) {
rbd_trash_image_source_t source =
- static_cast<rbd_trash_image_source_t>(entry.second.source);
- entries.push_back({entry.first, entry.second.name, source,
- entry.second.deletion_time.sec(),
- entry.second.deferment_end_time.sec()});
+ static_cast<rbd_trash_image_source_t>(spec.source);
+ entries.push_back({image_id, spec.name, source,
+ spec.deletion_time.sec(),
+ spec.deferment_end_time.sec()});
}
return 0;
<< "using it crashed. Try again after closing/unmapping "
<< "it or waiting 30s for the crashed client to timeout."
<< dendl;
+ } else if (r == -EUCLEAN) {
+ ldout(cct, 5) << "Image is not in the expected state. Ensure moving "
+ << "the image to the trash completed successfully."
+ << dendl;
} else if (r == -EMLINK) {
ldout(cct, 5) << "Remove the image from the group and try again."
<< dendl;
lderr(cct) << "error: deferment time has not expired." << dendl;
return -EPERM;
}
- if (trash_spec.state != cls::rbd::TRASH_IMAGE_STATE_NORMAL &&
- trash_spec.state != cls::rbd::TRASH_IMAGE_STATE_REMOVING) {
+ if (trash_spec.state == cls::rbd::TRASH_IMAGE_STATE_MOVING) {
+ lderr(cct) << "error: image is pending moving to the trash."
+ << dendl;
+ return -EUCLEAN;
+ } else if (trash_spec.state != cls::rbd::TRASH_IMAGE_STATE_NORMAL &&
+ trash_spec.state != cls::rbd::TRASH_IMAGE_STATE_REMOVING) {
lderr(cct) << "error: image is pending restoration." << dendl;
return -EBUSY;
}