Commit 17fdb235 authored by luchangqi.123's avatar luchangqi.123 Committed by Tomasz Zawadzki
Browse files

bdev: add json config saving for bdev_enable_histogram



When the "save_config" RPC command is called in SPDK,
the current environment is saved. However, the environment
created by "bdev_enable_histogram" is not included
in the saved configuration.

In a production environment, it is crucial to monitor
various IO indicators, and IO latency is one of the
important metrics. Fortunately, SPDK provides an RPC
method called "bdev_get_histogram" to obtain the IO
latency histogram of a bdev device. However, before
using this RPC method, it is necessary to first call
the "bdev_enable_histogram" command.

In a production environment, SPDK is typically configured
to automatically restart using the saved configuration
file (by using the "save_config" command in rpc.py)
with the help of systemd or Docker. However, since the
"bdev_enable_histogram" configuration is missing from
the saved configuration, the IO latency monitoring will
fail once SPDK restarts.

Change-Id: I02f217094478190e73ed1ffb8b56793b91050e3d
Signed-off-by: default avatarluchangqi.123 <luchangqi.123@bytedance.com>
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20502


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent c08f917f
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1841,6 +1841,25 @@ bdev_module_get_max_ctx_size(void)
	return max_bdev_module_size;
}

static void
bdev_enable_histogram_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
{
	if (!bdev->internal.histogram_enabled) {
		return;
	}

	spdk_json_write_object_begin(w);
	spdk_json_write_named_string(w, "method", "bdev_enable_histogram");

	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_string(w, "name", bdev->name);

	spdk_json_write_named_bool(w, "enable", bdev->internal.histogram_enabled);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
}

static void
bdev_qos_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
{
@@ -1904,6 +1923,7 @@ spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w)
		}

		bdev_qos_config_json(bdev, w);
		bdev_enable_histogram_config_json(bdev, w);
	}

	spdk_spin_unlock(&g_bdev_mgr.spinlock);