bdev: add bdev_auto_examine in bdev_set_options
The bdev_auto_examine flage will impact how bdev layer examine a disk. If bdev_auto_examine is true, the bdev layer will examine all bdevs as usual. If bdev_auto_examine is false, the bdev layer will only examine a bdev if it is in a whitelist. Signed-off-by: Peng Yu <yupeng0921@gmail.com> Change-Id: If5b26283905f97f8a95ae9065226fa3dae6c27a9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2114 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
f2ede6b486
commit
f233c376b1
@ -185,6 +185,7 @@ struct spdk_bdev_io_stat {
|
|||||||
struct spdk_bdev_opts {
|
struct spdk_bdev_opts {
|
||||||
uint32_t bdev_io_pool_size;
|
uint32_t bdev_io_pool_size;
|
||||||
uint32_t bdev_io_cache_size;
|
uint32_t bdev_io_cache_size;
|
||||||
|
bool bdev_auto_examine;
|
||||||
};
|
};
|
||||||
|
|
||||||
void spdk_bdev_get_opts(struct spdk_bdev_opts *opts);
|
void spdk_bdev_get_opts(struct spdk_bdev_opts *opts);
|
||||||
|
@ -62,6 +62,7 @@ int __itt_init_ittlib(const char *, __itt_group_id);
|
|||||||
|
|
||||||
#define SPDK_BDEV_IO_POOL_SIZE (64 * 1024 - 1)
|
#define SPDK_BDEV_IO_POOL_SIZE (64 * 1024 - 1)
|
||||||
#define SPDK_BDEV_IO_CACHE_SIZE 256
|
#define SPDK_BDEV_IO_CACHE_SIZE 256
|
||||||
|
#define SPDK_BDEV_AUTO_EXAMINE true
|
||||||
#define BUF_SMALL_POOL_SIZE 8191
|
#define BUF_SMALL_POOL_SIZE 8191
|
||||||
#define BUF_LARGE_POOL_SIZE 1023
|
#define BUF_LARGE_POOL_SIZE 1023
|
||||||
#define NOMEM_THRESHOLD_COUNT 8
|
#define NOMEM_THRESHOLD_COUNT 8
|
||||||
@ -137,6 +138,7 @@ struct lba_range {
|
|||||||
static struct spdk_bdev_opts g_bdev_opts = {
|
static struct spdk_bdev_opts g_bdev_opts = {
|
||||||
.bdev_io_pool_size = SPDK_BDEV_IO_POOL_SIZE,
|
.bdev_io_pool_size = SPDK_BDEV_IO_POOL_SIZE,
|
||||||
.bdev_io_cache_size = SPDK_BDEV_IO_CACHE_SIZE,
|
.bdev_io_cache_size = SPDK_BDEV_IO_CACHE_SIZE,
|
||||||
|
.bdev_auto_examine = SPDK_BDEV_AUTO_EXAMINE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static spdk_bdev_init_cb g_init_cb_fn = NULL;
|
static spdk_bdev_init_cb g_init_cb_fn = NULL;
|
||||||
@ -398,6 +400,25 @@ spdk_bdev_set_opts(struct spdk_bdev_opts *opts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Will implement the whitelist in the furture
|
||||||
|
*/
|
||||||
|
static inline bool
|
||||||
|
bdev_in_examine_whitelist(struct spdk_bdev *bdev)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
bdev_ok_to_examine(struct spdk_bdev *bdev)
|
||||||
|
{
|
||||||
|
if (g_bdev_opts.bdev_auto_examine) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return bdev_in_examine_whitelist(bdev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct spdk_bdev *
|
struct spdk_bdev *
|
||||||
spdk_bdev_first(void)
|
spdk_bdev_first(void)
|
||||||
{
|
{
|
||||||
@ -894,6 +915,7 @@ spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w)
|
|||||||
spdk_json_write_named_object_begin(w, "params");
|
spdk_json_write_named_object_begin(w, "params");
|
||||||
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_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_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_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
@ -5015,7 +5037,7 @@ bdev_start(struct spdk_bdev *bdev)
|
|||||||
|
|
||||||
/* Examine configuration before initializing I/O */
|
/* Examine configuration before initializing I/O */
|
||||||
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
|
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
|
||||||
if (module->examine_config) {
|
if (module->examine_config && bdev_ok_to_examine(bdev)) {
|
||||||
action = module->internal.action_in_progress;
|
action = module->internal.action_in_progress;
|
||||||
module->internal.action_in_progress++;
|
module->internal.action_in_progress++;
|
||||||
module->examine_config(bdev);
|
module->examine_config(bdev);
|
||||||
@ -5026,7 +5048,7 @@ bdev_start(struct spdk_bdev *bdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdev->internal.claim_module) {
|
if (bdev->internal.claim_module && bdev_ok_to_examine(bdev)) {
|
||||||
if (bdev->internal.claim_module->examine_disk) {
|
if (bdev->internal.claim_module->examine_disk) {
|
||||||
bdev->internal.claim_module->internal.action_in_progress++;
|
bdev->internal.claim_module->internal.action_in_progress++;
|
||||||
bdev->internal.claim_module->examine_disk(bdev);
|
bdev->internal.claim_module->examine_disk(bdev);
|
||||||
@ -5035,7 +5057,7 @@ bdev_start(struct spdk_bdev *bdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
|
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
|
||||||
if (module->examine_disk) {
|
if (module->examine_disk && bdev_ok_to_examine(bdev)) {
|
||||||
module->internal.action_in_progress++;
|
module->internal.action_in_progress++;
|
||||||
module->examine_disk(bdev);
|
module->examine_disk(bdev);
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,13 @@
|
|||||||
struct spdk_rpc_set_bdev_opts {
|
struct spdk_rpc_set_bdev_opts {
|
||||||
uint32_t bdev_io_pool_size;
|
uint32_t bdev_io_pool_size;
|
||||||
uint32_t bdev_io_cache_size;
|
uint32_t bdev_io_cache_size;
|
||||||
|
bool bdev_auto_examine;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct spdk_json_object_decoder rpc_set_bdev_opts_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_set_bdev_opts_decoders[] = {
|
||||||
{"bdev_io_pool_size", offsetof(struct spdk_rpc_set_bdev_opts, bdev_io_pool_size), spdk_json_decode_uint32, true},
|
{"bdev_io_pool_size", offsetof(struct spdk_rpc_set_bdev_opts, bdev_io_pool_size), spdk_json_decode_uint32, true},
|
||||||
{"bdev_io_cache_size", offsetof(struct spdk_rpc_set_bdev_opts, bdev_io_cache_size), spdk_json_decode_uint32, true},
|
{"bdev_io_cache_size", offsetof(struct spdk_rpc_set_bdev_opts, bdev_io_cache_size), spdk_json_decode_uint32, true},
|
||||||
|
{"bdev_auto_examine", offsetof(struct spdk_rpc_set_bdev_opts, bdev_auto_examine), spdk_json_decode_bool, true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -59,6 +61,7 @@ spdk_rpc_bdev_set_options(struct spdk_jsonrpc_request *request, const struct spd
|
|||||||
|
|
||||||
rpc_opts.bdev_io_pool_size = UINT32_MAX;
|
rpc_opts.bdev_io_pool_size = UINT32_MAX;
|
||||||
rpc_opts.bdev_io_cache_size = UINT32_MAX;
|
rpc_opts.bdev_io_cache_size = UINT32_MAX;
|
||||||
|
rpc_opts.bdev_auto_examine = true;
|
||||||
|
|
||||||
if (params != NULL) {
|
if (params != NULL) {
|
||||||
if (spdk_json_decode_object(params, rpc_set_bdev_opts_decoders,
|
if (spdk_json_decode_object(params, rpc_set_bdev_opts_decoders,
|
||||||
@ -77,6 +80,7 @@ spdk_rpc_bdev_set_options(struct spdk_jsonrpc_request *request, const struct spd
|
|||||||
if (rpc_opts.bdev_io_cache_size != UINT32_MAX) {
|
if (rpc_opts.bdev_io_cache_size != UINT32_MAX) {
|
||||||
bdev_opts.bdev_io_cache_size = rpc_opts.bdev_io_cache_size;
|
bdev_opts.bdev_io_cache_size = rpc_opts.bdev_io_cache_size;
|
||||||
}
|
}
|
||||||
|
bdev_opts.bdev_auto_examine = rpc_opts.bdev_auto_examine;
|
||||||
rc = spdk_bdev_set_opts(&bdev_opts);
|
rc = spdk_bdev_set_opts(&bdev_opts);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user