1
2
3
4
5
6
7 #ifndef DM_BIO_PRISON_H
8 #define DM_BIO_PRISON_H
9
10 #include "persistent-data/dm-block-manager.h"
11 #include "dm-thin-metadata.h"
12
13 #include <linux/bio.h>
14 #include <linux/rbtree.h>
15
16
17
18
19
20
21
22
23
24 struct dm_bio_prison;
25
26
27
28
29
30 struct dm_cell_key {
31 int virtual;
32 dm_thin_id dev;
33 dm_block_t block_begin, block_end;
34 };
35
36
37
38
39
40 struct dm_bio_prison_cell {
41 struct list_head user_list;
42 struct rb_node node;
43
44 struct dm_cell_key key;
45 struct bio *holder;
46 struct bio_list bios;
47 };
48
49 struct dm_bio_prison *dm_bio_prison_create(void);
50 void dm_bio_prison_destroy(struct dm_bio_prison *prison);
51
52
53
54
55
56
57
58
59 struct dm_bio_prison_cell *dm_bio_prison_alloc_cell(struct dm_bio_prison *prison,
60 gfp_t gfp);
61 void dm_bio_prison_free_cell(struct dm_bio_prison *prison,
62 struct dm_bio_prison_cell *cell);
63
64
65
66
67
68
69
70 int dm_get_cell(struct dm_bio_prison *prison,
71 struct dm_cell_key *key,
72 struct dm_bio_prison_cell *cell_prealloc,
73 struct dm_bio_prison_cell **cell_result);
74
75
76
77
78
79
80
81 int dm_bio_detain(struct dm_bio_prison *prison,
82 struct dm_cell_key *key,
83 struct bio *inmate,
84 struct dm_bio_prison_cell *cell_prealloc,
85 struct dm_bio_prison_cell **cell_result);
86
87 void dm_cell_release(struct dm_bio_prison *prison,
88 struct dm_bio_prison_cell *cell,
89 struct bio_list *bios);
90 void dm_cell_release_no_holder(struct dm_bio_prison *prison,
91 struct dm_bio_prison_cell *cell,
92 struct bio_list *inmates);
93 void dm_cell_error(struct dm_bio_prison *prison,
94 struct dm_bio_prison_cell *cell, blk_status_t error);
95
96
97
98
99
100 void dm_cell_visit_release(struct dm_bio_prison *prison,
101 void (*visit_fn)(void *, struct dm_bio_prison_cell *),
102 void *context, struct dm_bio_prison_cell *cell);
103
104
105
106
107
108
109
110
111
112
113
114 int dm_cell_promote_or_release(struct dm_bio_prison *prison,
115 struct dm_bio_prison_cell *cell);
116
117
118
119
120
121
122
123
124
125
126 struct dm_deferred_set;
127 struct dm_deferred_entry;
128
129 struct dm_deferred_set *dm_deferred_set_create(void);
130 void dm_deferred_set_destroy(struct dm_deferred_set *ds);
131
132 struct dm_deferred_entry *dm_deferred_entry_inc(struct dm_deferred_set *ds);
133 void dm_deferred_entry_dec(struct dm_deferred_entry *entry, struct list_head *head);
134 int dm_deferred_set_add_work(struct dm_deferred_set *ds, struct list_head *work);
135
136
137
138 #endif