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

bdev: make iobuf caches configurable



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


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 411613fe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2316,6 +2316,8 @@ Name | Optional | Type | Description
bdev_io_pool_size       | Optional | number      | Number of spdk_bdev_io structures in shared buffer pool
bdev_io_cache_size      | Optional | number      | Maximum number of spdk_bdev_io structures cached per thread
bdev_auto_examine       | Optional | boolean     | If set to false, the bdev layer will not examine every disks automatically
iobuf_small_cache_size  | Optional | number      | Size of the small iobuf per thread cache
iobuf_large_cache_size  | Optional | number      | Size of the large iobuf per thread cache

#### Example

+3 −2
Original line number Diff line number Diff line
@@ -200,8 +200,9 @@ struct spdk_bdev_opts {
	 */
	size_t opts_size;

	/* Hole at bytes 24-31. */
	uint8_t reserved[8];
	/* Size of the per-thread iobuf caches */
	uint32_t iobuf_small_cache_size;
	uint32_t iobuf_large_cache_size;
} __attribute__((packed));
SPDK_STATIC_ASSERT(sizeof(struct spdk_bdev_opts) == 32, "Incorrect size");

+11 −1
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ static struct spdk_bdev_opts g_bdev_opts = {
	.bdev_io_pool_size = SPDK_BDEV_IO_POOL_SIZE,
	.bdev_io_cache_size = SPDK_BDEV_IO_CACHE_SIZE,
	.bdev_auto_examine = SPDK_BDEV_AUTO_EXAMINE,
	.iobuf_small_cache_size = BUF_SMALL_CACHE_SIZE,
	.iobuf_large_cache_size = BUF_LARGE_CACHE_SIZE,
};

static spdk_bdev_init_cb	g_init_cb_fn = NULL;
@@ -453,6 +455,8 @@ spdk_bdev_get_opts(struct spdk_bdev_opts *opts, size_t opts_size)
	SET_FIELD(bdev_io_pool_size);
	SET_FIELD(bdev_io_cache_size);
	SET_FIELD(bdev_auto_examine);
	SET_FIELD(iobuf_small_cache_size);
	SET_FIELD(iobuf_large_cache_size);

	/* Do not remove this statement, you should always update this statement when you adding a new field,
	 * and do not forget to add the SET_FIELD statement for your added field. */
@@ -498,6 +502,8 @@ spdk_bdev_set_opts(struct spdk_bdev_opts *opts)
	SET_FIELD(bdev_io_pool_size);
	SET_FIELD(bdev_io_cache_size);
	SET_FIELD(bdev_auto_examine);
	SET_FIELD(iobuf_small_cache_size);
	SET_FIELD(iobuf_large_cache_size);

	g_bdev_opts.opts_size = opts->opts_size;

@@ -1904,6 +1910,8 @@ spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w)
	spdk_json_write_named_uint32(w, "bdev_io_pool_size", g_bdev_opts.bdev_io_pool_size);
	spdk_json_write_named_uint32(w, "bdev_io_cache_size", g_bdev_opts.bdev_io_cache_size);
	spdk_json_write_named_bool(w, "bdev_auto_examine", g_bdev_opts.bdev_auto_examine);
	spdk_json_write_named_uint32(w, "iobuf_small_cache_size", g_bdev_opts.iobuf_small_cache_size);
	spdk_json_write_named_uint32(w, "iobuf_large_cache_size", g_bdev_opts.iobuf_large_cache_size);
	spdk_json_write_object_end(w);
	spdk_json_write_object_end(w);

@@ -1962,7 +1970,9 @@ bdev_mgmt_channel_create(void *io_device, void *ctx_buf)
	uint32_t i;
	int rc;

	rc = spdk_iobuf_channel_init(&ch->iobuf, "bdev", BUF_SMALL_CACHE_SIZE, BUF_LARGE_CACHE_SIZE);
	rc = spdk_iobuf_channel_init(&ch->iobuf, "bdev",
				     g_bdev_opts.iobuf_small_cache_size,
				     g_bdev_opts.iobuf_large_cache_size);
	if (rc != 0) {
		SPDK_ERRLOG("Failed to create iobuf channel: %s\n", spdk_strerror(-rc));
		return -1;
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ static const struct spdk_json_object_decoder rpc_set_bdev_opts_decoders[] = {
	{"bdev_io_pool_size", offsetof(struct spdk_bdev_opts, bdev_io_pool_size), spdk_json_decode_uint32, true},
	{"bdev_io_cache_size", offsetof(struct spdk_bdev_opts, bdev_io_cache_size), spdk_json_decode_uint32, true},
	{"bdev_auto_examine", offsetof(struct spdk_bdev_opts, bdev_auto_examine), spdk_json_decode_bool, true},
	{"iobuf_small_cache_size", offsetof(struct spdk_bdev_opts, iobuf_small_cache_size), spdk_json_decode_uint32, true},
	{"iobuf_large_cache_size", offsetof(struct spdk_bdev_opts, iobuf_large_cache_size), spdk_json_decode_uint32, true},
};

static void
+8 −1
Original line number Diff line number Diff line
@@ -5,13 +5,16 @@


def bdev_set_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None,
                     bdev_auto_examine=None):
                     bdev_auto_examine=None, iobuf_small_cache_size=None,
                     iobuf_large_cache_size=None):
    """Set parameters for the bdev subsystem.

    Args:
        bdev_io_pool_size: number of bdev_io structures in shared buffer pool (optional)
        bdev_io_cache_size: maximum number of bdev_io structures cached per thread (optional)
        bdev_auto_examine: if set to false, the bdev layer will not examine every disks automatically (optional)
        iobuf_small_cache_size: size of the small iobuf per thread cache
        iobuf_large_cache_size: size of the large iobuf per thread cache
    """
    params = {}

@@ -21,6 +24,10 @@ def bdev_set_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None,
        params['bdev_io_cache_size'] = bdev_io_cache_size
    if bdev_auto_examine is not None:
        params["bdev_auto_examine"] = bdev_auto_examine
    if iobuf_small_cache_size is not None:
        params["iobuf_small_cache_size"] = iobuf_small_cache_size
    if iobuf_large_cache_size is not None:
        params["iobuf_large_cache_size"] = iobuf_large_cache_size
    return client.call('bdev_set_options', params)


Loading