Commit f39350be authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

module/raid: configurable process window size



Make the process window size configurable. In order to make it possible,
add new RPC bdev_raid_set_options.

Change-Id: I68f0ecda1b2057c58dfdce7369afa520e659e1aa
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21477


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 6eed119e
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -10406,6 +10406,48 @@ Example response:

## RAID

### bdev_raid_set_options {#rpc_bdev_raid_set_options}

Set options for bdev raid.

This RPC can be called at any time, but the new value will only take effect for new raid bdevs.

The `process_window_size_kb` parameter defines the size of the "window" (LBA range of the raid bdev)
in which a background process like rebuild performs its work. Any positive value is valid, but the value
actually used by a raid bdev can be adjusted to the size of the raid bdev or the write unit size.

#### Parameters

Name                       | Optional | Type        | Description
-------------------------- | -------- | ----------- | -----------
process_window_size_kb     | Optional | number      | Background process (e.g. rebuild) window size in KiB

#### Example

Example request:

~~~json
request:
{
  "jsonrpc": "2.0",
  "method": "bdev_raid_set_options",
  "id": 1,
  "params": {
    "process_window_size_kb": 512
  }
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

### bdev_raid_get_bdevs {#rpc_bdev_raid_get_bdevs}

This is used to list all the raid bdev details based on the input category requested. Category should be one
+49 −2
Original line number Diff line number Diff line
@@ -14,9 +14,10 @@
#include "spdk/likely.h"

#define RAID_OFFSET_BLOCKS_INVALID	UINT64_MAX
#define RAID_BDEV_PROCESS_WINDOW_SIZE	1024 * 1024
#define RAID_BDEV_PROCESS_MAX_QD	16

#define RAID_BDEV_PROCESS_WINDOW_SIZE_KB_DEFAULT 1024

static bool g_shutdown_started = false;

/* List of all raid bdevs */
@@ -74,6 +75,28 @@ struct raid_process_finish_action {
	TAILQ_ENTRY(raid_process_finish_action) link;
};

static struct spdk_raid_bdev_opts g_opts = {
	.process_window_size_kb = RAID_BDEV_PROCESS_WINDOW_SIZE_KB_DEFAULT,
};

void
raid_bdev_get_opts(struct spdk_raid_bdev_opts *opts)
{
	*opts = g_opts;
}

int
raid_bdev_set_opts(const struct spdk_raid_bdev_opts *opts)
{
	if (opts->process_window_size_kb == 0) {
		return -EINVAL;
	}

	g_opts = *opts;

	return 0;
}

static struct raid_bdev_module *
raid_bdev_module_find(enum raid_level level)
{
@@ -1232,6 +1255,28 @@ raid_bdev_exit(void)
	}
}

static void
raid_bdev_opts_config_json(struct spdk_json_write_ctx *w)
{
	spdk_json_write_object_begin(w);

	spdk_json_write_named_string(w, "method", "bdev_raid_set_options");

	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_uint32(w, "process_window_size_kb", g_opts.process_window_size_kb);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
}

static int
raid_bdev_config_json(struct spdk_json_write_ctx *w)
{
	raid_bdev_opts_config_json(w);

	return 0;
}

/*
 * brief:
 * raid_bdev_get_ctx_size is used to return the context size of bdev_io for raid
@@ -1253,6 +1298,7 @@ static struct spdk_bdev_module g_raid_if = {
	.module_init = raid_bdev_init,
	.fini_start = raid_bdev_fini_start,
	.module_fini = raid_bdev_exit,
	.config_json = raid_bdev_config_json,
	.get_ctx_size = raid_bdev_get_ctx_size,
	.examine_disk = raid_bdev_examine,
	.async_init = false,
@@ -2709,7 +2755,8 @@ raid_bdev_process_alloc(struct raid_bdev *raid_bdev, enum raid_process_type type
	process->raid_bdev = raid_bdev;
	process->type = type;
	process->target = target;
	process->max_window_size = spdk_max(RAID_BDEV_PROCESS_WINDOW_SIZE / raid_bdev->bdev.blocklen,
	process->max_window_size = spdk_max(spdk_divide_round_up(g_opts.process_window_size_kb * 1024UL,
					    raid_bdev->bdev.blocklen),
					    raid_bdev->bdev.write_unit_size);
	TAILQ_INIT(&process->requests);
	TAILQ_INIT(&process->finish_actions);
+8 −0
Original line number Diff line number Diff line
@@ -511,4 +511,12 @@ void raid_bdev_write_superblock(struct raid_bdev *raid_bdev, raid_bdev_write_sb_
int raid_bdev_load_base_bdev_superblock(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
					raid_bdev_load_sb_cb cb, void *cb_ctx);

struct spdk_raid_bdev_opts {
	/* Size of the background process window in KiB */
	uint32_t process_window_size_kb;
};

void raid_bdev_get_opts(struct spdk_raid_bdev_opts *opts);
int raid_bdev_set_opts(const struct spdk_raid_bdev_opts *opts);

#endif /* SPDK_BDEV_RAID_INTERNAL_H */
+31 −0
Original line number Diff line number Diff line
@@ -605,3 +605,34 @@ err:
	rpc_bdev_raid_remove_base_bdev_done(request, rc);
}
SPDK_RPC_REGISTER("bdev_raid_remove_base_bdev", rpc_bdev_raid_remove_base_bdev, SPDK_RPC_RUNTIME)

static const struct spdk_json_object_decoder rpc_bdev_raid_options_decoders[] = {
	{"process_window_size_kb", offsetof(struct spdk_raid_bdev_opts, process_window_size_kb), spdk_json_decode_uint32, true},
};

static void
rpc_bdev_raid_set_options(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
{
	struct spdk_raid_bdev_opts opts;
	int rc;

	raid_bdev_get_opts(&opts);
	if (params && spdk_json_decode_object(params, rpc_bdev_raid_options_decoders,
					      SPDK_COUNTOF(rpc_bdev_raid_options_decoders),
					      &opts)) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_PARSE_ERROR,
						 "spdk_json_decode_object failed");
		return;
	}

	rc = raid_bdev_set_opts(&opts);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
	} else {
		spdk_jsonrpc_send_bool_response(request, true);
	}

	return;
}
SPDK_RPC_REGISTER("bdev_raid_set_options", rpc_bdev_raid_set_options,
		  SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
+14 −0
Original line number Diff line number Diff line
@@ -389,6 +389,20 @@ def bdev_null_resize(client, name, new_size):
    return client.call('bdev_null_resize', params)


def bdev_raid_set_options(client, process_window_size_kb=None):
    """Set options for bdev raid.

    Args:
        process_window_size_kb: Background process (e.g. rebuild) window size in KiB
    """
    params = {}

    if process_window_size_kb is not None:
        params['process_window_size_kb'] = process_window_size_kb

    return client.call('bdev_raid_set_options', params)


def bdev_raid_get_bdevs(client, category):
    """Get list of raid bdevs based on category

Loading