* Validates an L2ARC log block address to make sure that it can be read * from the provided L2ARC device. */
| 10515 | * from the provided L2ARC device. |
| 10516 | */ |
| 10517 | boolean_t |
| 10518 | l2arc_log_blkptr_valid(l2arc_dev_t *dev, const l2arc_log_blkptr_t *lbp) |
| 10519 | { |
| 10520 | /* L2BLK_GET_PSIZE returns aligned size for log blocks */ |
| 10521 | uint64_t asize = L2BLK_GET_PSIZE((lbp)->lbp_prop); |
| 10522 | uint64_t end = lbp->lbp_daddr + asize - 1; |
| 10523 | uint64_t start = lbp->lbp_payload_start; |
| 10524 | boolean_t evicted = B_FALSE; |
| 10525 | |
| 10526 | /* |
| 10527 | * A log block is valid if all of the following conditions are true: |
| 10528 | * - it fits entirely (including its payload) between l2ad_start and |
| 10529 | * l2ad_end |
| 10530 | * - it has a valid size |
| 10531 | * - neither the log block itself nor part of its payload was evicted |
| 10532 | * by l2arc_evict(): |
| 10533 | * |
| 10534 | * l2ad_hand l2ad_evict |
| 10535 | * | | lbp_daddr |
| 10536 | * | start | | end |
| 10537 | * | | | | | |
| 10538 | * V V V V V |
| 10539 | * l2ad_start ============================================ l2ad_end |
| 10540 | * --------------------------|||| |
| 10541 | * ^ ^ |
| 10542 | * | log block |
| 10543 | * payload |
| 10544 | */ |
| 10545 | |
| 10546 | evicted = |
| 10547 | l2arc_range_check_overlap(start, end, dev->l2ad_hand) || |
| 10548 | l2arc_range_check_overlap(start, end, dev->l2ad_evict) || |
| 10549 | l2arc_range_check_overlap(dev->l2ad_hand, dev->l2ad_evict, start) || |
| 10550 | l2arc_range_check_overlap(dev->l2ad_hand, dev->l2ad_evict, end); |
| 10551 | |
| 10552 | return (start >= dev->l2ad_start && end <= dev->l2ad_end && |
| 10553 | asize > 0 && asize <= sizeof (l2arc_log_blk_phys_t) && |
| 10554 | (!evicted || dev->l2ad_first)); |
| 10555 | } |
| 10556 | |
| 10557 | /* |
| 10558 | * Inserts ARC buffer header `hdr' into the current L2ARC log block on |
no test coverage detected