Lines Matching refs:zone
228 struct reada_zone *zone; in reada_find_zone() local
234 zone = NULL; in reada_find_zone()
236 ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone, in reada_find_zone()
238 if (ret == 1 && logical >= zone->start && logical <= zone->end) { in reada_find_zone()
239 kref_get(&zone->refcnt); in reada_find_zone()
241 return zone; in reada_find_zone()
254 zone = kzalloc(sizeof(*zone), GFP_KERNEL); in reada_find_zone()
255 if (!zone) in reada_find_zone()
260 kfree(zone); in reada_find_zone()
264 zone->start = start; in reada_find_zone()
265 zone->end = end; in reada_find_zone()
266 INIT_LIST_HEAD(&zone->list); in reada_find_zone()
267 spin_lock_init(&zone->lock); in reada_find_zone()
268 zone->locked = 0; in reada_find_zone()
269 kref_init(&zone->refcnt); in reada_find_zone()
270 zone->elems = 0; in reada_find_zone()
271 zone->device = dev; /* our device always sits at index 0 */ in reada_find_zone()
274 zone->devs[i] = bbio->stripes[i].dev; in reada_find_zone()
276 zone->ndevs = bbio->num_stripes; in reada_find_zone()
280 (unsigned long)(zone->end >> PAGE_SHIFT), in reada_find_zone()
281 zone); in reada_find_zone()
284 kfree(zone); in reada_find_zone()
285 ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone, in reada_find_zone()
287 if (ret == 1 && logical >= zone->start && logical <= zone->end) in reada_find_zone()
288 kref_get(&zone->refcnt); in reada_find_zone()
290 zone = NULL; in reada_find_zone()
295 return zone; in reada_find_zone()
352 struct reada_zone *zone; in reada_find_extent() local
360 zone = reada_find_zone(dev, logical, bbio); in reada_find_extent()
361 if (!zone) in reada_find_extent()
364 re->zones[re->nzones++] = zone; in reada_find_extent()
365 spin_lock(&zone->lock); in reada_find_extent()
366 if (!zone->elems) in reada_find_extent()
367 kref_get(&zone->refcnt); in reada_find_extent()
368 ++zone->elems; in reada_find_extent()
369 spin_unlock(&zone->lock); in reada_find_extent()
371 kref_put(&zone->refcnt, reada_zone_release); in reada_find_extent()
458 struct reada_zone *zone; in reada_find_extent() local
460 zone = re->zones[nzones]; in reada_find_extent()
461 kref_get(&zone->refcnt); in reada_find_extent()
462 spin_lock(&zone->lock); in reada_find_extent()
463 --zone->elems; in reada_find_extent()
464 if (zone->elems == 0) { in reada_find_extent()
469 kref_put(&zone->refcnt, reada_zone_release); in reada_find_extent()
471 spin_unlock(&zone->lock); in reada_find_extent()
474 kref_put(&zone->refcnt, reada_zone_release); in reada_find_extent()
496 struct reada_zone *zone = re->zones[i]; in reada_extent_put() local
498 radix_tree_delete(&zone->device->reada_extents, index); in reada_extent_put()
504 struct reada_zone *zone = re->zones[i]; in reada_extent_put() local
506 kref_get(&zone->refcnt); in reada_extent_put()
507 spin_lock(&zone->lock); in reada_extent_put()
508 --zone->elems; in reada_extent_put()
509 if (zone->elems == 0) { in reada_extent_put()
512 kref_put(&zone->refcnt, reada_zone_release); in reada_extent_put()
514 spin_unlock(&zone->lock); in reada_extent_put()
517 kref_put(&zone->refcnt, reada_zone_release); in reada_extent_put()
526 struct reada_zone *zone = container_of(kref, struct reada_zone, refcnt); in reada_zone_release() local
528 radix_tree_delete(&zone->device->reada_zones, in reada_zone_release()
529 zone->end >> PAGE_SHIFT); in reada_zone_release()
531 kfree(zone); in reada_zone_release()
576 static void reada_peer_zones_set_lock(struct reada_zone *zone, int lock) in reada_peer_zones_set_lock() argument
579 unsigned long index = zone->end >> PAGE_SHIFT; in reada_peer_zones_set_lock()
581 for (i = 0; i < zone->ndevs; ++i) { in reada_peer_zones_set_lock()
583 peer = radix_tree_lookup(&zone->devs[i]->reada_zones, index); in reada_peer_zones_set_lock()
584 if (peer && peer->device != zone->device) in reada_peer_zones_set_lock()
608 struct reada_zone *zone; in reada_pick_zone() local
611 (void **)&zone, index, 1); in reada_pick_zone()
614 index = (zone->end >> PAGE_SHIFT) + 1; in reada_pick_zone()
615 if (zone->locked) { in reada_pick_zone()
616 if (zone->elems > top_locked_elems) { in reada_pick_zone()
617 top_locked_elems = zone->elems; in reada_pick_zone()
618 top_locked_zone = zone; in reada_pick_zone()
621 if (zone->elems > top_elems) { in reada_pick_zone()
622 top_elems = zone->elems; in reada_pick_zone()
623 top_zone = zone; in reada_pick_zone()
817 struct reada_zone *zone; in dump_devs() local
819 (void **)&zone, index, 1); in dump_devs()
823 zone->start, zone->end, zone->elems, in dump_devs()
824 zone->locked); in dump_devs()
825 for (j = 0; j < zone->ndevs; ++j) { in dump_devs()
827 zone->devs[j]->devid); in dump_devs()
829 if (device->reada_curr_zone == zone) in dump_devs()
831 device->reada_next - zone->start); in dump_devs()
833 index = (zone->end >> PAGE_SHIFT) + 1; in dump_devs()