Skip to content

Commit 717213d

Browse files
authored
Fix other nonrot bugs
There are still a variety of bugs involving the vdev_nonrot property that will cause problems if you try to run the test suite with segment-based weighting disabled, and with other things in the weighting code. Parents' nonrot property need to be updated when children are added. When vdevs are expanded and more metaslabs are added, the weights have to be recalculated (since the number of metaslabs is an input to the lba bias function). When opening, faulted or unopenable children should not be considered for whether a vdev is nonrot or not (since the nonrot property is determined during a successful open, this can cause false negatives). And draid spares need to have the nonrot property set correctly. Sponsored-by: Eshtek, creators of HexOS Sponsored-by: Klara, Inc. Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Rob Norris <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #17469
1 parent 585dbbf commit 717213d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

module/zfs/vdev.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ vdev_add_child(vdev_t *pvd, vdev_t *cvd)
553553

554554
pvd->vdev_child = newchild;
555555
pvd->vdev_child[id] = cvd;
556+
pvd->vdev_nonrot &= cvd->vdev_nonrot;
556557

557558
cvd->vdev_top = (pvd->vdev_top ? pvd->vdev_top: cvd);
558559
ASSERT(cvd->vdev_top->vdev_parent->vdev_parent == NULL);
@@ -1374,6 +1375,7 @@ vdev_add_parent(vdev_t *cvd, vdev_ops_t *ops)
13741375
mvd->vdev_physical_ashift = cvd->vdev_physical_ashift;
13751376
mvd->vdev_state = cvd->vdev_state;
13761377
mvd->vdev_crtxg = cvd->vdev_crtxg;
1378+
mvd->vdev_nonrot = cvd->vdev_nonrot;
13771379

13781380
vdev_remove_child(pvd, cvd);
13791381
vdev_add_child(pvd, mvd);
@@ -1579,6 +1581,18 @@ vdev_metaslab_init(vdev_t *vd, uint64_t txg)
15791581
vd->vdev_ms = mspp;
15801582
vd->vdev_ms_count = newc;
15811583

1584+
/*
1585+
* Weighting algorithms can depend on the number of metaslabs in the
1586+
* vdev. In order to ensure that all weights are correct at all times,
1587+
* we need to recalculate here.
1588+
*/
1589+
for (uint64_t m = 0; m < oldc; m++) {
1590+
metaslab_t *msp = vd->vdev_ms[m];
1591+
mutex_enter(&msp->ms_lock);
1592+
metaslab_recalculate_weight_and_sort(msp);
1593+
mutex_exit(&msp->ms_lock);
1594+
}
1595+
15821596
for (uint64_t m = oldc; m < newc; m++) {
15831597
uint64_t object = 0;
15841598
/*
@@ -1960,6 +1974,10 @@ vdev_open_children_impl(vdev_t *vd, vdev_open_children_func_t *open_func)
19601974
taskq_wait(tq);
19611975
for (int c = 0; c < children; c++) {
19621976
vdev_t *cvd = vd->vdev_child[c];
1977+
1978+
if (open_func(cvd) == B_FALSE ||
1979+
cvd->vdev_state <= VDEV_STATE_FAULTED)
1980+
continue;
19631981
vd->vdev_nonrot &= cvd->vdev_nonrot;
19641982
}
19651983

module/zfs/vdev_draid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,7 @@ vdev_draid_spare_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
24842484
*max_psize = max_asize + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
24852485

24862486
vds->vds_draid_vdev = tvd;
2487+
vd->vdev_nonrot = tvd->vdev_nonrot;
24872488

24882489
return (0);
24892490
}

0 commit comments

Comments
 (0)