/* * This describes the state of the block_group for async discard. This is due * to the two pass nature of it where extent discarding is prioritized over * bitmap discarding. BTRFS_DISCARD_RESET_CURSOR is set when we are resetting * between lists to prevent contention for discard state variables * (eg. discard_cursor).
*/ enum btrfs_discard_state {
BTRFS_DISCARD_EXTENTS,
BTRFS_DISCARD_BITMAPS,
BTRFS_DISCARD_RESET_CURSOR,
};
/* * Control flags for do_chunk_alloc's force field CHUNK_ALLOC_NO_FORCE means to * only allocate a chunk if we really need one. * * CHUNK_ALLOC_LIMITED means to only try and allocate one if we have very few * chunks already allocated. This is used as part of the clustering code to * help make sure we have a good pool of storage to cluster in, without filling * the FS with empty chunks * * CHUNK_ALLOC_FORCE means it must try to allocate one * * CHUNK_ALLOC_FORCE_FOR_EXTENT like CHUNK_ALLOC_FORCE but called from * find_free_extent() that also activaes the zone
*/ enum btrfs_chunk_alloc_enum {
CHUNK_ALLOC_NO_FORCE,
CHUNK_ALLOC_LIMITED,
CHUNK_ALLOC_FORCE,
CHUNK_ALLOC_FORCE_FOR_EXTENT,
};
/* Block group flags set at runtime */ enum btrfs_block_group_flags {
BLOCK_GROUP_FLAG_IREF,
BLOCK_GROUP_FLAG_REMOVED,
BLOCK_GROUP_FLAG_TO_COPY,
BLOCK_GROUP_FLAG_RELOCATING_REPAIR,
BLOCK_GROUP_FLAG_CHUNK_ITEM_INSERTED,
BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, /* Does the block group need to be added to the free space tree? */
BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, /* Set after we add a new block group to the free space tree. */
BLOCK_GROUP_FLAG_FREE_SPACE_ADDED, /* Indicate that the block group is placed on a sequential zone */
BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, /* * Indicate that block group is in the list of new block groups of a * transaction.
*/
BLOCK_GROUP_FLAG_NEW,
};
/* * The last committed used bytes of this block group, if the above @used * is still the same as @commit_used, we don't need to update block * group item of this block group.
*/
u64 commit_used; /* * If the free space extent count exceeds this number, convert the block * group to bitmaps.
*/
u32 bitmap_high_thresh;
/* * If the free space extent count drops below this number, convert the * block group back to extents.
*/
u32 bitmap_low_thresh;
/* * It is just used for the delayed data space allocation because * only the data space allocation and the relative metadata update * can be done cross the transaction.
*/ struct rw_semaphore data_rwsem;
/* For raid56, this is a full stripe, without parity */ unsignedlong full_stripe_len; unsignedlong runtime_flags;
unsignedint ro;
int disk_cache_state;
/* Cache tracking stuff */ int cached; struct btrfs_caching_control *caching_ctl;
struct btrfs_space_info *space_info;
/* Free space cache stuff */ struct btrfs_free_space_ctl *free_space_ctl;
/* Block group cache stuff */ struct rb_node cache_node;
/* For block groups in the same raid type */ struct list_head list;
refcount_t refs;
/* * List of struct btrfs_free_clusters for this block group. * Today it will only have one thing on it, but that may change
*/ struct list_head cluster_list;
/* * Used for several lists: * * 1) struct btrfs_fs_info::unused_bgs * 2) struct btrfs_fs_info::reclaim_bgs * 3) struct btrfs_transaction::deleted_bgs * 4) struct btrfs_trans_handle::new_bgs
*/ struct list_head bg_list;
/* For read-only block groups */ struct list_head ro_list;
/* * When non-zero it means the block group's logical address and its * device extents can not be reused for future block group allocations * until the counter goes down to 0. This is to prevent them from being * reused while some task is still using the block group after it was * deleted - we want to make sure they can only be reused for new block * groups after that task is done with the deleted block group.
*/
atomic_t frozen;
/* For discard operations */ struct list_head discard_list; int discard_index;
u64 discard_eligible_time;
u64 discard_cursor; enum btrfs_discard_state discard_state;
/* For dirty block groups */ struct list_head dirty_list; struct list_head io_list;
struct btrfs_io_ctl io_ctl;
/* * Incremented when doing extent allocations and holding a read lock * on the space_info's groups_sem semaphore. * Decremented when an ordered extent that represents an IO against this * block group's range is created (after it's added to its inode's * root's list of ordered extents) or immediately after the allocation * if it's a metadata extent or fallocate extent (for these cases we * don't create ordered extents).
*/
atomic_t reservations;
/* * Incremented while holding the spinlock *lock* by a task checking if * it can perform a nocow write (incremented if the value for the *ro* * field is 0). Decremented by such tasks once they create an ordered * extent or before that if some error happens before reaching that step. * This is to prevent races between block group relocation and nocow * writes through direct IO.
*/
atomic_t nocow_writers;
/* Lock for free space tree operations. */ struct mutex free_space_lock;
/* Protected by @free_space_lock. */ bool using_free_space_bitmaps; /* Protected by @free_space_lock. */ bool using_free_space_bitmaps_cached;
/* * Number of extents in this block group used for swap files. * All accesses protected by the spinlock 'lock'.
*/ int swap_extents;
/* * Allocation offset for the block group to implement sequential * allocation. This is used only on a zoned filesystem.
*/
u64 alloc_offset;
u64 zone_unusable;
u64 zone_capacity;
u64 meta_write_pointer; struct btrfs_chunk_map *physical_map; struct list_head active_bg_list; struct work_struct zone_finish_work; struct extent_buffer *last_eb; enum btrfs_block_group_size_class size_class;
u64 reclaim_mark;
};
staticinlinebool btrfs_is_block_group_data_only(conststruct btrfs_block_group *block_group)
{ /* * In mixed mode the fragmentation is expected to be high, lowering the * efficiency, so only proper data block groups are considered.
*/ return (block_group->flags & BTRFS_BLOCK_GROUP_DATA) &&
!(block_group->flags & BTRFS_BLOCK_GROUP_METADATA);
}
#ifdef CONFIG_BTRFS_DEBUG int btrfs_should_fragment_free_space(conststruct btrfs_block_group *block_group); #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.