MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_raidz_need_resilver

Function vdev_raidz_need_resilver

freebsd/contrib/openzfs/module/zfs/vdev_raidz.c:2573–2611  ·  view source on GitHub ↗

* Determine if any portion of the provided block resides on a child vdev * with a dirty DTL and therefore needs to be resilvered. The function * assumes that at least one DTL is dirty which implies that full stripe * width blocks must be resilvered. */

Source from the content-addressed store, hash-verified

2571 * width blocks must be resilvered.
2572 */
2573static boolean_t
2574vdev_raidz_need_resilver(vdev_t *vd, const dva_t *dva, size_t psize,
2575 uint64_t phys_birth)
2576{
2577 vdev_raidz_t *vdrz = vd->vdev_tsd;
2578 uint64_t dcols = vd->vdev_children;
2579 uint64_t nparity = vdrz->vd_nparity;
2580 uint64_t ashift = vd->vdev_top->vdev_ashift;
2581 /* The starting RAIDZ (parent) vdev sector of the block. */
2582 uint64_t b = DVA_GET_OFFSET(dva) >> ashift;
2583 /* The zio's size in units of the vdev's minimum sector size. */
2584 uint64_t s = ((psize - 1) >> ashift) + 1;
2585 /* The first column for this stripe. */
2586 uint64_t f = b % dcols;
2587
2588 /* Unreachable by sequential resilver. */
2589 ASSERT3U(phys_birth, !=, TXG_UNKNOWN);
2590
2591 if (!vdev_dtl_contains(vd, DTL_PARTIAL, phys_birth, 1))
2592 return (B_FALSE);
2593
2594 if (s + nparity >= dcols)
2595 return (B_TRUE);
2596
2597 for (uint64_t c = 0; c < s + nparity; c++) {
2598 uint64_t devidx = (f + c) % dcols;
2599 vdev_t *cvd = vd->vdev_child[devidx];
2600
2601 /*
2602 * dsl_scan_need_resilver() already checked vd with
2603 * vdev_dtl_contains(). So here just check cvd with
2604 * vdev_dtl_empty(), cheaper and a good approximation.
2605 */
2606 if (!vdev_dtl_empty(cvd, DTL_PARTIAL))
2607 return (B_TRUE);
2608 }
2609
2610 return (B_FALSE);
2611}
2612
2613static void
2614vdev_raidz_xlate(vdev_t *cvd, const range_seg64_t *logical_rs,

Callers

nothing calls this directly

Calls 2

vdev_dtl_containsFunction · 0.85
vdev_dtl_emptyFunction · 0.85

Tested by

no test coverage detected