Skip to content

Commit 6ac085b

Browse files
author
Paul Dagnelie
committed
Implement rebuild support
Signed-off-by: Paul Dagnelie <[email protected]> Sponsored-by: Eshtek, creators of HexOS Sponsored-by: Klara, Inc.
1 parent d64ed22 commit 6ac085b

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

module/zfs/spa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7822,6 +7822,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
78227822

78237823
if (tvd->vdev_ops != &vdev_mirror_ops &&
78247824
tvd->vdev_ops != &vdev_root_ops &&
7825+
tvd->vdev_ops != &vdev_anyraid_ops &&
78257826
tvd->vdev_ops != &vdev_draid_ops) {
78267827
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
78277828
}

module/zfs/vdev_anyraid.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,31 @@ vdev_anyraid_mapped(vdev_t *vd, uint64_t offset)
14851485
return (result);
14861486
}
14871487

1488+
/*
1489+
* Return the maximum asize for a rebuild zio in the provided range
1490+
* given the following constraints. An anyraid chunk may not:
1491+
*
1492+
* - Exceed the maximum allowed block size (SPA_MAXBLOCKSIZE), or
1493+
* - Span anyraid tiles
1494+
*/
1495+
static uint64_t
1496+
vdev_anyraid_rebuild_asize(vdev_t *vd, uint64_t start, uint64_t asize,
1497+
uint64_t max_segment)
1498+
{
1499+
vdev_anyraid_t *var = vd->vdev_tsd;
1500+
ASSERT3P(vd->vdev_ops, ==, &vdev_anyraid_ops);
1501+
1502+
uint64_t psize = MIN(P2ROUNDUP(max_segment, 1 << vd->vdev_ashift),
1503+
SPA_MAXBLOCKSIZE);
1504+
1505+
if (start / var->vd_tile_size !=
1506+
(start + psize) / var->vd_tile_size) {
1507+
psize = P2ROUNDUP(start, var->vd_tile_size) - start;
1508+
}
1509+
1510+
return (MIN(asize, vdev_psize_to_asize(vd, psize)));
1511+
}
1512+
14881513
vdev_ops_t vdev_anyraid_ops = {
14891514
.vdev_op_init = vdev_anyraid_init,
14901515
.vdev_op_fini = vdev_anyraid_fini,
@@ -1502,7 +1527,7 @@ vdev_ops_t vdev_anyraid_ops = {
15021527
.vdev_op_rele = NULL,
15031528
.vdev_op_remap = NULL,
15041529
.vdev_op_xlate = vdev_anyraid_xlate,
1505-
.vdev_op_rebuild_asize = NULL, // TODO do we want to support rebuilds?
1530+
.vdev_op_rebuild_asize = vdev_anyraid_rebuild_asize,
15061531
.vdev_op_metaslab_init = NULL,
15071532
.vdev_op_config_generate = vdev_anyraid_config_generate,
15081533
.vdev_op_nparity = vdev_anyraid_nparity,

module/zfs/vdev_rebuild.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ vdev_rebuild_blkptr_init(blkptr_t *bp, vdev_t *vd, uint64_t start,
525525
{
526526
ASSERT(vd->vdev_ops == &vdev_draid_ops ||
527527
vd->vdev_ops == &vdev_mirror_ops ||
528+
vd->vdev_ops == &vdev_anyraid_ops ||
528529
vd->vdev_ops == &vdev_replacing_ops ||
529530
vd->vdev_ops == &vdev_spare_ops);
530531

0 commit comments

Comments
 (0)