Lines Matching defs:cache
27 #include "free-space-cache.h"
67 static int block_group_bits(struct btrfs_block_group *cache, u64 bits)
69 return (cache->flags & bits) == bits;
2537 struct btrfs_block_group *cache,
2540 struct btrfs_fs_info *fs_info = cache->fs_info;
2542 spin_lock(&cache->space_info->lock);
2543 spin_lock(&cache->lock);
2544 cache->pinned += num_bytes;
2545 btrfs_space_info_update_bytes_pinned(fs_info, cache->space_info,
2548 cache->reserved -= num_bytes;
2549 cache->space_info->bytes_reserved -= num_bytes;
2551 spin_unlock(&cache->lock);
2552 spin_unlock(&cache->space_info->lock);
2562 struct btrfs_block_group *cache;
2564 cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
2565 BUG_ON(!cache); /* Logic error */
2567 pin_down_extent(trans, cache, bytenr, num_bytes, reserved);
2569 btrfs_put_block_group(cache);
2579 struct btrfs_block_group *cache;
2582 cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
2583 if (!cache)
2587 * Fully cache the free space first so that our pin removes the free space
2588 * from the cache.
2590 ret = btrfs_cache_block_group(cache, true);
2594 pin_down_extent(trans, cache, bytenr, num_bytes, 0);
2596 /* remove us from the free space cache (if we're there at all) */
2597 ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
2599 btrfs_put_block_group(cache);
2694 struct btrfs_block_group *cache = NULL;
2705 if (!cache ||
2706 start >= cache->start + cache->length) {
2707 if (cache)
2708 btrfs_put_block_group(cache);
2710 cache = btrfs_lookup_block_group(fs_info, start);
2711 BUG_ON(!cache); /* Logic error */
2714 cache->space_info,
2719 len = cache->start + cache->length - start;
2723 btrfs_add_free_space(cache, start, len);
2727 space_info = cache->space_info;
2743 spin_lock(&cache->lock);
2744 cache->pinned -= len;
2747 if (cache->ro) {
2755 spin_unlock(&cache->lock);
2778 if (cache)
2779 btrfs_put_block_group(cache);
3302 struct btrfs_block_group *cache;
3313 cache = btrfs_lookup_block_group(fs_info, buf->start);
3316 pin_down_extent(trans, cache, buf->start, buf->len, 1);
3317 btrfs_put_block_group(cache);
3342 pin_down_extent(trans, cache, buf->start, buf->len, 1);
3343 btrfs_put_block_group(cache);
3349 btrfs_add_free_space(cache, buf->start, buf->len);
3350 btrfs_free_reserved_bytes(cache, buf->len, 0);
3351 btrfs_put_block_group(cache);
3436 btrfs_lock_block_group(struct btrfs_block_group *cache,
3440 down_read(&cache->data_rwsem);
3443 static inline void btrfs_grab_block_group(struct btrfs_block_group *cache,
3446 btrfs_get_block_group(cache);
3448 down_read(&cache->data_rwsem);
3491 btrfs_release_block_group(struct btrfs_block_group *cache,
3495 up_read(&cache->data_rwsem);
3496 btrfs_put_block_group(cache);
4577 struct btrfs_block_group *cache;
4579 cache = btrfs_lookup_block_group(fs_info, start);
4580 if (!cache) {
4586 btrfs_add_free_space(cache, start, len);
4587 btrfs_free_reserved_bytes(cache, len, delalloc);
4590 btrfs_put_block_group(cache);
4597 struct btrfs_block_group *cache;
4600 cache = btrfs_lookup_block_group(trans->fs_info, start);
4601 if (!cache) {
4607 ret = pin_down_extent(trans, cache, start, len, 1);
4608 btrfs_put_block_group(cache);
4793 * space cache bits as well
6090 struct btrfs_block_group *cache = NULL;
6114 cache = btrfs_lookup_first_block_group(fs_info, range->start);
6115 for (; cache; cache = btrfs_next_block_group(cache)) {
6116 if (cache->start >= range_end) {
6117 btrfs_put_block_group(cache);
6121 start = max(range->start, cache->start);
6122 end = min(range_end, cache->start + cache->length);
6125 if (!btrfs_block_group_done(cache)) {
6126 ret = btrfs_cache_block_group(cache, true);
6133 ret = btrfs_trim_block_group(cache,