begin overwrite
| 618 | |
| 619 | // begin overwrite |
| 620 | int |
| 621 | CacheVC::openWriteOverwrite(int event, Event *e) |
| 622 | { |
| 623 | cancel_trigger(); |
| 624 | if (event != AIO_EVENT_DONE) { |
| 625 | if (event == EVENT_IMMEDIATE) { |
| 626 | last_collision = nullptr; |
| 627 | } |
| 628 | } else { |
| 629 | Doc *doc = nullptr; |
| 630 | set_io_not_in_progress(); |
| 631 | if (_action.cancelled) { |
| 632 | return openWriteCloseDir(event, e); |
| 633 | } |
| 634 | if (!io.ok()) { |
| 635 | goto Ldone; |
| 636 | } |
| 637 | doc = reinterpret_cast<Doc *>(buf->data()); |
| 638 | if (!(doc->first_key == first_key)) { |
| 639 | goto Lcollision; |
| 640 | } |
| 641 | od->first_dir = dir; |
| 642 | first_buf = buf; |
| 643 | goto Ldone; |
| 644 | } |
| 645 | Lcollision: { |
| 646 | CACHE_TRY_LOCK(lock, stripe->mutex, this_ethread()); |
| 647 | if (!lock.is_locked()) { |
| 648 | VC_LOCK_RETRY_EVENT(); |
| 649 | } |
| 650 | int res = dir_probe(&first_key, stripe, &dir, &last_collision); |
| 651 | if (res > 0) { |
| 652 | if ((res = do_read_call(&first_key)) == EVENT_RETURN) { |
| 653 | goto Lcallreturn; |
| 654 | } |
| 655 | return res; |
| 656 | } |
| 657 | } |
| 658 | Ldone: |
| 659 | SET_HANDLER(&CacheVC::openWriteMain); |
| 660 | return callcont(CACHE_EVENT_OPEN_WRITE); |
| 661 | Lcallreturn: |
| 662 | return handleEvent(AIO_EVENT_DONE, nullptr); // hopefully a tail call |
| 663 | } |
| 664 | |
| 665 | // openWriteStartDone handles vector read (addition of alternates) |
| 666 | // and lock misses |
no test coverage detected