Lines Matching refs:bytes

33 	u64 bytes;  member
43 u64 *bytes, bool for_alloc);
48 u64 bytes);
555 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes, in io_ctl_add_entry() argument
565 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
639 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
797 if (!e->bytes) { in __load_free_space_cache()
877 info->bytes); in copy_free_space_cache()
881 u64 bytes = ctl->unit; in copy_free_space_cache() local
883 while (search_bitmap(ctl, info, &offset, &bytes, in copy_free_space_cache()
886 bytes); in copy_free_space_cache()
889 bitmap_clear_bits(ctl, info, offset, bytes); in copy_free_space_cache()
891 bytes = ctl->unit; in copy_free_space_cache()
1047 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes, in write_cache_extent_entries()
1077 trim_entry->bytes, NULL); in write_cache_extent_entries()
1512 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit) in bytes_to_bits() argument
1514 return (unsigned long)(div_u64(bytes, unit)); in bytes_to_bits()
1645 prev->offset + prev->bytes > offset) in tree_search_offset()
1677 prev->offset + prev->bytes > offset) in tree_search_offset()
1682 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1694 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1715 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes; in __unlink_free_space()
1723 ctl->free_space -= info->bytes; in unlink_free_space()
1731 ASSERT(info->bytes || info->bitmap); in link_free_space()
1739 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in link_free_space()
1742 ctl->free_space += info->bytes; in link_free_space()
1749 u64 offset, u64 bytes) in __bitmap_clear_bits() argument
1755 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1761 info->bytes -= bytes; in __bitmap_clear_bits()
1774 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in __bitmap_clear_bits()
1780 u64 bytes) in bitmap_clear_bits() argument
1782 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1783 ctl->free_space -= bytes; in bitmap_clear_bits()
1788 u64 bytes) in bitmap_set_bits() argument
1794 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1800 info->bytes += bytes; in bitmap_set_bits()
1801 ctl->free_space += bytes; in bitmap_set_bits()
1812 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes; in bitmap_set_bits()
1822 u64 *bytes, bool for_alloc) in search_bitmap() argument
1836 bitmap_info->max_extent_size < *bytes) { in search_bitmap()
1837 *bytes = bitmap_info->max_extent_size; in search_bitmap()
1843 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1864 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1868 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1869 bitmap_info->max_extent_size = *bytes; in search_bitmap()
1877 return entry->bytes; in get_max_extent_size()
1882 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1900 if (entry->bytes < *bytes) { in find_free_space()
1909 if (*bytes >= align) { in find_free_space()
1919 if (entry->bytes < *bytes + align_off) { in find_free_space()
1926 u64 size = *bytes; in find_free_space()
1931 *bytes = size; in find_free_space()
1942 *bytes = entry->bytes - align_off; in find_free_space()
1953 info->bytes = 0; in add_new_bitmap()
1970 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) { in free_bitmap()
1973 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes; in free_bitmap()
1985 u64 *offset, u64 *bytes) in remove_from_bitmap() argument
2009 search_bytes = min(search_bytes, *bytes); in remove_from_bitmap()
2016 *bytes -= search_bytes; in remove_from_bitmap()
2018 if (*bytes) { in remove_from_bitmap()
2020 if (!bitmap_info->bytes) in remove_from_bitmap()
2054 } else if (!bitmap_info->bytes) in remove_from_bitmap()
2062 u64 bytes, enum btrfs_trim_state trim_state) in add_bytes_to_bitmap() argument
2075 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes; in add_bytes_to_bitmap()
2082 bytes_to_set = min(end - offset, bytes); in add_bytes_to_bitmap()
2109 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD) in use_bitmap()
2124 if (info->bytes <= fs_info->sectorsize * 8) { in use_bitmap()
2156 u64 bytes, offset, bytes_added; in insert_into_bitmap() local
2160 bytes = info->bytes; in insert_into_bitmap()
2198 bytes, trim_state); in insert_into_bitmap()
2199 bytes -= bytes_added; in insert_into_bitmap()
2203 if (!bytes) { in insert_into_bitmap()
2217 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in insert_into_bitmap()
2219 bytes -= bytes_added; in insert_into_bitmap()
2223 if (!bytes) { in insert_into_bitmap()
2295 u64 bytes = info->bytes; in try_merge_free_space() local
2303 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2317 info->bytes += right_info->bytes; in try_merge_free_space()
2324 left_info->offset + left_info->bytes == offset && in try_merge_free_space()
2331 info->bytes += left_info->bytes; in try_merge_free_space()
2346 const u64 end = info->offset + info->bytes; in steal_from_bitmap_to_end()
2348 u64 bytes; in steal_from_bitmap_to_end() local
2358 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2359 info->bytes += bytes; in steal_from_bitmap_to_end()
2366 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2368 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2370 if (!bitmap->bytes) in steal_from_bitmap_to_end()
2385 u64 bytes; in steal_from_bitmap_to_front() local
2411 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2413 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2415 info->offset -= bytes; in steal_from_bitmap_to_front()
2416 info->bytes += bytes; in steal_from_bitmap_to_front()
2423 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2425 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2427 if (!bitmap->bytes) in steal_from_bitmap_to_front()
2471 u64 offset, u64 bytes, in __btrfs_add_free_space() argument
2477 u64 filter_bytes = bytes; in __btrfs_add_free_space()
2486 info->bytes = bytes; in __btrfs_add_free_space()
2516 filter_bytes = max(filter_bytes, info->bytes); in __btrfs_add_free_space()
2644 u64 offset, u64 bytes) in btrfs_remove_free_space() argument
2664 offset + bytes) { in btrfs_remove_free_space()
2666 offset + bytes - block_group->start; in btrfs_remove_free_space()
2675 if (!bytes) in btrfs_remove_free_space()
2701 u64 to_free = min(bytes, info->bytes); in btrfs_remove_free_space()
2703 info->bytes -= to_free; in btrfs_remove_free_space()
2705 if (info->bytes) { in btrfs_remove_free_space()
2713 bytes -= to_free; in btrfs_remove_free_space()
2716 u64 old_end = info->bytes + info->offset; in btrfs_remove_free_space()
2718 info->bytes = offset - info->offset; in btrfs_remove_free_space()
2725 if (old_end < offset + bytes) { in btrfs_remove_free_space()
2726 bytes -= old_end - offset; in btrfs_remove_free_space()
2729 } else if (old_end == offset + bytes) { in btrfs_remove_free_space()
2736 offset + bytes, in btrfs_remove_free_space()
2737 old_end - (offset + bytes), in btrfs_remove_free_space()
2744 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2757 u64 bytes) in btrfs_dump_free_space() argument
2779 if (info->bytes >= bytes && !block_group->ro) in btrfs_dump_free_space()
2782 info->offset, info->bytes, in btrfs_dump_free_space()
2852 entry->bytes; in __btrfs_return_cluster_to_free_space()
2862 entry->bytes; in __btrfs_return_cluster_to_free_space()
2956 u64 offset, u64 bytes, u64 empty_size, in btrfs_find_space_for_alloc() argument
2963 u64 bytes_search = bytes + empty_size; in btrfs_find_space_for_alloc()
2979 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2982 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2984 if (!entry->bytes) in btrfs_find_space_for_alloc()
2993 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_find_space_for_alloc()
2995 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2996 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2998 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2999 if (!entry->bytes) in btrfs_find_space_for_alloc()
3061 u64 bytes, u64 min_start, in btrfs_alloc_from_bitmap() argument
3067 u64 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3071 search_bytes = bytes; in btrfs_alloc_from_bitmap()
3081 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
3092 struct btrfs_free_cluster *cluster, u64 bytes, in btrfs_alloc_from_cluster() argument
3105 if (bytes > cluster->max_size) in btrfs_alloc_from_cluster()
3117 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3121 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3133 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3144 cluster->window_start += bytes; in btrfs_alloc_from_cluster()
3148 entry->offset += bytes; in btrfs_alloc_from_cluster()
3149 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3163 atomic64_add(bytes, &discard_ctl->discard_bytes_saved); in btrfs_alloc_from_cluster()
3165 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
3167 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes; in btrfs_alloc_from_cluster()
3170 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3193 u64 offset, u64 bytes, in btrfs_bitmap_cluster() argument
3209 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
3274 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_no_bitmap() argument
3294 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3303 window_free = entry->bytes; in setup_cluster_no_bitmap()
3304 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3318 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3322 window_free += entry->bytes; in setup_cluster_no_bitmap()
3323 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3324 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3327 if (window_free < bytes || max_extent < cont1_bytes) in setup_cluster_no_bitmap()
3343 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3349 total_size += entry->bytes; in setup_cluster_no_bitmap()
3365 struct list_head *bitmaps, u64 offset, u64 bytes, in setup_cluster_bitmap() argument
3390 if (entry->bytes < bytes) in setup_cluster_bitmap()
3393 bytes, cont1_bytes, min_bytes); in setup_cluster_bitmap()
3415 u64 offset, u64 bytes, u64 empty_size) in btrfs_find_space_cluster() argument
3432 cont1_bytes = min_bytes = bytes + empty_size; in btrfs_find_space_cluster()
3434 cont1_bytes = bytes; in btrfs_find_space_cluster()
3437 cont1_bytes = max(bytes, (bytes + empty_size) >> 2); in btrfs_find_space_cluster()
3447 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3460 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size, in btrfs_find_space_cluster()
3464 bytes + empty_size, in btrfs_find_space_cluster()
3468 offset, bytes + empty_size, in btrfs_find_space_cluster()
3505 u64 *total_trimmed, u64 start, u64 bytes, in do_trimming() argument
3515 const u64 end = start + bytes; in do_trimming()
3530 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed); in do_trimming()
3541 if (start + bytes < reserved_start + reserved_bytes) in do_trimming()
3544 __btrfs_add_free_space(fs_info, ctl, start, bytes, trim_state); in do_trimming()
3578 u64 bytes; in trim_no_bitmap() local
3608 extent_bytes = entry->bytes; in trim_no_bitmap()
3612 bytes = entry->bytes; in trim_no_bitmap()
3613 if (bytes < minlen) { in trim_no_bitmap()
3625 bytes >= (max_discard_size + in trim_no_bitmap()
3627 bytes = max_discard_size; in trim_no_bitmap()
3630 entry->bytes -= max_discard_size; in trim_no_bitmap()
3637 bytes = min(extent_start + extent_bytes, end) - start; in trim_no_bitmap()
3638 if (bytes < minlen) { in trim_no_bitmap()
3650 trim_entry.bytes = extent_bytes; in trim_no_bitmap()
3654 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_no_bitmap()
3658 block_group->discard_cursor = start + bytes; in trim_no_bitmap()
3662 start += bytes; in trim_no_bitmap()
3709 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3724 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3741 u64 bytes; in trim_bitmaps() local
3786 bytes = minlen; in trim_bitmaps()
3787 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3813 bytes = min(bytes, end - start); in trim_bitmaps()
3814 if (bytes < minlen || (async && maxlen && bytes > maxlen)) { in trim_bitmaps()
3828 bytes > (max_discard_size + minlen)) in trim_bitmaps()
3829 bytes = max_discard_size; in trim_bitmaps()
3831 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3832 if (entry->bytes == 0) in trim_bitmaps()
3837 trim_entry.bytes = bytes; in trim_bitmaps()
3841 ret = do_trimming(block_group, total_trimmed, start, bytes, in trim_bitmaps()
3842 start, bytes, 0, &trim_entry); in trim_bitmaps()
3854 start += bytes; in trim_bitmaps()
4022 u64 offset, u64 bytes, bool bitmap) in test_add_free_space_entry() argument
4041 info->bytes = bytes; in test_add_free_space_entry()
4069 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes, in test_add_free_space_entry()
4072 bytes -= bytes_added; in test_add_free_space_entry()
4076 if (bytes) in test_add_free_space_entry()
4092 u64 offset, u64 bytes) in test_check_exists() argument
4121 offset + bytes > bit_off) { in test_check_exists()
4131 if (tmp->offset + tmp->bytes < offset) in test_check_exists()
4133 if (offset + bytes < tmp->offset) { in test_check_exists()
4145 if (offset + bytes < tmp->offset) in test_check_exists()
4147 if (tmp->offset + tmp->bytes < offset) { in test_check_exists()
4164 if (offset > info->offset && offset < info->offset + info->bytes) in test_check_exists()