| 188 | |
| 189 | template <typename I> |
| 190 | int get_pool_stats(librados::IoCtx& io_ctx, const ConfigProxy& config, |
| 191 | const std::vector<std::string>& image_ids, uint64_t* image_count, |
| 192 | uint64_t* provisioned_bytes, uint64_t* max_provisioned_bytes, |
| 193 | uint64_t* snapshot_count) { |
| 194 | |
| 195 | bool scan_snaps = ((max_provisioned_bytes != nullptr) || |
| 196 | (snapshot_count != nullptr)); |
| 197 | |
| 198 | SimpleThrottle throttle( |
| 199 | config.template get_val<uint64_t>("rbd_concurrent_management_ops"), true); |
| 200 | std::atomic<uint64_t> bytes{0}; |
| 201 | std::atomic<uint64_t> max_bytes{0}; |
| 202 | std::atomic<uint64_t> snaps{0}; |
| 203 | for (auto& image_id : image_ids) { |
| 204 | if (throttle.pending_error()) { |
| 205 | break; |
| 206 | } |
| 207 | |
| 208 | auto req = new ImageStatRequest<I>(io_ctx, throttle, image_id, |
| 209 | scan_snaps, &bytes, &max_bytes, &snaps); |
| 210 | req->send(); |
| 211 | } |
| 212 | |
| 213 | int r = throttle.wait_for_ret(); |
| 214 | if (r < 0) { |
| 215 | return r; |
| 216 | } |
| 217 | |
| 218 | if (image_count != nullptr) { |
| 219 | *image_count = image_ids.size(); |
| 220 | } |
| 221 | if (provisioned_bytes != nullptr) { |
| 222 | *provisioned_bytes = bytes.load(); |
| 223 | } |
| 224 | if (max_provisioned_bytes != nullptr) { |
| 225 | *max_provisioned_bytes = max_bytes.load(); |
| 226 | } |
| 227 | if (snapshot_count != nullptr) { |
| 228 | *snapshot_count = snaps.load(); |
| 229 | } |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | } // anonymous namespace |
| 235 |
no test coverage detected