Skip to content

Commit 74766ff

Browse files
Fixed the rate limit delete issue.
1 parent a7ce462 commit 74766ff

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

lib/bdev/bdev.c

+19-14
Original file line numberDiff line numberDiff line change
@@ -9212,10 +9212,13 @@ static void remove_bdev_from_group(char *bdev_names) {
92129212
struct spdk_bdev_qos_group_id_mapping *qos_group_id_object = NULL;
92139213
struct qos_bdev_list_node *bdev_node = NULL;
92149214

9215+
if (TAILQ_EMPTY(&g_qos_bdev_group_list)) {
9216+
return ;
9217+
}
92159218
TAILQ_FOREACH(qos_group_id_object, &g_qos_bdev_group_list, link) {
92169219
TAILQ_FOREACH(bdev_node, &qos_group_id_object->bdev_list, link) {
92179220
if (strcmp(bdev_node->bdev_name, bdev_names) == 0) {
9218-
SPDK_NOTICELOG("Removing the bdev from list: %s\n", bdev_node->bdev_name);
9221+
SPDK_NOTICELOG("Removing the bdev from list: %s vs %s\n", bdev_node->bdev_name, bdev_names);
92199222
TAILQ_REMOVE(&qos_group_id_object->bdev_list, bdev_node, link);
92209223
if(bdev_node->bdev_name) {
92219224
free(bdev_node->bdev_name);
@@ -9228,13 +9231,13 @@ static void remove_bdev_from_group(char *bdev_names) {
92289231
--qos_group_id_object->bdev_list_size;
92299232

92309233
if(qos_group_id_object->bdev_list_size == 0) {
9231-
SPDK_NOTICELOG("Cleaning the group mapping\n");
9232-
if(qos_group_id_object->rate_limits) {
9233-
SPDK_NOTICELOG("Cleaning the rate limit\n");
9234-
free(qos_group_id_object->rate_limits);
9235-
qos_group_id_object->rate_limits = NULL;
9236-
}
9237-
free(qos_group_id_object->rate_limits);
9234+
SPDK_NOTICELOG("Cleaning the group mapping for group %"PRIu64"\n",qos_group_id_object->bdev_group_id);
9235+
// if(qos_group_id_object->rate_limits != NULL) {
9236+
// SPDK_NOTICELOG("Cleaning the rate limit\n");
9237+
// //free(qos_group_id_object->rate_limits);
9238+
// //qos_group_id_object->rate_limits = NULL;
9239+
// }
9240+
//free(qos_group_id_object->rate_limits);
92389241
TAILQ_REMOVE(&g_qos_bdev_group_list, qos_group_id_object, link);
92399242
if(qos_group_id_object) {
92409243
free(qos_group_id_object);
@@ -9425,7 +9428,6 @@ bdev_set_qos_limit_done(struct set_qos_limit_ctx *ctx, int status)
94259428
ctx->cb_fn(ctx->cb_arg, 0);
94269429
free(ctx);
94279430
ctx = NULL;
9428-
spdk_spin_unlock(&ctx->bdev->internal.spinlock);
94299431
return;
94309432
}
94319433
rc = spdk_bdev_open_ext(next_qos_bdev_node->bdev_name, false, dummy_bdev_event_cb, NULL, &desc);
@@ -9434,7 +9436,6 @@ bdev_set_qos_limit_done(struct set_qos_limit_ctx *ctx, int status)
94349436
ctx->cb_fn(ctx->cb_arg, -ENXIO);
94359437
free(ctx);
94369438
ctx = NULL;
9437-
spdk_spin_unlock(&ctx->bdev->internal.spinlock);
94389439
return;
94399440
}
94409441

@@ -9456,7 +9457,6 @@ bdev_set_qos_limit_done(struct set_qos_limit_ctx *ctx, int status)
94569457
} else {
94579458
// End of the the nodes
94589459
if(ctx->is_remove_requets) {
9459-
94609460
remove_bdev_from_group(ctx->qos_bdev_node->bdev_name);
94619461
for(uint64_t i = 0 ; i < ctx->total_bdev_to_process; i++) {
94629462
if(ctx->remove_bdev_names[i] != NULL) {
@@ -9487,6 +9487,7 @@ bdev_disable_qos_done(void *cb_arg)
94879487
struct set_qos_limit_ctx *ctx = cb_arg;
94889488
struct spdk_bdev *bdev = ctx->bdev;
94899489
struct spdk_bdev_qos *qos;
9490+
bool deleted_common_rate_limit = false;
94909491

94919492
spdk_spin_lock(&bdev->internal.spinlock);
94929493
qos = bdev->internal.qos;
@@ -9504,9 +9505,13 @@ bdev_disable_qos_done(void *cb_arg)
95049505
if (ctx->total_bdev_to_process <= ctx->bdev_node_cout) {
95059506
free(ctx->qos_group_id_object->rate_limits);
95069507
ctx->qos_group_id_object->rate_limits = NULL;
9508+
deleted_common_rate_limit = true;
95079509
}
95089510
if (ctx->is_remove_requets == true) {
9509-
free(qos->rate_limits);
9511+
if(deleted_common_rate_limit == false ){
9512+
free(qos->rate_limits);
9513+
}
9514+
95109515
}
95119516
} else {
95129517
free(qos->rate_limits);
@@ -9944,8 +9949,8 @@ spdk_bdev_set_qos_rate_limits_ex(struct spdk_bdev *bdev, uint64_t *limits, uint6
99449949
}
99459950
} else {
99469951
if (bdev->internal.qos != NULL) {
9947-
SPDK_NOTICELOG("DISABLING the limits for bdev %s\n", bdev->name);
9948-
if(is_remove_bdev_request == true) {
9952+
SPDK_NOTICELOG("DISABLING the limits for bdev %s vs %d\n", bdev->name, qos_group_id_object->bdev_list_size);
9953+
if(is_remove_bdev_request == true && qos_group_id_object->bdev_list_size != 1) {
99499954
// Replace the rate_limits with new memory to make sure the group limits are intact.
99509955
bdev->internal.qos->rate_limits = calloc(SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES, sizeof(struct spdk_bdev_qos_limit));
99519956
if(remove_bdev_list != NULL) {

0 commit comments

Comments
 (0)