Lines Matching full:bytes
42 u64 bytes; member
52 u64 *bytes, bool for_alloc);
57 u64 bytes, bool update_stats);
578 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
588 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
662 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
725 * bytes we can have, or whatever is less than that. in recalculate_thresholds()
826 if (!e->bytes) { in __load_free_space_cache()
910 const u64 bytes = info->bytes; in copy_free_space_cache() local
915 ret = btrfs_add_free_space(block_group, offset, bytes); in copy_free_space_cache()
919 u64 bytes = ctl->unit; in copy_free_space_cache() local
921 ret = search_bitmap(ctl, info, &offset, &bytes, false); in copy_free_space_cache()
923 bitmap_clear_bits(ctl, info, offset, bytes, true); in copy_free_space_cache()
926 bytes); in copy_free_space_cache()
1103 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1133 trim_entry->bytes, NULL); in write_cache_extent_entries()
1571 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1573 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1661 * we've found already if it's larger, or we want to use ->bytes.
1663 * This matters because find_free_space() will skip entries who's ->bytes is
1664 * less than the required bytes. So if we didn't search down this bitmap, we
1667 * ->max_extent_size set to 4K and ->bytes set to 1M. A second entry hasn't set
1668 * ->max_extent_size yet, has ->bytes set to 8K and it's contiguous. We will
1684 return entry->bytes; in get_max_extent_size()
1704 * want a section that has at least bytes size and comes at or after the given
1761 prev->offset + prev->bytes > offset) in tree_search_offset()
1793 prev->offset + prev->bytes > offset) in tree_search_offset()
1798 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1814 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1833 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in unlink_free_space()
1837 ctl->free_space -= info->bytes; in unlink_free_space()
1847 ASSERT(info->bytes || info->bitmap); in link_free_space()
1856 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1859 ctl->free_space += info->bytes; in link_free_space()
1871 * want to re-link it into our ctl bytes index. in relink_bitmap_entry()
1884 u64 offset, u64 bytes, bool update_stat) in bitmap_clear_bits() argument
1890 count = bytes_to_bits(bytes, ctl->unit); in bitmap_clear_bits()
1896 info->bytes -= bytes; in bitmap_clear_bits()
1911 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in bitmap_clear_bits()
1915 ctl->free_space -= bytes; in bitmap_clear_bits()
1920 u64 bytes) in btrfs_bitmap_set_bits() argument
1926 count = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_set_bits()
1933 * We set some bytes, we have no idea what the max extent size is in btrfs_bitmap_set_bits()
1937 info->bytes += bytes; in btrfs_bitmap_set_bits()
1938 ctl->free_space += bytes; in btrfs_bitmap_set_bits()
1951 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in btrfs_bitmap_set_bits()
1956 * If we can not find suitable extent, we will use bytes to record
1961 u64 *bytes, bool for_alloc) in search_bitmap() argument
1975 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1976 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1982 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
2003 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
2007 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
2008 bitmap_info->max_extent_size = *bytes; in search_bitmap()
2013 /* Cache the size of the max extent in bytes */
2015 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
2046 * If we are using the bytes index then all subsequent entries in find_free_space()
2047 * in this tree are going to be < bytes, so simply set the max in find_free_space()
2053 if (entry->bytes < *bytes) { in find_free_space()
2064 if (*bytes >= align) { in find_free_space()
2075 * We don't break here if we're using the bytes index because we in find_free_space()
2081 if (entry->bytes < *bytes + align_off) { in find_free_space()
2089 u64 size = *bytes; in find_free_space()
2094 *bytes = size; in find_free_space()
2114 *bytes = entry->bytes - align_off; in find_free_space()
2125 info->bytes = 0; in add_new_bitmap()
2142 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
2145 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
2157 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2181 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2188 *bytes -= search_bytes; in remove_from_bitmap()
2190 if (*bytes) { in remove_from_bitmap()
2192 if (!bitmap_info->bytes) in remove_from_bitmap()
2196 * no entry after this bitmap, but we still have bytes to in remove_from_bitmap()
2226 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2234 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2247 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2254 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2275 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2290 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2322 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2326 bytes = info->bytes; in insert_into_bitmap()
2364 bytes, trim_state); in insert_into_bitmap()
2365 bytes -= bytes_added; in insert_into_bitmap()
2369 if (!bytes) { in insert_into_bitmap()
2383 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2385 bytes -= bytes_added; in insert_into_bitmap()
2389 if (!bytes) { in insert_into_bitmap()
2461 u64 bytes = info->bytes; in try_merge_free_space() local
2470 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2483 info->bytes += right_info->bytes; in try_merge_free_space()
2490 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2494 info->bytes += left_info->bytes; in try_merge_free_space()
2509 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2511 u64 bytes; in steal_from_bitmap_to_end() local
2521 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2522 info->bytes += bytes; in steal_from_bitmap_to_end()
2528 bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat); in steal_from_bitmap_to_end()
2530 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2545 u64 bytes; in steal_from_bitmap_to_front() local
2571 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2573 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2575 info->offset -= bytes; in steal_from_bitmap_to_front()
2576 info->bytes += bytes; in steal_from_bitmap_to_front()
2582 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat); in steal_from_bitmap_to_front()
2584 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2627 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2634 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2643 info->bytes = bytes; in __btrfs_add_free_space()
2674 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2804 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2824 offset + bytes) { in btrfs_remove_free_space()
2826 offset + bytes - block_group->start; in btrfs_remove_free_space()
2835 if (!bytes) in btrfs_remove_free_space()
2861 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2863 info->bytes -= to_free; in btrfs_remove_free_space()
2865 if (info->bytes) { in btrfs_remove_free_space()
2873 bytes -= to_free; in btrfs_remove_free_space()
2876 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2878 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2884 /* Not enough bytes in this entry to satisfy us */ in btrfs_remove_free_space()
2885 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2886 bytes -= old_end - offset; in btrfs_remove_free_space()
2889 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2896 offset + bytes, in btrfs_remove_free_space()
2897 old_end - (offset + bytes), in btrfs_remove_free_space()
2904 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2917 u64 bytes) in btrfs_dump_free_space() argument
2940 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2942 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s", in btrfs_dump_free_space()
2943 info->offset, info->bytes, str_yes_no(info->bitmap)); in btrfs_dump_free_space()
2949 "%d free space entries at or bigger than %llu bytes", in btrfs_dump_free_space()
2950 count, bytes); in btrfs_dump_free_space()
3014 entry->bytes; in __btrfs_return_cluster_to_free_space()
3024 entry->bytes; in __btrfs_return_cluster_to_free_space()
3088 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
3095 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
3113 bitmap_clear_bits(ctl, entry, offset, bytes, true); in btrfs_find_space_for_alloc()
3116 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3118 if (!entry->bytes) in btrfs_find_space_for_alloc()
3127 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
3129 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
3130 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
3132 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
3133 if (!entry->bytes) in btrfs_find_space_for_alloc()
3194 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
3200 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3204 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3214 bitmap_clear_bits(ctl, entry, ret, bytes, false); in btrfs_alloc_from_bitmap()
3220 * given a cluster, try to allocate 'bytes' from it, returns 0
3225 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
3238 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3250 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3254 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3266 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3277 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3281 entry->offset += bytes; in btrfs_alloc_from_cluster()
3282 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3296 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3298 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3300 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3303 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3326 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3344 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3413 * Try to find a cluster with at least bytes total bytes, at least one
3419 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3441 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3450 window_free = entry->bytes; in setup_cluster_no_bitmap()
3451 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3465 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3469 window_free += entry->bytes; in setup_cluster_no_bitmap()
3470 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3471 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3474 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3490 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3496 total_size += entry->bytes; in setup_cluster_no_bitmap()
3512 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3537 if (entry->bytes < bytes) in setup_cluster_bitmap()
3540 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3554 * is to find at least bytes+empty_size.
3562 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3579 cont1_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3582 cont1_bytes = bytes; in btrfs_find_space_cluster()
3585 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3595 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3608 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3612 bytes + empty_size, in btrfs_find_space_cluster()
3616 offset, bytes + empty_size, in btrfs_find_space_cluster()
3653 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3663 const u64 end = start + bytes; in do_trimming()
3678 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3692 __btrfs_add_free_space(block_group, start, bytes, trim_state); in do_trimming()
3726 u64 bytes; in trim_no_bitmap() local
3756 extent_bytes = entry->bytes; in trim_no_bitmap()
3760 bytes = entry->bytes; in trim_no_bitmap()
3761 if (bytes < minlen) { in trim_no_bitmap()
3768 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_no_bitmap()
3773 bytes >= (max_discard_size + in trim_no_bitmap()
3775 bytes = max_discard_size; in trim_no_bitmap()
3778 entry->bytes -= max_discard_size; in trim_no_bitmap()
3785 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3786 if (bytes < minlen) { in trim_no_bitmap()
3798 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3802 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3806 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3810 start += bytes; in trim_no_bitmap()
3857 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3872 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3889 u64 bytes; in trim_bitmaps() local
3934 bytes = minlen; in trim_bitmaps()
3935 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3961 bytes = min(bytes, end - start); in trim_bitmaps()
3962 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3969 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_bitmaps()
3976 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3977 bytes = max_discard_size; in trim_bitmaps()
3979 bitmap_clear_bits(ctl, entry, start, bytes, true); in trim_bitmaps()
3980 if (entry->bytes == 0) in trim_bitmaps()
3985 trim_entry.bytes = bytes; in trim_bitmaps()
3989 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3990 start, bytes, 0, &trim_entry); in trim_bitmaps()
4002 start += bytes; in trim_bitmaps()
4193 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4212 info->bytes = bytes; in test_add_free_space_entry()
4240 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4243 bytes -= bytes_added; in test_add_free_space_entry()
4247 if (bytes) in test_add_free_space_entry()
4263 u64 offset, u64 bytes) in test_check_exists() argument
4292 offset + bytes > bit_off) { in test_check_exists()
4302 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4304 if (offset + bytes < tmp->offset) { in test_check_exists()
4316 if (offset + bytes < tmp->offset) in test_check_exists()
4318 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4335 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()