Lines Matching full: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()
766 if (!e->bytes) { in __load_free_space_cache()
823 ctl->discardable_bytes[BTRFS_STAT_CURR] += e->bytes; in __load_free_space_cache()
970 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1000 trim_entry->bytes, NULL); in write_cache_extent_entries()
1440 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1442 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1515 * want a section that has at least bytes size and comes at or after the given
1573 prev->offset + prev->bytes > offset) in tree_search_offset()
1605 prev->offset + prev->bytes > offset) in tree_search_offset()
1610 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1622 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1643 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in __unlink_free_space()
1651 ctl->free_space -= info->bytes; in unlink_free_space()
1659 ASSERT(info->bytes || info->bitmap); in link_free_space()
1667 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1670 ctl->free_space += info->bytes; in link_free_space()
1704 * bytes we can have, or whatever is less than that. in recalculate_thresholds()
1715 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1721 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1727 info->bytes -= bytes; in __bitmap_clear_bits()
1740 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in __bitmap_clear_bits()
1746 u64 bytes) in bitmap_clear_bits() argument
1748 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1749 ctl->free_space -= bytes; in bitmap_clear_bits()
1754 u64 bytes) in bitmap_set_bits() argument
1760 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1766 info->bytes += bytes; in bitmap_set_bits()
1767 ctl->free_space += bytes; in bitmap_set_bits()
1778 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1783 * If we can not find suitable extent, we will use bytes to record
1788 u64 *bytes, bool for_alloc) in search_bitmap() argument
1802 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1803 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1809 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1830 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1834 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1835 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1843 return entry->bytes; in get_max_extent_size()
1846 /* Cache the size of the max extent in bytes */
1848 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1866 if (entry->bytes < *bytes) { in find_free_space()
1875 if (*bytes >= align) { in find_free_space()
1885 if (entry->bytes < *bytes + align_off) { in find_free_space()
1892 u64 size = *bytes; in find_free_space()
1897 *bytes = size; in find_free_space()
1908 *bytes = entry->bytes - align_off; in find_free_space()
1919 u64 bytes = bitmap_info->bytes; in count_bitmap_extents() local
1923 if (!block_group || !bytes) in count_bitmap_extents()
1928 bytes -= (rs - re) * ctl->unit; in count_bitmap_extents()
1931 if (!bytes) in count_bitmap_extents()
1942 info->bytes = 0; in add_new_bitmap()
1960 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
1963 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
1975 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
1999 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2006 *bytes -= search_bytes; in remove_from_bitmap()
2008 if (*bytes) { in remove_from_bitmap()
2010 if (!bitmap_info->bytes) in remove_from_bitmap()
2014 * no entry after this bitmap, but we still have bytes to in remove_from_bitmap()
2044 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2052 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2065 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2072 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2077 * We set some bytes, we have no idea what the max extent size is in add_bytes_to_bitmap()
2099 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2114 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2147 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2151 bytes = info->bytes; in insert_into_bitmap()
2189 bytes, trim_state); in insert_into_bitmap()
2190 bytes -= bytes_added; in insert_into_bitmap()
2194 if (!bytes) { in insert_into_bitmap()
2208 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2210 bytes -= bytes_added; in insert_into_bitmap()
2214 if (!bytes) { in insert_into_bitmap()
2286 u64 bytes = info->bytes; in try_merge_free_space() local
2294 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2308 info->bytes += right_info->bytes; in try_merge_free_space()
2315 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2322 info->bytes += left_info->bytes; in try_merge_free_space()
2337 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2339 u64 bytes; in steal_from_bitmap_to_end() local
2349 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2350 info->bytes += bytes; in steal_from_bitmap_to_end()
2357 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2359 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2361 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2376 u64 bytes; in steal_from_bitmap_to_front() local
2402 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2404 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2406 info->offset -= bytes; in steal_from_bitmap_to_front()
2407 info->bytes += bytes; in steal_from_bitmap_to_front()
2414 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2416 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2418 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2462 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2468 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2475 info->bytes = bytes; in __btrfs_add_free_space()
2505 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2560 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2571 if (!bytes) in btrfs_remove_free_space()
2597 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2599 info->bytes -= to_free; in btrfs_remove_free_space()
2601 if (info->bytes) { in btrfs_remove_free_space()
2609 bytes -= to_free; in btrfs_remove_free_space()
2612 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2614 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2620 /* Not enough bytes in this entry to satisfy us */ in btrfs_remove_free_space()
2621 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2622 bytes -= old_end - offset; in btrfs_remove_free_space()
2625 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2632 offset + bytes, in btrfs_remove_free_space()
2633 old_end - (offset + bytes), in btrfs_remove_free_space()
2640 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2653 u64 bytes) in btrfs_dump_free_space() argument
2664 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2666 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s", in btrfs_dump_free_space()
2667 info->offset, info->bytes, in btrfs_dump_free_space()
2674 "%d blocks of free space at or bigger than bytes is", count); in btrfs_dump_free_space()
2735 entry->bytes; in __btrfs_return_cluster_to_free_space()
2745 entry->bytes; in __btrfs_return_cluster_to_free_space()
2841 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2848 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2862 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2865 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2867 if (!entry->bytes) in btrfs_find_space_for_alloc()
2876 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2878 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2879 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2881 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2882 if (!entry->bytes) in btrfs_find_space_for_alloc()
2944 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
2950 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2954 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2964 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2970 * given a cluster, try to allocate 'bytes' from it, returns 0
2975 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
2986 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
2998 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3002 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3014 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3025 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3029 entry->offset += bytes; in btrfs_alloc_from_cluster()
3030 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3033 if (entry->bytes == 0) in btrfs_alloc_from_cluster()
3046 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3048 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3050 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3051 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3072 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3088 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3147 * Try to find a cluster with at least bytes total bytes, at least one
3153 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3173 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3182 window_free = entry->bytes; in setup_cluster_no_bitmap()
3183 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3197 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3201 window_free += entry->bytes; in setup_cluster_no_bitmap()
3202 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3203 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3206 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3222 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3228 total_size += entry->bytes; in setup_cluster_no_bitmap()
3244 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3269 if (entry->bytes < bytes) in setup_cluster_bitmap()
3272 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3286 * is to find at least bytes+empty_size.
3294 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3311 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3313 cont1_bytes = bytes; in btrfs_find_space_cluster()
3316 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3326 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3339 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3343 bytes + empty_size, in btrfs_find_space_cluster()
3347 offset, bytes + empty_size, in btrfs_find_space_cluster()
3384 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3394 const u64 end = start + bytes; in do_trimming()
3409 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3420 if (start + bytes < reserved_start + reserved_bytes) in do_trimming()
3423 __btrfs_add_free_space(fs_info, ctl, start, bytes, trim_state); in do_trimming()
3457 u64 bytes; in trim_no_bitmap() local
3487 extent_bytes = entry->bytes; in trim_no_bitmap()
3491 bytes = entry->bytes; in trim_no_bitmap()
3492 if (bytes < minlen) { in trim_no_bitmap()
3499 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_no_bitmap()
3504 bytes >= (max_discard_size + in trim_no_bitmap()
3506 bytes = max_discard_size; in trim_no_bitmap()
3509 entry->bytes -= max_discard_size; in trim_no_bitmap()
3516 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3517 if (bytes < minlen) { in trim_no_bitmap()
3529 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3533 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3537 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3541 start += bytes; in trim_no_bitmap()
3588 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3603 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3620 u64 bytes; in trim_bitmaps() local
3665 bytes = minlen; in trim_bitmaps()
3666 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3692 bytes = min(bytes, end - start); in trim_bitmaps()
3693 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3700 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_bitmaps()
3707 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3708 bytes = max_discard_size; in trim_bitmaps()
3710 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3711 if (entry->bytes == 0) in trim_bitmaps()
3716 trim_entry.bytes = bytes; in trim_bitmaps()
3720 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3721 start, bytes, 0, &trim_entry); in trim_bitmaps()
3733 start += bytes; in trim_bitmaps()
3857 entry->bytes--; in btrfs_find_ino_for_alloc()
3858 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3873 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
4003 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4022 info->bytes = bytes; in test_add_free_space_entry()
4050 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4053 bytes -= bytes_added; in test_add_free_space_entry()
4057 if (bytes) in test_add_free_space_entry()
4073 u64 offset, u64 bytes) in test_check_exists() argument
4102 offset + bytes > bit_off) { in test_check_exists()
4112 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4114 if (offset + bytes < tmp->offset) { in test_check_exists()
4126 if (offset + bytes < tmp->offset) in test_check_exists()
4128 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4145 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()