HomeFreeBSD

zpool_vdev_remove() should handle EALREADY error return

Description

zpool_vdev_remove() should handle EALREADY error return

When the vdev properties features was merged an extra check
was added in spa_vdev_remove_top_check() which checked
whether the vdev that we want to remove is already being
removed and if so return an EALREADY error.

static int
spa_vdev_remove_top_check(vdev_t *vd)
{
	... <snip> ...
	/*
	 * This device is already being removed
	 */
	if (vd->vdev_removing)
		return (SET_ERROR(EALREADY));

Before that change we'd still fail with an error but it
was a more generic one - here is the check that failed
later in the same function:

	/*
	 * There can not be a removal in progress.
	 */
	if (spa->spa_removing_phys.sr_state == DSS_SCANNING)
		return (SET_ERROR(EBUSY));

Changing the error code returned from that function changed
the behavior of the removal's library interface exposed to
the userland - spa_vdev_remove() now returns EZFS_UNKNOWN
instead of EZFS_EBUSY that was returning before.

This patch adds logic to make spa_vdev_remove() mindful
of the new EALREADY code and propagating EZFS_EBUSY
reverting to the previously established semantics of that
function.

Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #15013
Closes #15129

Details

Provenance
Serapheim Dimitropoulos <serapheim@delphix.com>Authored on Aug 1 2023, 9:47 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Aug 2 2023, 3:54 PM
Parents
rGbd1eab16ebd0: linux: zfs: ctldir: set [amc]time to snapshot's creation property
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG0ae7bfc0a424: zpool_vdev_remove() should handle EALREADY error return (authored by Serapheim Dimitropoulos <serapheim@delphix.com>).Aug 2 2023, 3:54 PM