Skip to content

Commit

Permalink
Fix incorrect error report on vdev attach/replace
Browse files Browse the repository at this point in the history
Report the correct error message in libzfs when attaching/replacing a
vdev with a higher ashift.

Signed-off-by: Ameer Hamza <[email protected]>
  • Loading branch information
ixhamza committed Aug 14, 2024
1 parent d06de4f commit 54b020f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3733,6 +3733,13 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk,
(void) zpool_standard_error(hdl, errno, errbuf);
}
break;

case ZFS_ERR_ASHIFT_MISMATCH:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"The new device cannot have a higher alignment requirement "
"than the top-level vdev."));
(void) zfs_error(hdl, EZFS_BADTARGET, errbuf);
break;
default:
(void) zpool_standard_error(hdl, errno, errbuf);
}
Expand Down
6 changes: 4 additions & 2 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -7602,8 +7602,10 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
* The new device cannot have a higher alignment requirement
* than the top-level vdev.
*/
if (newvd->vdev_ashift > oldvd->vdev_top->vdev_ashift)
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
if (newvd->vdev_ashift > oldvd->vdev_top->vdev_ashift) {
return (spa_vdev_exit(spa, newrootvd, txg,
ZFS_ERR_ASHIFT_MISMATCH));
}

/*
* RAIDZ-expansion-specific checks.
Expand Down

0 comments on commit 54b020f

Please sign in to comment.