Lines Matching refs:bytes

43 	u64 bytes;
53 u64 *bytes, bool for_alloc);
58 u64 bytes, bool update_stats);
577 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
587 put_unaligned_le64(bytes, &entry->bytes);
661 entry->bytes = get_unaligned_le64(&e->bytes);
724 * bytes we can have, or whatever is less than that.
825 if (!e->bytes) {
908 const u64 bytes = info->bytes;
913 ret = btrfs_add_free_space(block_group, offset, bytes);
917 u64 bytes = ctl->unit;
919 ret = search_bitmap(ctl, info, &offset, &bytes, false);
921 bitmap_clear_bits(ctl, info, offset, bytes, true);
924 bytes);
1101 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes,
1131 trim_entry->bytes, NULL);
1565 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit)
1567 return (unsigned long)(div_u64(bytes, unit));
1655 * we've found already if it's larger, or we want to use ->bytes.
1657 * This matters because find_free_space() will skip entries who's ->bytes is
1658 * less than the required bytes. So if we didn't search down this bitmap, we
1661 * ->max_extent_size set to 4K and ->bytes set to 1M. A second entry hasn't set
1662 * ->max_extent_size yet, has ->bytes set to 8K and it's contiguous. We will
1678 return entry->bytes;
1698 * want a section that has at least bytes size and comes at or after the given
1755 prev->offset + prev->bytes > offset)
1787 prev->offset + prev->bytes > offset)
1792 } else if (entry->offset + entry->bytes > offset)
1808 if (entry->offset + entry->bytes > offset)
1827 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes;
1831 ctl->free_space -= info->bytes;
1841 ASSERT(info->bytes || info->bitmap);
1850 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
1853 ctl->free_space += info->bytes;
1865 * want to re-link it into our ctl bytes index.
1878 u64 offset, u64 bytes, bool update_stat)
1884 count = bytes_to_bits(bytes, ctl->unit);
1890 info->bytes -= bytes;
1905 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
1909 ctl->free_space -= bytes;
1914 u64 bytes)
1920 count = bytes_to_bits(bytes, ctl->unit);
1927 * We set some bytes, we have no idea what the max extent size is
1931 info->bytes += bytes;
1932 ctl->free_space += bytes;
1945 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes;
1950 * If we can not find suitable extent, we will use bytes to record
1955 u64 *bytes, bool for_alloc)
1969 bitmap_info->max_extent_size < *bytes) {
1970 *bytes = bitmap_info->max_extent_size;
1976 bits = bytes_to_bits(*bytes, ctl->unit);
1997 *bytes = (u64)(found_bits) * ctl->unit;
2001 *bytes = (u64)(max_bits) * ctl->unit;
2002 bitmap_info->max_extent_size = *bytes;
2007 /* Cache the size of the max extent in bytes */
2009 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2040 * If we are using the bytes index then all subsequent entries
2041 * in this tree are going to be < bytes, so simply set the max
2047 if (entry->bytes < *bytes) {
2058 if (*bytes >= align) {
2069 * We don't break here if we're using the bytes index because we
2075 if (entry->bytes < *bytes + align_off) {
2083 u64 size = *bytes;
2088 *bytes = size;
2108 *bytes = entry->bytes - align_off;
2119 info->bytes = 0;
2136 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) {
2139 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes;
2151 u64 *offset, u64 *bytes)
2175 search_bytes = min(search_bytes, *bytes);
2182 *bytes -= search_bytes;
2184 if (*bytes) {
2186 if (!bitmap_info->bytes)
2190 * no entry after this bitmap, but we still have bytes to
2220 } else if (!bitmap_info->bytes)
2228 u64 bytes, enum btrfs_trim_state trim_state)
2241 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
2248 bytes_to_set = min(end - offset, bytes);
2269 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD)
2284 if (info->bytes <= fs_info->sectorsize * 8) {
2316 u64 bytes, offset, bytes_added;
2320 bytes = info->bytes;
2358 bytes, trim_state);
2359 bytes -= bytes_added;
2363 if (!bytes) {
2377 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes,
2379 bytes -= bytes_added;
2383 if (!bytes) {
2455 u64 bytes = info->bytes;
2464 right_info = tree_search_offset(ctl, offset + bytes, 0, 0);
2477 info->bytes += right_info->bytes;
2484 left_info->offset + left_info->bytes == offset &&
2488 info->bytes += left_info->bytes;
2503 const u64 end = info->offset + info->bytes;
2505 u64 bytes;
2515 bytes = (j - i) * ctl->unit;
2516 info->bytes += bytes;
2522 bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat);
2524 if (!bitmap->bytes)
2539 u64 bytes;
2565 bytes = (i + 1) * ctl->unit;
2567 bytes = (i - prev_j) * ctl->unit;
2569 info->offset -= bytes;
2570 info->bytes += bytes;
2576 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat);
2578 if (!bitmap->bytes)
2621 u64 offset, u64 bytes,
2628 u64 filter_bytes = bytes;
2637 info->bytes = bytes;
2668 filter_bytes = max(filter_bytes, info->bytes);
2794 u64 offset, u64 bytes)
2814 offset + bytes) {
2816 offset + bytes - block_group->start;
2825 if (!bytes)
2851 u64 to_free = min(bytes, info->bytes);
2853 info->bytes -= to_free;
2855 if (info->bytes) {
2863 bytes -= to_free;
2866 u64 old_end = info->bytes + info->offset;
2868 info->bytes = offset - info->offset;
2874 /* Not enough bytes in this entry to satisfy us */
2875 if (old_end < offset + bytes) {
2876 bytes -= old_end - offset;
2879 } else if (old_end == offset + bytes) {
2886 offset + bytes,
2887 old_end - (offset + bytes),
2894 ret = remove_from_bitmap(ctl, info, &offset, &bytes);
2907 u64 bytes)
2930 if (info->bytes >= bytes && !block_group->ro)
2932 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s",
2933 info->offset, info->bytes,
2940 "%d free space entries at or bigger than %llu bytes",
2941 count, bytes);
3005 entry->bytes;
3015 entry->bytes;
3079 u64 offset, u64 bytes, u64 empty_size,
3086 u64 bytes_search = bytes + empty_size;
3104 bitmap_clear_bits(ctl, entry, offset, bytes, true);
3107 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3109 if (!entry->bytes)
3118 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3120 entry->offset = offset + bytes;
3121 WARN_ON(entry->bytes < bytes + align_gap_len);
3123 entry->bytes -= bytes + align_gap_len;
3124 if (!entry->bytes)
3185 u64 bytes, u64 min_start,
3191 u64 search_bytes = bytes;
3195 search_bytes = bytes;
3205 bitmap_clear_bits(ctl, entry, ret, bytes, false);
3211 * given a cluster, try to allocate 'bytes' from it, returns 0
3216 struct btrfs_free_cluster *cluster, u64 bytes,
3229 if (bytes > cluster->max_size)
3241 if (entry->bytes < bytes)
3245 if (entry->bytes < bytes ||
3257 cluster, entry, bytes,
3268 cluster->window_start += bytes;
3272 entry->offset += bytes;
3273 entry->bytes -= bytes;
3287 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3289 ctl->free_space -= bytes;
3291 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
3294 if (entry->bytes == 0) {
3317 u64 offset, u64 bytes,
3335 want_bits = bytes_to_bits(bytes, ctl->unit);
3404 * Try to find a cluster with at least bytes total bytes, at least one
3410 struct list_head *bitmaps, u64 offset, u64 bytes,
3432 while (entry->bitmap || entry->bytes < min_bytes) {
3441 window_free = entry->bytes;
3442 max_extent = entry->bytes;
3456 if (entry->bytes < min_bytes)
3460 window_free += entry->bytes;
3461 if (entry->bytes > max_extent)
3462 max_extent = entry->bytes;
3465 if (window_free < bytes || max_extent < cont1_bytes)
3481 if (entry->bitmap || entry->bytes < min_bytes)
3487 total_size += entry->bytes;
3503 struct list_head *bitmaps, u64 offset, u64 bytes,
3528 if (entry->bytes < bytes)
3531 bytes, cont1_bytes, min_bytes);
3545 * is to find at least bytes+empty_size.
3553 u64 offset, u64 bytes, u64 empty_size)
3570 cont1_bytes = bytes + empty_size;
3573 cont1_bytes = bytes;
3576 cont1_bytes = max(bytes, (bytes + empty_size) >> 2);
3586 if (ctl->free_space < bytes) {
3599 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size,
3603 bytes + empty_size,
3607 offset, bytes + empty_size,
3644 u64 *total_trimmed, u64 start, u64 bytes,
3654 const u64 end = start + bytes;
3669 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed);
3683 __btrfs_add_free_space(block_group, start, bytes, trim_state);
3717 u64 bytes;
3747 extent_bytes = entry->bytes;
3751 bytes = entry->bytes;
3752 if (bytes < minlen) {
3759 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X.
3764 bytes >= (max_discard_size +
3766 bytes = max_discard_size;
3769 entry->bytes -= max_discard_size;
3776 bytes = min(extent_start + extent_bytes, end) - start;
3777 if (bytes < minlen) {
3789 trim_entry.bytes = extent_bytes;
3793 ret = do_trimming(block_group, total_trimmed, start, bytes,
3797 block_group->discard_cursor = start + bytes;
3801 start += bytes;
3848 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes;
3863 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes;
3880 u64 bytes;
3925 bytes = minlen;
3926 ret2 = search_bitmap(ctl, entry, &start, &bytes, false);
3952 bytes = min(bytes, end - start);
3953 if (bytes < minlen || (async && maxlen && bytes > maxlen)) {
3960 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X.
3967 bytes > (max_discard_size + minlen))
3968 bytes = max_discard_size;
3970 bitmap_clear_bits(ctl, entry, start, bytes, true);
3971 if (entry->bytes == 0)
3976 trim_entry.bytes = bytes;
3980 ret = do_trimming(block_group, total_trimmed, start, bytes,
3981 start, bytes, 0, &trim_entry);
3993 start += bytes;
4186 u64 offset, u64 bytes, bool bitmap)
4205 info->bytes = bytes;
4233 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes,
4236 bytes -= bytes_added;
4240 if (bytes)
4256 u64 offset, u64 bytes)
4285 offset + bytes > bit_off) {
4295 if (tmp->offset + tmp->bytes < offset)
4297 if (offset + bytes < tmp->offset) {
4309 if (offset + bytes < tmp->offset)
4311 if (tmp->offset + tmp->bytes < offset) {
4328 if (offset > info->offset && offset < info->offset + info->bytes)