Lines Matching refs:prison
38 struct dm_bio_prison_v2 *prison = kzalloc(sizeof(*prison), GFP_KERNEL); in dm_bio_prison_create_v2() local
41 if (!prison) in dm_bio_prison_create_v2()
44 prison->wq = wq; in dm_bio_prison_create_v2()
45 spin_lock_init(&prison->lock); in dm_bio_prison_create_v2()
47 ret = mempool_init_slab_pool(&prison->cell_pool, MIN_CELLS, _cell_cache); in dm_bio_prison_create_v2()
49 kfree(prison); in dm_bio_prison_create_v2()
53 prison->cells = RB_ROOT; in dm_bio_prison_create_v2()
55 return prison; in dm_bio_prison_create_v2()
59 void dm_bio_prison_destroy_v2(struct dm_bio_prison_v2 *prison) in dm_bio_prison_destroy_v2() argument
61 mempool_exit(&prison->cell_pool); in dm_bio_prison_destroy_v2()
62 kfree(prison); in dm_bio_prison_destroy_v2()
66 struct dm_bio_prison_cell_v2 *dm_bio_prison_alloc_cell_v2(struct dm_bio_prison_v2 *prison, gfp_t gf… in dm_bio_prison_alloc_cell_v2() argument
68 return mempool_alloc(&prison->cell_pool, gfp); in dm_bio_prison_alloc_cell_v2()
72 void dm_bio_prison_free_cell_v2(struct dm_bio_prison_v2 *prison, in dm_bio_prison_free_cell_v2() argument
75 mempool_free(cell, &prison->cell_pool); in dm_bio_prison_free_cell_v2()
114 static bool __find_or_insert(struct dm_bio_prison_v2 *prison, in __find_or_insert() argument
120 struct rb_node **new = &prison->cells.rb_node, *parent = NULL; in __find_or_insert()
144 rb_insert_color(&cell_prealloc->node, &prison->cells); in __find_or_insert()
149 static bool __get(struct dm_bio_prison_v2 *prison, in __get() argument
156 if (__find_or_insert(prison, key, cell_prealloc, cell)) { in __get()
172 bool dm_cell_get_v2(struct dm_bio_prison_v2 *prison, in dm_cell_get_v2() argument
181 spin_lock_irq(&prison->lock); in dm_cell_get_v2()
182 r = __get(prison, key, lock_level, inmate, cell_prealloc, cell_result); in dm_cell_get_v2()
183 spin_unlock_irq(&prison->lock); in dm_cell_get_v2()
189 static bool __put(struct dm_bio_prison_v2 *prison, in __put() argument
199 queue_work(prison->wq, cell->quiesce_continuation); in __put()
203 rb_erase(&cell->node, &prison->cells); in __put()
211 bool dm_cell_put_v2(struct dm_bio_prison_v2 *prison, in dm_cell_put_v2() argument
217 spin_lock_irqsave(&prison->lock, flags); in dm_cell_put_v2()
218 r = __put(prison, cell); in dm_cell_put_v2()
219 spin_unlock_irqrestore(&prison->lock, flags); in dm_cell_put_v2()
225 static int __lock(struct dm_bio_prison_v2 *prison, in __lock() argument
233 if (__find_or_insert(prison, key, cell_prealloc, &cell)) { in __lock()
256 int dm_cell_lock_v2(struct dm_bio_prison_v2 *prison, in dm_cell_lock_v2() argument
264 spin_lock_irq(&prison->lock); in dm_cell_lock_v2()
265 r = __lock(prison, key, lock_level, cell_prealloc, cell_result); in dm_cell_lock_v2()
266 spin_unlock_irq(&prison->lock); in dm_cell_lock_v2()
272 static void __quiesce(struct dm_bio_prison_v2 *prison, in __quiesce() argument
277 queue_work(prison->wq, continuation); in __quiesce()
282 void dm_cell_quiesce_v2(struct dm_bio_prison_v2 *prison, in dm_cell_quiesce_v2() argument
286 spin_lock_irq(&prison->lock); in dm_cell_quiesce_v2()
287 __quiesce(prison, cell, continuation); in dm_cell_quiesce_v2()
288 spin_unlock_irq(&prison->lock); in dm_cell_quiesce_v2()
292 static int __promote(struct dm_bio_prison_v2 *prison, in __promote() argument
303 int dm_cell_lock_promote_v2(struct dm_bio_prison_v2 *prison, in dm_cell_lock_promote_v2() argument
309 spin_lock_irq(&prison->lock); in dm_cell_lock_promote_v2()
310 r = __promote(prison, cell, new_lock_level); in dm_cell_lock_promote_v2()
311 spin_unlock_irq(&prison->lock); in dm_cell_lock_promote_v2()
317 static bool __unlock(struct dm_bio_prison_v2 *prison, in __unlock() argument
331 rb_erase(&cell->node, &prison->cells); in __unlock()
335 bool dm_cell_unlock_v2(struct dm_bio_prison_v2 *prison, in dm_cell_unlock_v2() argument
341 spin_lock_irq(&prison->lock); in dm_cell_unlock_v2()
342 r = __unlock(prison, cell, bios); in dm_cell_unlock_v2()
343 spin_unlock_irq(&prison->lock); in dm_cell_unlock_v2()