Lines Matching refs:prison
36 struct dm_bio_prison *prison = kzalloc(sizeof(*prison), GFP_KERNEL); in dm_bio_prison_create() local
39 if (!prison) in dm_bio_prison_create()
42 spin_lock_init(&prison->lock); in dm_bio_prison_create()
44 ret = mempool_init_slab_pool(&prison->cell_pool, MIN_CELLS, _cell_cache); in dm_bio_prison_create()
46 kfree(prison); in dm_bio_prison_create()
50 prison->cells = RB_ROOT; in dm_bio_prison_create()
52 return prison; in dm_bio_prison_create()
56 void dm_bio_prison_destroy(struct dm_bio_prison *prison) in dm_bio_prison_destroy() argument
58 mempool_exit(&prison->cell_pool); in dm_bio_prison_destroy()
59 kfree(prison); in dm_bio_prison_destroy()
63 struct dm_bio_prison_cell *dm_bio_prison_alloc_cell(struct dm_bio_prison *prison, gfp_t gfp) in dm_bio_prison_alloc_cell() argument
65 return mempool_alloc(&prison->cell_pool, gfp); in dm_bio_prison_alloc_cell()
69 void dm_bio_prison_free_cell(struct dm_bio_prison *prison, in dm_bio_prison_free_cell() argument
72 mempool_free(cell, &prison->cell_pool); in dm_bio_prison_free_cell()
109 static int __bio_detain(struct dm_bio_prison *prison, in __bio_detain() argument
116 struct rb_node **new = &prison->cells.rb_node, *parent = NULL; in __bio_detain()
141 rb_insert_color(&cell_prealloc->node, &prison->cells); in __bio_detain()
146 static int bio_detain(struct dm_bio_prison *prison, in bio_detain() argument
154 spin_lock_irq(&prison->lock); in bio_detain()
155 r = __bio_detain(prison, key, inmate, cell_prealloc, cell_result); in bio_detain()
156 spin_unlock_irq(&prison->lock); in bio_detain()
161 int dm_bio_detain(struct dm_bio_prison *prison, in dm_bio_detain() argument
167 return bio_detain(prison, key, inmate, cell_prealloc, cell_result); in dm_bio_detain()
171 int dm_get_cell(struct dm_bio_prison *prison, in dm_get_cell() argument
176 return bio_detain(prison, key, NULL, cell_prealloc, cell_result); in dm_get_cell()
183 static void __cell_release(struct dm_bio_prison *prison, in __cell_release() argument
187 rb_erase(&cell->node, &prison->cells); in __cell_release()
196 void dm_cell_release(struct dm_bio_prison *prison, in dm_cell_release() argument
200 spin_lock_irq(&prison->lock); in dm_cell_release()
201 __cell_release(prison, cell, bios); in dm_cell_release()
202 spin_unlock_irq(&prison->lock); in dm_cell_release()
209 static void __cell_release_no_holder(struct dm_bio_prison *prison, in __cell_release_no_holder() argument
213 rb_erase(&cell->node, &prison->cells); in __cell_release_no_holder()
217 void dm_cell_release_no_holder(struct dm_bio_prison *prison, in dm_cell_release_no_holder() argument
223 spin_lock_irqsave(&prison->lock, flags); in dm_cell_release_no_holder()
224 __cell_release_no_holder(prison, cell, inmates); in dm_cell_release_no_holder()
225 spin_unlock_irqrestore(&prison->lock, flags); in dm_cell_release_no_holder()
229 void dm_cell_error(struct dm_bio_prison *prison, in dm_cell_error() argument
236 dm_cell_release(prison, cell, &bios); in dm_cell_error()
245 void dm_cell_visit_release(struct dm_bio_prison *prison, in dm_cell_visit_release() argument
250 spin_lock_irq(&prison->lock); in dm_cell_visit_release()
252 rb_erase(&cell->node, &prison->cells); in dm_cell_visit_release()
253 spin_unlock_irq(&prison->lock); in dm_cell_visit_release()
257 static int __promote_or_release(struct dm_bio_prison *prison, in __promote_or_release() argument
261 rb_erase(&cell->node, &prison->cells); in __promote_or_release()
269 int dm_cell_promote_or_release(struct dm_bio_prison *prison, in dm_cell_promote_or_release() argument
274 spin_lock_irq(&prison->lock); in dm_cell_promote_or_release()
275 r = __promote_or_release(prison, cell); in dm_cell_promote_or_release()
276 spin_unlock_irq(&prison->lock); in dm_cell_promote_or_release()