Fix incorrect error report on vdev attach/replace

Report the correct error message in libzfs when attaching/replacing a
vdev with a higher ashift.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #16449
This commit is contained in:
Ameer Hamza 2024-08-16 00:39:44 +05:00 committed by GitHub
parent 83f359245a
commit 963e6c9f3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -3733,6 +3733,13 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk,
(void) zpool_standard_error(hdl, errno, errbuf); (void) zpool_standard_error(hdl, errno, errbuf);
} }
break; 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: default:
(void) zpool_standard_error(hdl, errno, errbuf); (void) zpool_standard_error(hdl, errno, errbuf);
} }

View File

@ -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 * The new device cannot have a higher alignment requirement
* than the top-level vdev. * than the top-level vdev.
*/ */
if (newvd->vdev_ashift > oldvd->vdev_top->vdev_ashift) if (newvd->vdev_ashift > oldvd->vdev_top->vdev_ashift) {
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP)); return (spa_vdev_exit(spa, newrootvd, txg,
ZFS_ERR_ASHIFT_MISMATCH));
}
/* /*
* RAIDZ-expansion-specific checks. * RAIDZ-expansion-specific checks.