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