Lines Matching refs:bytes

41 	u64 bytes;
51 u64 *bytes, bool for_alloc);
56 u64 bytes, bool update_stats);
580 static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
590 put_unaligned_le64(bytes, &entry->bytes);
664 entry->bytes = get_unaligned_le64(&e->bytes);
727 * bytes we can have, or whatever is less than that.
828 if (!e->bytes) {
911 const u64 bytes = info->bytes;
916 ret = btrfs_add_free_space(block_group, offset, bytes);
920 u64 bytes = ctl->unit;
922 ret = search_bitmap(ctl, info, &offset, &bytes, false);
924 bitmap_clear_bits(ctl, info, offset, bytes, true);
927 bytes);
1104 ret = io_ctl_add_entry(io_ctl, e->offset, e->bytes,
1134 trim_entry->bytes, NULL);
1567 static inline unsigned long bytes_to_bits(u64 bytes, u32 unit)
1569 return (unsigned long)(div_u64(bytes, unit));
1657 * we've found already if it's larger, or we want to use ->bytes.
1659 * This matters because find_free_space() will skip entries who's ->bytes is
1660 * less than the required bytes. So if we didn't search down this bitmap, we
1663 * ->max_extent_size set to 4K and ->bytes set to 1M. A second entry hasn't set
1664 * ->max_extent_size yet, has ->bytes set to 8K and it's contiguous. We will
1680 return entry->bytes;
1700 * want a section that has at least bytes size and comes at or after the given
1757 prev->offset + prev->bytes > offset)
1789 prev->offset + prev->bytes > offset)
1794 } else if (entry->offset + entry->bytes > offset)
1810 if (entry->offset + entry->bytes > offset)
1829 ctl->discardable_bytes[BTRFS_STAT_CURR] -= info->bytes;
1833 ctl->free_space -= info->bytes;
1843 ASSERT(info->bytes || info->bitmap);
1852 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
1855 ctl->free_space += info->bytes;
1867 * want to re-link it into our ctl bytes index.
1880 u64 offset, u64 bytes, bool update_stat)
1886 count = bytes_to_bits(bytes, ctl->unit);
1892 info->bytes -= bytes;
1907 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
1911 ctl->free_space -= bytes;
1916 u64 bytes)
1922 count = bytes_to_bits(bytes, ctl->unit);
1929 * We set some bytes, we have no idea what the max extent size is
1933 info->bytes += bytes;
1934 ctl->free_space += bytes;
1947 ctl->discardable_bytes[BTRFS_STAT_CURR] += bytes;
1952 * If we can not find suitable extent, we will use bytes to record
1957 u64 *bytes, bool for_alloc)
1971 bitmap_info->max_extent_size < *bytes) {
1972 *bytes = bitmap_info->max_extent_size;
1978 bits = bytes_to_bits(*bytes, ctl->unit);
1999 *bytes = (u64)(found_bits) * ctl->unit;
2003 *bytes = (u64)(max_bits) * ctl->unit;
2004 bitmap_info->max_extent_size = *bytes;
2009 /* Cache the size of the max extent in bytes */
2011 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2042 * If we are using the bytes index then all subsequent entries
2043 * in this tree are going to be < bytes, so simply set the max
2049 if (entry->bytes < *bytes) {
2060 if (*bytes >= align) {
2071 * We don't break here if we're using the bytes index because we
2077 if (entry->bytes < *bytes + align_off) {
2085 u64 size = *bytes;
2090 *bytes = size;
2110 *bytes = entry->bytes - align_off;
2121 info->bytes = 0;
2138 if (bitmap_info->bytes && !btrfs_free_space_trimmed(bitmap_info)) {
2141 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bitmap_info->bytes;
2153 u64 *offset, u64 *bytes)
2177 search_bytes = min(search_bytes, *bytes);
2184 *bytes -= search_bytes;
2186 if (*bytes) {
2188 if (!bitmap_info->bytes)
2192 * no entry after this bitmap, but we still have bytes to
2222 } else if (!bitmap_info->bytes)
2230 u64 bytes, enum btrfs_trim_state trim_state)
2243 ctl->discardable_bytes[BTRFS_STAT_CURR] += info->bytes;
2250 bytes_to_set = min(end - offset, bytes);
2271 if (!forced && info->bytes >= FORCE_EXTENT_THRESHOLD)
2286 if (info->bytes <= fs_info->sectorsize * 8) {
2318 u64 bytes, offset, bytes_added;
2322 bytes = info->bytes;
2360 bytes, trim_state);
2361 bytes -= bytes_added;
2365 if (!bytes) {
2379 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes,
2381 bytes -= bytes_added;
2385 if (!bytes) {
2457 u64 bytes = info->bytes;
2466 right_info = tree_search_offset(ctl, offset + bytes, 0, 0);
2479 info->bytes += right_info->bytes;
2486 left_info->offset + left_info->bytes == offset &&
2490 info->bytes += left_info->bytes;
2505 const u64 end = info->offset + info->bytes;
2507 u64 bytes;
2517 bytes = (j - i) * ctl->unit;
2518 info->bytes += bytes;
2524 bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat);
2526 if (!bitmap->bytes)
2541 u64 bytes;
2567 bytes = (i + 1) * ctl->unit;
2569 bytes = (i - prev_j) * ctl->unit;
2571 info->offset -= bytes;
2572 info->bytes += bytes;
2578 bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat);
2580 if (!bitmap->bytes)
2623 u64 offset, u64 bytes,
2630 u64 filter_bytes = bytes;
2639 info->bytes = bytes;
2670 filter_bytes = max(filter_bytes, info->bytes);
2796 u64 offset, u64 bytes)
2816 offset + bytes) {
2818 offset + bytes - block_group->start;
2827 if (!bytes)
2853 u64 to_free = min(bytes, info->bytes);
2855 info->bytes -= to_free;
2857 if (info->bytes) {
2865 bytes -= to_free;
2868 u64 old_end = info->bytes + info->offset;
2870 info->bytes = offset - info->offset;
2876 /* Not enough bytes in this entry to satisfy us */
2877 if (old_end < offset + bytes) {
2878 bytes -= old_end - offset;
2881 } else if (old_end == offset + bytes) {
2888 offset + bytes,
2889 old_end - (offset + bytes),
2896 ret = remove_from_bitmap(ctl, info, &offset, &bytes);
2909 u64 bytes)
2932 if (info->bytes >= bytes && !block_group->ro)
2934 btrfs_crit(fs_info, "entry offset %llu, bytes %llu, bitmap %s",
2935 info->offset, info->bytes,
2942 "%d free space entries at or bigger than %llu bytes",
2943 count, bytes);
3007 entry->bytes;
3017 entry->bytes;
3081 u64 offset, u64 bytes, u64 empty_size,
3088 u64 bytes_search = bytes + empty_size;
3106 bitmap_clear_bits(ctl, entry, offset, bytes, true);
3109 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3111 if (!entry->bytes)
3120 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3122 entry->offset = offset + bytes;
3123 WARN_ON(entry->bytes < bytes + align_gap_len);
3125 entry->bytes -= bytes + align_gap_len;
3126 if (!entry->bytes)
3187 u64 bytes, u64 min_start,
3193 u64 search_bytes = bytes;
3197 search_bytes = bytes;
3207 bitmap_clear_bits(ctl, entry, ret, bytes, false);
3213 * given a cluster, try to allocate 'bytes' from it, returns 0
3218 struct btrfs_free_cluster *cluster, u64 bytes,
3231 if (bytes > cluster->max_size)
3243 if (entry->bytes < bytes)
3247 if (entry->bytes < bytes ||
3259 cluster, entry, bytes,
3270 cluster->window_start += bytes;
3274 entry->offset += bytes;
3275 entry->bytes -= bytes;
3289 atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
3291 ctl->free_space -= bytes;
3293 ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
3296 if (entry->bytes == 0) {
3319 u64 offset, u64 bytes,
3337 want_bits = bytes_to_bits(bytes, ctl->unit);
3406 * Try to find a cluster with at least bytes total bytes, at least one
3412 struct list_head *bitmaps, u64 offset, u64 bytes,
3434 while (entry->bitmap || entry->bytes < min_bytes) {
3443 window_free = entry->bytes;
3444 max_extent = entry->bytes;
3458 if (entry->bytes < min_bytes)
3462 window_free += entry->bytes;
3463 if (entry->bytes > max_extent)
3464 max_extent = entry->bytes;
3467 if (window_free < bytes || max_extent < cont1_bytes)
3483 if (entry->bitmap || entry->bytes < min_bytes)
3489 total_size += entry->bytes;
3505 struct list_head *bitmaps, u64 offset, u64 bytes,
3530 if (entry->bytes < bytes)
3533 bytes, cont1_bytes, min_bytes);
3547 * is to find at least bytes+empty_size.
3555 u64 offset, u64 bytes, u64 empty_size)
3572 cont1_bytes = bytes + empty_size;
3575 cont1_bytes = bytes;
3578 cont1_bytes = max(bytes, (bytes + empty_size) >> 2);
3588 if (ctl->free_space < bytes) {
3601 trace_btrfs_find_cluster(block_group, offset, bytes, empty_size,
3605 bytes + empty_size,
3609 offset, bytes + empty_size,
3646 u64 *total_trimmed, u64 start, u64 bytes,
3656 const u64 end = start + bytes;
3671 ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed);
3685 __btrfs_add_free_space(block_group, start, bytes, trim_state);
3719 u64 bytes;
3749 extent_bytes = entry->bytes;
3753 bytes = entry->bytes;
3754 if (bytes < minlen) {
3761 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X.
3766 bytes >= (max_discard_size +
3768 bytes = max_discard_size;
3771 entry->bytes -= max_discard_size;
3778 bytes = min(extent_start + extent_bytes, end) - start;
3779 if (bytes < minlen) {
3791 trim_entry.bytes = extent_bytes;
3795 ret = do_trimming(block_group, total_trimmed, start, bytes,
3799 block_group->discard_cursor = start + bytes;
3803 start += bytes;
3850 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes;
3865 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes;
3882 u64 bytes;
3927 bytes = minlen;
3928 ret2 = search_bitmap(ctl, entry, &start, &bytes, false);
3954 bytes = min(bytes, end - start);
3955 if (bytes < minlen || (async && maxlen && bytes > maxlen)) {
3962 * Let bytes = BTRFS_MAX_DISCARD_SIZE + X.
3969 bytes > (max_discard_size + minlen))
3970 bytes = max_discard_size;
3972 bitmap_clear_bits(ctl, entry, start, bytes, true);
3973 if (entry->bytes == 0)
3978 trim_entry.bytes = bytes;
3982 ret = do_trimming(block_group, total_trimmed, start, bytes,
3983 start, bytes, 0, &trim_entry);
3995 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)