* Translate a logical range to the first contiguous physical range for the * specified vdev_t. This function is initially called with a leaf vdev and * will walk each parent vdev until it reaches a top-level vdev. Once the * top-level is reached the physical range is initialized and the recursive * function begins to unwind. As it unwinds it calls the parent's vdev * specific translation fun
| 5106 | * specific translation function to do the real conversion. |
| 5107 | */ |
| 5108 | void |
| 5109 | vdev_xlate(vdev_t *vd, const range_seg64_t *logical_rs, |
| 5110 | range_seg64_t *physical_rs, range_seg64_t *remain_rs) |
| 5111 | { |
| 5112 | /* |
| 5113 | * Walk up the vdev tree |
| 5114 | */ |
| 5115 | if (vd != vd->vdev_top) { |
| 5116 | vdev_xlate(vd->vdev_parent, logical_rs, physical_rs, |
| 5117 | remain_rs); |
| 5118 | } else { |
| 5119 | /* |
| 5120 | * We've reached the top-level vdev, initialize the physical |
| 5121 | * range to the logical range and set an empty remaining |
| 5122 | * range then start to unwind. |
| 5123 | */ |
| 5124 | physical_rs->rs_start = logical_rs->rs_start; |
| 5125 | physical_rs->rs_end = logical_rs->rs_end; |
| 5126 | |
| 5127 | remain_rs->rs_start = logical_rs->rs_start; |
| 5128 | remain_rs->rs_end = logical_rs->rs_start; |
| 5129 | |
| 5130 | return; |
| 5131 | } |
| 5132 | |
| 5133 | vdev_t *pvd = vd->vdev_parent; |
| 5134 | ASSERT3P(pvd, !=, NULL); |
| 5135 | ASSERT3P(pvd->vdev_ops->vdev_op_xlate, !=, NULL); |
| 5136 | |
| 5137 | /* |
| 5138 | * As this recursive function unwinds, translate the logical |
| 5139 | * range into its physical and any remaining components by calling |
| 5140 | * the vdev specific translate function. |
| 5141 | */ |
| 5142 | range_seg64_t intermediate = { 0 }; |
| 5143 | pvd->vdev_ops->vdev_op_xlate(vd, physical_rs, &intermediate, remain_rs); |
| 5144 | |
| 5145 | physical_rs->rs_start = intermediate.rs_start; |
| 5146 | physical_rs->rs_end = intermediate.rs_end; |
| 5147 | } |
| 5148 | |
| 5149 | void |
| 5150 | vdev_xlate_walk(vdev_t *vd, const range_seg64_t *logical_rs, |
no outgoing calls
no test coverage detected