| 441 | } |
| 442 | |
| 443 | int |
| 444 | CacheVC::openReadReadDone(int event, Event *e) |
| 445 | { |
| 446 | Doc *doc = nullptr; |
| 447 | |
| 448 | cancel_trigger(); |
| 449 | if (event == EVENT_IMMEDIATE) { |
| 450 | return EVENT_CONT; |
| 451 | } |
| 452 | set_io_not_in_progress(); |
| 453 | { |
| 454 | CACHE_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding); |
| 455 | if (!lock.is_locked()) { |
| 456 | VC_SCHED_LOCK_RETRY(); |
| 457 | } |
| 458 | if (event == AIO_EVENT_DONE && !io.ok()) { |
| 459 | goto Lerror; |
| 460 | } |
| 461 | if (last_collision && // no missed lock |
| 462 | stripe->dir_valid(&dir)) // object still valid |
| 463 | { |
| 464 | doc = reinterpret_cast<Doc *>(buf->data()); |
| 465 | if (doc->magic != DOC_MAGIC) { |
| 466 | char tmpstring[CRYPTO_HEX_SIZE]; |
| 467 | if (doc->magic == DOC_CORRUPT) { |
| 468 | Warning("Middle: Doc checksum does not match for %s", key.toHexStr(tmpstring)); |
| 469 | } else { |
| 470 | Warning("Middle: Doc magic does not match for %s", key.toHexStr(tmpstring)); |
| 471 | } |
| 472 | goto Lerror; |
| 473 | } |
| 474 | if (doc->key == key) { |
| 475 | goto LreadMain; |
| 476 | } |
| 477 | } |
| 478 | if (last_collision && dir_offset(&dir) != dir_offset(last_collision)) { |
| 479 | last_collision = nullptr; // object has been/is being overwritten |
| 480 | } |
| 481 | if (dir_probe(&key, stripe, &dir, &last_collision)) { |
| 482 | int ret = do_read_call(&key); |
| 483 | if (ret == EVENT_RETURN) { |
| 484 | goto Lcallreturn; |
| 485 | } |
| 486 | return EVENT_CONT; |
| 487 | } else if (write_vc) { |
| 488 | if (writer_done()) { |
| 489 | last_collision = nullptr; |
| 490 | while (dir_probe(&earliest_key, stripe, &dir, &last_collision)) { |
| 491 | if (dir_offset(&dir) == dir_offset(&earliest_dir)) { |
| 492 | DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead complete: %" PRId64, this, first_key.slice32(1), vio.ndone); |
| 493 | doc_len = vio.ndone; |
| 494 | goto Ldone; |
| 495 | } |
| 496 | } |
| 497 | DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead writer aborted: %" PRId64, this, first_key.slice32(1), vio.ndone); |
| 498 | goto Lerror; |
| 499 | } |
| 500 | if (writer_lock_retry < cache_config_read_while_writer_max_retries) { |
nothing calls this directly
no test coverage detected