module/raid: move error code check out of raid_bdev_queue_io_wait()
Don't pass the error code to the function and instead move the -ENOMEM check to the callers where it makes more sense. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Change-Id: Ib2fa92315dc2973d4023fd9509950589de946614 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473452 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
cb8dbf17dc
commit
d3a04643bf
@ -318,32 +318,22 @@ raid_bdev_base_io_completion(struct spdk_bdev_io *bdev_io, bool success, void *c
|
|||||||
* raid_bdev_io - pointer to raid bdev_io
|
* raid_bdev_io - pointer to raid bdev_io
|
||||||
* pd_idx - base_dev index in raid_bdev
|
* pd_idx - base_dev index in raid_bdev
|
||||||
* cb_fn - callback when the spdk_bdev_io for base_bdev becomes available
|
* cb_fn - callback when the spdk_bdev_io for base_bdev becomes available
|
||||||
* ret - return code
|
|
||||||
* returns:
|
* returns:
|
||||||
* none
|
* none
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
raid_bdev_queue_io_wait(struct spdk_bdev_io *raid_bdev_io, uint8_t pd_idx,
|
raid_bdev_queue_io_wait(struct spdk_bdev_io *raid_bdev_io, uint8_t pd_idx,
|
||||||
spdk_bdev_io_wait_cb cb_fn, int ret)
|
spdk_bdev_io_wait_cb cb_fn)
|
||||||
{
|
{
|
||||||
struct raid_bdev_io *raid_io = (struct raid_bdev_io *)raid_bdev_io->driver_ctx;
|
struct raid_bdev_io *raid_io = (struct raid_bdev_io *)raid_bdev_io->driver_ctx;
|
||||||
struct raid_bdev *raid_bdev = raid_io->raid_bdev;
|
struct raid_bdev *raid_bdev = raid_io->raid_bdev;
|
||||||
|
|
||||||
assert(ret != 0);
|
raid_io->waitq_entry.bdev = raid_bdev->base_bdev_info[pd_idx].bdev;
|
||||||
|
raid_io->waitq_entry.cb_fn = cb_fn;
|
||||||
if (ret == -ENOMEM) {
|
raid_io->waitq_entry.cb_arg = raid_bdev_io;
|
||||||
raid_io->waitq_entry.bdev = raid_bdev->base_bdev_info[pd_idx].bdev;
|
spdk_bdev_queue_io_wait(raid_bdev->base_bdev_info[pd_idx].bdev,
|
||||||
raid_io->waitq_entry.cb_fn = cb_fn;
|
raid_io->raid_ch->base_channel[pd_idx],
|
||||||
raid_io->waitq_entry.cb_arg = raid_bdev_io;
|
&raid_io->waitq_entry);
|
||||||
spdk_bdev_queue_io_wait(raid_bdev->base_bdev_info[pd_idx].bdev,
|
|
||||||
raid_io->raid_ch->base_channel[pd_idx],
|
|
||||||
&raid_io->waitq_entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SPDK_ERRLOG("bdev io submit error not due to ENOMEM, it should not happen\n");
|
|
||||||
assert(false);
|
|
||||||
spdk_bdev_io_complete(raid_bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -388,9 +378,14 @@ raid_bdev_submit_reset_request(struct raid_bdev_io *raid_io)
|
|||||||
raid_bdev_base_io_completion, bdev_io);
|
raid_bdev_base_io_completion, bdev_io);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
raid_io->base_bdev_io_submitted++;
|
raid_io->base_bdev_io_submitted++;
|
||||||
} else {
|
} else if (ret == -ENOMEM) {
|
||||||
raid_bdev_queue_io_wait(bdev_io, i,
|
raid_bdev_queue_io_wait(bdev_io, i,
|
||||||
_raid_bdev_submit_reset_request, ret);
|
_raid_bdev_submit_reset_request);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
SPDK_ERRLOG("bdev io submit error not due to ENOMEM, it should not happen\n");
|
||||||
|
assert(false);
|
||||||
|
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,6 @@ void
|
|||||||
raid_bdev_base_io_completion(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg);
|
raid_bdev_base_io_completion(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg);
|
||||||
void
|
void
|
||||||
raid_bdev_queue_io_wait(struct spdk_bdev_io *raid_bdev_io, uint8_t pd_idx,
|
raid_bdev_queue_io_wait(struct spdk_bdev_io *raid_bdev_io, uint8_t pd_idx,
|
||||||
spdk_bdev_io_wait_cb cb_fn, int ret);
|
spdk_bdev_io_wait_cb cb_fn);
|
||||||
|
|
||||||
#endif /* SPDK_BDEV_RAID_INTERNAL_H */
|
#endif /* SPDK_BDEV_RAID_INTERNAL_H */
|
||||||
|
@ -136,8 +136,12 @@ raid0_submit_rw_request(struct raid_bdev_io *raid_io)
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret == -ENOMEM) {
|
||||||
raid_bdev_queue_io_wait(bdev_io, pd_idx, raid0_waitq_io_process, ret);
|
raid_bdev_queue_io_wait(bdev_io, pd_idx, raid0_waitq_io_process);
|
||||||
|
} else if (ret != 0) {
|
||||||
|
SPDK_ERRLOG("bdev io submit error not due to ENOMEM, it should not happen\n");
|
||||||
|
assert(false);
|
||||||
|
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,9 +331,14 @@ raid0_submit_null_payload_request(struct raid_bdev_io *raid_io)
|
|||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
raid_io->base_bdev_io_submitted++;
|
raid_io->base_bdev_io_submitted++;
|
||||||
} else {
|
} else if (ret == -ENOMEM) {
|
||||||
raid_bdev_queue_io_wait(bdev_io, disk_idx,
|
raid_bdev_queue_io_wait(bdev_io, disk_idx,
|
||||||
_raid0_submit_null_payload_request, ret);
|
_raid0_submit_null_payload_request);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
SPDK_ERRLOG("bdev io submit error not due to ENOMEM, it should not happen\n");
|
||||||
|
assert(false);
|
||||||
|
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user