| 261 | } |
| 262 | |
| 263 | int queue_list_entries(cls_method_context_t hctx, const cls_queue_list_op& op, cls_queue_list_ret& op_ret, cls_queue_head& head) |
| 264 | { |
| 265 | // If queue is empty, return from here |
| 266 | if ((head.front.offset == head.tail.offset) && (head.front.gen == head.tail.gen)) { |
| 267 | CLS_LOG(20, "INFO: queue_list_entries(): Next offset is %s", head.front.to_str().c_str()); |
| 268 | op_ret.next_marker = head.front.to_str(); |
| 269 | op_ret.is_truncated = false; |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | cls_queue_marker start_marker; |
| 274 | start_marker.from_str(op.start_marker.c_str()); |
| 275 | cls_queue_marker next_marker = {0, 0}; |
| 276 | |
| 277 | uint64_t start_offset = 0, gen = 0; |
| 278 | if (start_marker.offset == 0) { |
| 279 | start_offset = head.front.offset; |
| 280 | gen = head.front.gen; |
| 281 | } else { |
| 282 | start_offset = start_marker.offset; |
| 283 | gen = start_marker.gen; |
| 284 | } |
| 285 | |
| 286 | op_ret.is_truncated = true; |
| 287 | uint64_t contiguous_data_size = 0, size_to_read = 0; |
| 288 | bool wrap_around = false; |
| 289 | |
| 290 | //Calculate length of contiguous data to be read depending on front, tail and start offset |
| 291 | if (head.tail.offset > head.front.offset) { |
| 292 | contiguous_data_size = head.tail.offset - start_offset; |
| 293 | } else if (head.front.offset >= head.tail.offset) { |
| 294 | if (start_offset >= head.front.offset) { |
| 295 | contiguous_data_size = head.queue_size - start_offset; |
| 296 | wrap_around = true; |
| 297 | } else if (start_offset <= head.tail.offset) { |
| 298 | contiguous_data_size = head.tail.offset - start_offset; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | CLS_LOG(10, "INFO: queue_list_entries(): front is: %s, tail is %s", head.front.to_str().c_str(), head.tail.to_str().c_str()); |
| 303 | |
| 304 | bool offset_populated = false, entry_start_processed = false; |
| 305 | uint64_t data_size = 0, num_ops = 0; |
| 306 | uint16_t entry_start = 0; |
| 307 | bufferlist bl; |
| 308 | string last_marker; |
| 309 | do |
| 310 | { |
| 311 | CLS_LOG(10, "INFO: queue_list_entries(): start_offset is %lu", start_offset); |
| 312 | |
| 313 | bufferlist bl_chunk; |
| 314 | //Read chunk size at a time, if it is less than contiguous data size, else read contiguous data size |
| 315 | size_to_read = std::min(contiguous_data_size, large_chunk_size); |
| 316 | CLS_LOG(10, "INFO: queue_list_entries(): size_to_read is %lu", size_to_read); |
| 317 | if (size_to_read == 0) { |
| 318 | next_marker = head.tail; |
| 319 | op_ret.is_truncated = false; |
| 320 | CLS_LOG(20, "INFO: queue_list_entries(): size_to_read is 0, hence breaking out!\n"); |
no test coverage detected