Lines Matching refs:bytes
32 u64 bytes; member
516 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
526 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
600 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
650 if (prev->offset + prev->bytes == e->offset) { in merge_space_tree()
653 prev->bytes += e->bytes; in merge_space_tree()
768 if (!e->bytes) { in __load_free_space_cache()
827 ctl->discardable_bytes[BTRFS_STAT_CURR] += e->bytes; in __load_free_space_cache()
974 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1004 trim_entry->bytes, NULL); in write_cache_extent_entries()
1444 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1446 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1577 prev->offset + prev->bytes > offset) in tree_search_offset()
1609 prev->offset + prev->bytes > offset) in tree_search_offset()
1614 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1626 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1647 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in __unlink_free_space()
1655 ctl->free_space -= info->bytes; in unlink_free_space()
1663 ASSERT(info->bytes || info->bitmap); in link_free_space()
1671 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1674 ctl->free_space += info->bytes; in link_free_space()
1719 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1725 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1731 info->bytes -= bytes; in __bitmap_clear_bits()
1744 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in __bitmap_clear_bits()
1750 u64 bytes) in bitmap_clear_bits() argument
1752 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1753 ctl->free_space -= bytes; in bitmap_clear_bits()
1758 u64 bytes) in bitmap_set_bits() argument
1764 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1770 info->bytes += bytes; in bitmap_set_bits()
1771 ctl->free_space += bytes; in bitmap_set_bits()
1782 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1792 u64 *bytes, bool for_alloc) in search_bitmap() argument
1806 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1807 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1813 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1834 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1838 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1839 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1847 return entry->bytes; in get_max_extent_size()
1852 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1870 if (entry->bytes < *bytes) { in find_free_space()
1879 if (*bytes >= align) { in find_free_space()
1889 if (entry->bytes < *bytes + align_off) { in find_free_space()
1896 u64 size = *bytes; in find_free_space()
1901 *bytes = size; in find_free_space()
1912 *bytes = entry->bytes - align_off; in find_free_space()
1923 u64 bytes = bitmap_info->bytes; in count_bitmap_extents() local
1927 if (!block_group || !bytes) in count_bitmap_extents()
1932 bytes -= (rs - re) * ctl->unit; in count_bitmap_extents()
1935 if (!bytes) in count_bitmap_extents()
1946 info->bytes = 0; in add_new_bitmap()
1964 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
1967 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
1979 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2003 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2010 *bytes -= search_bytes; in remove_from_bitmap()
2012 if (*bytes) { in remove_from_bitmap()
2014 if (!bitmap_info->bytes) in remove_from_bitmap()
2048 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2056 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2069 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2076 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2103 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2118 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2151 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2155 bytes = info->bytes; in insert_into_bitmap()
2193 bytes, trim_state); in insert_into_bitmap()
2194 bytes -= bytes_added; in insert_into_bitmap()
2198 if (!bytes) { in insert_into_bitmap()
2212 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2214 bytes -= bytes_added; in insert_into_bitmap()
2218 if (!bytes) { in insert_into_bitmap()
2290 u64 bytes = info->bytes; in try_merge_free_space() local
2298 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2312 info->bytes += right_info->bytes; in try_merge_free_space()
2319 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2326 info->bytes += left_info->bytes; in try_merge_free_space()
2341 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2343 u64 bytes; in steal_from_bitmap_to_end() local
2353 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2354 info->bytes += bytes; in steal_from_bitmap_to_end()
2361 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2363 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2365 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2380 u64 bytes; in steal_from_bitmap_to_front() local
2406 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2408 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2410 info->offset -= bytes; in steal_from_bitmap_to_front()
2411 info->bytes += bytes; in steal_from_bitmap_to_front()
2418 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2420 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2422 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2466 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2472 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2479 info->bytes = bytes; in __btrfs_add_free_space()
2509 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2564 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2575 if (!bytes) in btrfs_remove_free_space()
2601 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2603 info->bytes -= to_free; in btrfs_remove_free_space()
2605 if (info->bytes) { in btrfs_remove_free_space()
2613 bytes -= to_free; in btrfs_remove_free_space()
2616 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2618 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2625 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2626 bytes -= old_end - offset; in btrfs_remove_free_space()
2629 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2636 offset + bytes, in btrfs_remove_free_space()
2637 old_end - (offset + bytes), in btrfs_remove_free_space()
2644 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2657 u64 bytes) in btrfs_dump_free_space() argument
2668 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2671 info->offset, info->bytes, in btrfs_dump_free_space()
2741 entry->bytes; in __btrfs_return_cluster_to_free_space()
2751 entry->bytes; in __btrfs_return_cluster_to_free_space()
2845 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2852 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2866 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2869 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2871 if (!entry->bytes) in btrfs_find_space_for_alloc()
2880 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2882 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2883 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2885 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2886 if (!entry->bytes) in btrfs_find_space_for_alloc()
2948 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
2954 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2958 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2968 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2979 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
2990 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3002 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3006 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3018 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3029 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3033 entry->offset += bytes; in btrfs_alloc_from_cluster()
3034 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3048 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3050 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3052 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3055 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3078 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3094 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3159 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3179 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3188 window_free = entry->bytes; in setup_cluster_no_bitmap()
3189 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3203 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3207 window_free += entry->bytes; in setup_cluster_no_bitmap()
3208 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3209 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3212 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3228 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3234 total_size += entry->bytes; in setup_cluster_no_bitmap()
3250 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3275 if (entry->bytes < bytes) in setup_cluster_bitmap()
3278 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3300 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3317 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3319 cont1_bytes = bytes; in btrfs_find_space_cluster()
3322 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3332 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3345 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3349 bytes + empty_size, in btrfs_find_space_cluster()
3353 offset, bytes + empty_size, in btrfs_find_space_cluster()
3390 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3400 const u64 end = start + bytes; in do_trimming()
3415 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3426 if (start + bytes < reserved_start + reserved_bytes) in do_trimming()
3429 __btrfs_add_free_space(fs_info, ctl, start, bytes, trim_state); in do_trimming()
3463 u64 bytes; in trim_no_bitmap() local
3493 extent_bytes = entry->bytes; in trim_no_bitmap()
3497 bytes = entry->bytes; in trim_no_bitmap()
3498 if (bytes < minlen) { in trim_no_bitmap()
3510 bytes >= (max_discard_size + in trim_no_bitmap()
3512 bytes = max_discard_size; in trim_no_bitmap()
3515 entry->bytes -= max_discard_size; in trim_no_bitmap()
3522 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3523 if (bytes < minlen) { in trim_no_bitmap()
3535 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3539 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3543 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3547 start += bytes; in trim_no_bitmap()
3594 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3609 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3626 u64 bytes; in trim_bitmaps() local
3671 bytes = minlen; in trim_bitmaps()
3672 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3698 bytes = min(bytes, end - start); in trim_bitmaps()
3699 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3713 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3714 bytes = max_discard_size; in trim_bitmaps()
3716 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3717 if (entry->bytes == 0) in trim_bitmaps()
3722 trim_entry.bytes = bytes; in trim_bitmaps()
3726 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3727 start, bytes, 0, &trim_entry); in trim_bitmaps()
3739 start += bytes; in trim_bitmaps()
3863 entry->bytes--; in btrfs_find_ino_for_alloc()
3864 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3879 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
4009 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4028 info->bytes = bytes; in test_add_free_space_entry()
4056 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4059 bytes -= bytes_added; in test_add_free_space_entry()
4063 if (bytes) in test_add_free_space_entry()
4079 u64 offset, u64 bytes) in test_check_exists() argument
4108 offset + bytes > bit_off) { in test_check_exists()
4118 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4120 if (offset + bytes < tmp->offset) { in test_check_exists()
4132 if (offset + bytes < tmp->offset) in test_check_exists()
4134 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4151 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()