Lines Matching full:bytes
27 u64 bytes; member
515 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
525 entry->bytes = cpu_to_le64(bytes); in io_ctl_add_entry()
599 entry->bytes = le64_to_cpu(e->bytes); in io_ctl_read_entry()
649 if (prev->offset + prev->bytes == e->offset) { in merge_space_tree()
652 prev->bytes += e->bytes; in merge_space_tree()
755 if (!e->bytes) { in __load_free_space_cache()
952 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
982 trim_entry->bytes, NULL); in write_cache_extent_entries()
1432 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1434 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1507 * want a section that has at least bytes size and comes at or after the given
1565 prev->offset + prev->bytes > offset) in tree_search_offset()
1597 prev->offset + prev->bytes > offset) in tree_search_offset()
1602 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1614 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1638 ctl->free_space -= info->bytes; in unlink_free_space()
1646 ASSERT(info->bytes || info->bitmap); in link_free_space()
1652 ctl->free_space += info->bytes; in link_free_space()
1695 * bytes we can have, or whatever is less than that. in recalculate_thresholds()
1706 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1711 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1716 info->bytes -= bytes; in __bitmap_clear_bits()
1723 u64 bytes) in bitmap_clear_bits() argument
1725 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1726 ctl->free_space -= bytes; in bitmap_clear_bits()
1731 u64 bytes) in bitmap_set_bits() argument
1736 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1741 info->bytes += bytes; in bitmap_set_bits()
1742 ctl->free_space += bytes; in bitmap_set_bits()
1746 * If we can not find suitable extent, we will use bytes to record
1751 u64 *bytes, bool for_alloc) in search_bitmap() argument
1765 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1766 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1772 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1793 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1797 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1798 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1806 return entry->bytes; in get_max_extent_size()
1809 /* Cache the size of the max extent in bytes */
1811 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1829 if (entry->bytes < *bytes) { in find_free_space()
1838 if (*bytes >= align) { in find_free_space()
1848 if (entry->bytes < *bytes + align_off) { in find_free_space()
1855 u64 size = *bytes; in find_free_space()
1860 *bytes = size; in find_free_space()
1871 *bytes = entry->bytes - align_off; in find_free_space()
1882 info->bytes = 0; in add_new_bitmap()
1902 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
1926 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
1933 *bytes -= search_bytes; in remove_from_bitmap()
1935 if (*bytes) { in remove_from_bitmap()
1937 if (!bitmap_info->bytes) in remove_from_bitmap()
1941 * no entry after this bitmap, but we still have bytes to in remove_from_bitmap()
1971 } else if (!bitmap_info->bytes) in remove_from_bitmap()
1979 u64 bytes) in add_bytes_to_bitmap() argument
1986 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
1991 * We set some bytes, we have no idea what the max extent size is in add_bytes_to_bitmap()
2024 if (info->bytes <= fs_info->sectorsize * 4) { in use_bitmap()
2057 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2060 bytes = info->bytes; in insert_into_bitmap()
2097 offset, bytes); in insert_into_bitmap()
2098 bytes -= bytes_added; in insert_into_bitmap()
2102 if (!bytes) { in insert_into_bitmap()
2116 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in insert_into_bitmap()
2117 bytes -= bytes_added; in insert_into_bitmap()
2121 if (!bytes) { in insert_into_bitmap()
2176 u64 bytes = info->bytes; in try_merge_free_space() local
2183 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2195 info->bytes += right_info->bytes; in try_merge_free_space()
2201 left_info->offset + left_info->bytes == offset) { in try_merge_free_space()
2207 info->bytes += left_info->bytes; in try_merge_free_space()
2222 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2224 u64 bytes; in steal_from_bitmap_to_end() local
2234 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2235 info->bytes += bytes; in steal_from_bitmap_to_end()
2238 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2240 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2242 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2257 u64 bytes; in steal_from_bitmap_to_front() local
2283 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2285 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2287 info->offset -= bytes; in steal_from_bitmap_to_front()
2288 info->bytes += bytes; in steal_from_bitmap_to_front()
2291 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2293 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2295 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2339 u64 offset, u64 bytes) in __btrfs_add_free_space() argument
2349 info->bytes = bytes; in __btrfs_add_free_space()
2393 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2404 if (!bytes) in btrfs_remove_free_space()
2430 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2432 info->bytes -= to_free; in btrfs_remove_free_space()
2434 if (info->bytes) { in btrfs_remove_free_space()
2442 bytes -= to_free; in btrfs_remove_free_space()
2445 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2447 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2453 /* Not enough bytes in this entry to satisfy us */ in btrfs_remove_free_space()
2454 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2455 bytes -= old_end - offset; in btrfs_remove_free_space()
2458 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2464 ret = btrfs_add_free_space(block_group, offset + bytes, in btrfs_remove_free_space()
2465 old_end - (offset + bytes)); in btrfs_remove_free_space()
2471 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2483 u64 bytes) in btrfs_dump_free_space() argument
2494 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2496 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s", in btrfs_dump_free_space()
2497 info->offset, info->bytes, in btrfs_dump_free_space()
2504 "%d blocks of free space at or bigger than bytes is", count); in btrfs_dump_free_space()
2625 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2630 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2643 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2644 if (!entry->bytes) in btrfs_find_space_for_alloc()
2651 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2652 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2654 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2655 if (!entry->bytes) in btrfs_find_space_for_alloc()
2715 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
2721 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2725 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2735 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2741 * given a cluster, try to allocate 'bytes' from it, returns 0
2746 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
2755 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
2767 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
2771 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
2783 cluster, entry, bytes, in btrfs_alloc_from_cluster()
2794 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
2798 entry->offset += bytes; in btrfs_alloc_from_cluster()
2799 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
2802 if (entry->bytes == 0) in btrfs_alloc_from_cluster()
2814 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
2815 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
2834 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
2850 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
2909 * Try to find a cluster with at least bytes total bytes, at least one
2915 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
2935 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
2944 window_free = entry->bytes; in setup_cluster_no_bitmap()
2945 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2959 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2963 window_free += entry->bytes; in setup_cluster_no_bitmap()
2964 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
2965 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2968 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
2984 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2990 total_size += entry->bytes; in setup_cluster_no_bitmap()
3006 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3031 if (entry->bytes < bytes) in setup_cluster_bitmap()
3034 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3048 * is to find at least bytes+empty_size.
3057 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3073 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3075 cont1_bytes = bytes; in btrfs_find_space_cluster()
3078 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3088 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3101 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3105 bytes + empty_size, in btrfs_find_space_cluster()
3109 offset, bytes + empty_size, in btrfs_find_space_cluster()
3146 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3167 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3199 u64 bytes; in trim_no_bitmap() local
3239 extent_bytes = entry->bytes; in trim_no_bitmap()
3241 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3242 if (bytes < minlen) { in trim_no_bitmap()
3253 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3257 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3262 start += bytes; in trim_no_bitmap()
3282 u64 bytes; in trim_bitmaps() local
3306 bytes = minlen; in trim_bitmaps()
3307 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3315 bytes = min(bytes, end - start); in trim_bitmaps()
3316 if (bytes < minlen) { in trim_bitmaps()
3322 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3323 if (entry->bytes == 0) in trim_bitmaps()
3328 trim_entry.bytes = bytes; in trim_bitmaps()
3332 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3333 start, bytes, &trim_entry); in trim_bitmaps()
3340 start += bytes; in trim_bitmaps()
3451 entry->bytes--; in btrfs_find_ino_for_alloc()
3452 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3467 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
3599 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
3617 info->bytes = bytes; in test_add_free_space_entry()
3645 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in test_add_free_space_entry()
3647 bytes -= bytes_added; in test_add_free_space_entry()
3651 if (bytes) in test_add_free_space_entry()
3667 u64 offset, u64 bytes) in test_check_exists() argument
3696 offset + bytes > bit_off) { in test_check_exists()
3706 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
3708 if (offset + bytes < tmp->offset) { in test_check_exists()
3720 if (offset + bytes < tmp->offset) in test_check_exists()
3722 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
3739 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()