fs/ext4/extents-test.c

Source file repositories/reference/linux-study-clean/fs/ext4/extents-test.c

File Facts

System
Linux kernel
Corpus path
fs/ext4/extents-test.c
Extension
.c
Size
34736 bytes
Lines
1070
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 kunit_ctx {
	/*
	 * Ext4 inode which has only 1 unwrit extent
	 */
	struct ext4_inode_info *k_ei;
	/*
	 * Represents the underlying data area (used for zeroout testing)
	 */
	char *k_data;
} k_ctx;

/*
 * describes the state of an expected extent in extent tree.
 */
struct kunit_ext_state {
	ext4_lblk_t ex_lblk;
	ext4_lblk_t ex_len;
	bool is_unwrit;
};

/*
 * describes the state of the data area of a writ extent. Used for testing
 * correctness of zeroout.
 */
struct kunit_ext_data_state {
	char exp_char;
	ext4_lblk_t off_blk;
	ext4_lblk_t len_blk;
};

enum kunit_test_types {
	TEST_SPLIT_CONVERT,
	TEST_CREATE_BLOCKS,
};

struct kunit_ext_test_param {
	/* description of test */
	char *desc;

	/* determines which function will be tested */
	int type;

	/* is extent unwrit at beginning of test */
	bool is_unwrit_at_start;

	/* flags to pass while splitting */
	int split_flags;

	/* map describing range to split */
	struct ext4_map_blocks split_map;

	/* disable zeroout */
	bool disable_zeroout;

	/* no of extents expected after split */
	int nr_exp_ext;

	/*
	 * expected state of extents after split. We will never split into more
	 * than 3 extents
	 */
	struct kunit_ext_state exp_ext_state[3];

	/* Below fields used for zeroout tests */

	bool is_zeroout_test;
	/*
	 * no of expected data segments (zeroout tests). Example, if we expect
	 * data to be 4kb 0s, followed by 8kb non-zero, then nr_exp_data_segs==2
	 */
	int nr_exp_data_segs;

	/*
	 * expected state of data area after zeroout.
	 */
	struct kunit_ext_data_state exp_data_state[3];
};

static void ext_kill_sb(struct super_block *sb)
{
	generic_shutdown_super(sb);
}

static int ext_init_fs_context(struct fs_context *fc)
{
	return 0;
}

static int ext_set(struct super_block *sb, struct fs_context *fc)
{

Annotation

Implementation Notes