Lines Matching refs:caching_ctl

410 	if (!cache->caching_ctl) {
415 ctl = cache->caching_ctl;
443 struct btrfs_caching_control *caching_ctl;
446 caching_ctl = btrfs_get_caching_control(cache);
447 if (!caching_ctl)
456 progress = atomic_read(&caching_ctl->progress);
458 wait_event(caching_ctl->wait, btrfs_block_group_done(cache) ||
459 (progress != atomic_read(&caching_ctl->progress) &&
462 btrfs_put_caching_control(caching_ctl);
466 struct btrfs_caching_control *caching_ctl)
468 wait_event(caching_ctl->wait, btrfs_block_group_done(cache));
474 struct btrfs_caching_control *caching_ctl;
477 caching_ctl = btrfs_get_caching_control(cache);
478 if (!caching_ctl)
480 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl);
481 btrfs_put_caching_control(caching_ctl);
580 static int sample_block_group_extent_item(struct btrfs_caching_control *caching_ctl,
596 lockdep_assert_held(&caching_ctl->mutex);
629 lockdep_assert_held(&caching_ctl->mutex);
669 static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl,
682 lockdep_assert_held(&caching_ctl->mutex);
685 ret = sample_block_group_extent_item(caching_ctl, block_group, i, 5, &key);
702 static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
704 struct btrfs_block_group *block_group = caching_ctl->block_group;
771 mutex_unlock(&caching_ctl->mutex);
773 mutex_lock(&caching_ctl->mutex);
822 atomic_inc(&caching_ctl->progress);
823 wake_up(&caching_ctl->wait);
848 struct btrfs_caching_control *caching_ctl;
851 caching_ctl = container_of(work, struct btrfs_caching_control, work);
852 block_group = caching_ctl->block_group;
855 mutex_lock(&caching_ctl->mutex);
858 load_block_group_size_class(caching_ctl, block_group);
873 wake_up(&caching_ctl->wait);
885 ret = load_free_space_tree(caching_ctl);
887 ret = load_extent_tree_free(caching_ctl);
890 block_group->caching_ctl = NULL;
910 mutex_unlock(&caching_ctl->mutex);
912 wake_up(&caching_ctl->wait);
914 btrfs_put_caching_control(caching_ctl);
921 struct btrfs_caching_control *caching_ctl = NULL;
928 caching_ctl = kzalloc(sizeof(*caching_ctl), GFP_NOFS);
929 if (!caching_ctl)
932 INIT_LIST_HEAD(&caching_ctl->list);
933 mutex_init(&caching_ctl->mutex);
934 init_waitqueue_head(&caching_ctl->wait);
935 caching_ctl->block_group = cache;
936 refcount_set(&caching_ctl->count, 2);
937 atomic_set(&caching_ctl->progress, 0);
938 btrfs_init_work(&caching_ctl->work, caching_thread, NULL);
942 kfree(caching_ctl);
944 caching_ctl = cache->caching_ctl;
945 if (caching_ctl)
946 refcount_inc(&caching_ctl->count);
950 WARN_ON(cache->caching_ctl);
951 cache->caching_ctl = caching_ctl;
956 refcount_inc(&caching_ctl->count);
957 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups);
962 btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work);
964 if (wait && caching_ctl)
965 ret = btrfs_caching_ctl_wait_done(cache, caching_ctl);
966 if (caching_ctl)
967 btrfs_put_caching_control(caching_ctl);
1061 struct btrfs_caching_control *caching_ctl = NULL;
1174 caching_ctl = btrfs_get_caching_control(block_group);
1175 if (!caching_ctl) {
1180 caching_ctl = ctl;
1181 refcount_inc(&caching_ctl->count);
1186 if (caching_ctl)
1187 list_del_init(&caching_ctl->list);
1190 if (caching_ctl) {
1192 btrfs_put_caching_control(caching_ctl);
1193 btrfs_put_caching_control(caching_ctl);
4339 struct btrfs_caching_control *caching_ctl;
4355 caching_ctl = list_entry(info->caching_block_groups.next,
4357 list_del(&caching_ctl->list);
4358 btrfs_put_caching_control(caching_ctl);