]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/libpmemobj/alloc_class.h
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright 2016-2020, Intel Corporation */
5 * alloc_class.h -- internal definitions for allocation classes
8 #ifndef LIBPMEMOBJ_ALLOC_CLASS_H
9 #define LIBPMEMOBJ_ALLOC_CLASS_H 1
13 #include <sys/types.h>
14 #include "heap_layout.h"
21 #define MAX_ALLOCATION_CLASSES (UINT8_MAX)
22 #define DEFAULT_ALLOC_CLASS_ID (0)
23 #define RUN_UNIT_MAX RUN_BITS_PER_VALUE
25 struct alloc_class_collection
;
27 enum alloc_class_type
{
41 enum header_type header_type
;
42 enum alloc_class_type type
;
44 /* run-specific data */
45 struct run_descriptor rdsc
;
48 struct alloc_class_collection
*alloc_class_collection_new(void);
49 void alloc_class_collection_delete(struct alloc_class_collection
*ac
);
51 struct alloc_class
*alloc_class_by_run(
52 struct alloc_class_collection
*ac
,
53 size_t unit_size
, uint16_t flags
, uint32_t size_idx
);
54 struct alloc_class
*alloc_class_by_alloc_size(
55 struct alloc_class_collection
*ac
, size_t size
);
56 struct alloc_class
*alloc_class_by_id(
57 struct alloc_class_collection
*ac
, uint8_t id
);
59 int alloc_class_reserve(struct alloc_class_collection
*ac
, uint8_t id
);
60 int alloc_class_find_first_free_slot(struct alloc_class_collection
*ac
,
64 alloc_class_calc_size_idx(struct alloc_class
*c
, size_t size
);
67 alloc_class_new(int id
, struct alloc_class_collection
*ac
,
68 enum alloc_class_type type
, enum header_type htype
,
69 size_t unit_size
, size_t alignment
,
72 void alloc_class_delete(struct alloc_class_collection
*ac
,
73 struct alloc_class
*c
);