test/bdevio: Replace spdk_bdev_first/next_leaf() by spdk_for_each_bdev()
At the previous refactoring, most use cases for spdk_bdev_first/next() were replaced by spdk_for_each_bdev(). However, test/bdevio was not changed because this was a test tool. Finally, replace spdk_bdev_first_leaf() and spdk_bdev_next_leaf() by spdk_for_each_bdev() for test/bdevio in this patch. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: Ie62e7d2438b877e903af7882181564f8b7407c4d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16534 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
669069da0f
commit
d9cea478b2
@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2016 Intel Corporation.
|
* Copyright (C) 2016 Intel Corporation.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
* Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
@ -99,7 +99,7 @@ bdevio_construct_target_open_cb(enum spdk_bdev_event_type type, struct spdk_bdev
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bdevio_construct_target(struct spdk_bdev *bdev)
|
bdevio_construct_target(void *ctx, struct spdk_bdev *bdev)
|
||||||
{
|
{
|
||||||
struct io_target *target;
|
struct io_target *target;
|
||||||
int rc;
|
int rc;
|
||||||
@ -135,19 +135,14 @@ bdevio_construct_target(struct spdk_bdev *bdev)
|
|||||||
static int
|
static int
|
||||||
bdevio_construct_targets(void)
|
bdevio_construct_targets(void)
|
||||||
{
|
{
|
||||||
struct spdk_bdev *bdev;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
printf("I/O targets:\n");
|
printf("I/O targets:\n");
|
||||||
|
|
||||||
bdev = spdk_bdev_first_leaf();
|
rc = spdk_for_each_bdev_leaf(NULL, bdevio_construct_target);
|
||||||
while (bdev != NULL) {
|
if (rc < 0) {
|
||||||
rc = bdevio_construct_target(bdev);
|
SPDK_ERRLOG("Could not complete constructing bdevs, error=%d\n", rc);
|
||||||
if (rc < 0) {
|
return rc;
|
||||||
SPDK_ERRLOG("Could not construct bdev %s, error=%d\n", spdk_bdev_get_name(bdev), rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
bdev = spdk_bdev_next_leaf(bdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_io_targets == NULL) {
|
if (g_io_targets == NULL) {
|
||||||
@ -1507,7 +1502,7 @@ rpc_perform_tests(struct spdk_jsonrpc_request *request, const struct spdk_json_v
|
|||||||
req.name, spdk_strerror(ENODEV));
|
req.name, spdk_strerror(ENODEV));
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
rc = bdevio_construct_target(bdev);
|
rc = bdevio_construct_target(NULL, bdev);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
SPDK_ERRLOG("Could not construct target for bdev '%s'\n", spdk_bdev_get_name(bdev));
|
SPDK_ERRLOG("Could not construct target for bdev '%s'\n", spdk_bdev_get_name(bdev));
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||||
|
Loading…
Reference in New Issue
Block a user