Commit 93b53c02 authored by Mike Gerdts's avatar Mike Gerdts Committed by Jim Harris
Browse files

bdev: call bdev_ok_to_examine() once per examine



This calls bdev_ok_to_examine() once per bdev_examine(). Prior to this
commit, bdev_ok_to_examine() may be called up to twice per bdev module.

The results returned by bdev_ok_to_examine() could be affected by:

1. g_bdev_opts.bdev_auto_examime changing
2. spdk_bdev_examine() being called on a particular bdev
3. An alias being added for an existing bdev

It's not clear that anything good comes from racing in conditions 1 and
3. In condition 2, spdk_bdev_examine() calls bdev_examine(), so any
required examine_config() and examine_disk() calls are still made, just
now with less of a race with the previous invocation of
spdk_examine_confg().

Signed-off-by: default avatarMike Gerdts <mgerdts@nvidia.com>
Change-Id: I496fc44fd74693837d6b449d7fa60f58f9dbf36f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15284


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
parent ae215731
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -646,8 +646,12 @@ bdev_examine(struct spdk_bdev *bdev)
	struct spdk_bdev_module *module;
	uint32_t action;

	if (!bdev_ok_to_examine(bdev)) {
		return;
	}

	TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
		if (module->examine_config && bdev_ok_to_examine(bdev)) {
		if (module->examine_config) {
			spdk_spin_lock(&module->internal.spinlock);
			action = module->internal.action_in_progress;
			module->internal.action_in_progress++;
@@ -661,7 +665,7 @@ bdev_examine(struct spdk_bdev *bdev)
	}

	module = bdev->internal.claim_module;
	if (module != NULL && bdev_ok_to_examine(bdev)) {
	if (module != NULL) {
		if (module->examine_disk) {
			spdk_spin_lock(&module->internal.spinlock);
			module->internal.action_in_progress++;
@@ -672,7 +676,7 @@ bdev_examine(struct spdk_bdev *bdev)
	}

	TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
		if (module->examine_disk && bdev_ok_to_examine(bdev)) {
		if (module->examine_disk) {
			spdk_spin_lock(&module->internal.spinlock);
			module->internal.action_in_progress++;
			spdk_spin_unlock(&module->internal.spinlock);