Lines Matching refs:bytes
43 u64 bytes; member
53 u64 *bytes, bool for_alloc);
58 u64 bytes, bool update_stats);
577 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
587 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
661 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
825 if (!e->bytes) { in __load_free_space_cache()
908 const u64 bytes = info->bytes; in copy_free_space_cache() local
913 ret = btrfs_add_free_space(block_group, offset, bytes); in copy_free_space_cache()
917 u64 bytes = ctl->unit; in copy_free_space_cache() local
919 ret = search_bitmap(ctl, info, &offset, &bytes, false); in copy_free_space_cache()
921 bitmap_clear_bits(ctl, info, offset, bytes, true); in copy_free_space_cache()
924 bytes); in copy_free_space_cache()
1101 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1131 trim_entry->bytes, NULL); in write_cache_extent_entries()
1565 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1567 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1678 return entry->bytes; in get_max_extent_size()
1755 prev->offset + prev->bytes > offset) in tree_search_offset()
1787 prev->offset + prev->bytes > offset) in tree_search_offset()
1792 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1808 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1827 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in unlink_free_space()
1831 ctl->free_space -= info->bytes; in unlink_free_space()
1841 ASSERT(info->bytes || info->bitmap); in link_free_space()
1850 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1853 ctl->free_space += info->bytes; in link_free_space()
1878 u64 offset, u64 bytes, bool update_stat) in bitmap_clear_bits() argument
1884 count = bytes_to_bits(bytes, ctl->unit); in bitmap_clear_bits()
1890 info->bytes -= bytes; in bitmap_clear_bits()
1905 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in bitmap_clear_bits()
1909 ctl->free_space -= bytes; in bitmap_clear_bits()
1914 u64 bytes) in bitmap_set_bits() argument
1920 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1931 info->bytes += bytes; in bitmap_set_bits()
1932 ctl->free_space += bytes; in bitmap_set_bits()
1945 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1955 u64 *bytes, bool for_alloc) in search_bitmap() argument
1969 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1970 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1976 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1997 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
2001 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
2002 bitmap_info->max_extent_size = *bytes; in search_bitmap()
2009 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
2047 if (entry->bytes < *bytes) { in find_free_space()
2058 if (*bytes >= align) { in find_free_space()
2075 if (entry->bytes < *bytes + align_off) { in find_free_space()
2083 u64 size = *bytes; in find_free_space()
2088 *bytes = size; in find_free_space()
2108 *bytes = entry->bytes - align_off; in find_free_space()
2119 info->bytes = 0; in add_new_bitmap()
2136 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
2139 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
2151 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2175 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2182 *bytes -= search_bytes; in remove_from_bitmap()
2184 if (*bytes) { in remove_from_bitmap()
2186 if (!bitmap_info->bytes) in remove_from_bitmap()
2220 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2228 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2241 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2248 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2269 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2284 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2316 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2320 bytes = info->bytes; in insert_into_bitmap()
2358 bytes, trim_state); in insert_into_bitmap()
2359 bytes -= bytes_added; in insert_into_bitmap()
2363 if (!bytes) { in insert_into_bitmap()
2377 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2379 bytes -= bytes_added; in insert_into_bitmap()
2383 if (!bytes) { in insert_into_bitmap()
2455 u64 bytes = info->bytes; in try_merge_free_space() local
2464 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2477 info->bytes += right_info->bytes; in try_merge_free_space()
2484 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2488 info->bytes += left_info->bytes; in try_merge_free_space()
2503 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2505 u64 bytes; in steal_from_bitmap_to_end() local
2515 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2516 info->bytes += bytes; in steal_from_bitmap_to_end()
2522 bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat); in steal_from_bitmap_to_end()
2524 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2539 u64 bytes; in steal_from_bitmap_to_front() local
2565 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2567 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2569 info->offset -= bytes; in steal_from_bitmap_to_front()
2570 info->bytes += bytes; in steal_from_bitmap_to_front()
2576 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat); in steal_from_bitmap_to_front()
2578 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2621 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2628 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2637 info->bytes = bytes; in __btrfs_add_free_space()
2668 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2794 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2814 offset + bytes) { in btrfs_remove_free_space()
2816 offset + bytes - block_group->start; in btrfs_remove_free_space()
2825 if (!bytes) in btrfs_remove_free_space()
2851 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2853 info->bytes -= to_free; in btrfs_remove_free_space()
2855 if (info->bytes) { in btrfs_remove_free_space()
2863 bytes -= to_free; in btrfs_remove_free_space()
2866 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2868 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2875 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2876 bytes -= old_end - offset; in btrfs_remove_free_space()
2879 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2886 offset + bytes, in btrfs_remove_free_space()
2887 old_end - (offset + bytes), in btrfs_remove_free_space()
2894 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2907 u64 bytes) in btrfs_dump_free_space() argument
2930 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2933 info->offset, info->bytes, in btrfs_dump_free_space()
2941 count, bytes); in btrfs_dump_free_space()
3005 entry->bytes; in __btrfs_return_cluster_to_free_space()
3015 entry->bytes; in __btrfs_return_cluster_to_free_space()
3079 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
3086 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
3104 bitmap_clear_bits(ctl, entry, offset, bytes, true); in btrfs_find_space_for_alloc()
3107 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3109 if (!entry->bytes) in btrfs_find_space_for_alloc()
3118 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3120 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
3121 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
3123 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
3124 if (!entry->bytes) in btrfs_find_space_for_alloc()
3185 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
3191 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3195 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3205 bitmap_clear_bits(ctl, entry, ret, bytes, false); in btrfs_alloc_from_bitmap()
3216 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
3229 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3241 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3245 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3257 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3268 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3272 entry->offset += bytes; in btrfs_alloc_from_cluster()
3273 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3287 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3289 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3291 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3294 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3317 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3335 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3410 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3432 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3441 window_free = entry->bytes; in setup_cluster_no_bitmap()
3442 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3456 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3460 window_free += entry->bytes; in setup_cluster_no_bitmap()
3461 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3462 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3465 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3481 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3487 total_size += entry->bytes; in setup_cluster_no_bitmap()
3503 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3528 if (entry->bytes < bytes) in setup_cluster_bitmap()
3531 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3553 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3570 cont1_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3573 cont1_bytes = bytes; in btrfs_find_space_cluster()
3576 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3586 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3599 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3603 bytes + empty_size, in btrfs_find_space_cluster()
3607 offset, bytes + empty_size, in btrfs_find_space_cluster()
3644 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3654 const u64 end = start + bytes; in do_trimming()
3669 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3683 __btrfs_add_free_space(block_group, start, bytes, trim_state); in do_trimming()
3717 u64 bytes; in trim_no_bitmap() local
3747 extent_bytes = entry->bytes; in trim_no_bitmap()
3751 bytes = entry->bytes; in trim_no_bitmap()
3752 if (bytes < minlen) { in trim_no_bitmap()
3764 bytes >= (max_discard_size + in trim_no_bitmap()
3766 bytes = max_discard_size; in trim_no_bitmap()
3769 entry->bytes -= max_discard_size; in trim_no_bitmap()
3776 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3777 if (bytes < minlen) { in trim_no_bitmap()
3789 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3793 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3797 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3801 start += bytes; in trim_no_bitmap()
3848 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3863 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3880 u64 bytes; in trim_bitmaps() local
3925 bytes = minlen; in trim_bitmaps()
3926 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3952 bytes = min(bytes, end - start); in trim_bitmaps()
3953 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3967 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3968 bytes = max_discard_size; in trim_bitmaps()
3970 bitmap_clear_bits(ctl, entry, start, bytes, true); in trim_bitmaps()
3971 if (entry->bytes == 0) in trim_bitmaps()
3976 trim_entry.bytes = bytes; in trim_bitmaps()
3980 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3981 start, bytes, 0, &trim_entry); in trim_bitmaps()
3993 start += bytes; in trim_bitmaps()
4186 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4205 info->bytes = bytes; in test_add_free_space_entry()
4233 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4236 bytes -= bytes_added; in test_add_free_space_entry()
4240 if (bytes) in test_add_free_space_entry()
4256 u64 offset, u64 bytes) in test_check_exists() argument
4285 offset + bytes > bit_off) { in test_check_exists()
4295 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4297 if (offset + bytes < tmp->offset) { in test_check_exists()
4309 if (offset + bytes < tmp->offset) in test_check_exists()
4311 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4328 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()