1
2
3
4
5
6
7
8
9
10 #ifndef DM_REGION_HASH_H
11 #define DM_REGION_HASH_H
12
13 #include <linux/dm-dirty-log.h>
14
15
16
17
18 struct dm_region_hash;
19 struct dm_region;
20
21
22
23
24 enum dm_rh_region_states {
25 DM_RH_CLEAN = 0x01,
26 DM_RH_DIRTY = 0x02,
27 DM_RH_NOSYNC = 0x04,
28 DM_RH_RECOVERING = 0x08,
29 };
30
31
32
33
34 struct bio_list;
35 struct dm_region_hash *dm_region_hash_create(
36 void *context, void (*dispatch_bios)(void *context,
37 struct bio_list *bios),
38 void (*wakeup_workers)(void *context),
39 void (*wakeup_all_recovery_waiters)(void *context),
40 sector_t target_begin, unsigned max_recovery,
41 struct dm_dirty_log *log, uint32_t region_size,
42 region_t nr_regions);
43 void dm_region_hash_destroy(struct dm_region_hash *rh);
44
45 struct dm_dirty_log *dm_rh_dirty_log(struct dm_region_hash *rh);
46
47
48
49
50 region_t dm_rh_bio_to_region(struct dm_region_hash *rh, struct bio *bio);
51 sector_t dm_rh_region_to_sector(struct dm_region_hash *rh, region_t region);
52 void *dm_rh_region_context(struct dm_region *reg);
53
54
55
56
57 sector_t dm_rh_get_region_size(struct dm_region_hash *rh);
58 region_t dm_rh_get_region_key(struct dm_region *reg);
59
60
61
62
63
64 int dm_rh_get_state(struct dm_region_hash *rh, region_t region, int may_block);
65 void dm_rh_set_state(struct dm_region_hash *rh, region_t region,
66 enum dm_rh_region_states state, int may_block);
67
68
69 void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
70
71
72 int dm_rh_flush(struct dm_region_hash *rh);
73
74
75 void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);
76 void dm_rh_dec(struct dm_region_hash *rh, region_t region);
77
78
79 void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
80
81 void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio);
82
83
84
85
86
87
88 void dm_rh_recovery_prepare(struct dm_region_hash *rh);
89
90
91 struct dm_region *dm_rh_recovery_start(struct dm_region_hash *rh);
92
93
94 void dm_rh_recovery_end(struct dm_region *reg, int error);
95
96
97 int dm_rh_recovery_in_flight(struct dm_region_hash *rh);
98
99
100 void dm_rh_start_recovery(struct dm_region_hash *rh);
101 void dm_rh_stop_recovery(struct dm_region_hash *rh);
102
103 #endif