Lines Matching refs:cache
57 static int block_group_bits(struct btrfs_block_group_cache *cache, u64 bits) in block_group_bits() argument
59 return (cache->flags & bits) == bits; in block_group_bits()
73 void btrfs_free_excluded_extents(struct btrfs_block_group_cache *cache) in btrfs_free_excluded_extents() argument
75 struct btrfs_fs_info *fs_info = cache->fs_info; in btrfs_free_excluded_extents()
78 start = cache->key.objectid; in btrfs_free_excluded_extents()
79 end = start + cache->key.offset - 1; in btrfs_free_excluded_extents()
2549 struct btrfs_block_group_cache *cache; in first_logical_byte() local
2559 cache = btrfs_lookup_first_block_group(fs_info, search_start); in first_logical_byte()
2560 if (!cache) in first_logical_byte()
2563 bytenr = cache->key.objectid; in first_logical_byte()
2564 btrfs_put_block_group(cache); in first_logical_byte()
2569 static int pin_down_extent(struct btrfs_block_group_cache *cache, in pin_down_extent() argument
2572 struct btrfs_fs_info *fs_info = cache->fs_info; in pin_down_extent()
2574 spin_lock(&cache->space_info->lock); in pin_down_extent()
2575 spin_lock(&cache->lock); in pin_down_extent()
2576 cache->pinned += num_bytes; in pin_down_extent()
2577 btrfs_space_info_update_bytes_pinned(fs_info, cache->space_info, in pin_down_extent()
2580 cache->reserved -= num_bytes; in pin_down_extent()
2581 cache->space_info->bytes_reserved -= num_bytes; in pin_down_extent()
2583 spin_unlock(&cache->lock); in pin_down_extent()
2584 spin_unlock(&cache->space_info->lock); in pin_down_extent()
2586 percpu_counter_add_batch(&cache->space_info->total_bytes_pinned, in pin_down_extent()
2599 struct btrfs_block_group_cache *cache; in btrfs_pin_extent() local
2601 cache = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_pin_extent()
2602 BUG_ON(!cache); /* Logic error */ in btrfs_pin_extent()
2604 pin_down_extent(cache, bytenr, num_bytes, reserved); in btrfs_pin_extent()
2606 btrfs_put_block_group(cache); in btrfs_pin_extent()
2616 struct btrfs_block_group_cache *cache; in btrfs_pin_extent_for_log_replay() local
2619 cache = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_pin_extent_for_log_replay()
2620 if (!cache) in btrfs_pin_extent_for_log_replay()
2629 btrfs_cache_block_group(cache, 1); in btrfs_pin_extent_for_log_replay()
2631 pin_down_extent(cache, bytenr, num_bytes, 0); in btrfs_pin_extent_for_log_replay()
2634 ret = btrfs_remove_free_space(cache, bytenr, num_bytes); in btrfs_pin_extent_for_log_replay()
2635 btrfs_put_block_group(cache); in btrfs_pin_extent_for_log_replay()
2729 struct btrfs_block_group_cache *cache; in btrfs_prepare_extent_commit() local
2735 cache = caching_ctl->block_group; in btrfs_prepare_extent_commit()
2736 if (btrfs_block_group_cache_done(cache)) { in btrfs_prepare_extent_commit()
2737 cache->last_byte_to_unpin = (u64)-1; in btrfs_prepare_extent_commit()
2741 cache->last_byte_to_unpin = caching_ctl->progress; in btrfs_prepare_extent_commit()
2788 struct btrfs_block_group_cache *cache = NULL; in unpin_extent_range() local
2799 if (!cache || in unpin_extent_range()
2800 start >= cache->key.objectid + cache->key.offset) { in unpin_extent_range()
2801 if (cache) in unpin_extent_range()
2802 btrfs_put_block_group(cache); in unpin_extent_range()
2804 cache = btrfs_lookup_block_group(fs_info, start); in unpin_extent_range()
2805 BUG_ON(!cache); /* Logic error */ in unpin_extent_range()
2808 cache->space_info, in unpin_extent_range()
2813 len = cache->key.objectid + cache->key.offset - start; in unpin_extent_range()
2816 if (start < cache->last_byte_to_unpin) { in unpin_extent_range()
2817 len = min(len, cache->last_byte_to_unpin - start); in unpin_extent_range()
2819 btrfs_add_free_space(cache, start, len); in unpin_extent_range()
2824 space_info = cache->space_info; in unpin_extent_range()
2840 spin_lock(&cache->lock); in unpin_extent_range()
2841 cache->pinned -= len; in unpin_extent_range()
2846 if (cache->ro) { in unpin_extent_range()
2850 spin_unlock(&cache->lock); in unpin_extent_range()
2875 if (cache) in unpin_extent_range()
2876 btrfs_put_block_group(cache); in unpin_extent_range()
3266 struct btrfs_block_group_cache *cache; in btrfs_free_tree_block() local
3275 cache = btrfs_lookup_block_group(fs_info, buf->start); in btrfs_free_tree_block()
3278 pin_down_extent(cache, buf->start, buf->len, 1); in btrfs_free_tree_block()
3279 btrfs_put_block_group(cache); in btrfs_free_tree_block()
3285 btrfs_add_free_space(cache, buf->start, buf->len); in btrfs_free_tree_block()
3286 btrfs_free_reserved_bytes(cache, buf->len, 0); in btrfs_free_tree_block()
3287 btrfs_put_block_group(cache); in btrfs_free_tree_block()
3353 btrfs_lock_block_group(struct btrfs_block_group_cache *cache, in btrfs_lock_block_group() argument
3357 down_read(&cache->data_rwsem); in btrfs_lock_block_group()
3361 btrfs_grab_block_group(struct btrfs_block_group_cache *cache, in btrfs_grab_block_group() argument
3364 btrfs_get_block_group(cache); in btrfs_grab_block_group()
3366 down_read(&cache->data_rwsem); in btrfs_grab_block_group()
3408 btrfs_release_block_group(struct btrfs_block_group_cache *cache, in btrfs_release_block_group() argument
3412 up_read(&cache->data_rwsem); in btrfs_release_block_group()
3413 btrfs_put_block_group(cache); in btrfs_release_block_group()
4153 struct btrfs_block_group_cache *cache; in __btrfs_free_reserved_extent() local
4156 cache = btrfs_lookup_block_group(fs_info, start); in __btrfs_free_reserved_extent()
4157 if (!cache) { in __btrfs_free_reserved_extent()
4164 pin_down_extent(cache, start, len, 1); in __btrfs_free_reserved_extent()
4168 btrfs_add_free_space(cache, start, len); in __btrfs_free_reserved_extent()
4169 btrfs_free_reserved_bytes(cache, len, delalloc); in __btrfs_free_reserved_extent()
4173 btrfs_put_block_group(cache); in __btrfs_free_reserved_extent()
5643 struct btrfs_block_group_cache *cache = NULL; in btrfs_trim_fs() local
5665 cache = btrfs_lookup_first_block_group(fs_info, range->start); in btrfs_trim_fs()
5666 for (; cache; cache = btrfs_next_block_group(cache)) { in btrfs_trim_fs()
5667 if (cache->key.objectid >= range_end) { in btrfs_trim_fs()
5668 btrfs_put_block_group(cache); in btrfs_trim_fs()
5672 start = max(range->start, cache->key.objectid); in btrfs_trim_fs()
5673 end = min(range_end, cache->key.objectid + cache->key.offset); in btrfs_trim_fs()
5676 if (!btrfs_block_group_cache_done(cache)) { in btrfs_trim_fs()
5677 ret = btrfs_cache_block_group(cache, 0); in btrfs_trim_fs()
5683 ret = btrfs_wait_block_group_cache_done(cache); in btrfs_trim_fs()
5690 ret = btrfs_trim_block_group(cache, in btrfs_trim_fs()