Commit d040ae7e authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

iobuf: always dump config



Previously, the config was only dumped, if the iobuf_set_options RPC has
been received.  It used to work that way, because when iobuf was
initially introduced, these options could also be configured via
spdk_bdev_set_opts, for backwards compatibility.  However, this behavior
was removed in v23.05, so the config can be dumped indiscriminately now.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id2fb4a47ff6da2eb770b1339e9afe6fc18c4f64d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19681


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
parent a4009e7a
Loading
Loading
Loading
Loading
+11 −50
Original line number Diff line number Diff line
@@ -9,51 +9,16 @@
#include "spdk/thread.h"
#include "spdk_internal/init.h"

int iobuf_set_opts(struct spdk_iobuf_opts *opts);

static struct spdk_iobuf_opts g_opts;
static bool g_opts_set;

int
iobuf_set_opts(struct spdk_iobuf_opts *opts)
{
	int rc;

	rc = spdk_iobuf_set_opts(opts);
	if (rc != 0) {
		return rc;
	}

	g_opts = *opts;
	g_opts_set = true;

	return 0;
}

static void
iobuf_subsystem_initialize(void)
{
	int rc;

	if (g_opts_set) {
		/* We want to allow users to keep using bdev layer's spdk_bdev_opts to specify the
		 * sizes of the pools, but want to have iobuf_set_opts to take precedence over what
		 * was set by the spdk_bdev_opts.  So, reset the opts here in case bdev layer set
		 * them after iobuf_set_opts.
		 */
		rc = spdk_iobuf_set_opts(&g_opts);
		if (rc != 0) {
			/* This should never happen, we've already validated these options */
			assert(0);
			goto finish;
		}
	}

	rc = spdk_iobuf_initialize();
	if (rc != 0) {
		SPDK_ERRLOG("Failed to initialize iobuf\n");
	}
finish:

	spdk_subsystem_init_next(rc);
}

@@ -77,10 +42,7 @@ iobuf_write_config_json(struct spdk_json_write_ctx *w)
	spdk_iobuf_get_opts(&opts);

	spdk_json_write_array_begin(w);
	/* Make sure we don't override the options from spdk_bdev_opts, unless iobuf_set_options
	 * has been executed
	 */
	if (g_opts_set) {

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

@@ -90,9 +52,8 @@ iobuf_write_config_json(struct spdk_json_write_ctx *w)
	spdk_json_write_named_uint32(w, "small_bufsize", opts.small_bufsize);
	spdk_json_write_named_uint32(w, "large_bufsize", opts.large_bufsize);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
	}

	spdk_json_write_array_end(w);
}

+1 −3
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@
#include "spdk/string.h"
#include "spdk_internal/init.h"

int iobuf_set_opts(struct spdk_iobuf_opts *opts);

static const struct spdk_json_object_decoder rpc_iobuf_set_options_decoders[] = {
	{"small_pool_count", offsetof(struct spdk_iobuf_opts, small_pool_count), spdk_json_decode_uint64, true},
	{"large_pool_count", offsetof(struct spdk_iobuf_opts, large_pool_count), spdk_json_decode_uint64, true},
@@ -33,7 +31,7 @@ rpc_iobuf_set_options(struct spdk_jsonrpc_request *request, const struct spdk_js
		return;
	}

	rc = iobuf_set_opts(&opts);
	rc = spdk_iobuf_set_opts(&opts);
	if (rc != 0) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		return;
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ def filter_methods(do_remove_global_rpcs):
        'dpdk_cryptodev_scan_accel_module',
        'dpdk_cryptodev_set_driver',
        'virtio_blk_create_transport',
        'iobuf_set_options',
    ]

    data = json.loads(sys.stdin.read())