2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef __METADATA_PARTITION_H__
7 #define __METADATA_PARTITION_H__
9 #include "metadata_partition_structs.h"
10 #include "../ocf_cache_priv.h"
12 #define PARTITION_DEFAULT 0
13 #define PARTITION_INVALID ((ocf_part_id_t)-1)
14 #define PARTITION_SIZE_MAX ((ocf_cache_line_t)-1)
16 static inline void ocf_metadata_get_partition_info(
17 struct ocf_cache
*cache
, ocf_cache_line_t line
,
18 ocf_part_id_t
*part_id
, ocf_cache_line_t
*next_line
,
19 ocf_cache_line_t
*prev_line
)
21 cache
->metadata
.iface
.get_partition_info(cache
, line
, part_id
,
22 next_line
, prev_line
);
25 static inline ocf_part_id_t
ocf_metadata_get_partition_id(
26 struct ocf_cache
*cache
, ocf_cache_line_t line
)
28 ocf_part_id_t part_id
;
30 ocf_metadata_get_partition_info(cache
, line
, &part_id
, NULL
, NULL
);
35 static inline ocf_cache_line_t
ocf_metadata_get_partition_next(
36 struct ocf_cache
*cache
, ocf_cache_line_t line
)
38 ocf_cache_line_t next
;
40 ocf_metadata_get_partition_info(cache
, line
, NULL
, &next
, NULL
);
45 static inline ocf_cache_line_t
ocf_metadata_get_partition_prev(
46 struct ocf_cache
*cache
, ocf_cache_line_t line
)
48 ocf_cache_line_t prev
;
50 ocf_metadata_get_partition_info(cache
, line
, NULL
, NULL
, &prev
);
55 static inline void ocf_metadata_set_partition_next(
56 struct ocf_cache
*cache
, ocf_cache_line_t line
,
57 ocf_cache_line_t next_line
)
59 cache
->metadata
.iface
.set_partition_next(cache
, line
, next_line
);
62 static inline void ocf_metadata_set_partition_prev(
63 struct ocf_cache
*cache
, ocf_cache_line_t line
,
64 ocf_cache_line_t prev_line
)
66 cache
->metadata
.iface
.set_partition_prev(cache
, line
, prev_line
);
69 static inline void ocf_metadata_set_partition_info(
70 struct ocf_cache
*cache
, ocf_cache_line_t line
,
71 ocf_part_id_t part_id
, ocf_cache_line_t next_line
,
72 ocf_cache_line_t prev_line
)
74 cache
->metadata
.iface
.set_partition_info(cache
, line
, part_id
,
75 next_line
, prev_line
);
78 void ocf_metadata_add_to_partition(struct ocf_cache
*cache
,
79 ocf_part_id_t part_id
, ocf_cache_line_t line
);
81 void ocf_metadata_remove_from_partition(struct ocf_cache
*cache
,
82 ocf_part_id_t part_id
, ocf_cache_line_t line
);
84 #endif /* __METADATA_PARTITION_H__ */