Lines Matching defs:cache
26 #include "free-space-cache.h"
59 static int block_group_bits(struct btrfs_block_group *cache, u64 bits)
61 return (cache->flags & bits) == bits;
73 void btrfs_free_excluded_extents(struct btrfs_block_group *cache)
75 struct btrfs_fs_info *fs_info = cache->fs_info;
78 start = cache->start;
79 end = start + cache->length - 1;
2523 struct btrfs_block_group *cache;
2533 cache = btrfs_lookup_first_block_group(fs_info, search_start);
2534 if (!cache)
2537 bytenr = cache->start;
2538 btrfs_put_block_group(cache);
2544 struct btrfs_block_group *cache,
2547 struct btrfs_fs_info *fs_info = cache->fs_info;
2549 spin_lock(&cache->space_info->lock);
2550 spin_lock(&cache->lock);
2551 cache->pinned += num_bytes;
2552 btrfs_space_info_update_bytes_pinned(fs_info, cache->space_info,
2555 cache->reserved -= num_bytes;
2556 cache->space_info->bytes_reserved -= num_bytes;
2558 spin_unlock(&cache->lock);
2559 spin_unlock(&cache->space_info->lock);
2561 __btrfs_mod_total_bytes_pinned(cache->space_info, num_bytes);
2570 struct btrfs_block_group *cache;
2572 cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
2573 BUG_ON(!cache); /* Logic error */
2575 pin_down_extent(trans, cache, bytenr, num_bytes, reserved);
2577 btrfs_put_block_group(cache);
2587 struct btrfs_block_group *cache;
2592 cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
2593 if (!cache)
2597 * pull in the free space cache (if any) so that our pin
2598 * removes the free space from the cache. We have load_only set
2602 btrfs_cache_block_group(cache, 1);
2604 pin_down_extent(trans, cache, bytenr, num_bytes, 0);
2606 /* remove us from the free space cache (if we're there at all) */
2607 ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
2608 btrfs_put_block_group(cache);
2731 struct btrfs_block_group *cache = NULL;
2742 if (!cache ||
2743 start >= cache->start + cache->length) {
2744 if (cache)
2745 btrfs_put_block_group(cache);
2747 cache = btrfs_lookup_block_group(fs_info, start);
2748 BUG_ON(!cache); /* Logic error */
2751 cache->space_info,
2756 len = cache->start + cache->length - start;
2759 if (start < cache->last_byte_to_unpin && return_free_space) {
2760 u64 add_len = min(len, cache->last_byte_to_unpin - start);
2762 btrfs_add_free_space(cache, start, add_len);
2767 space_info = cache->space_info;
2783 spin_lock(&cache->lock);
2784 cache->pinned -= len;
2788 if (cache->ro) {
2792 spin_unlock(&cache->lock);
2816 if (cache)
2817 btrfs_put_block_group(cache);
3340 struct btrfs_block_group *cache;
3348 cache = btrfs_lookup_block_group(fs_info, buf->start);
3351 pin_down_extent(trans, cache, buf->start, buf->len, 1);
3352 btrfs_put_block_group(cache);
3358 btrfs_add_free_space(cache, buf->start, buf->len);
3359 btrfs_free_reserved_bytes(cache, buf->len, 0);
3360 btrfs_put_block_group(cache);
3416 btrfs_lock_block_group(struct btrfs_block_group *cache,
3420 down_read(&cache->data_rwsem);
3423 static inline void btrfs_grab_block_group(struct btrfs_block_group *cache,
3426 btrfs_get_block_group(cache);
3428 down_read(&cache->data_rwsem);
3471 btrfs_release_block_group(struct btrfs_block_group *cache,
3475 up_read(&cache->data_rwsem);
3476 btrfs_put_block_group(cache);
3520 * Whether we're updating free space cache, if true we need to re-search
3521 * current block group but don't try updating free space cache again.
3531 /* Total free space from free space cache, not always contiguous */
4317 struct btrfs_block_group *cache;
4319 cache = btrfs_lookup_block_group(fs_info, start);
4320 if (!cache) {
4326 btrfs_add_free_space(cache, start, len);
4327 btrfs_free_reserved_bytes(cache, len, delalloc);
4330 btrfs_put_block_group(cache);
4337 struct btrfs_block_group *cache;
4340 cache = btrfs_lookup_block_group(trans->fs_info, start);
4341 if (!cache) {
4347 ret = pin_down_extent(trans, cache, start, len, 1);
4348 btrfs_put_block_group(cache);
4539 * space cache bits as well
5830 struct btrfs_block_group *cache = NULL;
5852 cache = btrfs_lookup_first_block_group(fs_info, range->start);
5853 for (; cache; cache = btrfs_next_block_group(cache)) {
5854 if (cache->start >= range_end) {
5855 btrfs_put_block_group(cache);
5859 start = max(range->start, cache->start);
5860 end = min(range_end, cache->start + cache->length);
5863 if (!btrfs_block_group_done(cache)) {
5864 ret = btrfs_cache_block_group(cache, 0);
5870 ret = btrfs_wait_block_group_cache_done(cache);
5877 ret = btrfs_trim_block_group(cache,