ocf: add vbdev_ocf_mngt_stop() function

Add stop function to management interface.
It is needed for error handling when execution has to be aborted early.

Example flow:
```
rc = op();
if (rc) {
   handle();
   vbdev_ocf_mngt_stop();
} else {
   vbdev_ocf_mngt_continue();
}
```

This can be improved in the future, because currently, error
  handling cannot be a management operation on its own (but should be).

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Change-Id: I9ba528db8a9957ee561e5c1b5528b16bd143d5d8
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453654
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:
Vitaliy Mysak 2019-05-08 09:49:17 +02:00 committed by Darek Stojaczyk
parent 61948a1ca7
commit bbbe9e1ce6
2 changed files with 16 additions and 5 deletions

View File

@ -111,6 +111,18 @@ vbdev_ocf_mngt_poll(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn fn)
vbdev->mngt_ctx.poller_fn = fn;
}
void
vbdev_ocf_mngt_stop(struct vbdev_ocf *vbdev)
{
spdk_poller_unregister(&vbdev->mngt_ctx.poller);
if (vbdev->mngt_ctx.cb) {
vbdev->mngt_ctx.cb(vbdev->mngt_ctx.status, vbdev, vbdev->mngt_ctx.cb_arg);
}
memset(&vbdev->mngt_ctx, 0, sizeof(vbdev->mngt_ctx));
}
void
vbdev_ocf_mngt_continue(struct vbdev_ocf *vbdev, int status)
{
@ -129,9 +141,5 @@ vbdev_ocf_mngt_continue(struct vbdev_ocf *vbdev, int status)
return;
}
spdk_poller_unregister(&vbdev->mngt_ctx.poller);
if (vbdev->mngt_ctx.cb) {
vbdev->mngt_ctx.cb(vbdev->mngt_ctx.status, vbdev, vbdev->mngt_ctx.cb_arg);
}
memset(&vbdev->mngt_ctx, 0, sizeof(vbdev->mngt_ctx));
vbdev_ocf_mngt_stop(vbdev);
}

View File

@ -56,4 +56,7 @@ void vbdev_ocf_mngt_poll(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn fn);
* If next function is NULL, finish management operation and invoke callback */
void vbdev_ocf_mngt_continue(struct vbdev_ocf *vbdev, int status);
/* Stop the execution and invoke callback with last status returned */
void vbdev_ocf_mngt_stop(struct vbdev_ocf *vbdev);
#endif