fs/btrfs/extent_map.h

Source file repositories/reference/linux-study-clean/fs/btrfs/extent_map.h

File Facts

System
Linux kernel
Corpus path
fs/btrfs/extent_map.h
Extension
.h
Size
5655 bytes
Lines
196
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 extent_map {
	struct rb_node rb_node;

	/* All of these are in bytes. */

	/* File offset matching the offset of a BTRFS_EXTENT_ITEM_KEY key. */
	u64 start;

	/*
	 * Length of the file extent.
	 *
	 * For non-inlined file extents it's btrfs_file_extent_item::num_bytes.
	 * For inline extents it's sectorsize, since inline data starts at
	 * offsetof(struct btrfs_file_extent_item, disk_bytenr) thus
	 * btrfs_file_extent_item::num_bytes is not valid.
	 */
	u64 len;

	/*
	 * The bytenr of the full on-disk extent.
	 *
	 * For regular extents it's btrfs_file_extent_item::disk_bytenr.
	 * For holes it's EXTENT_MAP_HOLE and for inline extents it's
	 * EXTENT_MAP_INLINE.
	 */
	u64 disk_bytenr;

	/*
	 * The full on-disk extent length, matching
	 * btrfs_file_extent_item::disk_num_bytes.
	 */
	u64 disk_num_bytes;

	/*
	 * Offset inside the decompressed extent.
	 *
	 * For regular extents it's btrfs_file_extent_item::offset.
	 * For holes and inline extents it's 0.
	 */
	u64 offset;

	/*
	 * The decompressed size of the whole on-disk extent, matching
	 * btrfs_file_extent_item::ram_bytes.
	 */
	u64 ram_bytes;

	/*
	 * Generation of the extent map, for merged em it's the highest
	 * generation of all merged ems.
	 * For non-merged extents, it's from btrfs_file_extent_item::generation.
	 */
	u64 generation;
	u32 flags;
	refcount_t refs;
	struct list_head list;
};

struct extent_map_tree {
	struct rb_root root;
	struct list_head modified_extents;
	rwlock_t lock;
};

struct btrfs_inode;

static inline void btrfs_extent_map_set_compression(struct extent_map *em,
						    enum btrfs_compression_type type)
{
	if (type == BTRFS_COMPRESS_ZLIB)
		em->flags |= EXTENT_FLAG_COMPRESS_ZLIB;
	else if (type == BTRFS_COMPRESS_LZO)
		em->flags |= EXTENT_FLAG_COMPRESS_LZO;
	else if (type == BTRFS_COMPRESS_ZSTD)
		em->flags |= EXTENT_FLAG_COMPRESS_ZSTD;
}

static inline enum btrfs_compression_type btrfs_extent_map_compression(
						       const struct extent_map *em)
{
	if (em->flags & EXTENT_FLAG_COMPRESS_ZLIB)
		return BTRFS_COMPRESS_ZLIB;

	if (em->flags & EXTENT_FLAG_COMPRESS_LZO)
		return BTRFS_COMPRESS_LZO;

	if (em->flags & EXTENT_FLAG_COMPRESS_ZSTD)
		return BTRFS_COMPRESS_ZSTD;

	return BTRFS_COMPRESS_NONE;

Annotation

Implementation Notes