-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathengine_ops.c
More file actions
60 lines (44 loc) · 1.33 KB
/
Copy pathengine_ops.c
File metadata and controls
60 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_common.h"
#include "cache_engine.h"
#include "engine_ops.h"
#include "../ocf_request.h"
#include "../utils/utils_io.h"
#define OCF_ENGINE_DEBUG_IO_NAME "ops"
#include "engine_debug.h"
static void _ocf_engine_ops_complete(struct ocf_request *req, int error)
{
if (error)
env_atomic_cmpxchg(&req->error, 0, error);
if (env_atomic_dec_return(&req->req_remaining))
return;
OCF_DEBUG_RQ(req, "Completion");
if (env_atomic_read(&req->error)) {
/* An error occured */
ocf_engine_error(req, false, "Core operation failure");
}
/* Complete requests - both to cache and to core*/
req->complete(req, env_atomic_read(&req->error));
/* Release OCF request */
ocf_req_put(req);
}
int ocf_engine_ops(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_submit_volume_req(&req->core->volume, req,
_ocf_engine_ops_complete);
/* submit flush to cache device */
ocf_submit_cache_flush(req, _ocf_engine_ops_complete);
/* Put OCF request - decrease reference counter */
ocf_req_put(req);
return 0;
}