0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef DM_REGION_HASH_H
0011 #define DM_REGION_HASH_H
0012
0013 #include <linux/dm-dirty-log.h>
0014
0015
0016
0017
0018 struct dm_region_hash;
0019 struct dm_region;
0020
0021
0022
0023
0024 enum dm_rh_region_states {
0025 DM_RH_CLEAN = 0x01,
0026 DM_RH_DIRTY = 0x02,
0027 DM_RH_NOSYNC = 0x04,
0028 DM_RH_RECOVERING = 0x08,
0029 };
0030
0031
0032
0033
0034 struct bio_list;
0035 struct dm_region_hash *dm_region_hash_create(
0036 void *context, void (*dispatch_bios)(void *context,
0037 struct bio_list *bios),
0038 void (*wakeup_workers)(void *context),
0039 void (*wakeup_all_recovery_waiters)(void *context),
0040 sector_t target_begin, unsigned max_recovery,
0041 struct dm_dirty_log *log, uint32_t region_size,
0042 region_t nr_regions);
0043 void dm_region_hash_destroy(struct dm_region_hash *rh);
0044
0045 struct dm_dirty_log *dm_rh_dirty_log(struct dm_region_hash *rh);
0046
0047
0048
0049
0050 region_t dm_rh_bio_to_region(struct dm_region_hash *rh, struct bio *bio);
0051 sector_t dm_rh_region_to_sector(struct dm_region_hash *rh, region_t region);
0052 void *dm_rh_region_context(struct dm_region *reg);
0053
0054
0055
0056
0057 sector_t dm_rh_get_region_size(struct dm_region_hash *rh);
0058 region_t dm_rh_get_region_key(struct dm_region *reg);
0059
0060
0061
0062
0063
0064 int dm_rh_get_state(struct dm_region_hash *rh, region_t region, int may_block);
0065 void dm_rh_set_state(struct dm_region_hash *rh, region_t region,
0066 enum dm_rh_region_states state, int may_block);
0067
0068
0069 void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
0070
0071
0072 int dm_rh_flush(struct dm_region_hash *rh);
0073
0074
0075 void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);
0076 void dm_rh_dec(struct dm_region_hash *rh, region_t region);
0077
0078
0079 void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
0080
0081 void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio);
0082
0083
0084
0085
0086
0087
0088 void dm_rh_recovery_prepare(struct dm_region_hash *rh);
0089
0090
0091 struct dm_region *dm_rh_recovery_start(struct dm_region_hash *rh);
0092
0093
0094 void dm_rh_recovery_end(struct dm_region *reg, int error);
0095
0096
0097 int dm_rh_recovery_in_flight(struct dm_region_hash *rh);
0098
0099
0100 void dm_rh_start_recovery(struct dm_region_hash *rh);
0101 void dm_rh_stop_recovery(struct dm_region_hash *rh);
0102
0103 #endif