Lines Matching refs:dev
229 static struct reada_zone *reada_find_zone(struct btrfs_device *dev, u64 logical, in reada_find_zone() argument
232 struct btrfs_fs_info *fs_info = dev->fs_info; in reada_find_zone()
242 ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone, in reada_find_zone()
277 zone->device = dev; /* our device always sits at index 0 */ in reada_find_zone()
280 zone->devs[i] = bioc->stripes[i].dev; in reada_find_zone()
285 ret = radix_tree_insert(&dev->reada_zones, in reada_find_zone()
291 ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone, in reada_find_zone()
313 struct btrfs_device *dev; in reada_find_extent() local
363 dev = bioc->stripes[nzones].dev; in reada_find_extent()
366 if (!dev->bdev) in reada_find_extent()
369 zone = reada_find_zone(dev, logical, bioc); in reada_find_extent()
417 dev = re->zones[nzones]->device; in reada_find_extent()
419 if (dev == prev_dev) { in reada_find_extent()
429 if (!dev->bdev) in reada_find_extent()
432 if (test_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state)) in reada_find_extent()
436 dev == fs_info->dev_replace.tgtdev) { in reada_find_extent()
443 prev_dev = dev; in reada_find_extent()
444 ret = radix_tree_insert(&dev->reada_extents, index, re); in reada_find_extent()
447 dev = re->zones[nzones]->device; in reada_find_extent()
448 BUG_ON(dev == NULL); in reada_find_extent()
450 radix_tree_delete(&dev->reada_extents, index); in reada_find_extent()
610 static int reada_pick_zone(struct btrfs_device *dev) in reada_pick_zone() argument
619 if (dev->reada_curr_zone) { in reada_pick_zone()
620 reada_peer_zones_set_lock(dev->reada_curr_zone, 0); in reada_pick_zone()
621 kref_put(&dev->reada_curr_zone->refcnt, reada_zone_release); in reada_pick_zone()
622 dev->reada_curr_zone = NULL; in reada_pick_zone()
628 ret = radix_tree_gang_lookup(&dev->reada_zones, in reada_pick_zone()
632 index = (zone->end >> dev->fs_info->sectorsize_bits) + 1; in reada_pick_zone()
646 dev->reada_curr_zone = top_zone; in reada_pick_zone()
648 dev->reada_curr_zone = top_locked_zone; in reada_pick_zone()
652 dev->reada_next = dev->reada_curr_zone->start; in reada_pick_zone()
653 kref_get(&dev->reada_curr_zone->refcnt); in reada_pick_zone()
654 reada_peer_zones_set_lock(dev->reada_curr_zone, 1); in reada_pick_zone()
689 static int reada_start_machine_dev(struct btrfs_device *dev) in reada_start_machine_dev() argument
691 struct btrfs_fs_info *fs_info = dev->fs_info; in reada_start_machine_dev()
700 if (dev->reada_curr_zone == NULL) { in reada_start_machine_dev()
701 ret = reada_pick_zone(dev); in reada_start_machine_dev()
712 ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re, in reada_start_machine_dev()
713 dev->reada_next >> fs_info->sectorsize_bits, 1); in reada_start_machine_dev()
714 if (ret == 0 || re->logical > dev->reada_curr_zone->end) { in reada_start_machine_dev()
715 ret = reada_pick_zone(dev); in reada_start_machine_dev()
721 ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re, in reada_start_machine_dev()
722 dev->reada_next >> fs_info->sectorsize_bits, 1); in reada_start_machine_dev()
728 dev->reada_next = re->logical + fs_info->nodesize; in reada_start_machine_dev()
746 if (re->zones[i]->device == dev) { in reada_start_machine_dev()
753 atomic_inc(&dev->reada_in_flight); in reada_start_machine_dev()
764 atomic_dec(&dev->reada_in_flight); in reada_start_machine_dev()
1054 void btrfs_reada_remove_dev(struct btrfs_device *dev) in btrfs_reada_remove_dev() argument
1056 struct btrfs_fs_info *fs_info = dev->fs_info; in btrfs_reada_remove_dev()
1060 set_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state); in btrfs_reada_remove_dev()
1081 void btrfs_reada_undo_remove_dev(struct btrfs_device *dev) in btrfs_reada_undo_remove_dev() argument
1083 spin_lock(&dev->fs_info->reada_lock); in btrfs_reada_undo_remove_dev()
1084 clear_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state); in btrfs_reada_undo_remove_dev()
1085 spin_unlock(&dev->fs_info->reada_lock); in btrfs_reada_undo_remove_dev()