Lines Matching refs:bytes
34 u64 bytes; member
44 u64 *bytes, bool for_alloc);
49 u64 bytes, bool update_stats);
587 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
597 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
671 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
835 if (!e->bytes) { in __load_free_space_cache()
918 info->bytes); in copy_free_space_cache()
922 u64 bytes = ctl->unit; in copy_free_space_cache() local
924 while (search_bitmap(ctl, info, &offset, &bytes, in copy_free_space_cache()
927 bytes); in copy_free_space_cache()
930 bitmap_clear_bits(ctl, info, offset, bytes, true); in copy_free_space_cache()
932 bytes = ctl->unit; in copy_free_space_cache()
1104 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1134 trim_entry->bytes, NULL); in write_cache_extent_entries()
1569 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1571 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1668 return entry->bytes; in get_max_extent_size()
1743 prev->offset + prev->bytes > offset) in tree_search_offset()
1775 prev->offset + prev->bytes > offset) in tree_search_offset()
1780 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1796 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1813 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in unlink_free_space()
1817 ctl->free_space -= info->bytes; in unlink_free_space()
1825 ASSERT(info->bytes || info->bitmap); in link_free_space()
1835 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1838 ctl->free_space += info->bytes; in link_free_space()
1861 u64 offset, u64 bytes, bool update_stat) in bitmap_clear_bits() argument
1867 count = bytes_to_bits(bytes, ctl->unit); in bitmap_clear_bits()
1873 info->bytes -= bytes; in bitmap_clear_bits()
1888 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in bitmap_clear_bits()
1892 ctl->free_space -= bytes; in bitmap_clear_bits()
1897 u64 bytes) in bitmap_set_bits() argument
1903 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1914 info->bytes += bytes; in bitmap_set_bits()
1915 ctl->free_space += bytes; in bitmap_set_bits()
1928 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1938 u64 *bytes, bool for_alloc) in search_bitmap() argument
1952 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1953 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1959 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1980 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1984 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1985 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1992 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
2030 if (entry->bytes < *bytes) { in find_free_space()
2041 if (*bytes >= align) { in find_free_space()
2058 if (entry->bytes < *bytes + align_off) { in find_free_space()
2066 u64 size = *bytes; in find_free_space()
2071 *bytes = size; in find_free_space()
2091 *bytes = entry->bytes - align_off; in find_free_space()
2102 info->bytes = 0; in add_new_bitmap()
2119 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
2122 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
2134 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2158 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2165 *bytes -= search_bytes; in remove_from_bitmap()
2167 if (*bytes) { in remove_from_bitmap()
2169 if (!bitmap_info->bytes) in remove_from_bitmap()
2203 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2211 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2224 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2231 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2252 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2267 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2299 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2303 bytes = info->bytes; in insert_into_bitmap()
2341 bytes, trim_state); in insert_into_bitmap()
2342 bytes -= bytes_added; in insert_into_bitmap()
2346 if (!bytes) { in insert_into_bitmap()
2360 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2362 bytes -= bytes_added; in insert_into_bitmap()
2366 if (!bytes) { in insert_into_bitmap()
2438 u64 bytes = info->bytes; in try_merge_free_space() local
2446 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2457 info->bytes += right_info->bytes; in try_merge_free_space()
2464 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2468 info->bytes += left_info->bytes; in try_merge_free_space()
2483 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2485 u64 bytes; in steal_from_bitmap_to_end() local
2495 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2496 info->bytes += bytes; in steal_from_bitmap_to_end()
2502 bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat); in steal_from_bitmap_to_end()
2504 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2519 u64 bytes; in steal_from_bitmap_to_front() local
2545 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2547 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2549 info->offset -= bytes; in steal_from_bitmap_to_front()
2550 info->bytes += bytes; in steal_from_bitmap_to_front()
2556 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat); in steal_from_bitmap_to_front()
2558 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2601 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2608 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2617 info->bytes = bytes; in __btrfs_add_free_space()
2648 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2775 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2795 offset + bytes) { in btrfs_remove_free_space()
2797 offset + bytes - block_group->start; in btrfs_remove_free_space()
2806 if (!bytes) in btrfs_remove_free_space()
2832 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2834 info->bytes -= to_free; in btrfs_remove_free_space()
2836 if (info->bytes) { in btrfs_remove_free_space()
2844 bytes -= to_free; in btrfs_remove_free_space()
2847 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2849 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2856 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2857 bytes -= old_end - offset; in btrfs_remove_free_space()
2860 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2867 offset + bytes, in btrfs_remove_free_space()
2868 old_end - (offset + bytes), in btrfs_remove_free_space()
2875 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2888 u64 bytes) in btrfs_dump_free_space() argument
2911 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2914 info->offset, info->bytes, in btrfs_dump_free_space()
2985 entry->bytes; in __btrfs_return_cluster_to_free_space()
2995 entry->bytes; in __btrfs_return_cluster_to_free_space()
3063 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
3070 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
3088 bitmap_clear_bits(ctl, entry, offset, bytes, true); in btrfs_find_space_for_alloc()
3091 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3093 if (!entry->bytes) in btrfs_find_space_for_alloc()
3102 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3104 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
3105 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
3107 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
3108 if (!entry->bytes) in btrfs_find_space_for_alloc()
3169 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
3175 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3179 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3189 bitmap_clear_bits(ctl, entry, ret, bytes, false); in btrfs_alloc_from_bitmap()
3200 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
3213 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3225 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3229 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3241 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3252 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3256 entry->offset += bytes; in btrfs_alloc_from_cluster()
3257 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3271 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3273 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3275 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3278 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3301 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3317 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3393 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3413 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3422 window_free = entry->bytes; in setup_cluster_no_bitmap()
3423 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3437 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3441 window_free += entry->bytes; in setup_cluster_no_bitmap()
3442 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3443 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3446 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3462 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3469 total_size += entry->bytes; in setup_cluster_no_bitmap()
3485 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3510 if (entry->bytes < bytes) in setup_cluster_bitmap()
3513 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3535 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3552 cont1_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3555 cont1_bytes = bytes; in btrfs_find_space_cluster()
3558 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3568 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3581 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3585 bytes + empty_size, in btrfs_find_space_cluster()
3589 offset, bytes + empty_size, in btrfs_find_space_cluster()
3626 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3636 const u64 end = start + bytes; in do_trimming()
3651 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3662 if (start + bytes < reserved_start + reserved_bytes) in do_trimming()
3665 __btrfs_add_free_space(block_group, start, bytes, trim_state); in do_trimming()
3699 u64 bytes; in trim_no_bitmap() local
3729 extent_bytes = entry->bytes; in trim_no_bitmap()
3733 bytes = entry->bytes; in trim_no_bitmap()
3734 if (bytes < minlen) { in trim_no_bitmap()
3746 bytes >= (max_discard_size + in trim_no_bitmap()
3748 bytes = max_discard_size; in trim_no_bitmap()
3751 entry->bytes -= max_discard_size; in trim_no_bitmap()
3758 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3759 if (bytes < minlen) { in trim_no_bitmap()
3771 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3775 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3779 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3783 start += bytes; in trim_no_bitmap()
3830 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3845 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3862 u64 bytes; in trim_bitmaps() local
3907 bytes = minlen; in trim_bitmaps()
3908 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3934 bytes = min(bytes, end - start); in trim_bitmaps()
3935 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3949 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3950 bytes = max_discard_size; in trim_bitmaps()
3952 bitmap_clear_bits(ctl, entry, start, bytes, true); in trim_bitmaps()
3953 if (entry->bytes == 0) in trim_bitmaps()
3958 trim_entry.bytes = bytes; in trim_bitmaps()
3962 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3963 start, bytes, 0, &trim_entry); in trim_bitmaps()
3975 start += bytes; in trim_bitmaps()
4143 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4162 info->bytes = bytes; in test_add_free_space_entry()
4190 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4193 bytes -= bytes_added; in test_add_free_space_entry()
4197 if (bytes) in test_add_free_space_entry()
4213 u64 offset, u64 bytes) in test_check_exists() argument
4242 offset + bytes > bit_off) { in test_check_exists()
4252 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4254 if (offset + bytes < tmp->offset) { in test_check_exists()
4266 if (offset + bytes < tmp->offset) in test_check_exists()
4268 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4285 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()