Lines Matching refs:caching_ctl
421 if (!cache->caching_ctl) { in btrfs_get_caching_control()
426 ctl = cache->caching_ctl; in btrfs_get_caching_control()
454 struct btrfs_caching_control *caching_ctl; in btrfs_wait_block_group_cache_progress() local
457 caching_ctl = btrfs_get_caching_control(cache); in btrfs_wait_block_group_cache_progress()
458 if (!caching_ctl) in btrfs_wait_block_group_cache_progress()
467 progress = atomic_read(&caching_ctl->progress); in btrfs_wait_block_group_cache_progress()
469 wait_event(caching_ctl->wait, btrfs_block_group_done(cache) || in btrfs_wait_block_group_cache_progress()
470 (progress != atomic_read(&caching_ctl->progress) && in btrfs_wait_block_group_cache_progress()
473 btrfs_put_caching_control(caching_ctl); in btrfs_wait_block_group_cache_progress()
477 struct btrfs_caching_control *caching_ctl) in btrfs_caching_ctl_wait_done() argument
479 wait_event(caching_ctl->wait, btrfs_block_group_done(cache)); in btrfs_caching_ctl_wait_done()
485 struct btrfs_caching_control *caching_ctl; in btrfs_wait_block_group_cache_done() local
488 caching_ctl = btrfs_get_caching_control(cache); in btrfs_wait_block_group_cache_done()
489 if (!caching_ctl) in btrfs_wait_block_group_cache_done()
491 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); in btrfs_wait_block_group_cache_done()
492 btrfs_put_caching_control(caching_ctl); in btrfs_wait_block_group_cache_done()
590 static int sample_block_group_extent_item(struct btrfs_caching_control *caching_ctl, in sample_block_group_extent_item() argument
606 lockdep_assert_held(&caching_ctl->mutex); in sample_block_group_extent_item()
639 lockdep_assert_held(&caching_ctl->mutex); in sample_block_group_extent_item()
678 static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl, in load_block_group_size_class() argument
691 lockdep_assert_held(&caching_ctl->mutex); in load_block_group_size_class()
694 ret = sample_block_group_extent_item(caching_ctl, block_group, i, 5, &key); in load_block_group_size_class()
711 static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl) in load_extent_tree_free() argument
713 struct btrfs_block_group *block_group = caching_ctl->block_group; in load_extent_tree_free()
780 mutex_unlock(&caching_ctl->mutex); in load_extent_tree_free()
782 mutex_lock(&caching_ctl->mutex); in load_extent_tree_free()
831 atomic_inc(&caching_ctl->progress); in load_extent_tree_free()
832 wake_up(&caching_ctl->wait); in load_extent_tree_free()
856 struct btrfs_caching_control *caching_ctl; in caching_thread() local
859 caching_ctl = container_of(work, struct btrfs_caching_control, work); in caching_thread()
860 block_group = caching_ctl->block_group; in caching_thread()
863 mutex_lock(&caching_ctl->mutex); in caching_thread()
866 load_block_group_size_class(caching_ctl, block_group); in caching_thread()
881 wake_up(&caching_ctl->wait); in caching_thread()
893 ret = btrfs_load_free_space_tree(caching_ctl); in caching_thread()
895 ret = load_extent_tree_free(caching_ctl); in caching_thread()
898 block_group->caching_ctl = NULL; in caching_thread()
918 mutex_unlock(&caching_ctl->mutex); in caching_thread()
920 wake_up(&caching_ctl->wait); in caching_thread()
922 btrfs_put_caching_control(caching_ctl); in caching_thread()
929 struct btrfs_caching_control *caching_ctl = NULL; in btrfs_cache_block_group() local
936 caching_ctl = kzalloc(sizeof(*caching_ctl), GFP_NOFS); in btrfs_cache_block_group()
937 if (!caching_ctl) in btrfs_cache_block_group()
940 INIT_LIST_HEAD(&caching_ctl->list); in btrfs_cache_block_group()
941 mutex_init(&caching_ctl->mutex); in btrfs_cache_block_group()
942 init_waitqueue_head(&caching_ctl->wait); in btrfs_cache_block_group()
943 caching_ctl->block_group = cache; in btrfs_cache_block_group()
944 refcount_set(&caching_ctl->count, 2); in btrfs_cache_block_group()
945 atomic_set(&caching_ctl->progress, 0); in btrfs_cache_block_group()
946 btrfs_init_work(&caching_ctl->work, caching_thread, NULL); in btrfs_cache_block_group()
950 kfree(caching_ctl); in btrfs_cache_block_group()
952 caching_ctl = cache->caching_ctl; in btrfs_cache_block_group()
953 if (caching_ctl) in btrfs_cache_block_group()
954 refcount_inc(&caching_ctl->count); in btrfs_cache_block_group()
958 WARN_ON(cache->caching_ctl); in btrfs_cache_block_group()
959 cache->caching_ctl = caching_ctl; in btrfs_cache_block_group()
964 refcount_inc(&caching_ctl->count); in btrfs_cache_block_group()
965 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups); in btrfs_cache_block_group()
970 btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work); in btrfs_cache_block_group()
972 if (wait && caching_ctl) in btrfs_cache_block_group()
973 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); in btrfs_cache_block_group()
974 if (caching_ctl) in btrfs_cache_block_group()
975 btrfs_put_caching_control(caching_ctl); in btrfs_cache_block_group()
1076 struct btrfs_caching_control *caching_ctl = NULL; in btrfs_remove_block_group() local
1189 caching_ctl = btrfs_get_caching_control(block_group); in btrfs_remove_block_group()
1190 if (!caching_ctl) { in btrfs_remove_block_group()
1195 caching_ctl = ctl; in btrfs_remove_block_group()
1196 refcount_inc(&caching_ctl->count); in btrfs_remove_block_group()
1201 if (caching_ctl) in btrfs_remove_block_group()
1202 list_del_init(&caching_ctl->list); in btrfs_remove_block_group()
1205 if (caching_ctl) { in btrfs_remove_block_group()
1207 btrfs_put_caching_control(caching_ctl); in btrfs_remove_block_group()
1208 btrfs_put_caching_control(caching_ctl); in btrfs_remove_block_group()
4482 struct btrfs_caching_control *caching_ctl; in btrfs_free_block_groups() local
4498 caching_ctl = list_first_entry(&info->caching_block_groups, in btrfs_free_block_groups()
4500 list_del(&caching_ctl->list); in btrfs_free_block_groups()
4501 btrfs_put_caching_control(caching_ctl); in btrfs_free_block_groups()