Deleted Added
full compact
vdev_raidz.c (332525) vdev_raidz.c (339034)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 2570 unchanged lines hidden (view full) ---

2579 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2580 VDEV_AUX_NO_REPLICAS);
2581 else if (degraded + faulted != 0)
2582 vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED, VDEV_AUX_NONE);
2583 else
2584 vdev_set_state(vd, B_FALSE, VDEV_STATE_HEALTHY, VDEV_AUX_NONE);
2585}
2586
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 2570 unchanged lines hidden (view full) ---

2579 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
2580 VDEV_AUX_NO_REPLICAS);
2581 else if (degraded + faulted != 0)
2582 vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED, VDEV_AUX_NONE);
2583 else
2584 vdev_set_state(vd, B_FALSE, VDEV_STATE_HEALTHY, VDEV_AUX_NONE);
2585}
2586
2587/*
2588 * Determine if any portion of the provided block resides on a child vdev
2589 * with a dirty DTL and therefore needs to be resilvered. The function
2590 * assumes that at least one DTL is dirty which imples that full stripe
2591 * width blocks must be resilvered.
2592 */
2593static boolean_t
2594vdev_raidz_need_resilver(vdev_t *vd, uint64_t offset, size_t psize)
2595{
2596 uint64_t dcols = vd->vdev_children;
2597 uint64_t nparity = vd->vdev_nparity;
2598 uint64_t ashift = vd->vdev_top->vdev_ashift;
2599 /* The starting RAIDZ (parent) vdev sector of the block. */
2600 uint64_t b = offset >> ashift;
2601 /* The zio's size in units of the vdev's minimum sector size. */
2602 uint64_t s = ((psize - 1) >> ashift) + 1;
2603 /* The first column for this stripe. */
2604 uint64_t f = b % dcols;
2605
2606 if (s + nparity >= dcols)
2607 return (B_TRUE);
2608
2609 for (uint64_t c = 0; c < s + nparity; c++) {
2610 uint64_t devidx = (f + c) % dcols;
2611 vdev_t *cvd = vd->vdev_child[devidx];
2612
2613 /*
2614 * dsl_scan_need_resilver() already checked vd with
2615 * vdev_dtl_contains(). So here just check cvd with
2616 * vdev_dtl_empty(), cheaper and a good approximation.
2617 */
2618 if (!vdev_dtl_empty(cvd, DTL_PARTIAL))
2619 return (B_TRUE);
2620 }
2621
2622 return (B_FALSE);
2623}
2624
2587vdev_ops_t vdev_raidz_ops = {
2588 vdev_raidz_open,
2589 vdev_raidz_close,
2590 vdev_raidz_asize,
2591 vdev_raidz_io_start,
2592 vdev_raidz_io_done,
2593 vdev_raidz_state_change,
2625vdev_ops_t vdev_raidz_ops = {
2626 vdev_raidz_open,
2627 vdev_raidz_close,
2628 vdev_raidz_asize,
2629 vdev_raidz_io_start,
2630 vdev_raidz_io_done,
2631 vdev_raidz_state_change,
2632 vdev_raidz_need_resilver,
2594 NULL,
2595 NULL,
2596 NULL,
2597 VDEV_TYPE_RAIDZ, /* name of this vdev type */
2598 B_FALSE /* not a leaf vdev */
2599};
2633 NULL,
2634 NULL,
2635 NULL,
2636 VDEV_TYPE_RAIDZ, /* name of this vdev type */
2637 B_FALSE /* not a leaf vdev */
2638};