Skip to content

Commit b532f5f

Browse files
author
Alexander Indenbaum
committed
bdev_rbd: handle rbd_with_spdk_wq conf option
Signed-off-by: Alexander Indenbaum <aindenba@redhat.com>
1 parent a6de50e commit b532f5f

File tree

4 files changed

+107
-4
lines changed

4 files changed

+107
-4
lines changed

module/bdev/rbd/bdev_rbd.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static int bdev_rbd_count = 0;
3333
* global parameter to control CRC32C usage in RBD write operations.
3434
*/
3535
static bool g_rbd_with_crc32c = false;
36+
static bool g_rbd_with_spdk_wq = false;
3637

3738
struct bdev_rbd_pool_ctx {
3839
rados_t *cluster_p;
@@ -509,10 +510,16 @@ bdev_rbd_init_context(void *arg)
509510
}
510511

511512
assert(io_ctx != NULL);
512-
/* Find reactor thread, create SpdkContextWQ if available, then open with context_wq (NULL uses default AsioContextWQ) */
513-
struct spdk_thread *reactor_thread = bdev_rbd_find_reactor_thread();
514-
rbd->spdk_context_wq = bdev_rbd_spdk_context_wq_create_from_ioctx(
515-
*io_ctx, reactor_thread);
513+
if (g_rbd_with_spdk_wq) {
514+
/* Find reactor thread, create SpdkContextWQ if available, then open with context_wq (NULL uses default AsioContextWQ) */
515+
struct spdk_thread *reactor_thread = bdev_rbd_find_reactor_thread();
516+
rbd->spdk_context_wq = bdev_rbd_spdk_context_wq_create_from_ioctx(
517+
*io_ctx, reactor_thread);
518+
} else {
519+
rbd->spdk_context_wq = NULL;
520+
SPDK_NOTICELOG("rbd_with_spdk_wq is disabled, using AsioContextWQ for RBD image %s/%s\n",
521+
rbd->pool_name, rbd->rbd_name);
522+
}
516523
if (rbd->rbd_read_only) {
517524
SPDK_DEBUGLOG(bdev_rbd, "Will open RBD image %s/%s as read-only\n", rbd->pool_name, rbd->rbd_name);
518525
rc = rbd_open_read_only_with_context_wq(*io_ctx, rbd->rbd_name, &rbd->image, NULL, rbd->spdk_context_wq);
@@ -2013,3 +2020,16 @@ bdev_rbd_set_with_crc32c(bool enable)
20132020
{
20142021
g_rbd_with_crc32c = enable;
20152022
}
2023+
2024+
bool
2025+
bdev_rbd_get_with_spdk_wq(void)
2026+
{
2027+
return g_rbd_with_spdk_wq;
2028+
}
2029+
2030+
/** enable or disable SPDK ContextWQ for RBD operations */
2031+
void
2032+
bdev_rbd_set_with_spdk_wq(bool enable)
2033+
{
2034+
g_rbd_with_spdk_wq = enable;
2035+
}

module/bdev/rbd/bdev_rbd.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,19 @@ bool bdev_rbd_get_with_crc32c(void);
9696
*/
9797
void bdev_rbd_set_with_crc32c(bool enable);
9898

99+
/**
100+
* Get the current rbd_with_spdk_wq setting.
101+
*
102+
* \return true if SPDK ContextWQ is enabled, false otherwise
103+
*/
104+
bool bdev_rbd_get_with_spdk_wq(void);
105+
106+
/**
107+
* Set the rbd_with_spdk_wq parameter to enable/disable SPDK ContextWQ
108+
* for RBD operations.
109+
*
110+
* \param enable true to enable SPDK ContextWQ, false to disable (uses AsioContextWQ)
111+
*/
112+
void bdev_rbd_set_with_spdk_wq(bool enable);
113+
99114
#endif /* SPDK_BDEV_RBD_H */

module/bdev/rbd/bdev_rbd_rpc.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,53 @@ SPDK_RPC_REGISTER("bdev_rbd_wait_for_latest_osdmap", rpc_bdev_rbd_wait_for_lates
439439

440440
SPDK_RPC_REGISTER("bdev_rbd_get_with_crc32c", rpc_bdev_rbd_get_with_crc32c, SPDK_RPC_RUNTIME)
441441
SPDK_RPC_REGISTER("bdev_rbd_set_with_crc32c", rpc_bdev_rbd_set_with_crc32c, SPDK_RPC_STARTUP)
442+
443+
/**
444+
* RPC function to get the current rbd_with_spdk_wq setting
445+
*/
446+
static void
447+
rpc_bdev_rbd_get_with_spdk_wq(struct spdk_jsonrpc_request *request,
448+
const struct spdk_json_val *params)
449+
{
450+
struct spdk_json_write_ctx *w;
451+
452+
w = spdk_jsonrpc_begin_result(request);
453+
spdk_json_write_bool(w, bdev_rbd_get_with_spdk_wq());
454+
spdk_jsonrpc_end_result(request, w);
455+
}
456+
457+
/**
458+
* RPC function to set the rbd_with_spdk_wq parameter
459+
*/
460+
struct rpc_bdev_rbd_set_with_spdk_wq {
461+
bool enable;
462+
};
463+
464+
static const struct spdk_json_object_decoder rpc_bdev_rbd_set_with_spdk_wq_decoders[] = {
465+
{"enable", offsetof(struct rpc_bdev_rbd_set_with_spdk_wq, enable), spdk_json_decode_bool},
466+
};
467+
468+
static void
469+
rpc_bdev_rbd_set_with_spdk_wq(struct spdk_jsonrpc_request *request,
470+
const struct spdk_json_val *params)
471+
{
472+
struct rpc_bdev_rbd_set_with_spdk_wq req = {};
473+
struct spdk_json_write_ctx *w;
474+
475+
if (spdk_json_decode_object(params, rpc_bdev_rbd_set_with_spdk_wq_decoders,
476+
SPDK_COUNTOF(rpc_bdev_rbd_set_with_spdk_wq_decoders),
477+
&req)) {
478+
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
479+
"Missing or invalid enable parameter");
480+
return;
481+
}
482+
483+
bdev_rbd_set_with_spdk_wq(req.enable);
484+
485+
w = spdk_jsonrpc_begin_result(request);
486+
spdk_json_write_bool(w, bdev_rbd_get_with_spdk_wq());
487+
spdk_jsonrpc_end_result(request, w);
488+
}
489+
490+
SPDK_RPC_REGISTER("bdev_rbd_get_with_spdk_wq", rpc_bdev_rbd_get_with_spdk_wq, SPDK_RPC_RUNTIME)
491+
SPDK_RPC_REGISTER("bdev_rbd_set_with_spdk_wq", rpc_bdev_rbd_set_with_spdk_wq, SPDK_RPC_STARTUP)

python/spdk/rpc/bdev.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,24 @@ def bdev_rbd_set_with_crc32c(client, enable):
11671167
return client.call('bdev_rbd_set_with_crc32c', params)
11681168

11691169

1170+
def bdev_rbd_get_with_spdk_wq(client):
1171+
"""Get SPDK ContextWQ usage in RBD operations.
1172+
Returns:
1173+
True if SPDK ContextWQ is enabled, False otherwise
1174+
"""
1175+
return client.call('bdev_rbd_get_with_spdk_wq')
1176+
1177+
1178+
def bdev_rbd_set_with_spdk_wq(client, enable):
1179+
"""Set SPDK ContextWQ usage in RBD operations.
1180+
Args:
1181+
enable: enable or disable SPDK ContextWQ (False uses AsioContextWQ)
1182+
"""
1183+
params = dict()
1184+
params['enable'] = enable
1185+
return client.call('bdev_rbd_set_with_spdk_wq', params)
1186+
1187+
11701188
@deprecated_method
11711189
def bdev_error_create(client, base_name, uuid=None):
11721190
"""Construct an error injection block device.

0 commit comments

Comments
 (0)