0001
0002
0003
0004
0005
0006
0007 #ifndef DM_BIO_PRISON_H
0008 #define DM_BIO_PRISON_H
0009
0010 #include "persistent-data/dm-block-manager.h" /* FIXME: for dm_block_t */
0011 #include "dm-thin-metadata.h" /* FIXME: for dm_thin_id */
0012
0013 #include <linux/bio.h>
0014 #include <linux/rbtree.h>
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 struct dm_bio_prison;
0025
0026
0027
0028
0029
0030 struct dm_cell_key {
0031 int virtual;
0032 dm_thin_id dev;
0033 dm_block_t block_begin, block_end;
0034 };
0035
0036
0037
0038
0039
0040 struct dm_bio_prison_cell {
0041 struct list_head user_list;
0042 struct rb_node node;
0043
0044 struct dm_cell_key key;
0045 struct bio *holder;
0046 struct bio_list bios;
0047 };
0048
0049 struct dm_bio_prison *dm_bio_prison_create(void);
0050 void dm_bio_prison_destroy(struct dm_bio_prison *prison);
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct dm_bio_prison_cell *dm_bio_prison_alloc_cell(struct dm_bio_prison *prison,
0060 gfp_t gfp);
0061 void dm_bio_prison_free_cell(struct dm_bio_prison *prison,
0062 struct dm_bio_prison_cell *cell);
0063
0064
0065
0066
0067
0068
0069
0070 int dm_get_cell(struct dm_bio_prison *prison,
0071 struct dm_cell_key *key,
0072 struct dm_bio_prison_cell *cell_prealloc,
0073 struct dm_bio_prison_cell **cell_result);
0074
0075
0076
0077
0078
0079
0080
0081 int dm_bio_detain(struct dm_bio_prison *prison,
0082 struct dm_cell_key *key,
0083 struct bio *inmate,
0084 struct dm_bio_prison_cell *cell_prealloc,
0085 struct dm_bio_prison_cell **cell_result);
0086
0087 void dm_cell_release(struct dm_bio_prison *prison,
0088 struct dm_bio_prison_cell *cell,
0089 struct bio_list *bios);
0090 void dm_cell_release_no_holder(struct dm_bio_prison *prison,
0091 struct dm_bio_prison_cell *cell,
0092 struct bio_list *inmates);
0093 void dm_cell_error(struct dm_bio_prison *prison,
0094 struct dm_bio_prison_cell *cell, blk_status_t error);
0095
0096
0097
0098
0099
0100 void dm_cell_visit_release(struct dm_bio_prison *prison,
0101 void (*visit_fn)(void *, struct dm_bio_prison_cell *),
0102 void *context, struct dm_bio_prison_cell *cell);
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 int dm_cell_promote_or_release(struct dm_bio_prison *prison,
0115 struct dm_bio_prison_cell *cell);
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 struct dm_deferred_set;
0127 struct dm_deferred_entry;
0128
0129 struct dm_deferred_set *dm_deferred_set_create(void);
0130 void dm_deferred_set_destroy(struct dm_deferred_set *ds);
0131
0132 struct dm_deferred_entry *dm_deferred_entry_inc(struct dm_deferred_set *ds);
0133 void dm_deferred_entry_dec(struct dm_deferred_entry *entry, struct list_head *head);
0134 int dm_deferred_set_add_work(struct dm_deferred_set *ds, struct list_head *work);
0135
0136
0137
0138 #endif