bdev/nvme: Replace nvme_bdev_first/next_ctrlr() by nvme_ctrlr_for_each()
Replace two helper functions, nvme_bdev_first_ctrlr() and nvme_bdev_next_ctrlr() by an new helper function nvme_ctrlr_for_each(). This will make us easier to guard data structure correctly in the following patches. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ibd81286e454fd6127fd150a7d48d8381bd1b89d3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8721 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
4af68eade6
commit
ca4dfff9e1
@ -412,9 +412,9 @@ SPDK_RPC_REGISTER("bdev_nvme_attach_controller", rpc_bdev_nvme_attach_controller
|
|||||||
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_nvme_attach_controller, construct_nvme_bdev)
|
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_nvme_attach_controller, construct_nvme_bdev)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rpc_dump_nvme_controller_info(struct spdk_json_write_ctx *w,
|
rpc_dump_nvme_controller_info(struct nvme_ctrlr *nvme_ctrlr, void *ctx)
|
||||||
struct nvme_ctrlr *nvme_ctrlr)
|
|
||||||
{
|
{
|
||||||
|
struct spdk_json_write_ctx *w = ctx;
|
||||||
struct spdk_nvme_transport_id *trid;
|
struct spdk_nvme_transport_id *trid;
|
||||||
|
|
||||||
trid = nvme_ctrlr->connected_trid;
|
trid = nvme_ctrlr->connected_trid;
|
||||||
@ -483,11 +483,9 @@ rpc_bdev_nvme_get_controllers(struct spdk_jsonrpc_request *request,
|
|||||||
spdk_json_write_array_begin(w);
|
spdk_json_write_array_begin(w);
|
||||||
|
|
||||||
if (ctrlr != NULL) {
|
if (ctrlr != NULL) {
|
||||||
rpc_dump_nvme_controller_info(w, ctrlr);
|
rpc_dump_nvme_controller_info(ctrlr, w);
|
||||||
} else {
|
} else {
|
||||||
for (ctrlr = nvme_bdev_first_ctrlr(); ctrlr; ctrlr = nvme_bdev_next_ctrlr(ctrlr)) {
|
nvme_ctrlr_for_each(rpc_dump_nvme_controller_info, w);
|
||||||
rpc_dump_nvme_controller_info(w, ctrlr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_json_write_array_end(w);
|
spdk_json_write_array_end(w);
|
||||||
|
@ -71,16 +71,14 @@ nvme_ctrlr_get_by_name(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct nvme_ctrlr *
|
void
|
||||||
nvme_bdev_first_ctrlr(void)
|
nvme_ctrlr_for_each(nvme_ctrlr_for_each_fn fn, void *ctx)
|
||||||
{
|
{
|
||||||
return TAILQ_FIRST(&g_nvme_ctrlrs);
|
struct nvme_ctrlr *nvme_ctrlr;
|
||||||
}
|
|
||||||
|
|
||||||
struct nvme_ctrlr *
|
TAILQ_FOREACH(nvme_ctrlr, &g_nvme_ctrlrs, tailq) {
|
||||||
nvme_bdev_next_ctrlr(struct nvme_ctrlr *prev)
|
fn(nvme_ctrlr, ctx);
|
||||||
{
|
}
|
||||||
return TAILQ_NEXT(prev, tailq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -168,8 +168,10 @@ void nvme_ctrlr_depopulate_namespace_done(struct nvme_ns *nvme_ns);
|
|||||||
|
|
||||||
struct nvme_ctrlr *nvme_ctrlr_get(const struct spdk_nvme_transport_id *trid);
|
struct nvme_ctrlr *nvme_ctrlr_get(const struct spdk_nvme_transport_id *trid);
|
||||||
struct nvme_ctrlr *nvme_ctrlr_get_by_name(const char *name);
|
struct nvme_ctrlr *nvme_ctrlr_get_by_name(const char *name);
|
||||||
struct nvme_ctrlr *nvme_bdev_first_ctrlr(void);
|
|
||||||
struct nvme_ctrlr *nvme_bdev_next_ctrlr(struct nvme_ctrlr *prev);
|
typedef void (*nvme_ctrlr_for_each_fn)(struct nvme_ctrlr *nvme_ctrlr, void *ctx);
|
||||||
|
|
||||||
|
void nvme_ctrlr_for_each(nvme_ctrlr_for_each_fn fn, void *ctx);
|
||||||
|
|
||||||
void nvme_bdev_dump_trid_json(const struct spdk_nvme_transport_id *trid,
|
void nvme_bdev_dump_trid_json(const struct spdk_nvme_transport_id *trid,
|
||||||
struct spdk_json_write_ctx *w);
|
struct spdk_json_write_ctx *w);
|
||||||
|
Loading…
Reference in New Issue
Block a user