module/bdev: Use error_response() rather than bool_response(false) for JSON RPCs
For JSON RPC, boolean response with false value may not be regarded as error. Previously many cases were replaced to use spdk_jsonrpc_send_error_response() explicitly. However, this pattern did not become established and new bdev modules used spdk_jsonrpc_send_bool_response() with false. Once again, replace remaining cases in this patch. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: Ie8858bc8ff7c36bc3a829977044a91d459db76f2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16555 Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
5feab0ddcf
commit
c77bc554d2
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2018 Intel Corporation.
|
* Copyright (C) 2018 Intel Corporation.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -153,7 +154,11 @@ _rpc_bdev_compress_delete_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (c) croit GmbH.
|
* Copyright (c) croit GmbH.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -108,7 +109,11 @@ rpc_bdev_daos_delete_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2020 Intel Corporation.
|
* Copyright (C) 2020 Intel Corporation.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -142,7 +143,11 @@ rpc_bdev_ftl_delete_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -190,7 +195,11 @@ rpc_bdev_ftl_unmap_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -300,14 +309,14 @@ rpc_bdev_ftl_get_stats(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
stats = calloc(1, sizeof(struct ftl_stats));
|
stats = calloc(1, sizeof(struct ftl_stats));
|
||||||
if (!stats) {
|
if (!stats) {
|
||||||
spdk_jsonrpc_send_bool_response(request, false);
|
spdk_jsonrpc_send_error_response(request, -ENOMEM, spdk_strerror(ENOMEM));
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = bdev_ftl_get_stats(attrs.name, _rpc_bdev_ftl_get_stats, request, stats);
|
rc = bdev_ftl_get_stats(attrs.name, _rpc_bdev_ftl_get_stats, request, stats);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
free(stats);
|
free(stats);
|
||||||
spdk_jsonrpc_send_bool_response(request, false);
|
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1222,12 @@ _rpc_bdev_nvme_reset_controller_cb(void *_ctx)
|
|||||||
{
|
{
|
||||||
struct rpc_bdev_nvme_reset_controller_ctx *ctx = _ctx;
|
struct rpc_bdev_nvme_reset_controller_ctx *ctx = _ctx;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(ctx->request, ctx->success);
|
if (ctx->success) {
|
||||||
|
spdk_jsonrpc_send_bool_response(ctx->request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(ctx->request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||||
|
"Controller reset failed");
|
||||||
|
}
|
||||||
|
|
||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2018 Intel Corporation.
|
* Copyright (C) 2018 Intel Corporation.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (c) Samsung Electronics Co., Ltd.
|
* Copyright (c) Samsung Electronics Co., Ltd.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -95,7 +96,11 @@ _rpc_bdev_xnvme_delete_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2019 Intel Corporation.
|
* Copyright (C) 2019 Intel Corporation.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -89,7 +90,11 @@ _rpc_delete_zone_block_cb(void *cb_ctx, int rc)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_ctx;
|
struct spdk_jsonrpc_request *request = cb_ctx;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, rc == 0);
|
if (rc == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2020 Intel Corporation.
|
* Copyright (C) 2020 Intel Corporation.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -83,7 +84,12 @@ rpc_bdev_passthru_delete_cb(void *cb_arg, int bdeverrno)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = cb_arg;
|
struct spdk_jsonrpc_request *request = cb_arg;
|
||||||
|
|
||||||
spdk_jsonrpc_send_bool_response(request, bdeverrno == 0);
|
if (bdeverrno == 0) {
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
} else {
|
||||||
|
spdk_jsonrpc_send_error_response(request, bdeverrno, spdk_strerror(-bdeverrno));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user