Lines Matching refs:bytes
30 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 entry->bytes = cpu_to_le64(bytes); in io_ctl_add_entry()
600 entry->bytes = le64_to_cpu(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()
756 if (!e->bytes) { in __load_free_space_cache()
953 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
983 trim_entry->bytes, NULL); in write_cache_extent_entries()
1429 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1431 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1562 prev->offset + prev->bytes > offset) in tree_search_offset()
1594 prev->offset + prev->bytes > offset) in tree_search_offset()
1599 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1611 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1635 ctl->free_space -= info->bytes; in unlink_free_space()
1643 ASSERT(info->bytes || info->bitmap); in link_free_space()
1649 ctl->free_space += info->bytes; in link_free_space()
1703 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1708 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1713 info->bytes -= bytes; in __bitmap_clear_bits()
1720 u64 bytes) in bitmap_clear_bits() argument
1722 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1723 ctl->free_space -= bytes; in bitmap_clear_bits()
1728 u64 bytes) in bitmap_set_bits() argument
1733 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1738 info->bytes += bytes; in bitmap_set_bits()
1739 ctl->free_space += bytes; in bitmap_set_bits()
1748 u64 *bytes, bool for_alloc) in search_bitmap() argument
1762 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1763 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1769 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1790 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1794 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1795 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1803 return entry->bytes; in get_max_extent_size()
1808 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1826 if (entry->bytes < *bytes) { in find_free_space()
1835 if (*bytes >= align) { in find_free_space()
1845 if (entry->bytes < *bytes + align_off) { in find_free_space()
1852 u64 size = *bytes; in find_free_space()
1857 *bytes = size; in find_free_space()
1868 *bytes = entry->bytes - align_off; in find_free_space()
1879 info->bytes = 0; in add_new_bitmap()
1899 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
1923 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
1930 *bytes -= search_bytes; in remove_from_bitmap()
1932 if (*bytes) { in remove_from_bitmap()
1934 if (!bitmap_info->bytes) in remove_from_bitmap()
1968 } else if (!bitmap_info->bytes) in remove_from_bitmap()
1976 u64 bytes) in add_bytes_to_bitmap() argument
1983 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2021 if (info->bytes <= fs_info->sectorsize * 4) { in use_bitmap()
2054 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2057 bytes = info->bytes; in insert_into_bitmap()
2094 offset, bytes); in insert_into_bitmap()
2095 bytes -= bytes_added; in insert_into_bitmap()
2099 if (!bytes) { in insert_into_bitmap()
2113 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in insert_into_bitmap()
2114 bytes -= bytes_added; in insert_into_bitmap()
2118 if (!bytes) { in insert_into_bitmap()
2173 u64 bytes = info->bytes; in try_merge_free_space() local
2180 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2192 info->bytes += right_info->bytes; in try_merge_free_space()
2198 left_info->offset + left_info->bytes == offset) { in try_merge_free_space()
2204 info->bytes += left_info->bytes; in try_merge_free_space()
2219 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2221 u64 bytes; in steal_from_bitmap_to_end() local
2231 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2232 info->bytes += bytes; in steal_from_bitmap_to_end()
2235 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2237 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2239 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2254 u64 bytes; in steal_from_bitmap_to_front() local
2280 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2282 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2284 info->offset -= bytes; in steal_from_bitmap_to_front()
2285 info->bytes += bytes; in steal_from_bitmap_to_front()
2288 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2290 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2292 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2336 u64 offset, u64 bytes) in __btrfs_add_free_space() argument
2346 info->bytes = bytes; in __btrfs_add_free_space()
2398 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2409 if (!bytes) in btrfs_remove_free_space()
2435 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2437 info->bytes -= to_free; in btrfs_remove_free_space()
2439 if (info->bytes) { in btrfs_remove_free_space()
2447 bytes -= to_free; in btrfs_remove_free_space()
2450 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2452 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2459 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2460 bytes -= old_end - offset; in btrfs_remove_free_space()
2463 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2469 ret = btrfs_add_free_space(block_group, offset + bytes, in btrfs_remove_free_space()
2470 old_end - (offset + bytes)); in btrfs_remove_free_space()
2476 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2488 u64 bytes) in btrfs_dump_free_space() argument
2499 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2502 info->offset, info->bytes, in btrfs_dump_free_space()
2630 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2635 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2648 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2649 if (!entry->bytes) in btrfs_find_space_for_alloc()
2656 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2657 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2659 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2660 if (!entry->bytes) in btrfs_find_space_for_alloc()
2720 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
2726 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2730 search_bytes = bytes; in btrfs_alloc_from_bitmap()
2740 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2751 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
2760 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
2772 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
2776 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
2788 cluster, entry, bytes, in btrfs_alloc_from_cluster()
2799 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
2803 entry->offset += bytes; in btrfs_alloc_from_cluster()
2804 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
2807 if (entry->bytes == 0) in btrfs_alloc_from_cluster()
2819 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
2820 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
2839 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
2855 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
2920 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
2940 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
2949 window_free = entry->bytes; in setup_cluster_no_bitmap()
2950 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2964 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2968 window_free += entry->bytes; in setup_cluster_no_bitmap()
2969 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
2970 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2973 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
2989 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2995 total_size += entry->bytes; in setup_cluster_no_bitmap()
3011 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3036 if (entry->bytes < bytes) in setup_cluster_bitmap()
3039 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3061 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3078 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3080 cont1_bytes = bytes; in btrfs_find_space_cluster()
3083 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3093 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3106 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3110 bytes + empty_size, in btrfs_find_space_cluster()
3114 offset, bytes + empty_size, in btrfs_find_space_cluster()
3151 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3172 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3204 u64 bytes; in trim_no_bitmap() local
3244 extent_bytes = entry->bytes; in trim_no_bitmap()
3246 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3247 if (bytes < minlen) { in trim_no_bitmap()
3258 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3262 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3267 start += bytes; in trim_no_bitmap()
3287 u64 bytes; in trim_bitmaps() local
3311 bytes = minlen; in trim_bitmaps()
3312 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3320 bytes = min(bytes, end - start); in trim_bitmaps()
3321 if (bytes < minlen) { in trim_bitmaps()
3327 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3328 if (entry->bytes == 0) in trim_bitmaps()
3333 trim_entry.bytes = bytes; in trim_bitmaps()
3337 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3338 start, bytes, &trim_entry); in trim_bitmaps()
3345 start += bytes; in trim_bitmaps()
3452 entry->bytes--; in btrfs_find_ino_for_alloc()
3453 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3468 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
3600 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
3618 info->bytes = bytes; in test_add_free_space_entry()
3646 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in test_add_free_space_entry()
3648 bytes -= bytes_added; in test_add_free_space_entry()
3652 if (bytes) in test_add_free_space_entry()
3668 u64 offset, u64 bytes) in test_check_exists() argument
3697 offset + bytes > bit_off) { in test_check_exists()
3707 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
3709 if (offset + bytes < tmp->offset) { in test_check_exists()
3721 if (offset + bytes < tmp->offset) in test_check_exists()
3723 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
3740 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()