@ahrens, I figured it out: In illumos, ```kmem_alloc(0, ...)``` returns NULL
but in Linux, we get a magic pointer. I've done this little patch to
```vdev_compact_children()``` because apparently with the vdev removal code, it
now depends on ```vdev_child``` being nulled out during compaction.
```
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c
index 5185355..75554c0 100644
--- a/module/zfs/vdev.c
+++ b/module/zfs/vdev.c
@@ -291,17 +291,24 @@ vdev_compact_children(vdev_t *pvd)
ASSERT(spa_config_held(pvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL);
+ if (oldc == 0)
+ return;
+
for (int c = newc = 0; c < oldc; c++)
if (pvd->vdev_child[c])
newc++;
- newchild = kmem_zalloc(newc * sizeof (vdev_t *), KM_SLEEP);
+ if (newc > 0) {
+ newchild = kmem_zalloc(newc * sizeof (vdev_t *), KM_SLEEP);
- for (int c = newc = 0; c < oldc; c++) {
- if ((cvd = pvd->vdev_child[c]) != NULL) {
- newchild[newc] = cvd;
- cvd->vdev_id = newc++;
+ for (int c = newc = 0; c < oldc; c++) {
+ if ((cvd = pvd->vdev_child[c]) != NULL) {
+ newchild[newc] = cvd;
+ cvd->vdev_id = newc++;
+ }
}
+ } else {
+ newchild = NULL;
}
kmem_free(pvd->vdev_child, oldc * sizeof (vdev_t *));
```
Note: ZoL has always used ```kmem_zalloc()``` rather than ```kmem_alloc()```
here for probably no particularly good reason.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openzfs/openzfs/pull/482#issuecomment-347934379
------------------------------------------
openzfs-developer
Archives:
https://openzfs.topicbox.com/groups/developer/discussions/Teafc5ffabd7f916f-M130995cabd703692d289f22a
Powered by Topicbox: https://topicbox.com