bdev/nvme: Separate helper function find_io_path() between nvme and ocssd
This enables us to optimize nvme_bdev for multipath. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I09dcc6b34b4529fe1f90dbe0fddcbee807cf217e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8148 Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
6127461c93
commit
980b501c98
@ -251,6 +251,28 @@ static struct spdk_bdev_module nvme_if = {
|
||||
};
|
||||
SPDK_BDEV_MODULE_REGISTER(nvme, &nvme_if)
|
||||
|
||||
static inline bool
|
||||
bdev_nvme_find_io_path(struct nvme_bdev *nbdev, struct nvme_io_path *io_path,
|
||||
struct nvme_bdev_ns **_nvme_ns, struct spdk_nvme_qpair **_qpair)
|
||||
{
|
||||
if (spdk_unlikely(io_path->qpair == NULL)) {
|
||||
/* The device is currently resetting. */
|
||||
return false;
|
||||
}
|
||||
|
||||
*_nvme_ns = nbdev->nvme_ns;
|
||||
*_qpair = io_path->qpair;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bdev_nvme_find_admin_path(struct nvme_io_path *io_path,
|
||||
struct nvme_bdev_ctrlr **_nvme_bdev_ctrlr)
|
||||
{
|
||||
*_nvme_bdev_ctrlr = io_path->ctrlr;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void
|
||||
bdev_nvme_io_complete_nvme_status(struct nvme_bdev_io *bio,
|
||||
const struct spdk_nvme_cpl *cpl)
|
||||
|
@ -105,6 +105,20 @@ bdev_ocssd_get_ns_from_nvme(struct nvme_bdev_ns *nvme_ns)
|
||||
return nvme_ns->type_ctx;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bdev_ocssd_find_io_path(struct nvme_bdev *nbdev, struct nvme_io_path *io_path,
|
||||
struct nvme_bdev_ns **_nvme_ns, struct spdk_nvme_qpair **_qpair)
|
||||
{
|
||||
if (spdk_unlikely(io_path->qpair == NULL)) {
|
||||
/* The device is currently resetting. */
|
||||
return false;
|
||||
}
|
||||
|
||||
*_nvme_ns = nbdev->nvme_ns;
|
||||
*_qpair = io_path->qpair;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_ocssd_library_init(void)
|
||||
{
|
||||
@ -524,7 +538,7 @@ bdev_ocssd_io_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
|
||||
return;
|
||||
}
|
||||
|
||||
if (spdk_unlikely(!bdev_nvme_find_io_path(&ocssd_bdev->nvme_bdev, io_path,
|
||||
if (spdk_unlikely(!bdev_ocssd_find_io_path(&ocssd_bdev->nvme_bdev, io_path,
|
||||
&nvme_ns, &qpair))) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
return;
|
||||
@ -653,7 +667,7 @@ bdev_ocssd_zone_info_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
|
||||
|
||||
io_path = spdk_io_channel_get_ctx(spdk_bdev_io_get_io_channel(bdev_io));
|
||||
|
||||
if (spdk_unlikely(!bdev_nvme_find_io_path(&ocssd_bdev->nvme_bdev, io_path, &nvme_ns, &qpair))) {
|
||||
if (spdk_unlikely(!bdev_ocssd_find_io_path(&ocssd_bdev->nvme_bdev, io_path, &nvme_ns, &qpair))) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
return;
|
||||
}
|
||||
@ -786,7 +800,7 @@ _bdev_ocssd_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev
|
||||
struct nvme_bdev_ns *nvme_ns;
|
||||
struct spdk_nvme_qpair *qpair;
|
||||
|
||||
if (spdk_unlikely(!bdev_nvme_find_io_path(&ocssd_bdev->nvme_bdev, io_path,
|
||||
if (spdk_unlikely(!bdev_ocssd_find_io_path(&ocssd_bdev->nvme_bdev, io_path,
|
||||
&nvme_ns, &qpair))) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -177,26 +177,4 @@ void nvme_bdev_dump_trid_json(const struct spdk_nvme_transport_id *trid,
|
||||
void nvme_bdev_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr);
|
||||
void nvme_bdev_ctrlr_unregister(void *ctx);
|
||||
|
||||
static inline bool
|
||||
bdev_nvme_find_io_path(struct nvme_bdev *nbdev, struct nvme_io_path *io_path,
|
||||
struct nvme_bdev_ns **_nvme_ns, struct spdk_nvme_qpair **_qpair)
|
||||
{
|
||||
if (spdk_unlikely(io_path->qpair == NULL)) {
|
||||
/* The device is currently resetting. */
|
||||
return false;
|
||||
}
|
||||
|
||||
*_nvme_ns = nbdev->nvme_ns;
|
||||
*_qpair = io_path->qpair;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bdev_nvme_find_admin_path(struct nvme_io_path *io_path,
|
||||
struct nvme_bdev_ctrlr **_nvme_bdev_ctrlr)
|
||||
{
|
||||
*_nvme_bdev_ctrlr = io_path->ctrlr;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* SPDK_COMMON_BDEV_NVME_H */
|
||||
|
Loading…
Reference in New Issue
Block a user