ocf: add timeout functionality for vbdev_ocf_mngt_ interface
Allow user to set timeout for poller in management operations. Now also all management pollers have 5 sec default timeout. Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Change-Id: Ic75f2b150ef21ccd673b80aa84f16c9a24f90e32 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453655 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
bbbe9e1ce6
commit
c967d539d8
@ -74,7 +74,12 @@ mngt_poll_fn(void *opaque)
|
||||
struct vbdev_ocf *vbdev = opaque;
|
||||
|
||||
if (vbdev->mngt_ctx.poller_fn) {
|
||||
vbdev->mngt_ctx.poller_fn(vbdev);
|
||||
if (vbdev->mngt_ctx.timeout_ts &&
|
||||
spdk_get_ticks() >= vbdev->mngt_ctx.timeout_ts) {
|
||||
vbdev_ocf_mngt_continue(vbdev, -ETIMEDOUT);
|
||||
} else {
|
||||
vbdev->mngt_ctx.poller_fn(vbdev);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -104,11 +109,22 @@ vbdev_ocf_mngt_start(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
vbdev_ocf_mngt_poll_set_timeout(struct vbdev_ocf *vbdev, uint64_t millisec)
|
||||
{
|
||||
uint64_t ticks;
|
||||
|
||||
ticks = millisec * spdk_get_ticks_hz() / 1000;
|
||||
vbdev->mngt_ctx.timeout_ts = spdk_get_ticks() + ticks;
|
||||
}
|
||||
|
||||
void
|
||||
vbdev_ocf_mngt_poll(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn fn)
|
||||
{
|
||||
assert(vbdev->mngt_ctx.poller != NULL);
|
||||
vbdev->mngt_ctx.poller_fn = fn;
|
||||
vbdev_ocf_mngt_poll_set_timeout(vbdev, 5000);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -49,7 +49,8 @@ int vbdev_ocf_mngt_start(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn *path,
|
||||
vbdev_ocf_mngt_callback cb, void *cb_arg);
|
||||
|
||||
/* Continue execution with polling operation (fn)
|
||||
* fn must invoke vbdev_ocf_mngt_continue() to stop polling */
|
||||
* fn must invoke vbdev_ocf_mngt_continue() to stop polling
|
||||
* Poller has default timeout of 5 seconds */
|
||||
void vbdev_ocf_mngt_poll(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn fn);
|
||||
|
||||
/* Continue execution with next function that is on path
|
||||
|
@ -99,6 +99,8 @@ struct vbdev_ocf_mngt_ctx {
|
||||
struct spdk_poller *poller;
|
||||
/* Function that gets invoked by poller on each iteration */
|
||||
vbdev_ocf_mngt_fn poller_fn;
|
||||
/* Poller timeout time stamp - when the poller should stop with error */
|
||||
uint64_t timeout_ts;
|
||||
|
||||
/* Status of management operation */
|
||||
int status;
|
||||
|
Loading…
Reference in New Issue
Block a user