-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathengine_inv.c
More file actions
66 lines (50 loc) · 1.55 KB
/
Copy pathengine_inv.c
File metadata and controls
66 lines (50 loc) · 1.55 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
59
60
61
62
63
64
65
66
/*
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_inv.h"
#include "engine_common.h"
#include "cache_engine.h"
#include "../ocf_request.h"
#include "../utils/utils_cache_line.h"
#include "../metadata/metadata.h"
#include "../concurrency/ocf_concurrency.h"
#define OCF_ENGINE_DEBUG_IO_NAME "inv"
#include "engine_debug.h"
static void _ocf_invalidate_req(struct ocf_request *req, int error)
{
if (error) {
env_atomic_cmpxchg(&req->error, 0, error);
ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
}
if (env_atomic_dec_return(&req->req_remaining))
return;
OCF_DEBUG_RQ(req, "Completion");
if (env_atomic_read(&req->error))
ocf_engine_error(req, true, "Failed to flush metadata to cache");
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);
/* Put OCF request - decrease reference counter */
ocf_req_put(req);
}
static int _ocf_invalidate_do(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
ENV_BUG_ON(env_atomic_read(&req->req_remaining));
ocf_hb_req_prot_lock_wr(req);
ocf_purge_map_info(req);
ocf_hb_req_prot_unlock_wr(req);
env_atomic_inc(&req->req_remaining);
if (ocf_volume_is_atomic(&cache->device->volume) &&
req->info.flush_metadata) {
/* Metadata flush IO */
ocf_metadata_flush_do_asynch(cache, req, _ocf_invalidate_req);
}
_ocf_invalidate_req(req, 0);
return 0;
}
void ocf_engine_invalidate(struct ocf_request *req)
{
ocf_engine_push_req_front_cb(req, _ocf_invalidate_do, true);
}