Skip to content

Commit

Permalink
Fix json parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacKhor committed Aug 9, 2024
1 parent 360252f commit 37f9b72
Show file tree
Hide file tree
Showing 4 changed files with 2,455 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/bdev_lsvd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,14 @@ int bdev_lsvd_create(str pool_name, str image_name, str user_cfg)

int bdev_lsvd_delete(str img_name)
{
// TODO this currently deadlocks because of spdk's threading model, need to
// make it async
log_info("Deleting image '{}'", img_name);
auto p = std::promise<int>();
spdk_bdev_unregister_by_name(
img_name.c_str(), &lsvd_if,
[](void *arg, int rc) {
log_info("Image deletion complete, rc = {}", rc);
auto p = (std::promise<int> *)arg;
p->set_value(rc);
},
Expand Down
13 changes: 5 additions & 8 deletions src/bdev_lsvd_rpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ struct rpc_create_lsvd {
};

static const struct spdk_json_object_decoder rpc_create_lsvd_decoders[] = {
{"image_name", offsetof(rpc_create_lsvd, image_name),
spdk_json_decode_string, false},
{"pool_name", offsetof(rpc_create_lsvd, pool_name), spdk_json_decode_string,
false},
{"config", offsetof(rpc_create_lsvd, config), spdk_json_decode_string,
true},
{"image_name", offsetof(rpc_create_lsvd, image_name), spdk_json_decode_string, false},
{"pool_name", offsetof(rpc_create_lsvd, pool_name), spdk_json_decode_string, false},
{"config", offsetof(rpc_create_lsvd, config), spdk_json_decode_string, true},
};

static void rpc_bdev_lsvd_create(spdk_jsonrpc_request *req_json,
Expand All @@ -53,6 +50,7 @@ static void rpc_bdev_lsvd_create(spdk_jsonrpc_request *req_json,
PR_GOTO_IF(w == nullptr, fail, "failed to create json result");
spdk_json_write_bool(w, true);
spdk_jsonrpc_end_result(req_json, w);
return;

fail:
spdk_jsonrpc_send_error_response(req_json, rc,
Expand All @@ -66,8 +64,7 @@ struct rpc_delete_lsvd {
};

static const struct spdk_json_object_decoder rpc_delete_lsvd_decoders[] = {
{"image_name", offsetof(struct rpc_delete_lsvd, image_name),
spdk_json_decode_string, false},
{"image_name", offsetof(struct rpc_delete_lsvd, image_name), spdk_json_decode_string, false},
};

static void rpc_bdev_lsvd_delete(struct spdk_jsonrpc_request *req_json,
Expand Down
Loading

0 comments on commit 37f9b72

Please sign in to comment.