ocf/src/engine/engine_flush.c
Robert Baldyga 1ed707361f Modify engines to use forward API
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
2024-09-19 15:55:19 +02:00

58 lines
1.3 KiB
C

/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_common.h"
#include "engine_io.h"
#include "cache_engine.h"
#include "engine_flush.h"
#include "../ocf_request.h"
#define OCF_ENGINE_DEBUG_IO_NAME "flush"
#include "engine_debug.h"
static void _ocf_engine_flush_complete(struct ocf_request *req, int error)
{
if (error)
req->error = req->error ?: error;
if (env_atomic_dec_return(&req->req_remaining))
return;
OCF_DEBUG_RQ(req, "Completion");
if (req->error) {
/* An error occured */
ocf_engine_error(req, false, "Core operation failure");
}
/* Complete requests - both to cache and to core*/
req->complete(req, req->error);
/* Release OCF request */
ocf_req_put(req);
}
int ocf_engine_flush(struct ocf_request *req)
{
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* IO to the core device and to the cache device */
env_atomic_set(&req->req_remaining, 2);
/* Submit operation into core device */
ocf_engine_forward_core_flush_req(req, _ocf_engine_flush_complete);
/* submit flush to cache device */
ocf_engine_forward_cache_flush_req(req, _ocf_engine_flush_complete);
/* Put OCF request - decrease reference counter */
ocf_req_put(req);
return 0;
}