Commit 283abcb9 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

bdev: temporarily allow bdev descriptors to be closed from any thread



Bdev descriptors could be closed only from the same thread
that opened them. This restriction was suddenly introduced
at one point without making sure all the SPDK code respects
it. Vhost can still close descriptors from any arbitrary
thread and fixing that would require some more effort.

With this patch we remove the thread-specific assert from
spdk_bdev_close() and hence allow vhost to work properly
in debug builds. Vhost can still have a possible data
race with bdev hotremove notification, but let's get rid
of the abort() from the usual code path first.

Change-Id: I6fac66a5ebc907b1c5418fff618f0b64cd9b69f4
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451561


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent f93b6fb0
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3933,7 +3933,10 @@ spdk_bdev_close(struct spdk_bdev_desc *desc)
	SPDK_DEBUGLOG(SPDK_LOG_BDEV, "Closing descriptor %p for bdev %s on thread %p\n", desc, bdev->name,
		      spdk_get_thread());

	assert(desc->thread == spdk_get_thread());
	if (desc->thread != spdk_get_thread()) {
		SPDK_ERRLOG("Descriptor %p for bdev %s closed on wrong thread (%p, expected %p)\n",
			    desc, bdev->name, spdk_get_thread(), desc->thread);
	}

	pthread_mutex_lock(&bdev->internal.mutex);

+2 −2
Original line number Diff line number Diff line
@@ -361,7 +361,7 @@ unregister_and_close(void)
	/* Try hotremoving a bdev with descriptors which don't provide
	 * the notification callback */
	spdk_bdev_open(&g_bdev.bdev, true, NULL, NULL, &desc);
	CU_ASSERT(desc != NULL);
	SPDK_CU_ASSERT_FATAL(desc != NULL);

	/* There is an open descriptor on the device. Unregister it,
	 * which can't proceed until the descriptor is closed. */
@@ -387,8 +387,8 @@ unregister_and_close(void)

	remove_notify = false;
	spdk_bdev_open(&g_bdev.bdev, true, _bdev_removed, &remove_notify, &desc);
	SPDK_CU_ASSERT_FATAL(desc != NULL);
	CU_ASSERT(remove_notify == false);
	CU_ASSERT(desc != NULL);

	/* There is an open descriptor on the device. Unregister it,
	 * which can't proceed until the descriptor is closed. */