Lines Matching refs:info
23 #include "space-info.h"
48 struct btrfs_free_space *info);
50 struct btrfs_free_space *info, bool update_stat);
57 struct btrfs_free_space *info, u64 offset,
62 struct btrfs_free_space *info;
66 info = rb_entry(node, struct btrfs_free_space, offset_index);
67 if (!info->bitmap) {
68 unlink_free_space(ctl, info, true);
69 kmem_cache_free(btrfs_free_space_cachep, info);
71 free_bitmap(ctl, info);
900 struct btrfs_free_space *info;
905 info = rb_entry(n, struct btrfs_free_space, offset_index);
906 if (!info->bitmap) {
907 const u64 offset = info->offset;
908 const u64 bytes = info->bytes;
910 unlink_free_space(ctl, info, true);
912 kmem_cache_free(btrfs_free_space_cachep, info);
916 u64 offset = info->offset;
919 ret = search_bitmap(ctl, info, &offset, &bytes, false);
921 bitmap_clear_bits(ctl, info, offset, bytes, true);
927 free_bitmap(ctl, info);
1363 * Write out cached info to an inode.
1605 struct btrfs_free_space *info;
1608 info = rb_entry(parent, struct btrfs_free_space, offset_index);
1610 if (new_entry->offset < info->offset) {
1612 } else if (new_entry->offset > info->offset) {
1629 if (info->bitmap) {
1635 if (!info->bitmap) {
1816 struct btrfs_free_space *info,
1821 rb_erase(&info->offset_index, &ctl->free_space_offset);
1822 rb_erase_cached(&info->bytes_index, &ctl->free_space_bytes);
1825 if (!info->bitmap && !btrfs_free_space_trimmed(info)) {
1827 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes;
1831 ctl->free_space -= info->bytes;
1835 struct btrfs_free_space *info)
1841 ASSERT(info->bytes || info->bitmap);
1842 ret = tree_insert_offset(ctl, NULL, info);
1846 rb_add_cached(&info->bytes_index, &ctl->free_space_bytes, entry_less);
1848 if (!info->bitmap && !btrfs_free_space_trimmed(info)) {
1850 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
1853 ctl->free_space += info->bytes;
1859 struct btrfs_free_space *info)
1861 ASSERT(info->bitmap);
1867 if (RB_EMPTY_NODE(&info->bytes_index))
1872 rb_erase_cached(&info->bytes_index, &ctl->free_space_bytes);
1873 rb_add_cached(&info->bytes_index, &ctl->free_space_bytes, entry_less);
1877 struct btrfs_free_space *info,
1883 start = offset_to_bit(info->offset, ctl->unit, offset);
1888 bitmap_clear(info->bitmap, start, count);
1890 info->bytes -= bytes;
1891 if (info->max_extent_size > ctl->unit)
1892 info->max_extent_size = 0;
1894 relink_bitmap_entry(ctl, info);
1896 if (start && test_bit(start - 1, info->bitmap))
1899 if (end < BITS_PER_BITMAP && test_bit(end, info->bitmap))
1902 info->bitmap_extents += extent_delta;
1903 if (!btrfs_free_space_trimmed(info)) {
1913 struct btrfs_free_space *info, u64 offset,
1919 start = offset_to_bit(info->offset, ctl->unit, offset);
1924 bitmap_set(info->bitmap, start, count);
1930 info->max_extent_size = 0;
1931 info->bytes += bytes;
1934 relink_bitmap_entry(ctl, info);
1936 if (start && test_bit(start - 1, info->bitmap))
1939 if (end < BITS_PER_BITMAP && test_bit(end, info->bitmap))
1942 info->bitmap_extents += extent_delta;
1943 if (!btrfs_free_space_trimmed(info)) {
2116 struct btrfs_free_space *info, u64 offset)
2118 info->offset = offset_to_bitmap(ctl, offset);
2119 info->bytes = 0;
2120 info->bitmap_extents = 0;
2121 INIT_LIST_HEAD(&info->list);
2122 link_free_space(ctl, info);
2227 struct btrfs_free_space *info, u64 offset,
2238 if (btrfs_free_space_trimmed(info)) {
2240 info->bitmap_extents;
2241 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
2243 info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
2246 end = info->offset + (u64)(BITS_PER_BITMAP * ctl->unit);
2250 bitmap_set_bits(ctl, info, offset, bytes_to_set);
2257 struct btrfs_free_space *info)
2269 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD)
2284 if (info->bytes <= fs_info->sectorsize * 8) {
2311 struct btrfs_free_space *info)
2320 bytes = info->bytes;
2321 offset = info->offset;
2322 trim_state = info->trim_state;
2324 if (!ctl->op->use_bitmap(ctl, info))
2390 if (info && info->bitmap) {
2391 add_new_bitmap(ctl, info, offset);
2393 info = NULL;
2398 /* no pre-allocated info, allocate a new one */
2399 if (!info) {
2400 info = kmem_cache_zalloc(btrfs_free_space_cachep,
2402 if (!info) {
2410 info->bitmap = kmem_cache_zalloc(btrfs_free_space_bitmap_cachep,
2412 info->trim_state = BTRFS_TRIM_STATE_TRIMMED;
2414 if (!info->bitmap) {
2422 if (info) {
2423 if (info->bitmap)
2425 info->bitmap);
2426 kmem_cache_free(btrfs_free_space_cachep, info);
2449 struct btrfs_free_space *info, bool update_stat)
2454 u64 offset = info->offset;
2455 u64 bytes = info->bytes;
2456 const bool is_trimmed = btrfs_free_space_trimmed(info);
2477 info->bytes += right_info->bytes;
2487 info->offset = left_info->offset;
2488 info->bytes += left_info->bytes;
2497 struct btrfs_free_space *info,
2503 const u64 end = info->offset + info->bytes;
2516 info->bytes += bytes;
2520 info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
2531 struct btrfs_free_space *info,
2541 bitmap_offset = offset_to_bitmap(ctl, info->offset);
2543 if (bitmap_offset == info->offset) {
2544 if (info->offset == 0)
2546 bitmap_offset = offset_to_bitmap(ctl, info->offset - 1);
2553 i = offset_to_bit(bitmap->offset, ctl->unit, info->offset) - 1;
2569 info->offset -= bytes;
2570 info->bytes += bytes;
2574 info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
2576 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat);
2596 struct btrfs_free_space *info,
2603 ASSERT(!info->bitmap);
2604 ASSERT(RB_EMPTY_NODE(&info->offset_index));
2610 stole_end = steal_from_bitmap_to_end(ctl, info, update_stat);
2612 stole_front = steal_from_bitmap_to_front(ctl, info,
2616 try_merge_free_space(ctl, info, update_stat);
2626 struct btrfs_free_space *info;
2632 info = kmem_cache_zalloc(btrfs_free_space_cachep, GFP_NOFS);
2633 if (!info)
2636 info->offset = offset;
2637 info->bytes = bytes;
2638 info->trim_state = trim_state;
2639 RB_CLEAR_NODE(&info->offset_index);
2640 RB_CLEAR_NODE(&info->bytes_index);
2644 if (try_merge_free_space(ctl, info, true))
2652 ret = insert_into_bitmap(ctl, info);
2666 steal_from_bitmap(ctl, info, true);
2668 filter_bytes = max(filter_bytes, info->bytes);
2670 ret = link_free_space(ctl, info);
2672 kmem_cache_free(btrfs_free_space_cachep, info);
2797 struct btrfs_free_space *info;
2804 * Since the allocation info of tree-log nodes are not recorded
2828 info = tree_search_offset(ctl, offset, 0, 0);
2829 if (!info) {
2834 info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
2836 if (!info) {
2848 if (!info->bitmap) {
2849 unlink_free_space(ctl, info, true);
2850 if (offset == info->offset) {
2851 u64 to_free = min(bytes, info->bytes);
2853 info->bytes -= to_free;
2854 info->offset += to_free;
2855 if (info->bytes) {
2856 ret = link_free_space(ctl, info);
2859 kmem_cache_free(btrfs_free_space_cachep, info);
2866 u64 old_end = info->bytes + info->offset;
2868 info->bytes = offset - info->offset;
2869 ret = link_free_space(ctl, info);
2888 info->trim_state);
2894 ret = remove_from_bitmap(ctl, info, &offset, &bytes);
2911 struct btrfs_free_space *info;
2929 info = rb_entry(n, struct btrfs_free_space, offset_index);
2930 if (info->bytes >= bytes && !block_group->ro)
2933 info->offset, info->bytes,
2934 (info->bitmap) ? "yes" : "no");
3056 struct btrfs_free_space *info;
3064 info = rb_entry(node, struct btrfs_free_space, offset_index);
3066 if (!btrfs_free_space_trimmed(info)) {
4189 struct btrfs_free_space *info = NULL, *bitmap_info;
4196 if (!info) {
4197 info = kmem_cache_zalloc(btrfs_free_space_cachep, GFP_NOFS);
4198 if (!info)
4204 info->offset = offset;
4205 info->bytes = bytes;
4206 info->max_extent_size = 0;
4207 ret = link_free_space(ctl, info);
4210 kmem_cache_free(btrfs_free_space_cachep, info);
4217 kmem_cache_free(btrfs_free_space_cachep, info);
4226 info->bitmap = map;
4228 add_new_bitmap(ctl, info, offset);
4229 bitmap_info = info;
4230 info = NULL;
4243 if (info)
4244 kmem_cache_free(btrfs_free_space_cachep, info);
4259 struct btrfs_free_space *info;
4263 info = tree_search_offset(ctl, offset, 0, 0);
4264 if (!info) {
4265 info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
4267 if (!info)
4272 if (info->bitmap) {
4279 ret = search_bitmap(ctl, info, &bit_off, &bit_bytes, false);
4291 n = rb_prev(&info->offset_index);
4301 info = tmp;
4305 n = rb_next(&info->offset_index);
4315 info = tmp;
4323 if (info->offset == offset) {
4328 if (offset > info->offset && offset < info->offset + info->bytes)