Commit 5abf2ecf authored by Wael Halbawi's avatar Wael Halbawi Committed by Jim Harris
Browse files

Do not recreate passthru vbdev unnecessarily.



The passthru module associates a vbdev and the underlying bdev.
This association lives throughout the lifetime of the module and because
of this, passthru vbdevs are recreated when they shouldn't be.

This patch ensures that the association between a vbdev and a bdev is
broken when the vbdev is removed, so that if the underlying bdev is ever
recreated (after being deleted), the vbdev does not reappear.

Note that this change does not affect hot-remove operations.

Change-Id: I5cb4cf7efcb5e5eeaeef79849e0aaefec4684a4f
Signed-off-by: default avatarWael Halbawi <waelhalbawi@gmail.com>
Reviewed-on: https://review.gerrithub.io/422474


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e9424c7e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -572,11 +572,27 @@ create_passthru_disk(const char *bdev_name, const char *vbdev_name)
void
delete_passthru_disk(struct spdk_bdev *bdev, spdk_delete_passthru_complete cb_fn, void *cb_arg)
{
	struct bdev_names *name;

	if (!bdev || bdev->module != &passthru_if) {
		cb_fn(cb_arg, -ENODEV);
		return;
	}

	/* Remove the association (vbdev, bdev) from g_bdev_names. This is required so that the
	 * vbdev does not get re-created if the same bdev is constructed at some other time,
	 * unless the underlying bdev was hot-removed.
	 */
	TAILQ_FOREACH(name, &g_bdev_names, link) {
		if (strcmp(name->vbdev_name, bdev->name) == 0) {
			TAILQ_REMOVE(&g_bdev_names, name, link);
			free(name->bdev_name);
			free(name->vbdev_name);
			free(name);
			break;
		}
	}

	spdk_bdev_unregister(bdev, cb_fn, cb_arg);
}