Lines Matching refs:caching_ctl

408 	if (!cache->caching_ctl) {  in btrfs_get_caching_control()
413 ctl = cache->caching_ctl; in btrfs_get_caching_control()
441 struct btrfs_caching_control *caching_ctl; in btrfs_wait_block_group_cache_progress() local
444 caching_ctl = btrfs_get_caching_control(cache); in btrfs_wait_block_group_cache_progress()
445 if (!caching_ctl) in btrfs_wait_block_group_cache_progress()
454 progress = atomic_read(&caching_ctl->progress); in btrfs_wait_block_group_cache_progress()
456 wait_event(caching_ctl->wait, btrfs_block_group_done(cache) || in btrfs_wait_block_group_cache_progress()
457 (progress != atomic_read(&caching_ctl->progress) && in btrfs_wait_block_group_cache_progress()
460 btrfs_put_caching_control(caching_ctl); in btrfs_wait_block_group_cache_progress()
464 struct btrfs_caching_control *caching_ctl) in btrfs_caching_ctl_wait_done() argument
466 wait_event(caching_ctl->wait, btrfs_block_group_done(cache)); in btrfs_caching_ctl_wait_done()
472 struct btrfs_caching_control *caching_ctl; in btrfs_wait_block_group_cache_done() local
475 caching_ctl = btrfs_get_caching_control(cache); in btrfs_wait_block_group_cache_done()
476 if (!caching_ctl) in btrfs_wait_block_group_cache_done()
478 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); in btrfs_wait_block_group_cache_done()
479 btrfs_put_caching_control(caching_ctl); in btrfs_wait_block_group_cache_done()
578 static int sample_block_group_extent_item(struct btrfs_caching_control *caching_ctl, in sample_block_group_extent_item() argument
594 lockdep_assert_held(&caching_ctl->mutex); in sample_block_group_extent_item()
627 lockdep_assert_held(&caching_ctl->mutex); in sample_block_group_extent_item()
667 static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl, in load_block_group_size_class() argument
680 lockdep_assert_held(&caching_ctl->mutex); in load_block_group_size_class()
683 ret = sample_block_group_extent_item(caching_ctl, block_group, i, 5, &key); in load_block_group_size_class()
700 static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl) in load_extent_tree_free() argument
702 struct btrfs_block_group *block_group = caching_ctl->block_group; in load_extent_tree_free()
769 mutex_unlock(&caching_ctl->mutex); in load_extent_tree_free()
771 mutex_lock(&caching_ctl->mutex); in load_extent_tree_free()
820 atomic_inc(&caching_ctl->progress); in load_extent_tree_free()
821 wake_up(&caching_ctl->wait); in load_extent_tree_free()
846 struct btrfs_caching_control *caching_ctl; in caching_thread() local
849 caching_ctl = container_of(work, struct btrfs_caching_control, work); in caching_thread()
850 block_group = caching_ctl->block_group; in caching_thread()
853 mutex_lock(&caching_ctl->mutex); in caching_thread()
856 load_block_group_size_class(caching_ctl, block_group); in caching_thread()
871 wake_up(&caching_ctl->wait); in caching_thread()
883 ret = load_free_space_tree(caching_ctl); in caching_thread()
885 ret = load_extent_tree_free(caching_ctl); in caching_thread()
888 block_group->caching_ctl = NULL; in caching_thread()
908 mutex_unlock(&caching_ctl->mutex); in caching_thread()
910 wake_up(&caching_ctl->wait); in caching_thread()
912 btrfs_put_caching_control(caching_ctl); in caching_thread()
919 struct btrfs_caching_control *caching_ctl = NULL; in btrfs_cache_block_group() local
926 caching_ctl = kzalloc(sizeof(*caching_ctl), GFP_NOFS); in btrfs_cache_block_group()
927 if (!caching_ctl) in btrfs_cache_block_group()
930 INIT_LIST_HEAD(&caching_ctl->list); in btrfs_cache_block_group()
931 mutex_init(&caching_ctl->mutex); in btrfs_cache_block_group()
932 init_waitqueue_head(&caching_ctl->wait); in btrfs_cache_block_group()
933 caching_ctl->block_group = cache; in btrfs_cache_block_group()
934 refcount_set(&caching_ctl->count, 2); in btrfs_cache_block_group()
935 atomic_set(&caching_ctl->progress, 0); in btrfs_cache_block_group()
936 btrfs_init_work(&caching_ctl->work, caching_thread, NULL); in btrfs_cache_block_group()
940 kfree(caching_ctl); in btrfs_cache_block_group()
942 caching_ctl = cache->caching_ctl; in btrfs_cache_block_group()
943 if (caching_ctl) in btrfs_cache_block_group()
944 refcount_inc(&caching_ctl->count); in btrfs_cache_block_group()
948 WARN_ON(cache->caching_ctl); in btrfs_cache_block_group()
949 cache->caching_ctl = caching_ctl; in btrfs_cache_block_group()
954 refcount_inc(&caching_ctl->count); in btrfs_cache_block_group()
955 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups); in btrfs_cache_block_group()
960 btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work); in btrfs_cache_block_group()
962 if (wait && caching_ctl) in btrfs_cache_block_group()
963 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl); in btrfs_cache_block_group()
964 if (caching_ctl) in btrfs_cache_block_group()
965 btrfs_put_caching_control(caching_ctl); in btrfs_cache_block_group()
1066 struct btrfs_caching_control *caching_ctl = NULL; in btrfs_remove_block_group() local
1179 caching_ctl = btrfs_get_caching_control(block_group); in btrfs_remove_block_group()
1180 if (!caching_ctl) { in btrfs_remove_block_group()
1185 caching_ctl = ctl; in btrfs_remove_block_group()
1186 refcount_inc(&caching_ctl->count); in btrfs_remove_block_group()
1191 if (caching_ctl) in btrfs_remove_block_group()
1192 list_del_init(&caching_ctl->list); in btrfs_remove_block_group()
1195 if (caching_ctl) { in btrfs_remove_block_group()
1197 btrfs_put_caching_control(caching_ctl); in btrfs_remove_block_group()
1198 btrfs_put_caching_control(caching_ctl); in btrfs_remove_block_group()
4407 struct btrfs_caching_control *caching_ctl; in btrfs_free_block_groups() local
4423 caching_ctl = list_entry(info->caching_block_groups.next, in btrfs_free_block_groups()
4425 list_del(&caching_ctl->list); in btrfs_free_block_groups()
4426 btrfs_put_caching_control(caching_ctl); in btrfs_free_block_groups()