| 606 | } |
| 607 | |
| 608 | Status BlockCache::remove(HashedKey hk) { |
| 609 | auto start = getSteadyClock(); |
| 610 | SCOPE_EXIT { |
| 611 | removeLatency_.trackValue(toMicros(getSteadyClock() - start).count()); |
| 612 | }; |
| 613 | removeCount_.inc(); |
| 614 | |
| 615 | Buffer value; |
| 616 | if ((itemDestructorEnabled_ && destructorCb_) || preciseRemove_) { |
| 617 | uint32_t unused = 0; |
| 618 | Status status = lookup(hk, value, unused); |
| 619 | |
| 620 | if (status != Status::Ok) { |
| 621 | // device error, or region reclaimed, or item not found |
| 622 | value.reset(); |
| 623 | if (status == Status::Retry) { |
| 624 | return status; |
| 625 | } else if (status != Status::NotFound) { |
| 626 | lookupForItemDestructorErrorCount_.inc(); |
| 627 | if (status == Status::ChecksumError) { |
| 628 | // checksum error doesn't need to be treated as a whole device's bad |
| 629 | // status |
| 630 | return status; |
| 631 | } else { |
| 632 | // still fail after retry, return a BadState to disable navy |
| 633 | return Status::BadState; |
| 634 | } |
| 635 | } else { |
| 636 | // NotFound |
| 637 | removeAttemptCollisions_.inc(); |
| 638 | if (preciseRemove_) { |
| 639 | return status; |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | return removeImpl(hk, value.view()); |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * Callback for region eviction. |