From 40cac0ecaddd1a30d93d4e3cca4788453198e4da Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Wed, 17 Apr 2019 18:55:31 +0000 Subject: [PATCH] ocf: send flush during shutdown Do management flush during OCF shutdown to write all dirty requests to cores. Dirty requests are relevant to WriteBack mode only. Change-Id: I778a73ed8ab5659921f192f638027d513c239814 Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450683 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris --- lib/bdev/ocf/vbdev_ocf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/bdev/ocf/vbdev_ocf.c b/lib/bdev/ocf/vbdev_ocf.c index 86c71081cd..64edc14801 100644 --- a/lib/bdev/ocf/vbdev_ocf.c +++ b/lib/bdev/ocf/vbdev_ocf.c @@ -306,8 +306,40 @@ wait_for_requests(struct vbdev_ocf *vbdev) vbdev_ocf_mngt_poll(vbdev, wait_for_requests_poll); } +static void +flush_vbdev_cmpl(ocf_cache_t cache, void *priv, int error) +{ + struct vbdev_ocf *vbdev = priv; + + ocf_mngt_cache_unlock(cache); + vbdev_ocf_mngt_continue(vbdev, error); +} + +static void +flush_vbdev_poll(struct vbdev_ocf *vbdev) +{ + if (!ocf_cache_is_running(vbdev->ocf_cache)) { + vbdev_ocf_mngt_continue(vbdev, -EINVAL); + return; + } + + if (ocf_mngt_cache_trylock(vbdev->ocf_cache)) { + return; + } + + vbdev_ocf_mngt_poll(vbdev, NULL); + ocf_mngt_cache_flush(vbdev->ocf_cache, false, flush_vbdev_cmpl, vbdev); +} + +static void +flush_vbdev(struct vbdev_ocf *vbdev) +{ + vbdev_ocf_mngt_poll(vbdev, flush_vbdev_poll); +} + /* Procedures called during unregister */ vbdev_ocf_mngt_fn unregister_path[] = { + flush_vbdev, wait_for_requests, stop_vbdev, detach_cache,