module/blobfs: 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. Replace one of the
remaining cases in this patch.

rpc_blobfs_detect() uses boolean response for not only true but also
false, but it had a memory leak bug. Fix it together in this patch.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Iaff21115282f638038345daa986b5c743ba9a3ed
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16621
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2023-01-31 11:48:17 +09:00 committed by Jim Harris
parent c77bc554d2
commit 841cd8b939

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2019 Intel Corporation.
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* All rights reserved.
*/
@ -54,7 +55,11 @@ rpc_blobfs_set_cache_size(struct spdk_jsonrpc_request *request,
rc = spdk_fs_set_cache_size(req.size_in_mb);
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));
}
}
SPDK_RPC_REGISTER("blobfs_set_cache_size", rpc_blobfs_set_cache_size,
@ -89,7 +94,7 @@ _rpc_blobfs_detect_done(void *cb_arg, int fserrno)
} else if (fserrno != 0) {
spdk_jsonrpc_send_error_response(req->request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
spdk_strerror(-fserrno));
free_rpc_blobfs_detect(req);
return;
}