From 963e6c9f3ffc0bc767ca8b89549be595f29f9470 Mon Sep 17 00:00:00 2001 From: Ameer Hamza Date: Fri, 16 Aug 2024 00:39:44 +0500 Subject: [PATCH] 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 Reviewed-by: Alexander Motin Signed-off-by: Ameer Hamza Closes #16449 --- lib/libzfs/libzfs_pool.c | 7 +++++++ module/zfs/spa.c | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 8a043aa0f8..e493e8562a 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -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); } diff --git a/module/zfs/spa.c b/module/zfs/spa.c index cafc7196c3..99a8d107ec 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -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.