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()
768 if (!e->bytes) { in __load_free_space_cache()
828 ctl->discardable_bytes[BTRFS_STAT_CURR] += e->bytes; in __load_free_space_cache()
975 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1005 trim_entry->bytes, NULL); in write_cache_extent_entries()
1445 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1447 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1520 * want a section that has at least bytes size and comes at or after the given
1578 prev->offset + prev->bytes > offset) in tree_search_offset()
1610 prev->offset + prev->bytes > offset) in tree_search_offset()
1615 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1627 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1648 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in __unlink_free_space()
1656 ctl->free_space -= info->bytes; in unlink_free_space()
1664 ASSERT(info->bytes || info->bitmap); in link_free_space()
1672 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1675 ctl->free_space += info->bytes; in link_free_space()
1709 * bytes we can have, or whatever is less than that. in recalculate_thresholds()
1720 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1726 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1732 info->bytes -= bytes; in __bitmap_clear_bits()
1745 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in __bitmap_clear_bits()
1751 u64 bytes) in bitmap_clear_bits() argument
1753 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1754 ctl->free_space -= bytes; in bitmap_clear_bits()
1759 u64 bytes) in bitmap_set_bits() argument
1765 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1771 info->bytes += bytes; in bitmap_set_bits()
1772 ctl->free_space += bytes; in bitmap_set_bits()
1783 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1788 * If we can not find suitable extent, we will use bytes to record
1793 u64 *bytes, bool for_alloc) in search_bitmap() argument
1807 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1808 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1814 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1835 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1839 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1840 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1848 return entry->bytes; in get_max_extent_size()
1851 /* Cache the size of the max extent in bytes */
1853 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1871 if (entry->bytes < *bytes) { in find_free_space()
1880 if (*bytes >= align) { in find_free_space()
1890 if (entry->bytes < *bytes + align_off) { in find_free_space()
1897 u64 size = *bytes; in find_free_space()
1902 *bytes = size; in find_free_space()
1913 *bytes = entry->bytes - align_off; in find_free_space()
1924 u64 bytes = bitmap_info->bytes; in count_bitmap_extents() local
1928 if (!block_group || !bytes) in count_bitmap_extents()
1933 bytes -= (rs - re) * ctl->unit; in count_bitmap_extents()
1936 if (!bytes) in count_bitmap_extents()
1947 info->bytes = 0; in add_new_bitmap()
1965 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
1968 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
1980 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2004 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2011 *bytes -= search_bytes; in remove_from_bitmap()
2013 if (*bytes) { in remove_from_bitmap()
2015 if (!bitmap_info->bytes) in remove_from_bitmap()
2019 * no entry after this bitmap, but we still have bytes to in remove_from_bitmap()
2049 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2057 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2070 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2077 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2082 * We set some bytes, we have no idea what the max extent size is in add_bytes_to_bitmap()
2104 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2119 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2152 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2156 bytes = info->bytes; in insert_into_bitmap()
2194 bytes, trim_state); in insert_into_bitmap()
2195 bytes -= bytes_added; in insert_into_bitmap()
2199 if (!bytes) { in insert_into_bitmap()
2213 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2215 bytes -= bytes_added; in insert_into_bitmap()
2219 if (!bytes) { in insert_into_bitmap()
2291 u64 bytes = info->bytes; in try_merge_free_space() local
2299 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2313 info->bytes += right_info->bytes; in try_merge_free_space()
2320 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2327 info->bytes += left_info->bytes; in try_merge_free_space()
2342 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2344 u64 bytes; in steal_from_bitmap_to_end() local
2354 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2355 info->bytes += bytes; in steal_from_bitmap_to_end()
2362 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2364 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2366 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2381 u64 bytes; in steal_from_bitmap_to_front() local
2407 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2409 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2411 info->offset -= bytes; in steal_from_bitmap_to_front()
2412 info->bytes += bytes; in steal_from_bitmap_to_front()
2419 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2421 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2423 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2467 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2473 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2480 info->bytes = bytes; in __btrfs_add_free_space()
2510 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2565 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2576 if (!bytes) in btrfs_remove_free_space()
2602 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2604 info->bytes -= to_free; in btrfs_remove_free_space()
2606 if (info->bytes) { in btrfs_remove_free_space()
2614 bytes -= to_free; in btrfs_remove_free_space()
2617 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2619 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2625 /* Not enough bytes in this entry to satisfy us */ in btrfs_remove_free_space()
2626 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2627 bytes -= old_end - offset; in btrfs_remove_free_space()
2630 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2637 offset + bytes, in btrfs_remove_free_space()
2638 old_end - (offset + bytes), in btrfs_remove_free_space()
2645 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2658 u64 bytes) in btrfs_dump_free_space() argument
2669 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2671 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s", in btrfs_dump_free_space()
2672 info->offset, info->bytes, in btrfs_dump_free_space()
2679 "%d blocks of free space at or bigger than bytes is", count); in btrfs_dump_free_space()
2742 entry->bytes; in __btrfs_return_cluster_to_free_space()
2752 entry->bytes; in __btrfs_return_cluster_to_free_space()
2846 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2853 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2867 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2870 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2872 if (!entry->bytes) in btrfs_find_space_for_alloc()
2881 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2883 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2884 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2886 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2887 if (!entry->bytes) in btrfs_find_space_for_alloc()
2949 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
2955 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2959 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2969 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2975 * given a cluster, try to allocate 'bytes' from it, returns 0
2980 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
2991 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3003 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3007 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3019 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3030 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3034 entry->offset += bytes; in btrfs_alloc_from_cluster()
3035 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3049 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3051 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3053 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3056 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3079 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3095 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3154 * Try to find a cluster with at least bytes total bytes, at least one
3160 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3180 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3189 window_free = entry->bytes; in setup_cluster_no_bitmap()
3190 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3204 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3208 window_free += entry->bytes; in setup_cluster_no_bitmap()
3209 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3210 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3213 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3229 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3235 total_size += entry->bytes; in setup_cluster_no_bitmap()
3251 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3276 if (entry->bytes < bytes) in setup_cluster_bitmap()
3279 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3293 * is to find at least bytes+empty_size.
3301 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3318 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3320 cont1_bytes = bytes; in btrfs_find_space_cluster()
3323 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3333 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3346 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3350 bytes + empty_size, in btrfs_find_space_cluster()
3354 offset, bytes + empty_size, in btrfs_find_space_cluster()
3391 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3401 const u64 end = start + bytes; in do_trimming()
3416 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3427 if (start + bytes < reserved_start + reserved_bytes) in do_trimming()
3430 __btrfs_add_free_space(fs_info, ctl, start, bytes, trim_state); in do_trimming()
3464 u64 bytes; in trim_no_bitmap() local
3494 extent_bytes = entry->bytes; in trim_no_bitmap()
3498 bytes = entry->bytes; in trim_no_bitmap()
3499 if (bytes < minlen) { in trim_no_bitmap()
3506 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_no_bitmap()
3511 bytes >= (max_discard_size + in trim_no_bitmap()
3513 bytes = max_discard_size; in trim_no_bitmap()
3516 entry->bytes -= max_discard_size; in trim_no_bitmap()
3523 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3524 if (bytes < minlen) { in trim_no_bitmap()
3536 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3540 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3544 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3548 start += bytes; in trim_no_bitmap()
3595 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3610 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3627 u64 bytes; in trim_bitmaps() local
3672 bytes = minlen; in trim_bitmaps()
3673 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3699 bytes = min(bytes, end - start); in trim_bitmaps()
3700 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3707 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X. in trim_bitmaps()
3714 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3715 bytes = max_discard_size; in trim_bitmaps()
3717 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3718 if (entry->bytes == 0) in trim_bitmaps()
3723 trim_entry.bytes = bytes; in trim_bitmaps()
3727 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3728 start, bytes, 0, &trim_entry); in trim_bitmaps()
3740 start += bytes; in trim_bitmaps()
3864 entry->bytes--; in btrfs_find_ino_for_alloc()
3865 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3880 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
4010 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4029 info->bytes = bytes; in test_add_free_space_entry()
4057 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4060 bytes -= bytes_added; in test_add_free_space_entry()
4064 if (bytes) in test_add_free_space_entry()
4080 u64 offset, u64 bytes) in test_check_exists() argument
4109 offset + bytes > bit_off) { in test_check_exists()
4119 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4121 if (offset + bytes < tmp->offset) { in test_check_exists()
4133 if (offset + bytes < tmp->offset) in test_check_exists()
4135 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4152 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()