forked from dmdedup/dmdedup3.19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdm-dedup-backend.h
114 lines (99 loc) · 2.95 KB
/
dm-dedup-backend.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (C) 2012-2014 Vasily Tarasov
* Copyright (C) 2012-2014 Geoff Kuenning
* Copyright (C) 2012-2014 Sonam Mandal
* Copyright (C) 2012-2014 Karthikeyani Palanisami
* Copyright (C) 2012-2014 Philip Shilane
* Copyright (C) 2012-2014 Sagar Trehan
* Copyright (C) 2012-2014 Erez Zadok
*
* This file is released under the GPL.
*/
#ifndef BACKEND_H
#define BACKEND_H
struct metadata; /* metadata store identifier */
struct kvstore; /* key-value store identifier */
#define BF_NEGATIVE -1
#define BF_POSITIVE 0
struct metadata_ops {
/*
* Returns ERR_PTR(*) on error.
* Valid pointer on success.
*/
struct metadata * (*init_meta)(void *init_param, bool *unformatted);
void (*exit_meta)(struct metadata *md);
/*
* Creates linear key-value store. Ksize and vsize in bytes.
* If ksize or vsize are equal to zero, it means that keys
* and values will be of a variable size. kmax is the
* maximum _value_ of the key. If kmax is equal to zero,
* then maximum is not known by the caller.
*
* Returns -ERR_PTR(*) on error.
* Valid pointer on success.
*/
struct kvstore * (*kvs_create_linear)(struct metadata *md,
uint32_t ksize, uint32_t vsize, uint32_t kmax,
bool unformatted);
/*
* Creates sparse key-value store. Ksize and vsize in bytes.
* If ksize or vsize are equal to zero, it means that keys
* and values will be of a variable size. knummax is the
* maximum _number_ of the keys. If keymax is equal to zero,
* then maximum is not known by the caller.
*
* Returns -ERR_PTR(*) on error.
* Valid pointer on success.
*/
struct kvstore * (*kvs_create_sparse)(struct metadata *md,
uint32_t ksize, uint32_t vsize, uint32_t knummax,
bool unformatted);
/*
* Returns -ERR* on error.
* Returns 0 on success. In this case, "blockn" contains a newly
* allocated block number.
*/
int (*alloc_data_block)(struct metadata *md, uint64_t *blockn);
/*
* Returns -ERR* on error.
* Returns 0 on success.
*/
int (*inc_refcount)(struct metadata *md, uint64_t blockn);
/*
* Returns -ERR* on error.
* Returns 0 on success.
*/
int (*dec_refcount)(struct metadata *md, uint64_t blockn);
/*
* Returns -ERR* on error.
* Returns 0 on success.
*/
int (*get_refcount)(struct metadata *md, uint64_t blockn);
/*
* Returns -ERR on error.
* Return 0 on success.
*/
int (*flush_meta)(struct metadata *md);
/*
* Returns the private data stored in the metadata.
*
* Returns -ERR* on error.
* Returns 0 on success.
*/
int (*get_private_data)(struct metadata *md, void **data,
uint32_t size);
/*
* Fills in private data stored in the metadata.
*
* Returns -ERR* on error.
* Returns 0 on success.
*/
int (*set_private_data)(struct metadata *md, void *data, uint32_t size);
/*
* This is a hack to drop cache. In future we want to implement
* proper message passing interface, to accomplish this and other
* tasks.
*/
void (*flush_bufio_cache)(struct metadata *md);
};
#endif /* BACKEND_H */