fs/btrfs/free-space-cache.h

Source file repositories/reference/linux-study-clean/fs/btrfs/free-space-cache.h

File Facts

System
Linux kernel
Corpus path
fs/btrfs/free-space-cache.h
Extension
.h
Size
5813 bytes
Lines
175
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct btrfs_free_space {
	struct rb_node offset_index;
	struct rb_node bytes_index;
	u64 offset;
	u64 bytes;
	u64 max_extent_size;
	unsigned long *bitmap;
	struct list_head list;
	enum btrfs_trim_state trim_state;
	s32 bitmap_extents;
};

static inline bool btrfs_free_space_trimmed(struct btrfs_free_space *info)
{
	return (info->trim_state == BTRFS_TRIM_STATE_TRIMMED);
}

static inline bool btrfs_free_space_trimming_bitmap(
					    struct btrfs_free_space *info)
{
	return (info->trim_state == BTRFS_TRIM_STATE_TRIMMING);
}

static inline bool btrfs_trim_interrupted(void)
{
	return fatal_signal_pending(current) || freezing(current);
}

/*
 * Deltas are an effective way to populate global statistics.  Give macro names
 * to make it clear what we're doing.  An example is discard_extents in
 * btrfs_free_space_ctl.
 */
enum {
	BTRFS_STAT_CURR,
	BTRFS_STAT_PREV,
	BTRFS_STAT_NR_ENTRIES,
};

struct btrfs_free_space_ctl {
	struct rb_root free_space_offset;
	struct rb_root_cached free_space_bytes;
	spinlock_t tree_lock;
	int extents_thresh;
	int free_extents;
	int total_bitmaps;
	u64 free_space;
	s32 discardable_extents[BTRFS_STAT_NR_ENTRIES];
	s64 discardable_bytes[BTRFS_STAT_NR_ENTRIES];
	struct btrfs_block_group *block_group;
	struct mutex cache_writeout_mutex;
	struct list_head trimming_ranges;
};

struct btrfs_io_ctl {
	void *cur, *orig;
	struct page *page;
	struct page **pages;
	struct btrfs_fs_info *fs_info;
	struct inode *inode;
	unsigned long size;
	int index;
	int num_pages;
	int entries;
	int bitmaps;
};

int __init btrfs_free_space_init(void);
void __cold btrfs_free_space_exit(void);
struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
		struct btrfs_path *path);
int create_free_space_inode(struct btrfs_trans_handle *trans,
			    struct btrfs_block_group *block_group,
			    struct btrfs_path *path);
int btrfs_remove_free_space_inode(struct btrfs_trans_handle *trans,
				  struct inode *inode,
				  struct btrfs_block_group *block_group);

int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
				    struct btrfs_block_group *block_group,
				    struct inode *inode);
int load_free_space_cache(struct btrfs_block_group *block_group);
int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
			struct btrfs_block_group *block_group,
			struct btrfs_path *path);
int btrfs_write_out_cache(struct btrfs_trans_handle *trans,
			  struct btrfs_block_group *block_group,
			  struct btrfs_path *path);

void btrfs_init_free_space_ctl(struct btrfs_block_group *block_group,

Annotation

Implementation Notes