Skip to content

Don't allow attach to a raidz child vdev #15564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -7063,12 +7063,13 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,

if (!replacing) {
/*
* For attach, the only allowable parent is a mirror or the root
* vdev.
* For attach, the only allowable parent is a mirror or
* the root vdev. A raidz vdev can be attached to, but
* you cannot attach to a raidz child.
*/
if (pvd->vdev_ops != &vdev_mirror_ops &&
Copy link
Contributor

@ryao ryao Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to clarify in the comment that the condition is a list of permitted cases under de morgan's law. If it were me, I would append the following:

As per De Morgan's law: !(A OR B OR C) === !A AND !B AND !C

pvd->vdev_ops != &vdev_raidz_ops &&
pvd->vdev_ops != &vdev_root_ops)
pvd->vdev_ops != &vdev_root_ops &&
!raidz)
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));

pvops = &vdev_mirror_ops;
Expand Down